@lcap/asl
Version:
NetEase Application Specific Language
320 lines (319 loc) • 9.51 kB
TypeScript
import { Vertex, LEVEL_ENUM, Logic, Schema, ActionOptions } from '..';
export declare enum LOGIC_TYPE {
Start = "Start",
ProcessOutcome = "ProcessOutcome",
End = "End",
IfStatement = "IfStatement",
SwitchStatement = "SwitchStatement",
SwitchCase = "SwitchCase",
ForEachStatement = "ForEachStatement",
WhileStatement = "WhileStatement",
AssignmentExpression = "AssignmentExpression",
Comment = "Comment",
CallLogic = "CallLogic",
CallInterface = "CallInterface",
CallInterParam = "CallInterParam",
CallGraphQL = "CallGraphQL",
DBQuery = "DBQuery",
CronJob = "CronJob",
JSONSerialize = "JSONSerialize",
JSONDeserialize = "JSONDeserialize",
CallMessageShow = "CallMessageShow",
CallConsoleLog = "CallConsoleLog",
JSBlock = "JSBlock",
TypeNote = "TypeNote",
CallQueryComponent = "CallQueryComponent",
Identifier = "Identifier",
NumericLiteral = "NumericLiteral",
BooleanLiteral = "BooleanLiteral",
StringLiteral = "StringLiteral",
NullLiteral = "NullLiteral",
UnaryExpression = "UnaryExpression",
BinaryExpression = "BinaryExpression",
LogicalExpression = "LogicalExpression",
MemberExpression = "MemberExpression",
CallExpression = "CallExpression",
ObjectExpression = "ObjectExpression",
ArrayExpression = "ArrayExpression",
Destination = "Destination",
DestinationParam = "DestinationParam",
BuiltInFunction = "BuiltInFunction",
BuiltInFuncParam = "BuiltInFuncParam",
Unparsed = "Unparsed",
QuerySelectExpression = "QuerySelectExpression",
QueryFromExpression = "QueryFromExpression",
QueryJoinExpression = "QueryJoinExpression",
QueryAggregateExpression = "QueryAggregateExpression"
}
export declare function evaluate(node: LogicNode | ExpressionNode, finalCode?: boolean): string;
export declare const logicItemKeyOfLogicItem: string[];
export declare const logicItemArrayKeyOfLogicItem: string[];
/**
* 逻辑项类
*/
export declare class LogicItem extends Vertex {
/**
* 概念类型
*/
readonly level: LEVEL_ENUM;
/**
* Id
*/
readonly id: string;
/**
* 父级 Id
*/
readonly parentId: string;
/**
* 所属父级属性
*/
readonly parentAttr: string;
readonly parent: LogicItem;
readonly logicId: string;
readonly logic: Logic;
/**
* 标题
*/
readonly label: string;
folded: boolean;
placeholderName: string;
/**
* OffsetX
*/
readonly offsetX: number;
/**
* OffsetY
*/
readonly offsetY: number;
/**
* 所在位置
*/
readonly _posIndex: number;
/**
* 标题
*/
readonly type: string;
/**
* Ref
*/
readonly refTarget: any;
readonly callInterParam: any;
readonly callInterParamValue: any;
readonly builtInFuncParamValue: any;
readonly pageParamKey: any;
readonly pageParamKeyValue: any;
/**
* CallQueryComponent 对应的 structure 的 id
*/
readonly structureRef: string;
readonly schema?: Schema;
/**
* 类型校验结果
*/
typeCheckNote: any;
/**
* @param source 需要合并的部分参数
*/
constructor(source?: Partial<LogicItem>);
/**
* 纯前端添加
*/
addIn(parent: LogicItem, parentId: string, parentAttr: string, _posIndex: number): void;
/**
* @temp 临时的
* @param body
*/
static preprocess(body: any): void;
/**
* 创建
* @requires this.logic
* @param parent
* @param parentId
* @param parentAttr
* @param _posIndex
* @param cache 在前端不处理节点
*/
create({ parent, parentId, parentAttr, _posIndex, cache, offsetX, offsetY, }: {
parent: LogicItem;
parentId: string;
parentAttr: string;
_posIndex?: number;
cache?: boolean;
offsetX?: number;
offsetY?: number;
}, actionOptions?: ActionOptions): Promise<void>;
/**
* 创建或移动
* @requires this.logic
* @param parent
* @param parentId
* @param parentAttr
* @param _posIndex
* @param cache 在前端不处理节点
*/
move({ parent, parentId, parentAttr, _posIndex, cache, offsetX, offsetY, }: {
parent: LogicItem;
parentId: string;
parentAttr: string;
_posIndex?: number;
cache?: boolean;
offsetX?: number;
offsetY?: number;
}, actionOptions?: ActionOptions): Promise<void>;
/**
* 创建或移动
* @requires this.logic
* @param parent
* @param parentId
* @param parentAttr
* @param _posIndex
* @param cache 在前端不处理节点
*/
createOrMove(options: {
parent: LogicItem;
parentId: string;
parentAttr: string;
_posIndex?: number;
cache?: boolean;
offsetX?: number;
offsetY?: number;
}, actionOptions?: ActionOptions): Promise<void>;
/**
* 粘贴
* @param logicItems
* @param targetType
* @param targetId
*/
static paste(logicItems: LogicItem[] | LogicItem, targetType: 'logic' | 'html' | 'processComponent', targetId: string): Promise<void>;
static redoPaste(res: any): Promise<void>;
static undoPaste(res: any): Promise<void>;
/**
* 粘贴预处理,用于粘贴到表达式输入弹窗。此处,粘贴没有立即提交到后端,点击确定按钮后才提交。
* @param logicItems
* @param targetType
* @param targetId
*/
static pretreatmentBeforePaste(logicItems: LogicItem[] | LogicItem, targetType: 'logic' | 'html' | 'processComponent', targetId: string): Promise<any>;
/**
* 纯前端创建
*/
virtualCreate(parent: LogicItem, parentId: string, parentAttr: string, _posIndex?: number, cache?: boolean): void;
/**
* 纯前端 replaceWith
*/
virtualReplaceWith(logicItem: LogicItem): Promise<this>;
/**
* 纯前端删除
*/
remove(): void;
/**
* 删除逻辑节点
* @param cache 在前端不处理节点
*/
delete(cache?: boolean, actionOptions?: ActionOptions): Promise<void>;
/**
* LogicItem 有选择框的情况,为了减少变量变更,使用 replaceWith 的方式
*/
replaceWith(logicItem: LogicItem): Promise<this>;
/**
* 修改逻辑项
*/
update(source?: LogicItem, actionOptions?: ActionOptions): Promise<any>;
/**
* 设置逻辑项标题
* @param label 标题
*/
setLabel(label: string): Promise<void>;
/**
* 从后端 JSON 生成规范的 ExpressionNode 对象
* @param source JSON
* @param logic 父级 logic
*/
static from(source: any, logic: Logic, parent: LogicItem, shouldCreateNewItem?: boolean): LogicItem;
/**
* 校验类型
*/
checkType(): Promise<void>;
private _checkType;
static assignTypeCheckResult(logicItem: LogicItem | LogicItem[], typeCheckResult: any): void;
/**
* 生成 JS 脚本
*/
toScript(): string;
getLogicItem(type: LOGIC_TYPE): LogicItem;
getSelectedTabOfCallQueryComponent(activeImage: any): {
tab: string;
parentAttr: any;
};
}
export declare class LogicNode extends LogicItem {
/**
* 逻辑节点类型
*/
readonly type: LOGIC_TYPE;
readonly test: ExpressionNode;
readonly consequent: Array<LogicNode>;
readonly alternate: Array<LogicNode>;
readonly cases: Array<LogicNode>;
readonly each: ExpressionNode;
readonly item: ExpressionNode;
readonly index: ExpressionNode;
readonly start: ExpressionNode;
readonly end: ExpressionNode;
readonly body: Array<LogicNode>;
readonly operator: string;
readonly left: LogicItem;
readonly right: LogicItem;
readonly arguments: Array<ExpressionNode>;
readonly params: Array<ExpressionNode>;
readonly value: string;
readonly method: string;
readonly entity: string;
readonly action: string;
readonly processDefinitionKey: string;
readonly taskId: string;
readonly finished: string;
readonly processInstanceId: string;
readonly schemaRef: string;
readonly returnSchema: Schema;
readonly cron: string;
readonly page: string;
readonly url: string;
readonly code: string;
readonly calleeCode: string;
readonly interfaceKey: string;
readonly name: string;
readonly from: ExpressionNode;
/**
* @param source 需要合并的部分参数
*/
constructor(source?: Partial<LogicNode>);
}
export declare class ExpressionNode extends LogicItem {
/**
* 逻辑节点类型
*/
readonly type: LOGIC_TYPE;
readonly left: LogicItem;
readonly right: LogicItem;
readonly code: string;
readonly name: string;
readonly key: ExpressionNode;
readonly value: string | ExpressionNode;
readonly object: ExpressionNode;
readonly property: ExpressionNode;
readonly operator: string;
readonly properties: Array<ExpressionNode>;
readonly elements: Array<ExpressionNode>;
readonly callee: ExpressionNode;
readonly argument: ExpressionNode;
/**
* SchemaRef
*/
readonly schemaRef: string;
readonly joinType: 'INNER' | 'LEFT' | 'RIGHT' | 'FULL';
/**
* @param source 需要合并的部分参数
*/
constructor(source?: Partial<ExpressionNode>);
}