Comparing version 0.1.19 to 0.1.20
@@ -13,5 +13,7 @@ "use strict"; | ||
if (code.includes('ID_ENUMVALUE_')) { | ||
const id = code.split('.').pop().replace('ID_ENUMVALUE_', ''); | ||
const param = exports.vertexsMap.get(id); | ||
return param && `'${param.value}'` || `'${id}'`; | ||
code = code.replace(/ID_([\w-]+).ID_ENUMVALUE_([\w-]+)/g, (m) => { | ||
const id = m.split('.').pop().replace('ID_ENUMVALUE_', ''); | ||
const param = exports.vertexsMap.get(id); | ||
return param && `'${param.value}'` || `'${id}'`; | ||
}); | ||
} | ||
@@ -18,0 +20,0 @@ // @TODO: 最好后端把 ID 中的 - 都去掉 |
@@ -282,3 +282,3 @@ "use strict"; | ||
function genInitData(schema, relationship = 'None', usedSchemaRefs = {}) { | ||
if (relationship !== 'None' && Object.keys(usedSchemaRefs).every((ref) => ref.includes('/entities/'))) { | ||
if (relationship && relationship !== 'None' && Object.keys(usedSchemaRefs).every((ref) => ref.includes('/entities/'))) { | ||
if (!relationship || relationship.endsWith('ToOne')) { | ||
@@ -285,0 +285,0 @@ return { type: 'ObjectExpression', properties: [{ |
@@ -163,2 +163,3 @@ import { Vertex, LEVEL_ENUM, Logic, Schema } from '..'; | ||
readonly arguments: Array<ExpressionNode>; | ||
readonly params: Array<ExpressionNode>; | ||
readonly value: string; | ||
@@ -165,0 +166,0 @@ readonly method: string; |
@@ -405,3 +405,5 @@ "use strict"; | ||
__1.typeCheck.delete(this.id); | ||
parent?.checkType?.(); | ||
if (parent && parent.checkType) { | ||
parent.checkType(); | ||
} | ||
} | ||
@@ -528,3 +530,3 @@ !cache && this.remove(); | ||
query: { | ||
logicId: this.logic?.id, | ||
logicId: this.logic && this.logic.id, | ||
loItemId: node.id, | ||
@@ -535,4 +537,4 @@ }, | ||
id: node.id, | ||
logicId: this.logic?.id, | ||
typeCheckNote: res?.typeCheckNote, | ||
logicId: this.logic && this.logic.id, | ||
typeCheckNote: res && res.typeCheckNote, | ||
}); | ||
@@ -647,2 +649,3 @@ this._assignTypeCheckResult(node, res); | ||
this.arguments = undefined; | ||
this.params = undefined; | ||
this.value = undefined; | ||
@@ -708,2 +711,5 @@ this.method = undefined; | ||
decorators_1.immutable() | ||
], LogicNode.prototype, "params", void 0); | ||
__decorate([ | ||
decorators_1.immutable() | ||
], LogicNode.prototype, "value", void 0); | ||
@@ -710,0 +716,0 @@ __decorate([ |
@@ -176,3 +176,3 @@ import { LEVEL_ENUM, Page, Element } from '..'; | ||
*/ | ||
mergeCode(code: string, nodePath: string): Promise<void>; | ||
mergeCode(code: string, nodePath: string, position: string, parentNodePath: string): Promise<void>; | ||
/** | ||
@@ -179,0 +179,0 @@ * 从后端 JSON 生成规范的 View 对象 |
@@ -375,3 +375,3 @@ "use strict"; | ||
*/ | ||
async mergeCode(code, nodePath) { | ||
async mergeCode(code, nodePath, position, parentNodePath) { | ||
/** | ||
@@ -409,3 +409,3 @@ * 本来的 Name 相关的集合 | ||
const template = __1.utils.sliceTagContent(code, 'template'); | ||
const parentNode = this.findElementByNodePath(nodePath); | ||
const parentNode = this.findElementByNodePath(parentNodePath); | ||
const viewId = parentNode.view.id; | ||
@@ -420,7 +420,17 @@ const parentId = parentNode.id; | ||
const newNode = __1.Element.parse(template, body.$def); | ||
newNode.assign({ | ||
const paramObj = { | ||
viewId, | ||
parentId, | ||
}); | ||
}; | ||
newNode.assign(paramObj); | ||
body.$html = newNode.toJSON(); | ||
if (position === 'append') { | ||
// 父节点最后追加 | ||
body.$html._posIndex = parentNode.children && parentNode.children.length || 0; | ||
} | ||
else { | ||
// 添加目标标节点的位置 | ||
const posIndex = nodePath.split('/').pop(); | ||
body.$html._posIndex = +posIndex; | ||
} | ||
utils_1.traverse((current) => { | ||
@@ -427,0 +437,0 @@ if (current.node.level === 'element' && current.node.name) |
{ | ||
"name": "@lcap/asl", | ||
"description": "Lowcode Application Specific Language", | ||
"version": "0.1.19", | ||
"version": "0.1.20", | ||
"author": "Forrest <rainforest92@126.com>", | ||
@@ -6,0 +6,0 @@ "scripts": { |
@@ -14,5 +14,7 @@ import { Vertex, Entity } from './index'; | ||
if(code.includes('ID_ENUMVALUE_')){ | ||
const id = code.split('.').pop().replace('ID_ENUMVALUE_', ''); | ||
const param = vertexsMap.get(id); | ||
return param && `'${(param as any).value}'` || `'${id}'`; | ||
code = code.replace(/ID_([\w-]+).ID_ENUMVALUE_([\w-]+)/g, (m) => { | ||
const id = m.split('.').pop().replace('ID_ENUMVALUE_', ''); | ||
const param = vertexsMap.get(id); | ||
return param && `'${(param as any).value}'` || `'${id}'`; | ||
}); | ||
} | ||
@@ -19,0 +21,0 @@ // @TODO: 最好后端把 ID 中的 - 都去掉 |
@@ -274,3 +274,3 @@ import { Schema } from '..'; | ||
export function genInitData(schema: Schema, relationship = 'None', usedSchemaRefs: { [name: string]: boolean } = {}): any { | ||
if (relationship !== 'None' && Object.keys(usedSchemaRefs).every((ref) => ref.includes('/entities/'))) { | ||
if (relationship && relationship !== 'None' && Object.keys(usedSchemaRefs).every((ref) => ref.includes('/entities/'))) { | ||
if (!relationship || relationship.endsWith('ToOne')) { | ||
@@ -277,0 +277,0 @@ return { type: 'ObjectExpression', properties: [{ |
@@ -445,3 +445,5 @@ import { immutable, excludedInJSON, circular, action } from '../decorators'; | ||
parent?.checkType?.(); | ||
if(parent && parent.checkType){ | ||
parent.checkType(); | ||
} | ||
} | ||
@@ -496,3 +498,3 @@ | ||
// 合并params里的id | ||
if(body.params && body.params.length){ | ||
if(body.params && body.params.length) { | ||
const logicItem = LogicItem.from(result, this.logic, this.parent); | ||
@@ -587,3 +589,3 @@ this.assign({ params: (logicItem as any).params }); | ||
query: { | ||
logicId: this.logic?.id, | ||
logicId: this.logic && this.logic.id, | ||
loItemId: node.id, | ||
@@ -595,4 +597,4 @@ }, | ||
id: node.id, | ||
logicId: this.logic?.id, | ||
typeCheckNote: res?.typeCheckNote, | ||
logicId: this.logic && this.logic.id, | ||
typeCheckNote: res && res.typeCheckNote, | ||
}); | ||
@@ -659,2 +661,4 @@ | ||
@immutable() | ||
public readonly params: Array<ExpressionNode> = undefined; | ||
@immutable() | ||
public readonly value: string = undefined; | ||
@@ -661,0 +665,0 @@ @immutable() |
@@ -423,3 +423,3 @@ import { immutable, circular, action } from '../decorators'; | ||
*/ | ||
async mergeCode(code: string, nodePath: string) { | ||
async mergeCode(code: string, nodePath: string, position: string, parentNodePath: string) { | ||
type Replacement = { [name: string]: string }; | ||
@@ -469,3 +469,5 @@ /** | ||
const template = utils.sliceTagContent(code, 'template'); | ||
const parentNode = this.findElementByNodePath(nodePath); | ||
const parentNode = this.findElementByNodePath(parentNodePath); | ||
const viewId = parentNode.view.id; | ||
@@ -482,8 +484,19 @@ const parentId = parentNode.id; | ||
const newNode = Element.parse(template, body.$def); | ||
newNode.assign({ | ||
const paramObj = { | ||
viewId, | ||
parentId, | ||
}) | ||
}; | ||
newNode.assign(paramObj); | ||
body.$html = newNode.toJSON(); | ||
if (position === 'append') { | ||
// 父节点最后追加 | ||
body.$html._posIndex = parentNode.children && parentNode.children.length || 0; | ||
} else { | ||
// 添加目标标节点的位置 | ||
const posIndex = nodePath.split('/').pop(); | ||
body.$html._posIndex = +posIndex; | ||
} | ||
traverse((current) => { | ||
@@ -490,0 +503,0 @@ if (current.node.level === 'element' && current.node.name) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5970347
38231