Component Form Conventions
The framework will scan the registered components and generate component form configurations according to the following conventions, which are used for rendering component configuration forms in the visual editor.
- Generate a component name (lowercase first letter) based on the component structure name
- Generate form items based on the structure defined by the
Config
field of the component structure. (The first letter of the field is lowercase or customized throughjson tag
) - Generate default values for form items based on the
Config
field of the component instance returned by theNew()
method - Generate categories based on component package names. The component categories are: transform action、filter、external、flow、ci、ai、aiot
- The endpoint component type is prefixed with
endpoint/
TIP
Components can implement the following optional interface to override the definitions from the Component Configuration Form Conventions :
type ComponentDefGetter interface {
Def() ComponentForm
}
1
2
3
2
3
# Example
Component definition:
// JsTransformNodeConfiguration node configuration, generates form items for exportable fields
type JsTransformNodeConfiguration struct {
JsScript string
}
// JsTransformNode is the custom component struct, corresponding to the generated component name: jsTransformNode
type JsTransformNode struct {
// Node configuration, If the node requires form configuration, it must have a `Config` field.
Config JsTransformNodeConfiguration
jsEngine types.JsEngine
}
// Type function returns the type of the component
func (x *JsTransformNode) Type() string {
return "jsTransform"
}
// New function initializes based on the Config field, obtaining the default values for form items
func (x *JsTransformNode) New() types.Node {
return &JsTransformNode{Config: JsTransformNodeConfiguration{
JsScript: "return {'msg':msg,'metadata':metadata,'msgType':msgType};",
}}
}
// Other interfaces are not shown here
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Automatically generate component configuration form definition:
{
"type": "jsTransform",
"category": "transform",
"fields": [
{
"name": "jsScript",
"type": "string",
"defaultValue": "return {'msg':msg,'metadata':metadata,'msgType':msgType};",
"label": "",
"desc": "",
"validate": "",
"fields": null
}
],
"label": "JsTransformNode",
"desc": "",
"icon": "",
"relationTypes": [
"Success",
"Failure"
]
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
- Component Configuration Form Definition
- You can make international settings for component configuration in the RuleGo-Editor visual editor
local_zh.js
file.
Edit this page on GitHub (opens new window)
Last Updated: 2024/10/23, 10:13:01