BusinessLogic 业务组件逻辑
1. 结构声明
- TS Declaration
- JSON Schema
class BusinessLogic extends Logic {
isPublic: boolean;
}
{
"type": "object",
"properties": {
"composedBy": {
"type": "array",
"items": {
"type": "string"
}
},
"name": {
"type": "string"
},
"title": {
"type": "string"
},
"description": {
"type": "string"
},
"triggerType": {
"type": "string"
},
"cron": {
"type": "string"
},
"overridable": {
"type": "boolean"
},
"transactional": {
"$ref": "#/definitions/Transactional"
},
"typeParams": {
"type": "array",
"items": {
"$ref": "#/definitions/TypeParam"
}
},
"params": {
"type": "array",
"items": {
"$ref": "#/definitions/Param"
}
},
"returns": {
"type": "array",
"items": {
"$ref": "#/definitions/Return"
}
},
"variables": {
"type": "array",
"items": {
"$ref": "#/definitions/Variable"
}
},
"body": {
"type": "array",
"items": {
"$ref": "#/definitions/LogicItem"
}
},
"playground": {
"type": "array",
"items": {
"$ref": "#/definitions/LogicItem"
}
},
"isPublic": {
"type": "boolean"
}
},
"required": [
"body",
"isPublic",
"name",
"params",
"playground",
"returns",
"variables"
],
"additionalProperties": false
}
2. 节点示例
(1) 示例
AST 如下:
- JSON
- YAML
{
"concept": "BusinessLogic",
"isPublic": true,
"name": "reset",
"description": "重置状态",
"params": [],
"returns": [],
"variables": [],
"body": [
{
"concept": "Start",
"label": "开始"
},
{
"concept": "CallLogic",
"uuid": "c223c0c29a2b41f48e7d17b9ea1c076c",
"calleeNamespace": "nasl.ui",
"calleeName": "showMessage",
"shortcut": true,
"arguments": [
{
"concept": "Argument",
"keyword": "text",
"expression": {
"concept": "StringLiteral",
"value": "重置状态"
}
}
],
"label": "弹出消息"
},
{
"concept": "End",
"label": "结束"
}
],
"playground": []
}
concept: BusinessLogic
isPublic: true
name: reset
description: 重置状态
params: []
returns: []
variables: []
body:
- concept: Start
label: 开始
- concept: CallLogic
uuid: c223c0c29a2b41f48e7d17b9ea1c076c
calleeNamespace: nasl.ui
calleeName: showMessage
shortcut: true
arguments:
- concept: Argument
keyword: text
expression:
concept: StringLiteral
value: 重置状态
label: 弹出消息
- concept: End
label: 结束
playground: []
对应的代码如下:
- 文本化 NASL
public @(
description = "重置状态",
)
logic reset() {
nasl::ui::showMessage('重置状态')
end
}