NewComposite 实体/(匿名)数据结构构造器
1. 结构声明
- TS Declaration
- JSON Schema
class NewComposite extends LogicItem {
properties: Array<Identifier>;
rights: Array<SelectMembers>;
assignmentLines: Array<AssignmentLine>;
hideProperties: boolean = false;
hideDefaults: boolean = false;
autoConnection: boolean = true;
}
{
"type": "object",
"properties": {
"composedBy": {
"type": "array",
"items": {
"type": "string"
}
},
"label": {
"type": "string"
},
"description": {
"type": "string"
},
"folded": {
"type": "boolean"
},
"offsetX": {
"type": "number"
},
"offsetY": {
"type": "number"
},
"typeAnnotation": {
"$ref": "#/definitions/TypeAnnotation"
},
"properties": {
"type": "array",
"items": {
"$ref": "#/definitions/Identifier"
}
},
"rights": {
"type": "array",
"items": {
"$ref": "#/definitions/SelectMembers"
}
},
"assignmentLines": {
"type": "array",
"items": {
"$ref": "#/definitions/AssignmentLine"
}
},
"hideProperties": {
"type": "boolean"
},
"hideDefaults": {
"type": "boolean"
},
"autoConnection": {
"type": "boolean"
}
},
"required": [
"properties",
"rights",
"assignmentLines",
"hideProperties",
"hideDefaults",
"autoConnection"
],
"additionalProperties": false
}
2. 节点示例
(1) 示例
AST 如下:
- JSON
- YAML
{
"concept": "NewComposite",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "reference",
"typeNamespace": "app.dataSources.defaultDS.entities",
"typeName": "Student",
"inferred": false,
"ruleMap": {}
},
"properties": [
{
"concept": "Identifier",
"namespace": "",
"name": "id"
},
{
"concept": "Identifier",
"namespace": "",
"name": "createdTime"
},
{
"concept": "Identifier",
"namespace": "",
"name": "updatedTime"
},
{
"concept": "Identifier",
"namespace": "",
"name": "createdBy"
},
{
"concept": "Identifier",
"namespace": "",
"name": "updatedBy"
},
{
"concept": "Identifier",
"namespace": "",
"name": "name"
}
],
"rights": [
{
"concept": "SelectMembers",
"hideMembers": false,
"expression": {
"concept": "StringLiteral",
"value": "学生甲"
},
"members": []
}
],
"assignmentLines": [
{
"concept": "AssignmentLine",
"leftIndex": [
0,
5
],
"rightIndex": [
0
]
}
],
"hideProperties": false,
"hideDefaults": false,
"autoConnection": true
}
concept: NewComposite
typeAnnotation:
concept: TypeAnnotation
typeKind: reference
typeNamespace: app.dataSources.defaultDS.entities
typeName: Student
inferred: false
ruleMap: {}
properties:
- concept: Identifier
namespace: ""
name: id
- concept: Identifier
namespace: ""
name: createdTime
- concept: Identifier
namespace: ""
name: updatedTime
- concept: Identifier
namespace: ""
name: createdBy
- concept: Identifier
namespace: ""
name: updatedBy
- concept: Identifier
namespace: ""
name: name
rights:
- concept: SelectMembers
hideMembers: false
expression:
concept: StringLiteral
value: 学生甲
members: []
assignmentLines:
- concept: AssignmentLine
leftIndex:
- 0
- 5
rightIndex:
- 0
hideProperties: false
hideDefaults: false
autoConnection: true
对应的代码如下:
- 文本化 NASL
- Natural TS
app::dataSources::defaultDS::entities::Student {
id = '学生甲',
}
nasl.util.NewEntity<Student>({ id: '学生甲', createdTime: undefined, updatedTime: undefined, createdBy: undefined, updatedBy: undefined, name: undefined })
(2) 新建匿名数据结构
AST 如下:
- JSON
- YAML
{
"concept": "NewComposite",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "anonymousStructure",
"typeNamespace": "",
"typeName": "",
"inferred": false,
"ruleMap": {},
"properties": [
{
"concept": "StructureProperty",
"name": "name"
},
{
"concept": "StructureProperty",
"name": "age"
}
]
},
"properties": [
{
"concept": "Identifier",
"namespace": "",
"name": "name"
},
{
"concept": "Identifier",
"namespace": "",
"name": "age"
}
],
"rights": [
{
"concept": "SelectMembers",
"hideMembers": false,
"expression": {
"concept": "NumericLiteral",
"value": "24",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Long",
"inferred": false,
"ruleMap": {}
}
},
"members": []
},
{
"concept": "SelectMembers",
"hideMembers": false,
"expression": {
"concept": "StringLiteral",
"value": "学生甲"
},
"members": []
}
],
"assignmentLines": [
{
"concept": "AssignmentLine",
"leftIndex": [
0,
0
],
"rightIndex": [
1
]
},
{
"concept": "AssignmentLine",
"leftIndex": [
0,
1
],
"rightIndex": [
0
]
}
],
"hideProperties": false,
"hideDefaults": false,
"autoConnection": true
}
concept: NewComposite
typeAnnotation:
concept: TypeAnnotation
typeKind: anonymousStructure
typeNamespace: ""
typeName: ""
inferred: false
ruleMap: {}
properties:
- concept: StructureProperty
name: name
- concept: StructureProperty
name: age
properties:
- concept: Identifier
namespace: ""
name: name
- concept: Identifier
namespace: ""
name: age
rights:
- concept: SelectMembers
hideMembers: false
expression:
concept: NumericLiteral
value: "24"
typeAnnotation:
concept: TypeAnnotation
typeKind: primitive
typeNamespace: nasl.core
typeName: Long
inferred: false
ruleMap: {}
members: []
- concept: SelectMembers
hideMembers: false
expression:
concept: StringLiteral
value: 学生甲
members: []
assignmentLines:
- concept: AssignmentLine
leftIndex:
- 0
- 0
rightIndex:
- 1
- concept: AssignmentLine
leftIndex:
- 0
- 1
rightIndex:
- 0
hideProperties: false
hideDefaults: false
autoConnection: true
对应的代码如下:
- 文本化 NASL
- Natural TS
{
name = 24,
age = '学生甲',
}
nasl.util.NewAnonymousStructure({ name: 24, age: '学生甲' })