@lcap/asl
Version:
NetEase Application Specific Language
122 lines (121 loc) • 2.94 kB
TypeScript
import { LEVEL_ENUM, Vertex, DataNode, Service, Structure, MicroService, Interface, ObjectSchema, EntityProperty, ActionOptions, EntityIndex } from '..';
export interface Resolver {
level: 'resolver';
name: string;
interface: Interface;
entity: Entity;
isLeaf: boolean;
}
export declare const systemProperty: {
[name: string]: any;
};
/**
* 实体类
*/
export declare class Entity extends Vertex implements ObjectSchema {
/**
* 概念类型
*/
readonly level: LEVEL_ENUM;
/**
* 实体 Id
*/
readonly id: string;
/**
* dataTypes 中的唯一标识
*/
readonly schemaRef: string;
/**
* 实体名称
*/
readonly name: string;
/**
* 实体描述
*/
readonly description: string;
/**
* 实体类型(如enum)
*/
readonly type: 'object';
/**
* 实体属性列表
*/
readonly propertyList: Array<EntityProperty>;
/**
* 实体索引列表
*/
readonly indexList: Array<EntityIndex>;
readonly resolvers: Array<Resolver>;
/**
* 所属服务 Id
*/
readonly serviceId: string;
/**
* 所属服务类型
*/
readonly serviceType: string;
/**
* 所属服务
*/
readonly service: MicroService;
/**
* 上个版本数据
*/
readonly lastVersionDef: any;
/**
* 父节点
*/
readonly dataNode: DataNode;
/**
* 周边存在的名称
*/
existingNames: Array<string>;
static properties2PropertyList: any;
/**
* @param source 需要合并的部分参数
*/
constructor(source?: Partial<Entity>);
/**
* 按当前 id 加载实体数据
* @requires this.id
*/
load(): Promise<this>;
/**
* 添加实体
*/
create(none?: void, actionOptions?: ActionOptions): Promise<this>;
/**
* 修改实体
*/
update(none?: void, actionOptions?: ActionOptions, then?: () => Promise<any>): Promise<this>;
/**
* 删除实体
*/
delete(none?: void, actionOptions?: ActionOptions): Promise<void>;
/**
* 设置实体名称
* @param name 名称
*/
setName(name: string): Promise<void>;
/**
* 设置实体描述
* @param description 描述
*/
setDescription(description: string): Promise<void>;
/**
* 同步interfaces
* interface、logic、params、returns、variabes采用plainAssign
* 创建、删除实体,修改实体名称、增删改实体property需要同步
*/
syncInterfaces(isDelete?: boolean): Promise<void>;
/**
* 同步structures
* 创建、删除实体,修改实体名称需要同步
*/
syncStructures(isDelete?: boolean): Promise<Structure[]>;
/**
* 从后端 JSON 生成规范的 Entity 对象
*/
static from(source: any, service: Service): Entity;
}
export default Entity;