UNPKG

@lcap/asl

Version:

NetEase Application Specific Language

159 lines 5.03 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.BaseVariable = exports.updateAllVariablesChildrenSchema = exports.updateVariablesChildrenSchema = exports.variablesMap = void 0; const decorators_1 = require("../decorators"); const __1 = require(".."); /** * 开发时所有的变量,一般用于数据类型变更等 */ exports.variablesMap = new Map(); function updateVariablesChildrenSchema(schemaRef) { // Map 直接 forEach 会有问题 const variables = Array.from(exports.variablesMap, ([name, value]) => value); variables.forEach((variable) => { if (variable.schema && variable.schema.typeKey && variable.schema.typeKey === schemaRef) { variable.genSchemaChildren(); } }); } exports.updateVariablesChildrenSchema = updateVariablesChildrenSchema; /** * 针对 param1.b.c 的形式,c 实体修改后需要改 param1 的 childrenSchema * 建立反向引用太复杂,干脆直接更新全量引用类型的变量结构 */ function updateAllVariablesChildrenSchema() { // Map 直接 forEach 会有问题 const variables = Array.from(exports.variablesMap, ([name, value]) => value); variables.forEach((variable) => { if (variable.schema && variable.schema.typeKey) { variable.genSchemaChildren(); } }); } exports.updateAllVariablesChildrenSchema = updateAllVariablesChildrenSchema; /** * 逻辑输入参数 */ class BaseVariable extends __1.Vertex { /** * @param source 需要合并的部分参数 */ constructor(source) { super(); /** * 概念类型 */ this.level = __1.LEVEL_ENUM.variable; /** * 参数类型 * 这里暂时用不到,固定 */ this.type = 'Identifier'; /** * Id */ this.id = undefined; /** * 代码唯一标识 */ this.code = undefined; /** * 名称 */ this.name = undefined; /** * 描述 */ this.description = undefined; /** * 位置 */ this._posIndex = undefined; /** * 逻辑Id */ this.logicId = undefined; /** * 逻辑 */ this.logic = undefined; /** * 描述 */ this.schema = undefined; this.schemaChildren = undefined; /** * 是否必须 */ this.required = undefined; /** * 节点是否为叶子节点 * 前端 UI 状态 */ this.isLeaf = true; source && this.assign(source); } assign(source) { const oldId = this.id; oldId && exports.variablesMap.delete(oldId); this.id && exports.variablesMap.set(this.id, this); super.assign(source); } genCode() { return `ID_${this.id}`; } genSchemaChildren() { const children = !this.entityFieldId ? __1.genRefSchemaChildren(this.schema, this.code) : undefined; this.assign({ schemaChildren: children, isLeaf: !children, }); } } __decorate([ decorators_1.immutable() ], BaseVariable.prototype, "level", void 0); __decorate([ decorators_1.immutable() ], BaseVariable.prototype, "type", void 0); __decorate([ decorators_1.immutable() ], BaseVariable.prototype, "id", void 0); __decorate([ decorators_1.immutable() ], BaseVariable.prototype, "code", void 0); __decorate([ decorators_1.immutable() ], BaseVariable.prototype, "name", void 0); __decorate([ decorators_1.immutable() ], BaseVariable.prototype, "description", void 0); __decorate([ decorators_1.immutable() ], BaseVariable.prototype, "_posIndex", void 0); __decorate([ decorators_1.immutable() ], BaseVariable.prototype, "logicId", void 0); __decorate([ decorators_1.excludedInJSON(), decorators_1.immutable() ], BaseVariable.prototype, "logic", void 0); __decorate([ decorators_1.immutable() ], BaseVariable.prototype, "schema", void 0); __decorate([ decorators_1.excludedInJSON(), decorators_1.immutable() ], BaseVariable.prototype, "schemaChildren", void 0); __decorate([ decorators_1.immutable() ], BaseVariable.prototype, "required", void 0); exports.BaseVariable = BaseVariable; exports.default = BaseVariable; //# sourceMappingURL=BaseVariable.js.map