fix: add GetInputForm for string_transform (#16900)

### Summary

As title:

#### merge:
<img width="2972" height="1473" alt="image"
src="https://github.com/user-attachments/assets/2171e31f-13f4-4799-a6d0-1b9326210658"
/>

---
#### split
<img width="858" height="416" alt="image"
src="https://github.com/user-attachments/assets/f89d39e3-da85-4349-a53c-e27a17cc9dfa"
/>
This commit is contained in:
Haruko386
2026-07-15 10:54:18 +08:00
committed by GitHub
parent 276941f7b4
commit 3339040987
2 changed files with 129 additions and 0 deletions

View File

@@ -181,6 +181,61 @@ func (s *StringTransformComponent) Inputs() map[string]string {
return out
}
func (s *StringTransformComponent) GetInputForm() map[string]any {
if s.param.Method == "split" {
return map[string]any{
"line": map[string]any{
"name": "String",
"type": "line",
},
}
}
out := make(map[string]any)
for k, o := range getInputElementsFromText(s.param.Script) {
name, _ := o["name"].(string)
if name == "" {
name = k
}
out[k] = map[string]any{
"name": name,
"type": "line",
}
}
if len(out) == 0 {
return nil
}
return out
}
func getInputElementsFromText(txt string) map[string]map[string]any {
res := make(map[string]map[string]any)
for _, match := range runtime.VarRefPattern.FindAllStringSubmatch(txt, -1) {
if len(match) < 2 {
continue
}
exp := match[1]
if _, ok := res[exp]; ok {
continue
}
cpnID, varName := "", exp
if at := strings.Index(exp, "@"); at > 0 {
cpnID = exp[:at]
varName = exp[at+1:]
}
name := exp
if cpnID != "" {
name = cpnID + "@" + varName
}
res[exp] = map[string]any{
"name": name,
"value": nil,
"_retrieval": nil,
"_cpn_id": cpnID,
}
}
return res
}
// Outputs returns the transformed payload.
func (s *StringTransformComponent) Outputs() map[string]string {
return map[string]string{