Skip to main content
Version: 3.7

Module 模块

作为分解应用复杂性、支持导入导出的基本单元。目前这个版本是兼容版,只支持三种类型:扩展模块、接口应用、扩展组件。与后续产品制定的模块类型不冲突。

1. 结构声明

class Module extends BaseNode {
type: 'extension' | 'interface' | 'component' | 'connector' | 'customInterface';
version?: string;
name: string = '';
title?: string;
description?: string;
provider?: string;
externalDependencyMap?: {
maven?: Array<{
groupId: string;
artifactId: string;
version: string;
}>;
};
compilerInfoMap?: {
java?: Array<{
packageName: string;
className: string;
naslName: string;
type: string;
javaTypes: Map<string, string>;
}>;
js?: {
prefix: string;
};
} | Map<string, string>;
dataSources: Array<DataSource>;
structures: Array<Structure>;
enums: Array<Enum>;
logics: Array<Logic>;
interfaces: Array<AbstractInterface>;
views: Array<View>;
frontendVariables: Array<Variable>;
processes: Array<Process>;
processV2s: Array<ProcessV2>;
frontends: Array<FrontendLibrary>;
configuration?: Configuration;
triggerLaunchers: Array<TriggerLauncher>;
connections: Array<Connection>;
metadataTypes: Array<MetadataType>;
}

2. 节点示例

(1) 示例

AST 如下:

{
"concept": "Module",
"type": "extension",
"version": "1.0.0",
"name": "lcap_auth",
"title": "lcap-auth",
"description": "认证扩展依赖库",
"provider": "资产中心-租户",
"externalDependencyMap": {
"maven": [
{
"groupId": "com.netease.lowcode",
"artifactId": "lcap-auth",
"version": "1.0.0"
}
]
},
"dataSources": [],
"structures": [
{
"concept": "Structure",
"name": "LCAPUser",
"description": "System built in generic class LCAPUser",
"properties": [
{
"concept": "StructureProperty",
"name": "userId",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "String",
"inferred": false,
"ruleMap": {}
}
},
{
"concept": "StructureProperty",
"name": "userName",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "String",
"inferred": false,
"ruleMap": {}
}
},
{
"concept": "StructureProperty",
"name": "extensionInfos",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "generic",
"typeNamespace": "nasl.collection",
"typeName": "Map",
"typeArguments": [
{
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "String",
"inferred": false,
"ruleMap": {}
},
{
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "String",
"inferred": false,
"ruleMap": {}
}
],
"inferred": false,
"ruleMap": {}
}
}
]
}
],
"enums": [],
"logics": [
{
"concept": "Logic",
"name": "getUser",
"description": "获取当前登录用户",
"overridable": true,
"params": [],
"returns": [
{
"concept": "Return",
"name": "result",
"description": "LCAPUser 用户信息",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "reference",
"typeNamespace": "extensions.lcap_auth.structures",
"typeName": "LCAPUser",
"inferred": false,
"ruleMap": {}
}
}
],
"variables": [],
"body": [],
"playground": []
}
],
"interfaces": [],
"views": [],
"frontendVariables": [],
"processes": [],
"processV2s": [],
"frontends": [],
"triggerLaunchers": [],
"connections": [],
"metadataTypes": []
}

对应的代码如下:

@(
type = "extension",
version = "1.0.0",
title = "lcap-auth",
description = "认证扩展依赖库",
provider = "资产中心-租户",
externalDependencyMap = [ "maven" -> [{"groupId":"com.netease.lowcode","artifactId":"lcap-auth","version":"1.0.0"}] ],
)
module lcap_auth {
@(description = "System built in generic class LCAPUser")
struct LCAPUser {
userId: String;

userName: String;

extensionInfos: Map<String, String>;
}
//
@(
description = "获取当前登录用户",
overridable = true,
)
declare logic getUser() => result: extensions::lcap_auth::structures::LCAPUser;
//
}

(2) 示例

AST 如下:

{
"concept": "Module",
"type": "interface",
"name": "getPhoneFrom",
"dataSources": [],
"structures": [
{
"concept": "Structure",
"name": "result",
"description": "",
"typeParams": [],
"properties": [
{
"concept": "StructureProperty",
"name": "province",
"description": "",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "String",
"inferred": false,
"ruleMap": {}
},
"jsonName": "province"
},
{
"concept": "StructureProperty",
"name": "city",
"description": "",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "String",
"inferred": false,
"ruleMap": {}
},
"jsonName": "city"
},
{
"concept": "StructureProperty",
"name": "areaCode",
"description": "",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "String",
"inferred": false,
"ruleMap": {}
},
"jsonName": "areacode"
},
{
"concept": "StructureProperty",
"name": "zip",
"description": "",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "String",
"inferred": false,
"ruleMap": {}
},
"jsonName": "zip"
},
{
"concept": "StructureProperty",
"name": "company",
"description": "",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "String",
"inferred": false,
"ruleMap": {}
},
"jsonName": "company"
}
]
},
{
"concept": "Structure",
"name": "ApiReturnOfPhone",
"description": "",
"typeParams": [],
"properties": [
{
"concept": "StructureProperty",
"name": "error_code",
"description": "",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Long",
"inferred": false,
"ruleMap": {}
},
"jsonName": "error_code"
},
{
"concept": "StructureProperty",
"name": "reason",
"description": "",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "String",
"inferred": false,
"ruleMap": {}
},
"defaultValue": {
"concept": "DefaultValue",
"expression": {
"concept": "StringLiteral",
"value": ""
},
"playground": []
},
"jsonName": "reason"
},
{
"concept": "StructureProperty",
"name": "result",
"description": "",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "reference",
"typeNamespace": "apis.getPhoneFrom.structures",
"typeName": "result",
"inferred": false,
"ruleMap": {}
},
"jsonName": "result"
}
]
}
],
"enums": [],
"logics": [],
"interfaces": [
{
"concept": "Interface",
"name": "phone",
"path": "/gw/getPhoneFrom/mobile/get",
"method": "GET",
"description": "",
"params": [
{
"concept": "InterfaceParam",
"name": "phone",
"description": "",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Long",
"inferred": false,
"ruleMap": {}
},
"in": "query",
"required": true
},
{
"concept": "InterfaceParam",
"name": "key",
"description": "",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "String",
"inferred": false,
"ruleMap": {}
},
"in": "query",
"required": true,
"defaultValue": {
"concept": "DefaultValue",
"expression": {
"concept": "StringLiteral",
"value": ""
},
"playground": []
}
},
{
"concept": "InterfaceParam",
"name": "type",
"description": "",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "String",
"inferred": false,
"ruleMap": {}
},
"in": "query",
"required": false,
"defaultValue": {
"concept": "DefaultValue",
"expression": {
"concept": "StringLiteral",
"value": ""
},
"playground": []
}
}
],
"returns": [
{
"concept": "Return",
"name": "result",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "reference",
"typeNamespace": "apis.getPhoneFrom.structures",
"typeName": "ApiReturnOfPhone",
"inferred": false,
"ruleMap": {}
}
}
]
}
],
"views": [],
"frontendVariables": [],
"processes": [],
"processV2s": [],
"frontends": [],
"triggerLaunchers": [],
"connections": [],
"metadataTypes": []
}

对应的代码如下:

@(
type = "interface",
)
module getPhoneFrom {
@(description = "")
struct result {
@(
description = "",
jsonName = "province",
)
province: String;

@(
description = "",
jsonName = "city",
)
city: String;

@(
description = "",
jsonName = "areacode",
)
areaCode: String;

@(
description = "",
jsonName = "zip",
)
zip: String;

@(
description = "",
jsonName = "company",
)
company: String;
}
//
@(description = "")
struct ApiReturnOfPhone {
@(
description = "",
jsonName = "error_code",
)
error_code: Integer;

@(
description = "",
jsonName = "reason",
)
reason: String = '';

@(
description = "",
jsonName = "result",
)
result: apis::getPhoneFrom::structures::result;
}
//
interface phone(
@(
description = "",
in = "query",
)
phone: Integer,
@(
description = "",
in = "query",
)
key: String = '',
@(
description = "",
in = "query",
)
type: String = '') => result: apis::getPhoneFrom::structures::ApiReturnOfPhone;
}