@nocobase/plugin-workflow 0.9.1-alpha.2 → 0.9.2-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 (131) hide show
  1. package/lib/client/AddButton.js +17 -64
  2. package/lib/client/Branch.js +0 -13
  3. package/lib/client/ExecutionCanvas.js +16 -63
  4. package/lib/client/ExecutionLink.js +3 -21
  5. package/lib/client/ExecutionPage.js +1 -19
  6. package/lib/client/ExecutionResourceProvider.js +6 -23
  7. package/lib/client/FlowContext.js +0 -8
  8. package/lib/client/WorkflowCanvas.js +56 -127
  9. package/lib/client/WorkflowLink.js +3 -21
  10. package/lib/client/WorkflowPage.js +1 -19
  11. package/lib/client/WorkflowProvider.js +24 -47
  12. package/lib/client/WorkflowShortcut.js +0 -16
  13. package/lib/client/components/CollectionBlockInitializer.js +12 -22
  14. package/lib/client/components/CollectionFieldInitializers.js +5 -24
  15. package/lib/client/components/CollectionFieldset.js +31 -79
  16. package/lib/client/components/Duration.js +0 -14
  17. package/lib/client/components/DynamicExpression.d.ts +4 -0
  18. package/lib/client/components/DynamicExpression.js +102 -0
  19. package/lib/client/components/FieldsSelect.d.ts +2 -0
  20. package/lib/client/components/FieldsSelect.js +66 -0
  21. package/lib/client/components/FilterDynamicComponent.js +1 -10
  22. package/lib/client/components/NullRender.js +0 -1
  23. package/lib/client/components/OpenDrawer.js +10 -35
  24. package/lib/client/components/RadioWithTooltip.js +5 -27
  25. package/lib/client/components/renderEngineReference.d.ts +1 -0
  26. package/lib/client/components/renderEngineReference.js +55 -0
  27. package/lib/client/constants.js +0 -9
  28. package/lib/client/index.js +0 -6
  29. package/lib/client/interfaces/expression.d.ts +3 -0
  30. package/lib/client/interfaces/expression.js +37 -0
  31. package/lib/client/locale/index.js +5 -15
  32. package/lib/client/locale/pt-BR.d.ts +130 -0
  33. package/lib/client/locale/pt-BR.js +136 -0
  34. package/lib/client/locale/zh-CN.d.ts +16 -1
  35. package/lib/client/locale/zh-CN.js +17 -2
  36. package/lib/client/nodes/calculation.d.ts +54 -3
  37. package/lib/client/nodes/calculation.js +136 -63
  38. package/lib/client/nodes/condition.d.ts +1 -1
  39. package/lib/client/nodes/condition.js +21 -76
  40. package/lib/client/nodes/create.d.ts +35 -9
  41. package/lib/client/nodes/create.js +13 -19
  42. package/lib/client/nodes/delay.d.ts +1 -3
  43. package/lib/client/nodes/delay.js +3 -10
  44. package/lib/client/nodes/destroy.d.ts +1 -6
  45. package/lib/client/nodes/destroy.js +12 -9
  46. package/lib/client/nodes/index.d.ts +2 -2
  47. package/lib/client/nodes/index.js +45 -147
  48. package/lib/client/nodes/manual/AssigneesSelect.js +6 -17
  49. package/lib/client/nodes/manual/ModeConfig.js +0 -27
  50. package/lib/client/nodes/manual/SchemaConfig.js +87 -449
  51. package/lib/client/nodes/manual/WorkflowTodo.js +99 -163
  52. package/lib/client/nodes/manual/WorkflowTodoBlockInitializer.js +4 -20
  53. package/lib/client/nodes/manual/forms/customForm.d.ts +40 -0
  54. package/lib/client/nodes/manual/forms/customForm.js +411 -0
  55. package/lib/client/nodes/manual/index.d.ts +12 -1
  56. package/lib/client/nodes/manual/index.js +54 -41
  57. package/lib/client/nodes/parallel.js +7 -41
  58. package/lib/client/nodes/query.d.ts +28 -7
  59. package/lib/client/nodes/query.js +15 -22
  60. package/lib/client/nodes/request.d.ts +2 -3
  61. package/lib/client/nodes/request.js +5 -22
  62. package/lib/client/nodes/update.d.ts +1 -6
  63. package/lib/client/nodes/update.js +8 -16
  64. package/lib/client/schemas/collection.d.ts +20 -4
  65. package/lib/client/schemas/collection.js +26 -22
  66. package/lib/client/schemas/executions.js +3 -18
  67. package/lib/client/schemas/workflows.js +10 -33
  68. package/lib/client/style.js +24 -21
  69. package/lib/client/triggers/collection.d.ts +24 -20
  70. package/lib/client/triggers/collection.js +34 -123
  71. package/lib/client/triggers/index.d.ts +2 -5
  72. package/lib/client/triggers/index.js +34 -105
  73. package/lib/client/triggers/schedule/DateFieldsSelect.js +6 -29
  74. package/lib/client/triggers/schedule/EndsByField.js +1 -18
  75. package/lib/client/triggers/schedule/OnField.js +10 -38
  76. package/lib/client/triggers/schedule/RepeatField.js +4 -32
  77. package/lib/client/triggers/schedule/ScheduleConfig.js +10 -51
  78. package/lib/client/triggers/schedule/index.d.ts +21 -0
  79. package/lib/client/triggers/schedule/index.js +21 -22
  80. package/lib/client/triggers/schedule/locale/Cron.zh-CN.js +8 -4
  81. package/lib/client/utils.d.ts +1 -0
  82. package/lib/client/utils.js +31 -10
  83. package/lib/client/variable.d.ts +7 -6
  84. package/lib/client/variable.js +132 -71
  85. package/lib/index.js +0 -2
  86. package/lib/server/Plugin.d.ts +7 -7
  87. package/lib/server/Plugin.js +76 -111
  88. package/lib/server/Processor.d.ts +2 -0
  89. package/lib/server/Processor.js +62 -125
  90. package/lib/server/actions/index.js +3 -10
  91. package/lib/server/actions/nodes.js +34 -87
  92. package/lib/server/actions/workflows.js +46 -96
  93. package/lib/server/collections/executions.js +1 -1
  94. package/lib/server/collections/flow_nodes.js +7 -4
  95. package/lib/server/collections/jobs.js +1 -1
  96. package/lib/server/collections/workflows.js +3 -4
  97. package/lib/server/fields/expression-field.d.ts +8 -0
  98. package/lib/server/fields/expression-field.js +26 -0
  99. package/lib/server/fields/index.d.ts +1 -0
  100. package/lib/server/fields/index.js +12 -0
  101. package/lib/server/functions/index.js +3 -14
  102. package/lib/server/index.js +0 -6
  103. package/lib/server/instructions/calculation.js +22 -17
  104. package/lib/server/instructions/condition.js +8 -52
  105. package/lib/server/instructions/create.js +31 -15
  106. package/lib/server/instructions/delay.js +4 -32
  107. package/lib/server/instructions/destroy.js +6 -12
  108. package/lib/server/instructions/index.js +6 -23
  109. package/lib/server/instructions/manual/actions.js +22 -31
  110. package/lib/server/instructions/manual/collecions/users_jobs.js +1 -1
  111. package/lib/server/instructions/manual/index.d.ts +13 -12
  112. package/lib/server/instructions/manual/index.js +9 -47
  113. package/lib/server/instructions/parallel.js +9 -36
  114. package/lib/server/instructions/query.js +17 -15
  115. package/lib/server/instructions/request.js +7 -30
  116. package/lib/server/instructions/update.js +8 -14
  117. package/lib/server/migrations/20221129153547-calculation-variables.js +3 -27
  118. package/lib/server/migrations/20230221032941-change-request-body-type.js +3 -26
  119. package/lib/server/migrations/20230221071831-calculation-expression.js +1 -33
  120. package/lib/server/migrations/20230221121203-condition-calculation.js +5 -28
  121. package/lib/server/migrations/20230221162902-jsonb-to-json.js +3 -18
  122. package/lib/server/migrations/20230411034722-manual-multi-form.d.ts +4 -0
  123. package/lib/server/migrations/20230411034722-manual-multi-form.js +303 -0
  124. package/lib/server/models/Execution.js +0 -5
  125. package/lib/server/models/FlowNode.js +0 -5
  126. package/lib/server/models/Job.js +0 -5
  127. package/lib/server/models/Workflow.js +0 -5
  128. package/lib/server/triggers/collection.js +39 -61
  129. package/lib/server/triggers/index.js +3 -22
  130. package/lib/server/triggers/schedule.js +72 -194
  131. package/package.json +14 -11
@@ -0,0 +1,136 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _default = {
8
+ "Workflow": "Fluxo de trabalho",
9
+ "Execution history": "Histórico de execução",
10
+ "Executed": "Executado",
11
+ "Trigger type": "Tipo de acionador",
12
+ "Status": "Status",
13
+ "On": "Ligado",
14
+ "Off": "Desligado",
15
+ "Version": "Versão",
16
+ "Copy to new version": "Copiar para nova versão",
17
+ "Duplicate": "Duplicar",
18
+ "Loading": "Carregando",
19
+ "Load failed": "Falha ao carregar",
20
+ "Trigger": "Acionador",
21
+ "Trigger variables": "Variáveis do acionador",
22
+ "Trigger data": "Dados do acionador",
23
+ "Trigger time": "Tempo do acionador",
24
+ "Triggered at": "Acionado em",
25
+ "Collection event": "Evento da coleção",
26
+ "Trigger on": "Acionar em",
27
+ "After record added": "Depois do registro ser adicionado",
28
+ "After record updated": "Depois do registro ser atualizado",
29
+ "After record added or updated": "Depois do registro ser adicionado ou atualizado",
30
+ "After record deleted": "Depois do registro ser excluído",
31
+ "Changed fields": "Campos alterados",
32
+ "Triggered only if one of the selected fields changes. If unselected, it means that it will be triggered when any field changes. When record is added or deleted, any field is considered to have been changed.": "Acionado apenas se um dos campos selecionados for alterado. Se não estiver selecionado, será acionado quando qualquer campo for alterado. Quando um registro é adicionado ou excluído, qualquer campo é considerado como tendo sido alterado.",
33
+ "Only triggers when match conditions": "Aciona somente quando as condições correspondem",
34
+ "Schedule event": "Evento programado",
35
+ "Trigger mode": "Modo de acionamento",
36
+ "Based on certain date": "Com base em uma data específica",
37
+ "Based on date field of collection": "Com base no campo de data da coleção",
38
+ "Starts on": "Começa em",
39
+ "Ends on": "Termina em",
40
+ "No end": "Sem fim",
41
+ "Exactly at": "Exatamente às",
42
+ "Repeat mode": "Modo de repetição",
43
+ "Repeat limit": "Limite de repetição",
44
+ "No limit": "Sem limite",
45
+ "Seconds": "Segundos",
46
+ "Minutes": "Minutos",
47
+ "Hours": "Horas",
48
+ "Days": "Dias",
49
+ "Weeks": "Semanas",
50
+ "Months": "Meses",
51
+ "No repeat": "Sem repetição",
52
+ "Every": "Cada",
53
+ "By minute": "Por minuto",
54
+ "By hour": "Por hora",
55
+ "By day": "Por dia",
56
+ "By week": "Por semana",
57
+ "By month": "Por mês",
58
+ "By field": "Por campo",
59
+ "By custom date": "Por data personalizada",
60
+ "Advanced": "Avançado",
61
+ "End": "Fim",
62
+ "Node result": "Resultado do nó",
63
+ "Constant": "Constante",
64
+ "Null": "Nulo",
65
+ "Boolean": "Booleano",
66
+ "String": "String",
67
+ "Calculator": "Calculadora",
68
+ "Arithmetic calculation": "Cálculo aritmético",
69
+ "String operation": "Operação de string",
70
+ "Executed at": "Executado em",
71
+ "Queueing": "Em fila",
72
+ "On going": "Em andamento",
73
+ "Succeeded": "Sucesso",
74
+ "Failed": "Falhou",
75
+ "Pending": "Pendente",
76
+ "Canceled": "Cancelado",
77
+ "This node contains branches, deleting will also be preformed to them, are you sure?": "Este nó contém ramos, a exclusão também será realizada neles, você tem certeza?",
78
+ "Control": "Controle",
79
+ "Collection operations": "Operações de coleção",
80
+ "Extended types": "Tipos estendidos",
81
+ "Node type": "Tipo de nó",
82
+ "Calculation": "Cálculo",
83
+ "Configure calculation": "Configurar cálculo",
84
+ "Calculation result": "Resultado do cálculo",
85
+ "True": "Verdadeiro",
86
+ "False": "Falso",
87
+ "concat": "concatenar",
88
+ "Condition": "Condição",
89
+ "Mode": "Modo",
90
+ "Continue when \"Yes\"": "Continuar quando \"Sim\"",
91
+ "Branch into \"Yes\" and \"No\"": "Ramo em \"Sim\" e \"Não\"",
92
+ "Conditions": "Condições",
93
+ "Parallel branch": "Ramo paralelo",
94
+ "Add branch": "Adicionar ramo",
95
+ "All succeeded": "Todos com sucesso",
96
+ "Any succeeded": "Qualquer um com sucesso",
97
+ "Any succeeded or failed": "Qualquer um com sucesso ou falha",
98
+ "Continue after all branches succeeded": "Continuar após todos os ramos com sucesso",
99
+ "Continue after any branch succeeded": "Continuar após qualquer ramo com sucesso",
100
+ "Continue after any branch succeeded, or exit after any branch failed": "Continuar após qualquer ramo com sucesso ou sair após qualquer ramo falhar",
101
+ "Delay": "Atraso",
102
+ "Duration": "Duração",
103
+ "End Status": "Status final",
104
+ "Select status": "Selecionar status",
105
+ "Succeed and continue": "Ter sucesso e continuar",
106
+ "Fail and exit": "Falhar e sair",
107
+ "Create record": "Criar registro",
108
+ "Update record": "Atualizar registro",
109
+ "Query record": "Consultar registro",
110
+ "Multiple records": "Múltiplos registros",
111
+ "Please select collection first": "Por favor, selecione uma coleção primeiro",
112
+ "Only update records matching conditions": "Atualizar somente registros que atendem às condições",
113
+ "Fields that are not assigned a value will be set to the default value, and those that do not have a default value are set to null.": "Campos que não recebem valor serão definidos como valor padrão e aqueles sem valor padrão serão definidos como nulo.",
114
+ "Trigger in executed workflow cannot be modified": "O acionador em fluxo de trabalho executado não pode ser modificado",
115
+ "Node in executed workflow cannot be modified": "O nó em fluxo de trabalho executado não pode ser modificado",
116
+ 'Can not delete': 'Não é possível excluir',
117
+ 'The result of this node has been referenced by other nodes ({{nodes}}), please remove the usage before deleting.': 'O resultado deste nó foi referenciado por outros nós ({{nodes}}), por favor, remova a referência antes de excluir.',
118
+ 'HTTP request': 'Requisição HTTP',
119
+ 'HTTP method': 'Método HTTP',
120
+ 'URL': 'URL',
121
+ 'Headers': 'Cabeçalhos',
122
+ 'Add request header': 'Adicionar cabeçalho de requisição',
123
+ 'Parameters': 'Parâmetros',
124
+ 'Add parameter': 'Adicionar parâmetro',
125
+ 'Body': 'Corpo',
126
+ 'Use variable': 'Usar variável',
127
+ 'Format': 'Formato',
128
+ 'Insert': 'Inserir',
129
+ 'Timeout config': 'Configuração de tempo limite',
130
+ 'ms': 'ms',
131
+ 'Input request data': 'Dados de entrada da requisição',
132
+ 'Only support standard JSON data': 'Suporta somente dados JSON padrão',
133
+ '"Content-Type" only support "application/json", and no need to specify': '"Content-Type" somente suporta "application/json" e não precisa ser especificado',
134
+ 'Ignore fail request and continue workflow': 'Ignorar falhas na requisição e continuar o fluxo de trabalho'
135
+ };
136
+ exports.default = _default;
@@ -25,6 +25,8 @@ declare const _default: {
25
25
  'Changed fields': string;
26
26
  'Triggered only if one of the selected fields changes. If unselected, it means that it will be triggered when any field changes. When record is added or deleted, any field is considered to have been changed.': string;
27
27
  'Only triggers when match conditions': string;
28
+ 'Preload associations': string;
29
+ 'Only configured association field could be accessed in following nodes': string;
28
30
  'Schedule event': string;
29
31
  'Trigger mode': string;
30
32
  'Based on certain date': string;
@@ -58,7 +60,8 @@ declare const _default: {
58
60
  'Arithmetic calculation': string;
59
61
  'String operation': string;
60
62
  'System variables': string;
61
- 'Current time': string;
63
+ 'System time': string;
64
+ 'Date variables': string;
62
65
  'Executed at': string;
63
66
  Queueing: string;
64
67
  'On going': string;
@@ -80,6 +83,11 @@ declare const _default: {
80
83
  'Extended types': string;
81
84
  'Node type': string;
82
85
  Calculation: string;
86
+ 'Expression type': string;
87
+ Static: string;
88
+ Dynamic: string;
89
+ 'Select dynamic expression': string;
90
+ 'Variable datasource': string;
83
91
  'Calculation engine': string;
84
92
  Basic: string;
85
93
  'Calculation expression': string;
@@ -123,12 +131,16 @@ declare const _default: {
123
131
  'Any pass': string;
124
132
  'Anyone pass': string;
125
133
  'Field name existed in form': string;
134
+ 'Custom form': string;
135
+ 'Data record': string;
126
136
  'Create record': string;
127
137
  'Update record': string;
128
138
  'Query record': string;
129
139
  'Multiple records': string;
140
+ 'Fail on no data': string;
130
141
  'Please select collection first': string;
131
142
  'Only update records matching conditions': string;
143
+ 'Please add at least one condition': string;
132
144
  'Fields that are not assigned a value will be set to the default value, and those that do not have a default value are set to null.': string;
133
145
  'Trigger in executed workflow cannot be modified': string;
134
146
  'Node in executed workflow cannot be modified': string;
@@ -153,5 +165,8 @@ declare const _default: {
153
165
  'Ignore fail request and continue workflow': string;
154
166
  'Workflow todos': string;
155
167
  Task: string;
168
+ 'Dynamic expression': string;
169
+ 'An expression for calculation in each rows': string;
170
+ Unconfigured: string;
156
171
  };
157
172
  export default _default;
@@ -31,6 +31,8 @@ var _default = {
31
31
  'Changed fields': '发生变动的字段',
32
32
  'Triggered only if one of the selected fields changes. If unselected, it means that it will be triggered when any field changes. When record is added or deleted, any field is considered to have been changed.': '只有被选中的某个字段发生变动时才会触发。如果不选择,则表示任何字段变动时都会触发。新增或删除数据时,任意字段都被认为发生变动。',
33
33
  'Only triggers when match conditions': '满足以下条件才触发',
34
+ 'Preload associations': '预加载关联数据',
35
+ 'Only configured association field could be accessed in following nodes': '仅已配置的关系数据可以在后续节点中被访问',
34
36
  'Schedule event': '定时任务',
35
37
  'Trigger mode': '触发模式',
36
38
  'Based on certain date': '自定义时间',
@@ -64,7 +66,8 @@ var _default = {
64
66
  'Arithmetic calculation': '算术运算',
65
67
  'String operation': '字符串',
66
68
  'System variables': '系统变量',
67
- 'Current time': '当前时间',
69
+ 'System time': '系统时间',
70
+ 'Date variables': '日期变量',
68
71
  'Executed at': '执行于',
69
72
  'Queueing': '队列中',
70
73
  'On going': '进行中',
@@ -86,6 +89,11 @@ var _default = {
86
89
  'Extended types': '扩展类型',
87
90
  'Node type': '节点类型',
88
91
  'Calculation': '运算',
92
+ 'Expression type': '表达式类型',
93
+ 'Static': '静态',
94
+ 'Dynamic': '动态',
95
+ 'Select dynamic expression': '选择动态表达式',
96
+ 'Variable datasource': '变量数据源',
89
97
  'Calculation engine': '运算引擎',
90
98
  'Basic': '基础',
91
99
  'Calculation expression': '运算表达式',
@@ -129,12 +137,16 @@ var _default = {
129
137
  'Any pass': '任意通过',
130
138
  'Anyone pass': '任何一人通过即通过',
131
139
  'Field name existed in form': '表单中已有对应标识的字段',
140
+ 'Custom form': '自定义表单',
141
+ 'Data record': '数据记录',
132
142
  'Create record': '新增数据',
133
143
  'Update record': '更新数据',
134
144
  'Query record': '查询数据',
135
145
  'Multiple records': '多条数据',
146
+ 'Fail on no data': '无数据时报错',
136
147
  'Please select collection first': '请先选择数据表',
137
148
  'Only update records matching conditions': '只更新满足条件的数据',
149
+ 'Please add at least one condition': '请添加至少一个条件',
138
150
  'Fields that are not assigned a value will be set to the default value, and those that do not have a default value are set to null.': '未被赋值的字段将被设置为默认值,没有默认值的设置为空值。',
139
151
  'Trigger in executed workflow cannot be modified': '已经执行过工作流的触发器不能被修改',
140
152
  'Node in executed workflow cannot be modified': '已经执行过工作流中的节点不能被修改',
@@ -158,6 +170,9 @@ var _default = {
158
170
  '"Content-Type" only support "application/json", and no need to specify': '"Content-Type" 请求头仅支持 "application/json",无需填写',
159
171
  'Ignore fail request and continue workflow': '忽略失败的请求并继续工作流',
160
172
  'Workflow todos': '工作流待办',
161
- 'Task': '任务'
173
+ 'Task': '任务',
174
+ 'Dynamic expression': '动态表达式',
175
+ 'An expression for calculation in each rows': '每行数据计算规则不同时使用',
176
+ 'Unconfigured': '未配置'
162
177
  };
163
178
  exports.default = _default;
@@ -1,11 +1,23 @@
1
1
  import { SchemaInitializerItemOptions } from '@nocobase/client';
2
2
  import { useWorkflowVariableOptions } from '../variable';
3
3
  import { RadioWithTooltip } from '../components/RadioWithTooltip';
4
+ declare function useWorkflowVariableEntityOptions(): {
5
+ label: any;
6
+ value: any;
7
+ key: any;
8
+ children: any;
9
+ disabled: boolean;
10
+ }[];
4
11
  declare const _default: {
5
12
  title: string;
6
13
  type: string;
7
14
  group: string;
8
15
  fieldset: {
16
+ dynamic: {
17
+ type: string;
18
+ 'x-component': string;
19
+ default: boolean;
20
+ };
9
21
  engine: {
10
22
  type: string;
11
23
  title: string;
@@ -16,6 +28,14 @@ declare const _default: {
16
28
  };
17
29
  required: boolean;
18
30
  default: string;
31
+ 'x-reactions': {
32
+ dependencies: string[];
33
+ fulfill: {
34
+ state: {
35
+ visible: string;
36
+ };
37
+ };
38
+ };
19
39
  };
20
40
  expression: {
21
41
  type: string;
@@ -28,27 +48,58 @@ declare const _default: {
28
48
  "x-validator"(value: any, rules: any, { form }: {
29
49
  form: any;
30
50
  }): string;
31
- 'x-reactions': {
51
+ 'x-reactions': ({
52
+ dependencies: string[];
53
+ fulfill: {
54
+ state: {
55
+ visible: string;
56
+ };
57
+ schema?: undefined;
58
+ };
59
+ } | {
32
60
  dependencies: string[];
33
61
  fulfill: {
34
62
  schema: {
35
63
  description: string;
36
64
  };
65
+ state?: undefined;
37
66
  };
38
- };
67
+ })[];
39
68
  required: boolean;
40
69
  };
70
+ scope: {
71
+ type: string;
72
+ title: string;
73
+ 'x-decorator': string;
74
+ 'x-component': string;
75
+ 'x-component-props': {
76
+ scope: string;
77
+ };
78
+ 'x-reactions': {
79
+ dependencies: string[];
80
+ fulfill: {
81
+ state: {
82
+ visible: string;
83
+ };
84
+ };
85
+ };
86
+ };
41
87
  };
42
88
  view: {};
43
89
  scope: {
44
90
  useWorkflowVariableOptions: typeof useWorkflowVariableOptions;
45
- renderReference: (key: string) => JSX.Element;
91
+ useWorkflowVariableEntityOptions: typeof useWorkflowVariableEntityOptions;
92
+ renderEngineReference: (key: string) => JSX.Element;
46
93
  };
47
94
  components: {
48
95
  CalculationResult({ dataSource }: {
49
96
  dataSource: any;
50
97
  }): string | JSX.Element;
51
98
  RadioWithTooltip: typeof RadioWithTooltip;
99
+ DynamicConfig: ({ value, onChange }: {
100
+ value: any;
101
+ onChange: any;
102
+ }) => JSX.Element;
52
103
  };
53
104
  getOptions(config: any, types: any): any[];
54
105
  useInitializers(node: any): SchemaInitializerItemOptions;
@@ -4,96 +4,159 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  function _react() {
9
8
  const data = _interopRequireDefault(require("react"));
10
-
11
9
  _react = function _react() {
12
10
  return data;
13
11
  };
14
-
15
12
  return data;
16
13
  }
17
-
14
+ function _antd() {
15
+ const data = require("@formily/antd");
16
+ _antd = function _antd() {
17
+ return data;
18
+ };
19
+ return data;
20
+ }
18
21
  function _css() {
19
22
  const data = require("@emotion/css");
20
-
21
23
  _css = function _css() {
22
24
  return data;
23
25
  };
24
-
25
26
  return data;
26
27
  }
27
-
28
28
  function _jsonTemplates() {
29
29
  const data = _interopRequireDefault(require("json-templates"));
30
-
31
30
  _jsonTemplates = function _jsonTemplates() {
32
31
  return data;
33
32
  };
34
-
35
33
  return data;
36
34
  }
37
-
35
+ function _reactI18next() {
36
+ const data = require("react-i18next");
37
+ _reactI18next = function _reactI18next() {
38
+ return data;
39
+ };
40
+ return data;
41
+ }
42
+ function _antd2() {
43
+ const data = require("antd");
44
+ _antd2 = function _antd2() {
45
+ return data;
46
+ };
47
+ return data;
48
+ }
38
49
  function _client() {
39
50
  const data = require("@nocobase/client");
40
-
41
51
  _client = function _client() {
42
52
  return data;
43
53
  };
44
-
45
54
  return data;
46
55
  }
47
-
48
56
  function _client2() {
49
57
  const data = require("@nocobase/evaluators/client");
50
-
51
58
  _client2 = function _client2() {
52
59
  return data;
53
60
  };
54
-
55
61
  return data;
56
62
  }
57
-
58
63
  var _FlowContext = require("../FlowContext");
59
-
60
64
  var _locale = require("../locale");
61
-
62
65
  var _variable = require("../variable");
63
-
64
66
  var _RadioWithTooltip = require("../components/RadioWithTooltip");
65
-
67
+ var _renderEngineReference = require("../components/renderEngineReference");
66
68
  const _excluded = ["node", "insert"];
67
-
68
69
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
69
-
70
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
71
-
72
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
73
-
74
70
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
75
-
76
71
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
77
-
78
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
79
-
72
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
73
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
74
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
75
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
76
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
77
+ function matchDynamicExpressionCollectionField(field) {
78
+ const _useCollectionManager = (0, _client().useCollectionManager)(),
79
+ getCollectionFields = _useCollectionManager.getCollectionFields,
80
+ getCollection = _useCollectionManager.getCollection;
81
+ if (field.type !== 'belongsTo') {
82
+ return false;
83
+ }
84
+ const fields = getCollectionFields(field.target);
85
+ return fields.some(f => f.interface === 'expression');
86
+ }
87
+ const DynamicConfig = ({
88
+ value,
89
+ onChange: _onChange
90
+ }) => {
91
+ const _useTranslation = (0, _reactI18next().useTranslation)(),
92
+ t = _useTranslation.t;
93
+ const scope = (0, _variable.useWorkflowVariableOptions)([matchDynamicExpressionCollectionField]);
94
+ return _react().default.createElement(_antd().FormLayout, {
95
+ layout: "vertical"
96
+ }, _react().default.createElement(_antd().FormItem, {
97
+ label: t('Expression type', {
98
+ ns: _locale.NAMESPACE
99
+ })
100
+ }, _react().default.createElement(_antd2().Radio.Group, {
101
+ value: value === false ? false : value || null,
102
+ onChange: ev => {
103
+ _onChange(ev.target.value);
104
+ }
105
+ }, _react().default.createElement(_antd2().Radio, {
106
+ value: false
107
+ }, t("Static", {
108
+ ns: _locale.NAMESPACE
109
+ })), _react().default.createElement(_antd2().Radio, {
110
+ value: value || null
111
+ }, t("Dynamic", {
112
+ ns: _locale.NAMESPACE
113
+ })))), value !== false ? _react().default.createElement(_antd().FormItem, {
114
+ label: t('Select dynamic expression', {
115
+ ns: _locale.NAMESPACE
116
+ })
117
+ }, _react().default.createElement(_client().Variable.Input, {
118
+ value: value || null,
119
+ onChange: v => _onChange(v),
120
+ scope: scope
121
+ })) : null);
122
+ };
123
+ function useWorkflowVariableEntityOptions() {
124
+ return (0, _variable.useWorkflowVariableOptions)([{
125
+ type: "reference",
126
+ options: {
127
+ collection: "*",
128
+ entity: true
129
+ }
130
+ }]);
131
+ }
80
132
  var _default = {
81
133
  title: `{{t("Calculation", { ns: "${_locale.NAMESPACE}" })}}`,
82
134
  type: 'calculation',
83
135
  group: 'control',
84
136
  fieldset: {
137
+ dynamic: {
138
+ type: 'string',
139
+ 'x-component': 'DynamicConfig',
140
+ default: false
141
+ },
85
142
  engine: {
86
143
  type: 'string',
87
144
  title: `{{t("Calculation engine", { ns: "${_locale.NAMESPACE}" })}}`,
88
145
  'x-decorator': 'FormItem',
89
146
  'x-component': 'RadioWithTooltip',
90
147
  'x-component-props': {
91
- options: Array.from(_client2().evaluators.getEntities()).reduce((result, [value, options]) => result.concat(_objectSpread({
92
- value
93
- }, options)), [])
148
+ options: (0, _client2().getOptions)()
94
149
  },
95
150
  required: true,
96
- default: 'math.js'
151
+ default: 'math.js',
152
+ 'x-reactions': {
153
+ dependencies: ['dynamic'],
154
+ fulfill: {
155
+ state: {
156
+ visible: '{{$deps[0] === false}}'
157
+ }
158
+ }
159
+ }
97
160
  },
98
161
  expression: {
99
162
  type: 'string',
@@ -103,17 +166,13 @@ var _default = {
103
166
  'x-component-props': {
104
167
  scope: '{{useWorkflowVariableOptions}}'
105
168
  },
106
-
107
169
  ['x-validator'](value, rules, {
108
170
  form
109
171
  }) {
110
172
  const values = form.values;
111
-
112
173
  const _evaluators$get = _client2().evaluators.get(values.engine),
113
- evaluate = _evaluators$get.evaluate;
114
-
115
- const exp = value.trim().replace(/{{([^{}]+)}}/g, '1');
116
-
174
+ evaluate = _evaluators$get.evaluate;
175
+ const exp = value.trim().replace(/{{([^{}]+)}}/g, ' 1 ');
117
176
  try {
118
177
  evaluate(exp);
119
178
  return '';
@@ -121,36 +180,57 @@ var _default = {
121
180
  return (0, _locale.lang)('Expression syntax error');
122
181
  }
123
182
  },
124
-
125
- 'x-reactions': {
183
+ 'x-reactions': [{
184
+ dependencies: ['dynamic'],
185
+ fulfill: {
186
+ state: {
187
+ visible: '{{$deps[0] === false}}'
188
+ }
189
+ }
190
+ }, {
126
191
  dependencies: ['engine'],
127
192
  fulfill: {
128
193
  schema: {
129
- description: '{{renderReference($deps[0])}}'
194
+ description: '{{renderEngineReference($deps[0])}}'
130
195
  }
131
196
  }
132
- },
197
+ }],
133
198
  required: true
199
+ },
200
+ scope: {
201
+ type: 'string',
202
+ title: `{{t("Variable datasource", { ns: "${_locale.NAMESPACE}" })}}`,
203
+ 'x-decorator': 'FormItem',
204
+ 'x-component': 'Variable.Input',
205
+ 'x-component-props': {
206
+ scope: '{{useWorkflowVariableEntityOptions}}'
207
+ },
208
+ 'x-reactions': {
209
+ dependencies: ['dynamic'],
210
+ fulfill: {
211
+ state: {
212
+ visible: '{{$deps[0] !== false}}'
213
+ }
214
+ }
215
+ }
134
216
  }
135
217
  },
136
218
  view: {},
137
219
  scope: {
138
220
  useWorkflowVariableOptions: _variable.useWorkflowVariableOptions,
139
- renderReference: _client2().renderReference
221
+ useWorkflowVariableEntityOptions,
222
+ renderEngineReference: _renderEngineReference.renderEngineReference
140
223
  },
141
224
  components: {
142
225
  CalculationResult({
143
226
  dataSource
144
227
  }) {
145
228
  var _execution$jobs;
146
-
147
229
  const _useFlowContext = (0, _FlowContext.useFlowContext)(),
148
- execution = _useFlowContext.execution;
149
-
230
+ execution = _useFlowContext.execution;
150
231
  if (!execution) {
151
232
  return (0, _locale.lang)('Calculation result');
152
233
  }
153
-
154
234
  const result = (0, _jsonTemplates().default)(dataSource)({
155
235
  $jobsMapByNodeId: ((_execution$jobs = execution.jobs) !== null && _execution$jobs !== void 0 ? _execution$jobs : []).reduce((map, job) => Object.assign(map, {
156
236
  [job.nodeId]: job.result
@@ -162,22 +242,19 @@ var _default = {
162
242
  `
163
243
  }, JSON.stringify(result, null, 2));
164
244
  },
165
-
166
- RadioWithTooltip: _RadioWithTooltip.RadioWithTooltip
245
+ RadioWithTooltip: _RadioWithTooltip.RadioWithTooltip,
246
+ DynamicConfig
167
247
  },
168
-
169
248
  getOptions(config, types) {
170
- if (types && !types.some(type => type in _variable.TypeSets || Object.values(_variable.TypeSets).some(set => set.has(type)))) {
249
+ if (types && !types.some(type => type in _variable.BaseTypeSets || Object.values(_variable.BaseTypeSets).some(set => set.has(type)))) {
171
250
  return null;
172
251
  }
173
-
174
- return [// { key: '', value: '', label: lang('Calculation result') }
252
+ return [
253
+ // { key: '', value: '', label: lang('Calculation result') }
175
254
  ];
176
255
  },
177
-
178
256
  useInitializers(node) {
179
257
  var _node$title;
180
-
181
258
  return {
182
259
  type: 'item',
183
260
  title: (_node$title = node.title) !== null && _node$title !== void 0 ? _node$title : `#${node.id}`,
@@ -185,19 +262,15 @@ var _default = {
185
262
  node
186
263
  };
187
264
  }
188
-
189
265
  };
190
266
  exports.default = _default;
191
-
192
267
  function CalculationInitializer(_ref) {
193
268
  let node = _ref.node,
194
- insert = _ref.insert,
195
- props = _objectWithoutProperties(_ref, _excluded);
196
-
269
+ insert = _ref.insert,
270
+ props = _objectWithoutProperties(_ref, _excluded);
197
271
  return _react().default.createElement(_client().SchemaInitializer.Item, _objectSpread(_objectSpread({}, props), {}, {
198
272
  onClick: () => {
199
273
  var _node$title2;
200
-
201
274
  insert({
202
275
  type: 'void',
203
276
  name: node.id,