Skip to content

Commit 06d863a

Browse files
committed
Merge branch 'elsa-0.1.x'
2 parents 6c64d37 + ff19fbe commit 06d863a

File tree

4 files changed

+56
-12
lines changed

4 files changed

+56
-12
lines changed

.github/workflows/elsa-compile.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ on:
44
push:
55
branches:
66
- 'main'
7-
- '[0-9]+.[0-9]+.x' # 匹配 x.x.x 格式且最后一位为 x(如 1.2.x、22.1.x)
7+
- 'elsa-[0-9]+\.[0-9]+\.x' # 转义小数点,匹配如 elsa-0.1.x
88
paths:
99
- 'framework/elsa/**'
1010
pull_request:
1111
branches:
1212
- 'main'
13-
- '[0-9]+.[0-9]+.x'
13+
- 'elsa-[0-9]+\.[0-9]+\.x' # 转义小数点,匹配如 elsa-0.1.x
1414
paths:
1515
- 'framework/elsa/**'
1616

framework/elsa/fit-elsa-react/src/common/Consts.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,5 +213,5 @@ export const DEFAULT_KNOWLEDGE_RETRIEVAL_NODE_KNOWLEDGE_CONFIG_ID = {
213213
name: 'knowledgeConfigId',
214214
type: DATA_TYPES.STRING,
215215
from: FROM_TYPE.INPUT,
216-
value: null,
216+
value: '',
217217
};

framework/elsa/fit-elsa-react/src/components/retrieval/KnowledgeForm.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ const _KnowledgeForm = ({knowledge, groupId, knowledgeConfigId, disabled, maximu
7979
shapeId: shape.id,
8080
selectedKnowledgeBases: getSelectedKnowledgeBases(),
8181
groupId: groupId ?? DEFAULT_KNOWLEDGE_REPO_GROUP,
82+
selectedKnowledgeConfigId: knowledgeConfigId,
8283
onSelect: onSelect,
8384
},
8485
});

framework/elsa/fit-elsa-react/src/data/GraphOperator.js

Lines changed: 52 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* Licensed under the MIT License. See License.txt in the project root for license information.
55
*--------------------------------------------------------------------------------------------*/
66

7+
import {v4 as uuidv4} from 'uuid';
78
import {configToStruct, toConfig} from '@/components/util/JadeConfigUtils.js';
89
import {DATA_TYPES, FROM_TYPE} from '@/common/Consts.js';
910
import {ShapeDataValidationProcessor} from '@/data/ShapeDataValidationProcessor.js';
@@ -75,10 +76,49 @@ const graphOperator = (graphString) => {
7576
* @param updates 待修改的值.
7677
*/
7778
self.update = (keys, updates) => {
78-
const config = getConfigByKeys(keys);
79-
updateConfig(config, updates);
79+
if (!keys || keys.length === 0) {
80+
throw new Error('Keys cannot be empty');
81+
}
82+
// 获取除最后一层外的所有路径
83+
const parentKeys = keys.slice(0, -1);
84+
const lastKey = keys[keys.length - 1];
85+
// 检查父路径是否存在
86+
const parentConfig = getConfigByKeys(parentKeys);
87+
if (!parentConfig || !parentConfig.value) {
88+
throw new Error(`Parent path does not exist: ${parentKeys.join('.')}`);
89+
}
90+
// 检查最后一层是否存在
91+
let targetConfig = parentConfig.value.find(v => v.name === lastKey);
92+
// 如果最后一层不存在,则创建
93+
if (!targetConfig) {
94+
targetConfig = {
95+
id: uuidv4(),
96+
name: lastKey,
97+
from: FROM_TYPE.INPUT,
98+
type: getTypeFromUpdates(updates),
99+
value: updates
100+
};
101+
parentConfig.value.push(targetConfig);
102+
}
103+
updateConfig(targetConfig, updates);
80104
};
81105

106+
// 根据updates的类型返回对应的DATA_TYPES
107+
const getTypeFromUpdates = (updates) => {
108+
if (Array.isArray(updates)) {
109+
return DATA_TYPES.ARRAY;
110+
} else if (updates && typeof updates === 'object') {
111+
return DATA_TYPES.OBJECT;
112+
} else if (typeof updates === 'string') {
113+
return DATA_TYPES.STRING;
114+
} else if (typeof updates === 'number') {
115+
return DATA_TYPES.NUMBER;
116+
} else if (typeof updates === 'boolean') {
117+
return DATA_TYPES.BOOLEAN;
118+
}
119+
return DATA_TYPES.STRING; // 或者其他默认类型
120+
}
121+
82122
const updateConfig = (config, updates) => {
83123
if (Array.isArray(updates)) {
84124
config.value = updates.map(update => {
@@ -97,19 +137,22 @@ const graphOperator = (graphString) => {
97137
const update = updates[k];
98138
const correspondingConfig = config.value?.find(v => v.name === k);
99139
if (!correspondingConfig) {
100-
return;
101-
}
102-
103-
// 处理对象
104-
if (typeof update === 'object') {
105-
updateConfig(correspondingConfig, update);
140+
config.value = config.value || []; // 确保 config.value 是数组
141+
config.value.push({
142+
id: uuidv4(),
143+
name: k,
144+
from: FROM_TYPE.INPUT,
145+
type: getTypeFromUpdates(update),
146+
value: update,
147+
});
106148
return;
107149
}
108150

109151
// 如果类型是reference,则不进行修改。
110-
if (correspondingConfig.from === FROM_TYPE.REFERENCE) {
152+
if (String(correspondingConfig.from ?? "").toLowerCase() === FROM_TYPE.REFERENCE.toLowerCase()) {
111153
return;
112154
}
155+
113156
updateConfig(correspondingConfig, update);
114157
}
115158
});

0 commit comments

Comments
 (0)