Socket
Socket
Sign inDemoInstall

@lcap/asl

Package Overview
Dependencies
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lcap/asl - npm Package Compare versions

Comparing version 0.1.4 to 0.1.5

out/types/data/Entity.d.ts

2

out/service/common/preprocess.js

@@ -29,3 +29,3 @@ "use strict";

external: 'EXTERNAL',
ENTITY: 'ENTITY',
entity: 'ENTITY',
};

@@ -32,0 +32,0 @@ const ReverseServiceType = {};

@@ -891,46 +891,38 @@ "use strict";

},
"consequent": {
"level": "logicNode",
"type": "BlockStatement",
"body": [
{
"level": "logicNode",
"type": "CallInterface",
"label": "调用接口",
"interfaceKey": "zystest3_backend/updateProduct",
"params": [
{
"name": "body",
"in": "body",
"value": {
"type": "Identifier",
"name": "input"
}
"consequent": [
{
"level": "logicNode",
"type": "CallInterface",
"label": "调用接口",
"interfaceKey": "zystest3_backend/updateProduct",
"params": [
{
"name": "body",
"in": "body",
"value": {
"type": "Identifier",
"name": "input"
}
]
}
]
},
"alternate": {
"level": "logicNode",
"type": "BlockStatement",
"body": [
{
"level": "logicNode",
"type": "CallInterface",
"label": "调用接口",
"interfaceKey": "zystest3_backend/createProduct",
"params": [
{
"name": "body",
"in": "body",
"value": {
"type": "Identifier",
"name": "input"
}
}
]
}
],
"alternate": [
{
"level": "logicNode",
"type": "CallInterface",
"label": "调用接口",
"interfaceKey": "zystest3_backend/createProduct",
"params": [
{
"name": "body",
"in": "body",
"value": {
"type": "Identifier",
"name": "input"
}
]
}
]
}
}
]
}
]
},

@@ -937,0 +929,0 @@ {

@@ -53,12 +53,3 @@ declare namespace _default {

export { _delete as delete };
export namespace addParam {
export namespace url_5 {
const path_5: string;
export { path_5 as path };
const method_5: string;
export { method_5 as method };
}
export { url_5 as url };
}
}
export default _default;

@@ -47,9 +47,3 @@ "use strict";

},
addParam: {
url: {
path: '/proxy/graph/api/v1/graph/view/param',
method: 'post',
},
},
};
//# sourceMappingURL=view.js.map

@@ -43,2 +43,6 @@ import { LEVEL_ENUM, Vertex, App, Page, DataNode, Entity, Structure, Enum, Interface } from '..';

/**
* 接口列表
*/
readonly interfaces: Array<Interface>;
/**
* 所在的 App

@@ -45,0 +49,0 @@ * 父级引用,便于在树状结构中查找

@@ -64,2 +64,6 @@ "use strict";

/**
* 接口列表
*/
this.interfaces = [];
/**
* 所在的 App

@@ -103,3 +107,3 @@ * 父级引用,便于在树状结构中查找

async loadInterfaces() {
const interfaces = await data_1.interfaceService.loadList({
let interfaces = await data_1.interfaceService.loadList({
query: {

@@ -109,3 +113,5 @@ serviceId: this.id,

});
return interfaces.map((item) => __1.Interface.from(item, this));
interfaces = interfaces.map((item) => __1.Interface.from(item, this));
this.assign({ interfaces });
return interfaces;
}

@@ -138,2 +144,5 @@ }

__decorate([
decorators_1.immutable()
], Service.prototype, "interfaces", void 0);
__decorate([
decorators_1.circular(),

@@ -184,3 +193,3 @@ decorators_1.immutable()

console.log(result, 'result');
result.id = result.appId;
// result.id = result.appId;
this.assign(result);

@@ -220,10 +229,10 @@ return this;

name: 'cloud-admin-template',
version: "0.2.22"
version: '0.2.22',
},
ui: {
name: "cloud-ui.vusion",
version: "0.11.23"
name: 'cloud-ui.vusion',
version: '0.11.23',
},
componentDependencies: {
'lcap-login': "^0.3.3"
'lcap-login': '^0.3.3',
},

@@ -230,0 +239,0 @@ };

@@ -29,4 +29,4 @@ "use strict";

this.erdiagrams = [];
this.entityExpanded = false;
this.structureExpanded = false;
this.entityExpanded = true;
this.structureExpanded = true;
this.service = undefined;

@@ -33,0 +33,0 @@ source && this.assign(source);

@@ -35,2 +35,3 @@ "use strict";

const Structure_1 = __importStar(require("./Structure"));
;
/**

@@ -120,3 +121,3 @@ * 实体属性类

__1.convert2RefType(result);
this.plainAssign(result);
this.deepPick(result, ['id']);
__1.history.push(`添加实体"${this.root.name}"属性"${this.name}"`);

@@ -151,4 +152,4 @@ return this;

});
__1.convert2RefType(result);
this.plainAssign(result);
// convert2RefType(result);
// this.plainAssign(result);
return this;

@@ -212,5 +213,3 @@ }

this.assign({ relationship });
await this.save({
relationship,
});
await this.update();
}

@@ -423,5 +422,5 @@ /**

});
this.plainAssign(result);
__1.convert2RefType(result);
this.propertyList.forEach((property, index) => property.plainAssign(result.propertyList[index]));
this.deepPick(result, ['id']);
// convert2RefType(result);
// this.propertyList.forEach((property, index) => property.plainAssign(result.propertyList[index]));
this.assign({

@@ -433,4 +432,9 @@ schemaRef: `#/${this.dataNode.service.id}/${result.id}`,

await this.addEntityStructures();
await this.addEntityInterfaces();
return this;
}
/**
* 添加实体相关的数据结构
* @TODO 后面改为后端实现
*/
async addEntityStructures() {

@@ -441,6 +445,8 @@ const structures = entityUtils_1.getEntityStructures(this);

const refStructures = structures.filter((structure) => structure.structureRef);
const normalTasks = normalStructures.map(async (item) => {
let normalTasks = normalStructures.map(async (item) => {
const structure = new Structure_1.default(Object.assign(item, {
serviceId: this.dataNode.service.id,
serviceType: this.dataNode.service.type,
serviceType: 'entity',
entityId: this.id,
dataNode: this.dataNode,
editable: false,

@@ -456,2 +462,3 @@ }));

catch (err) {
console.error(err);
return 'error';

@@ -462,7 +469,9 @@ }

normalResults = normalResults.filter((result) => result !== 'error');
this.dataNode.structures.push(...normalResults);
const refTasks = refStructures.map(async (item) => {
this.dataNode.structures.unshift(...normalResults);
let refTasks = refStructures.map(async (item) => {
const structure = new Structure_1.default(Object.assign(item, {
serviceId: this.dataNode.service.id,
serviceType: this.dataNode.service.type,
serviceType: 'entity',
entityId: this.id,
dataNode: this.dataNode,
editable: false,

@@ -483,2 +492,3 @@ }));

catch (err) {
console.error(err);
return 'error';

@@ -489,14 +499,19 @@ }

refResults = refResults.filter((result) => result !== 'error');
this.dataNode.structures.push(...refResults);
this.dataNode.structures.unshift(...refResults);
}
async addEntityInterface() {
/**
* 添加实体相关的接口
* @TODO 后面改为后端实现
*/
async addEntityInterfaces() {
const tasks = entityUtils_1.getEntityInterfaces(this).map(async (item) => {
let itemString = JSON.stringify(item.data);
const reg = /<(.+?)>/g;
const reg = /<#\/(.+?)>/g;
let ref = itemString.match(reg);
if (ref) {
ref = ref[0].replace('<', '').replace('>', '');
const refData = __1.dataTypesMap[ref];
if (refData) {
itemString = itemString.replace(reg, `#/${this.dataNode.service.id}/${refData.id}`);
const name = ref[0].replace('<#/', '').replace('>', '');
const dataTypeKey = Object.keys(__1.dataTypesMap).find((key) => __1.dataTypesMap[key].name === name);
const dataType = __1.dataTypesMap[dataTypeKey];
if (dataType) {
itemString = itemString.replace(reg, `#/${this.dataNode.service.id}/${dataType.id}`);
item.data = JSON.parse(itemString);

@@ -507,15 +522,17 @@ }

const parameters = JSON.parse(item.data.parameters);
const params = Object.keys(parameters).map((key) => __1.convert2SchemaType(Object.assign({
level: 'param',
type: 'Identifier',
}, parameters[key])));
const params = Object.keys(parameters).map((key) => {
const param = new __1.Param(Object.assign({
type: 'Identifier',
}, parameters[key]));
param.assign({ schema: __1.convert2RefType(param.schema) });
return param;
});
if (item.data.requestBody) {
const content = JSON.parse(item.data.requestBody).content;
if (content) {
params.push(__1.convert2SchemaType({
level: 'param',
params.push(new __1.Param({
type: 'Identifier',
name: 'body',
in: 'body',
schema: content['application/json'].schema,
schema: __1.convert2RefType(content['application/json'].schema),
}));

@@ -525,9 +542,52 @@ }

const responses = JSON.parse(item.data.responses);
const returns = responses[200] ? [{
level: 'return',
const returns = responses[200] ? [new __1.Return({
type: 'Identifier',
name: 'result',
schema: responses[200].content['application/json'].schema,
}] : [];
schema: __1.convert2RefType(responses[200].content['application/json'].schema),
})] : [];
try {
const logic = new __1.Logic({
name: item.data.name,
description: '',
params,
returns,
variables: [],
moduleId: this.dataNode.service.id,
moduleType: 'microService',
serviceId: this.dataNode.service.id,
serviceType: 'entity',
entityId: this.id,
editable: false,
});
const itface = new __1.Interface(Object.assign({
serviceId: this.dataNode.service.id,
serviceType: 'entity',
editable: false,
}, item.data));
itface.assign({ logic });
await itface.create();
return itface;
}
catch {
return Promise.resolve('error');
}
// return interfaceService.create({
// body: item.data,
// }).then((res) => ({
// data: Object.assign({ id: res, level: 'interface' }, item.data),
// resolver: item.resolver,
// }))
// .catch((err) => 'error');
});
const results = await Promise.all(tasks);
const interfaces = results.filter((item) => item !== 'error');
this.dataNode.service.interfaces.unshift(...interfaces);
// // 发送消息更新接口
// this.$publish('data.fragment.addInterface', {
// interfaces: interfaces.map((item) => item.data),
// service: this.dataNode.service,
// });
// // 创建resolvers
// return this.updateResolvers(this, interfaces);
// });
}

@@ -557,4 +617,4 @@ /**

});
__1.convert2RefType(result);
this.plainAssign(result);
// convert2RefType(result);
// this.plainAssign(result);
return this;

@@ -567,2 +627,3 @@ }

if (this.id) {
await this.removeEntityInterfaces();
await this.removeEntityStructures();

@@ -580,2 +641,5 @@ await data_1.entityService.delete({

}
/**
* 删除实体相关的数据结构
*/
async removeEntityStructures() {

@@ -607,2 +671,17 @@ const structureNames = entityUtils_1.getEntityStructureNames(this.name);

/**
* 删除实体相关的接口
*/
async removeEntityInterfaces() {
const interfaces = this.dataNode.service.interfaces.filter((item) => item.logic && item.logic.entityId === this.id);
const tasks = interfaces.map(async (item) => {
try {
await item.delete();
}
catch (err) {
return 'error';
}
});
await Promise.all(tasks);
}
/**
* 设置实体名称

@@ -609,0 +688,0 @@ * @param name 名称

@@ -436,3 +436,3 @@ "use strict";

schema: {
$ref: `<#/${service.name}/structures/ApiReturnOfPageOf${utils_1.firstUpperCase(entity.name)}>`,
$ref: `<#/ApiReturnOfPageOf${utils_1.firstUpperCase(entity.name)}>`,
},

@@ -465,3 +465,3 @@ },

schema: {
$ref: `<#/${service.name}/structures/ApiReturnOf${utils_1.firstUpperCase(entity.name)}>`,
$ref: `<#/ApiReturnOf${utils_1.firstUpperCase(entity.name)}>`,
},

@@ -497,3 +497,3 @@ },

schema: {
$ref: `<#/${service.name}/structures/ApiReturnOf${utils_1.firstUpperCase(entity.name)}>`,
$ref: `<#/ApiReturnOf${utils_1.firstUpperCase(entity.name)}>`,
},

@@ -559,3 +559,3 @@ },

schema: {
$ref: `<#/${service.name}/structures/ApiReturnOf${utils_1.firstUpperCase(entity.name)}>`,
$ref: `<#/ApiReturnOf${utils_1.firstUpperCase(entity.name)}>`,
},

@@ -582,3 +582,3 @@ },

schema: {
$ref: `<#/${service.name}/structures/ApiReturnOflong${utils_1.firstUpperCase(entity.name)}>`,
$ref: `<#/ApiReturnOflong${utils_1.firstUpperCase(entity.name)}>`,
},

@@ -605,3 +605,3 @@ },

schema: {
$ref: `<#/${service.name}/structures/ApiReturnOflong${utils_1.firstUpperCase(entity.name)}>`,
$ref: `<#/ApiReturnOflong${utils_1.firstUpperCase(entity.name)}>`,
},

@@ -628,3 +628,3 @@ },

schema: {
$ref: `<#/${service.name}/structures/ApiReturnOflong${utils_1.firstUpperCase(entity.name)}>`,
$ref: `<#/ApiReturnOflong${utils_1.firstUpperCase(entity.name)}>`,
},

@@ -631,0 +631,0 @@ },

@@ -63,3 +63,3 @@ "use strict";

}
this.plainAssign(result);
this.deepPick(result, ['id']);
// const schemaRef = `#/${source.serviceId}/${result.id}`;

@@ -66,0 +66,0 @@ __1.history.push(`添加枚举"${this.name}"`);

@@ -53,3 +53,3 @@ import { LEVEL_ENUM, Vertex, MicroService, Logic, Service } from '..';

*/
readonly serviceType: 'micro';
readonly serviceType: 'micro' | 'entity';
/**

@@ -60,2 +60,6 @@ * Service Id

/**
* 所属实体 Id
*/
readonly entityId: string;
/**
* Service 名称

@@ -62,0 +66,0 @@ */

@@ -75,2 +75,6 @@ "use strict";

/**
* 所属实体 Id
*/
this.entityId = undefined;
/**
* Service 名称

@@ -122,17 +126,9 @@ */

async create() {
const logic = new __1.Logic({
name: this.name,
description: '',
moduleType: 'microService',
moduleId: this.service.id,
interface: this,
});
await logic.create();
await this.logic.create();
this.assign({
path: '/' + this.name,
logicId: logic.id,
logic,
logicId: this.logic.id,
});
const body = this.toJSON();
body.logicId = logic.id;
body.logicId = this.logic.id;
__1.utils.logger.debug('添加接口', body);

@@ -150,2 +146,4 @@ const result = await data_1.interfaceService.create({

async delete() {
if (this.logic)
await this.logic.delete();
if (this.id) {

@@ -152,0 +150,0 @@ await data_1.interfaceService.delete({

@@ -164,2 +164,6 @@ import { LEVEL_ENUM, Vertex, DataNode, Schema, ObjectSchema, Service } from '..';

/**
* 所属实体 Id
*/
readonly entityId: string;
/**
* 所属服务

@@ -166,0 +170,0 @@ */

@@ -103,3 +103,3 @@ "use strict";

dataTypes_1.convert2RefType(result);
this.plainAssign(result);
this.deepPick(result, ['id']);
__1.history.push(`添加数据结构"${this.root.name}"属性"${this.name}"`);

@@ -134,4 +134,4 @@ return this;

});
dataTypes_1.convert2RefType(result);
this.plainAssign(result);
// convert2RefType(result);
// this.plainAssign(result);
return this;

@@ -333,2 +333,6 @@ }

/**
* 所属实体 Id
*/
this.entityId = undefined;
/**
* 所属服务

@@ -374,4 +378,4 @@ */

dataTypes_1.convert2RefType(result);
this.plainAssign(result);
this.propertyList.forEach((property, index) => property.plainAssign(result.propertyList[index]));
this.deepPick(result, ['id']);
// this.propertyList.forEach((property, index) => property.plainAssign(result.propertyList[index]));
this.assign({

@@ -466,2 +470,5 @@ schemaRef: `#/${this.dataNode.service.id}/${result.id}`,

decorators_1.immutable()
], Structure.prototype, "entityId", void 0);
__decorate([
decorators_1.immutable()
], Structure.prototype, "service", void 0);

@@ -468,0 +475,0 @@ __decorate([

@@ -21,2 +21,4 @@ export { Vertex } from './common/Vertex';

export { View } from './page/View';
export { ViewParam } from './page/ViewParam';
export { ViewVariable } from './page/ViewVariable';
export { Block } from './page/Block';

@@ -23,0 +25,0 @@ export { Process } from './process/Process';

@@ -28,3 +28,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.LEVEL_ENUM = exports.utils = exports.history = exports.config = exports.Directive = exports.Event = exports.Attr = exports.Element = exports.Block = exports.View = exports.Page = exports.Return = exports.Variable = exports.Param = exports.BaseVariable = exports.ExpressionNode = exports.LogicNode = exports.LogicItem = exports.Logic = exports.Interface = exports.convert2SchemaType = exports.convert2RefType = exports.dataTypesMap = exports.EnumProperty = exports.EnumItem = exports.Enum = exports.StructureProperty = exports.Structure = exports.EntityProperty = exports.Entity = exports.DataNode = exports.SERVICE_TYPE = exports.MicroService = exports.WebService = exports.Service = exports.App = exports.vertexsMap = exports.Vertex = void 0;
exports.LEVEL_ENUM = exports.utils = exports.history = exports.config = exports.Directive = exports.Event = exports.Attr = exports.Element = exports.Block = exports.ViewVariable = exports.ViewParam = exports.View = exports.Page = exports.Return = exports.Variable = exports.Param = exports.BaseVariable = exports.ExpressionNode = exports.LogicNode = exports.LogicItem = exports.Logic = exports.Interface = exports.convert2SchemaType = exports.convert2RefType = exports.dataTypesMap = exports.EnumProperty = exports.EnumItem = exports.Enum = exports.StructureProperty = exports.Structure = exports.EntityProperty = exports.Entity = exports.DataNode = exports.SERVICE_TYPE = exports.MicroService = exports.WebService = exports.Service = exports.App = exports.vertexsMap = exports.Vertex = void 0;
var Vertex_1 = require("./common/Vertex");

@@ -78,2 +78,6 @@ Object.defineProperty(exports, "Vertex", { enumerable: true, get: function () { return Vertex_1.Vertex; } });

Object.defineProperty(exports, "View", { enumerable: true, get: function () { return View_1.View; } });
var ViewParam_1 = require("./page/ViewParam");
Object.defineProperty(exports, "ViewParam", { enumerable: true, get: function () { return ViewParam_1.ViewParam; } });
var ViewVariable_1 = require("./page/ViewVariable");
Object.defineProperty(exports, "ViewVariable", { enumerable: true, get: function () { return ViewVariable_1.ViewVariable; } });
var Block_1 = require("./page/Block");

@@ -80,0 +84,0 @@ Object.defineProperty(exports, "Block", { enumerable: true, get: function () { return Block_1.Block; } });

@@ -33,2 +33,14 @@ import { Vertex, LEVEL_ENUM, Interface, Param, Return, Variable } from '..';

/**
* serviceId 或者 viewId
*/
readonly serviceId: string;
/**
* 值为 view 或者 microService
*/
readonly serviceType: 'view' | 'entity' | 'microService';
/**
* 所属实体 Id
*/
readonly entityId: string;
/**
* 输入参数列表

@@ -35,0 +47,0 @@ */

@@ -14,2 +14,3 @@ "use strict";

const LogicItem_1 = require("./LogicItem");
const dataTypes_1 = require("../data/dataTypes");
/**

@@ -49,2 +50,14 @@ * 逻辑类

/**
* serviceId 或者 viewId
*/
this.serviceId = undefined;
/**
* 值为 view 或者 microService
*/
this.serviceType = undefined;
/**
* 所属实体 Id
*/
this.entityId = undefined;
/**
* 接口

@@ -68,2 +81,5 @@ */

const body = this.toJSON();
body.params.forEach((param) => dataTypes_1.convert2SchemaType(param.schema));
body.returns.forEach((ret) => dataTypes_1.convert2SchemaType(ret.schema));
body.variables.forEach((variable) => dataTypes_1.convert2SchemaType(variable.schema));
__1.utils.logger.debug('添加逻辑', body);

@@ -73,3 +89,3 @@ const result = await logic_1.logicService.create({

});
this.plainAssign(result);
this.deepPick(result, ['id']);
__1.history.push(`添加逻辑"${this.name}"`);

@@ -154,3 +170,6 @@ return this;

logic.body.forEach((node, index) => {
node = logic.body[index] = new LogicItem_1.LogicNode(node);
if (node.level === __1.LEVEL_ENUM.logicNode)
node = logic.body[index] = LogicItem_1.LogicNode.from(node, logic);
else if (node.level === __1.LEVEL_ENUM.expressionNode)
node = logic.body[index] = LogicItem_1.ExpressionNode.from(node, logic);
node.assign({ parentList: logic.body });

@@ -183,2 +202,11 @@ });

decorators_1.immutable()
], Logic.prototype, "serviceId", void 0);
__decorate([
decorators_1.immutable()
], Logic.prototype, "serviceType", void 0);
__decorate([
decorators_1.immutable()
], Logic.prototype, "entityId", void 0);
__decorate([
decorators_1.immutable()
], Logic.prototype, "params", void 0);

@@ -185,0 +213,0 @@ __decorate([

@@ -68,2 +68,3 @@ import { Vertex, LEVEL_ENUM, Logic } from '..';

static insertBefore(list: Array<LogicNode>, index: number, logicNode: LogicNode): Promise<LogicNode>;
static append(list: Array<LogicNode>, logicNode: LogicNode, listKey: string, parentNode: LogicNode): Promise<LogicNode>;
}

@@ -100,3 +101,3 @@ export declare class ExpressionNode extends LogicItem {

*/
static from(source: any): ExpressionNode;
static from(source: any, logic: Logic): ExpressionNode;
}

@@ -125,2 +125,11 @@ "use strict";

static from(source, logic) {
const keys = ['test', 'left', 'right', 'each', 'item', 'index', 'start', 'end', 'variables', 'taskId', 'processInstanceId', 'startedBy', 'errorMessage', 'params'];
keys.forEach((key) => {
if (source[key] && source[key].level) {
if (source[key].level === __1.LEVEL_ENUM.logicNode)
source[key] = LogicNode.from(source[key], logic);
else if (source[key].level === __1.LEVEL_ENUM.expressionNode)
source[key] = ExpressionNode.from(source[key], logic);
}
});
return new LogicNode(source);

@@ -145,2 +154,18 @@ }

}
static async append(list, logicNode, listKey, parentNode) {
const index = list.length - 1;
const beforeNode = list[index];
// logicNode = new LogicNode(logicNode);
list.splice(index + 1, 0, logicNode);
logicNode.assign({ parentList: list });
const body = logicNode.toJSON();
body.parentId = beforeNode ? beforeNode.id : parentNode.id;
body.parentAttr = beforeNode ? undefined : listKey;
__1.utils.logger.debug('在该逻辑节点后插入一个节点', body);
const result = await logic_1.logicService.addItem({
body,
});
logicNode.plainAssign(result);
return logicNode;
}
}

@@ -211,3 +236,3 @@ __decorate([

async insertAt(key, logicItem) {
this.assign({ key: logicItem });
this.assign({ [key]: logicItem });
const body = logicItem.toJSON();

@@ -228,3 +253,12 @@ body.parentId = this.id;

*/
static from(source) {
static from(source, logic) {
const keys = ['test', 'left', 'right', 'each', 'item', 'index', 'start', 'end', 'variables', 'taskId', 'processInstanceId', 'startedBy', 'errorMessage', 'params'];
keys.forEach((key) => {
if (source[key] && source[key].level) {
if (source[key].level === __1.LEVEL_ENUM.logicNode)
source[key] = LogicNode.from(source[key], logic);
else if (source[key].level === __1.LEVEL_ENUM.expressionNode)
source[key] = ExpressionNode.from(source[key], logic);
}
});
return new ExpressionNode(source);

@@ -231,0 +265,0 @@ }

@@ -46,3 +46,3 @@ "use strict";

dataTypes_1.convert2RefType(result.schema);
this.plainAssign(result);
this.deepPick(result, ['id']);
__1.history.push(`添加逻辑"${this.logic.name}"输入参数"${this.name}"`);

@@ -77,4 +77,4 @@ return this;

});
dataTypes_1.convert2RefType(result.schema);
this.plainAssign(result);
// convert2RefType(result.schema);
// this.plainAssign(result);
return this;

@@ -81,0 +81,0 @@ }

@@ -42,3 +42,3 @@ "use strict";

dataTypes_1.convert2RefType(result.schema);
this.plainAssign(result);
this.deepPick(result, ['id']);
__1.history.push(`添加逻辑"${this.logic.name}"输出参数"${this.name}"`);

@@ -73,4 +73,4 @@ return this;

});
dataTypes_1.convert2RefType(result.schema);
this.plainAssign(result);
// convert2RefType(result.schema);
// this.plainAssign(result);
return this;

@@ -77,0 +77,0 @@ }

@@ -42,3 +42,3 @@ "use strict";

dataTypes_1.convert2RefType(result.schema);
this.plainAssign(result);
this.deepPick(result, ['id']);
__1.history.push(`添加逻辑"${this.logic.name}"局部变量"${this.name}"`);

@@ -73,4 +73,4 @@ return this;

});
dataTypes_1.convert2RefType(result.schema);
this.plainAssign(result);
// convert2RefType(result.schema);
// this.plainAssign(result);
return this;

@@ -77,0 +77,0 @@ }

@@ -42,2 +42,6 @@ import { LEVEL_ENUM, Page, Element } from '..';

/**
* views目录路径
*/
readonly path: string;
/**
* 所属页面

@@ -44,0 +48,0 @@ */

@@ -62,2 +62,6 @@ "use strict";

/**
* views目录路径
*/
this.path = undefined;
/**
* 所属页面

@@ -179,3 +183,3 @@ */

async addParam(paramOptions) {
// const id = await
// const id = await
}

@@ -218,6 +222,10 @@ async addLogic(logicOptions) {

const view = new View(source);
const path = parent ? `${parent.path}/${view.name}/views` : `/${page.name}/views`;
view.assign({
path,
});
view.assign({
parent,
page,
children: view.children.map((child) => View.from(child, parent, page)),
children: view.children.map((child) => View.from(child, view, page)),
});

@@ -273,2 +281,5 @@ if (view.$html) {

__decorate([
decorators_1.immutable()
], View.prototype, "path", void 0);
__decorate([
decorators_1.circular(),

@@ -275,0 +286,0 @@ decorators_1.immutable()

@@ -0,1 +1,176 @@

"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.ViewParam = void 0;
const decorators_1 = require("../decorators");
const __1 = require("..");
const logic_1 = require("../../service/logic");
const dataTypes_1 = require("../data/dataTypes");
const basicTypes_1 = require("../data/basicTypes");
/**
* 逻辑输入参数
*/
class ViewParam extends __1.Param {
/**
* @param source 需要合并的部分参数
*/
constructor(source) {
super();
/**
* 概念类型
*/
this.level = __1.LEVEL_ENUM.param;
/**
* 请求类型
*/
this.in = undefined;
source && this.assign(source);
}
/**
* 添加逻辑输入参数
*/
async create() {
const body = this.toJSON();
dataTypes_1.convert2SchemaType(body.schema);
body._posIndex = this.logic.params.indexOf(this);
__1.utils.logger.debug('添加逻辑输入参数', body);
const result = await logic_1.paramService.create({
body,
});
dataTypes_1.convert2RefType(result.schema);
this.deepPick(result, ['id']);
__1.history.push(`添加逻辑"${this.logic.name}"输入参数"${this.name}"`);
return this;
}
/**
* 删除逻辑输入参数
*/
async delete() {
if (this.id) {
await logic_1.paramService.delete({
query: {
loValId: this.id,
logicId: this.logic.id,
},
});
}
const index = this.logic.params.indexOf(this);
~index && this.logic.params.splice(index, 1);
__1.history.push(`删除逻辑"${this.logic.name}"输入参数"${this.name}"`);
}
/**
* 修改逻辑输入参数
*/
async update() {
const body = this.toJSON();
dataTypes_1.convert2SchemaType(body.schema);
__1.utils.logger.debug('修改逻辑输入参数', body);
const result = await logic_1.paramService.update({
body,
});
// convert2RefType(result.schema);
// this.plainAssign(result);
return this;
}
/**
* 设置逻辑输入参数名称
* @param name 名称
*/
async setName(name) {
const oldName = this.name;
this.assign({ name });
await this.update();
__1.history.push(`设置逻辑"${this.logic.name}"的输入参数"${oldName}"的名称为"${name}"`);
}
/**
* 设置逻辑输入参数描述
* @param description 描述
*/
async setDescription(description) {
this.assign({ description });
await this.update();
__1.history.push(`设置逻辑"${this.logic.name}"的输入参数"${this.name}"的描述为"${description}"`);
}
/**
* 设置逻辑输入参数类型
*/
async setDataType($ref) {
this.schema.$ref = $ref;
// if (this.defaultValue)
this.assign({ defaultValue: basicTypes_1.getBasicTypeDefaultValue() });
await this.update();
__1.history.push(`设置逻辑"${this.logic.name}"的输入参数"${this.name}"的类型为"${$ref}"`);
}
/**
* 设置逻辑输入参数为列表
* @param isArray
*/
async setAsList(isArray) {
this.schema.isArray = isArray;
this.assign({ defaultValue: basicTypes_1.getBasicTypeDefaultValue() });
await this.update();
__1.history.push(`设置逻辑"${this.logic.name}"的输入参数"${this.name}"${isArray ? '为' : '不为'}列表`);
}
/**
* 设置逻辑输入参数默认值
*/
async setDefaultValue(defaultValue) {
this.assign({ defaultValue });
await this.update();
}
/**
* 设置逻辑输入参数必须
* @param required 必须
*/
async setRequired(required) {
this.assign({ required });
await this.update();
__1.history.push(`设置逻辑"${this.logic.name}"的输入参数"${this.name}"为"${required ? '必须' : '不必须'}"`);
}
/**
* 从后端 JSON 生成规范的 ViewParam 对象
*/
static from(source, logic) {
dataTypes_1.convert2RefType(source.schema);
source.logic = logic;
return new ViewParam(source);
}
}
__decorate([
decorators_1.immutable()
], ViewParam.prototype, "level", void 0);
__decorate([
decorators_1.immutable()
], ViewParam.prototype, "in", void 0);
__decorate([
decorators_1.action('添加逻辑输入参数')
], ViewParam.prototype, "create", null);
__decorate([
decorators_1.action('删除逻辑输入参数')
], ViewParam.prototype, "delete", null);
__decorate([
decorators_1.action('设置逻辑输入参数名称')
], ViewParam.prototype, "setName", null);
__decorate([
decorators_1.action('设置逻辑输入参数描述')
], ViewParam.prototype, "setDescription", null);
__decorate([
decorators_1.action('设置逻辑输入参数类型')
], ViewParam.prototype, "setDataType", null);
__decorate([
decorators_1.action('设置逻辑输入参数为列表')
], ViewParam.prototype, "setAsList", null);
__decorate([
decorators_1.action('设置逻辑输入参数默认值')
], ViewParam.prototype, "setDefaultValue", null);
__decorate([
decorators_1.action('设置逻辑输入参数必须')
], ViewParam.prototype, "setRequired", null);
exports.ViewParam = ViewParam;
exports.default = ViewParam;
//# sourceMappingURL=ViewParam.js.map
{
"name": "@lcap/asl",
"description": "Lowcode Application Specific Language",
"version": "0.1.4",
"version": "0.1.5",
"author": "Forrest <rainforest92@126.com>",

@@ -15,3 +15,3 @@ "scripts": {

},
"main": "./out/index.js",
"main": "./out/types",
"license": "MIT",

@@ -18,0 +18,0 @@ "keywords": [

@@ -8,3 +8,3 @@ import * as utils from '../../types/common/utils';

external: 'EXTERNAL',
ENTITY: 'ENTITY',
entity: 'ENTITY',
};

@@ -11,0 +11,0 @@

@@ -890,46 +890,38 @@ // import { createPreServiceType, postServiceType } from '../common/preprocess';

},
"consequent": {
"level": "logicNode",
"type": "BlockStatement",
"body": [
{
"level": "logicNode",
"type": "CallInterface",
"label": "调用接口",
"interfaceKey": "zystest3_backend/updateProduct",
"params": [
{
"name": "body",
"in": "body",
"value": {
"type": "Identifier",
"name": "input"
}
"consequent": [
{
"level": "logicNode",
"type": "CallInterface",
"label": "调用接口",
"interfaceKey": "zystest3_backend/updateProduct",
"params": [
{
"name": "body",
"in": "body",
"value": {
"type": "Identifier",
"name": "input"
}
]
}
]
},
"alternate": {
"level": "logicNode",
"type": "BlockStatement",
"body": [
{
"level": "logicNode",
"type": "CallInterface",
"label": "调用接口",
"interfaceKey": "zystest3_backend/createProduct",
"params": [
{
"name": "body",
"in": "body",
"value": {
"type": "Identifier",
"name": "input"
}
}
]
}
],
"alternate": [
{
"level": "logicNode",
"type": "CallInterface",
"label": "调用接口",
"interfaceKey": "zystest3_backend/createProduct",
"params": [
{
"name": "body",
"in": "body",
"value": {
"type": "Identifier",
"name": "input"
}
]
}
]
}
}
]
}
]
},

@@ -936,0 +928,0 @@ {

@@ -46,8 +46,2 @@ import { prePosIndex } from '../common/preprocess';

},
addParam: {
url: {
path: '/proxy/graph/api/v1/graph/view/param',
method: 'post',
},
},
}

@@ -440,5 +440,17 @@ const generate = require("@babel/generator").default;

checkThis(node.test);
if (Array.isArray(node.consequent)) {
node.consequent = {
type: "BlockStatement",
body: node.consequent
};
}
if (Array.isArray(node.alternate)) {
node.alternate = {
type: "BlockStatement",
body: node.alternate
};
}
} else if (node.type === "WhileStatement") {
checkThis(node.test);
if (Array.isArray) {
if (Array.isArray(node.body)) {
node.body = {

@@ -445,0 +457,0 @@ type: "BlockStatement",

@@ -61,2 +61,7 @@ import { immutable, circular, action } from '../decorators';

/**
* 接口列表
*/
@immutable()
public readonly interfaces: Array<Interface> = [];
/**
* 所在的 App

@@ -111,3 +116,3 @@ * 父级引用,便于在树状结构中查找

async loadInterfaces() {
const interfaces: Array<Interface> = await interfaceService.loadList({
let interfaces: Array<Interface> = await interfaceService.loadList({
query: {

@@ -118,3 +123,5 @@ serviceId: this.id,

return interfaces.map((item) => Interface.from(item, this));
interfaces = interfaces.map((item) => Interface.from(item, this));
this.assign({interfaces});
return interfaces;
}

@@ -181,3 +188,3 @@ }

console.log(result, 'result');
result.id = result.appId;
// result.id = result.appId;
this.assign(result);

@@ -222,15 +229,14 @@ return this;

name: 'cloud-admin-template',
version: "0.2.22"
version: '0.2.22',
},
ui: {
name: "cloud-ui.vusion",
version: "0.11.23"
name: 'cloud-ui.vusion',
version: '0.11.23',
},
componentDependencies: {
'lcap-login': "^0.3.3"
'lcap-login': '^0.3.3',
},
}
}
else if (typeof source.packageInfo === 'string')
source.packageInfo = JSON.parse(source.packageInfo)
};
} else if (typeof source.packageInfo === 'string')
source.packageInfo = JSON.parse(source.packageInfo);
return new WebService(source);

@@ -237,0 +243,0 @@ }

@@ -20,4 +20,4 @@ import { immutable, circular } from '../decorators';

public readonly erdiagrams: Array<any> = [];
public entityExpanded: boolean = false;
public structureExpanded: boolean = false;
public entityExpanded: boolean = true;
public structureExpanded: boolean = true;

@@ -24,0 +24,0 @@ @circular()

import { immutable, circular, excludedInJSON, action } from '../decorators';
import { config, history, utils ,LEVEL_ENUM, Vertex, DataNode, MicroService, Schema, ObjectSchema, dataTypesMap, convert2RefType, convert2SchemaType } from '..';
import { config, history, utils ,LEVEL_ENUM, Vertex, DataNode, MicroService, Schema, Interface, Logic, Param, Return, Variable, ObjectSchema, dataTypesMap, convert2RefType, convert2SchemaType } from '..';
import { entityService } from '../../service/data';

@@ -8,2 +8,9 @@ import { getBasicTypeDefaultValue } from './basicTypes';

export interface Display {
readonly inDetail: boolean;
readonly inFilter: boolean;
readonly inForm: boolean;
readonly inTable: boolean;
};
/**

@@ -67,8 +74,3 @@ * 实体属性类

@immutable()
public readonly display: {
readonly inDetail: boolean;
readonly inFilter: boolean;
readonly inForm: boolean;
readonly inTable: boolean;
} = undefined;
public readonly display: Display = undefined;
/**

@@ -116,3 +118,3 @@ * 父级 Id

convert2RefType(result);
this.plainAssign(result);
this.deepPick(result, ['id'])

@@ -151,4 +153,4 @@ history.push(`添加实体"${this.root.name}"属性"${this.name}"`);

});
convert2RefType(result);
this.plainAssign(result);
// convert2RefType(result);
// this.plainAssign(result);

@@ -222,5 +224,3 @@ return this;

this.assign({ relationship });
await this.save({
relationship,
});
await this.update();
}

@@ -385,5 +385,5 @@ /**

});
this.plainAssign(result);
convert2RefType(result);
this.propertyList.forEach((property, index) => property.plainAssign(result.propertyList[index]));
this.deepPick(result, ['id']);
// convert2RefType(result);
// this.propertyList.forEach((property, index) => property.plainAssign(result.propertyList[index]));

@@ -397,5 +397,10 @@ this.assign({

await this.addEntityStructures();
await this.addEntityInterfaces();
return this;
}
/**
* 添加实体相关的数据结构
* @TODO 后面改为后端实现
*/
async addEntityStructures() {

@@ -406,6 +411,9 @@ const structures = getEntityStructures(this);

const refStructures = structures.filter((structure) => structure.structureRef);
const normalTasks = normalStructures.map(async (item) => {
let normalTasks = normalStructures.map(async (item) => {
const structure = new Structure(Object.assign(item, {
serviceId: this.dataNode.service.id,
serviceType: this.dataNode.service.type,
serviceType: 'entity',
entityId: this.id,
dataNode: this.dataNode,
editable: false,

@@ -421,14 +429,16 @@ }) as Partial<Structure>);

} catch(err) {
console.error(err);
return 'error';
}
});
let normalResults = await Promise.all(normalTasks);
normalResults = normalResults.filter((result) => result !== 'error');
this.dataNode.structures.push(...normalResults as Array<Structure>);
this.dataNode.structures.unshift(...normalResults as Array<Structure>);
const refTasks = refStructures.map(async (item) => {
let refTasks = refStructures.map(async (item) => {
const structure = new Structure(Object.assign(item, {
serviceId: this.dataNode.service.id,
serviceType: this.dataNode.service.type,
serviceType: 'entity',
entityId: this.id,
dataNode: this.dataNode,
editable: false,

@@ -449,20 +459,25 @@ }) as Partial<Structure>);

} catch(err) {
console.error(err);
return 'error';
}
});
let refResults = await Promise.all(refTasks);
refResults = refResults.filter((result) => result !== 'error');
this.dataNode.structures.push(...refResults as Array<Structure>);
this.dataNode.structures.unshift(...refResults as Array<Structure>);
}
async addEntityInterface() {
/**
* 添加实体相关的接口
* @TODO 后面改为后端实现
*/
async addEntityInterfaces() {
const tasks = getEntityInterfaces(this).map(async (item) => {
let itemString = JSON.stringify(item.data);
const reg = /<(.+?)>/g;
const reg = /<#\/(.+?)>/g;
let ref: any = itemString.match(reg);
if (ref) {
ref = ref[0].replace('<', '').replace('>', '');
const refData = dataTypesMap[ref];
if (refData) {
itemString = itemString.replace(reg, `#/${this.dataNode.service.id}/${refData.id}`);
const name = ref[0].replace('<#/', '').replace('>', '');
const dataTypeKey = Object.keys(dataTypesMap).find((key) => dataTypesMap[key].name === name);
const dataType = dataTypesMap[dataTypeKey] as any;
if (dataType) {
itemString = itemString.replace(reg, `#/${this.dataNode.service.id}/${dataType.id}`);
item.data = JSON.parse(itemString);

@@ -474,17 +489,18 @@ }

const parameters = JSON.parse(item.data.parameters);
const params = Object.keys(parameters).map((key) => convert2SchemaType(
Object.assign({
level: 'param',
const params = Object.keys(parameters).map((key) => {
const param = new Param(Object.assign({
type: 'Identifier',
}, parameters[key]),
));
}, parameters[key]));
param.assign({ schema: convert2RefType(param.schema) });
return param;
});
if (item.data.requestBody) {
const content = JSON.parse(item.data.requestBody).content;
if (content) {
params.push(convert2SchemaType({
level: 'param',
params.push(new Param({
type: 'Identifier',
name: 'body',
in: 'body',
schema: content['application/json'].schema,
schema: convert2RefType(content['application/json'].schema),
}));

@@ -494,9 +510,52 @@ }

const responses = JSON.parse(item.data.responses);
const returns = responses[200] ? [{
level: 'return',
const returns = responses[200] ? [new Return({
type: 'Identifier',
name: 'result',
schema: responses[200].content['application/json'].schema,
}] : [];
schema: convert2RefType(responses[200].content['application/json'].schema),
})] : [];
try {
const logic = new Logic({
name: item.data.name,
description: '',
params,
returns,
variables: [],
moduleId: this.dataNode.service.id,
moduleType: 'microService',
serviceId: this.dataNode.service.id,
serviceType: 'entity',
entityId: this.id,
editable: false,
});
const itface = new Interface(Object.assign({
serviceId: this.dataNode.service.id,
serviceType: 'entity',
editable: false,
}, item.data) as any);
itface.assign({ logic });
await itface.create();
return itface;
} catch {
return Promise.resolve('error');
}
// return interfaceService.create({
// body: item.data,
// }).then((res) => ({
// data: Object.assign({ id: res, level: 'interface' }, item.data),
// resolver: item.resolver,
// }))
// .catch((err) => 'error');
});
const results = await Promise.all(tasks);
const interfaces = results.filter((item) => item !== 'error') as Array<Interface>;
(this.dataNode.service as MicroService).interfaces.unshift(...interfaces);
// // 发送消息更新接口
// this.$publish('data.fragment.addInterface', {
// interfaces: interfaces.map((item) => item.data),
// service: this.dataNode.service,
// });
// // 创建resolvers
// return this.updateResolvers(this, interfaces);
// });
}

@@ -526,4 +585,4 @@ /**

});
convert2RefType(result);
this.plainAssign(result);
// convert2RefType(result);
// this.plainAssign(result);
return this;

@@ -537,2 +596,3 @@ }

if (this.id) {
await this.removeEntityInterfaces();
await this.removeEntityStructures();

@@ -552,2 +612,5 @@ await entityService.delete({

}
/**
* 删除实体相关的数据结构
*/
async removeEntityStructures() {

@@ -579,2 +642,16 @@ const structureNames = getEntityStructureNames(this.name);

/**
* 删除实体相关的接口
*/
async removeEntityInterfaces() {
const interfaces = (this.dataNode.service as MicroService).interfaces.filter((item) => item.logic && item.logic.entityId === this.id);
const tasks = interfaces.map(async (item) => {
try {
await item.delete();
} catch (err) {
return 'error';
}
});
await Promise.all(tasks);
}
/**
* 设置实体名称

@@ -581,0 +658,0 @@ * @param name 名称

@@ -473,3 +473,3 @@ import { firstUpperCase } from '../common/utils';

schema: {
$ref: `<#/${service.name}/structures/ApiReturnOfPageOf${firstUpperCase(entity.name)}>`,
$ref: `<#/ApiReturnOfPageOf${firstUpperCase(entity.name)}>`,
},

@@ -502,3 +502,3 @@ },

schema: {
$ref: `<#/${service.name}/structures/ApiReturnOf${firstUpperCase(entity.name)}>`,
$ref: `<#/ApiReturnOf${firstUpperCase(entity.name)}>`,
},

@@ -534,3 +534,3 @@ },

schema: {
$ref: `<#/${service.name}/structures/ApiReturnOf${firstUpperCase(entity.name)}>`,
$ref: `<#/ApiReturnOf${firstUpperCase(entity.name)}>`,
},

@@ -596,3 +596,3 @@ },

schema: {
$ref: `<#/${service.name}/structures/ApiReturnOf${firstUpperCase(entity.name)}>`,
$ref: `<#/ApiReturnOf${firstUpperCase(entity.name)}>`,
},

@@ -619,3 +619,3 @@ },

schema: {
$ref: `<#/${service.name}/structures/ApiReturnOflong${firstUpperCase(entity.name)}>`,
$ref: `<#/ApiReturnOflong${firstUpperCase(entity.name)}>`,
},

@@ -642,3 +642,3 @@ },

schema: {
$ref: `<#/${service.name}/structures/ApiReturnOflong${firstUpperCase(entity.name)}>`,
$ref: `<#/ApiReturnOflong${firstUpperCase(entity.name)}>`,
},

@@ -665,3 +665,3 @@ },

schema: {
$ref: `<#/${service.name}/structures/ApiReturnOflong${firstUpperCase(entity.name)}>`,
$ref: `<#/ApiReturnOflong${firstUpperCase(entity.name)}>`,
},

@@ -668,0 +668,0 @@ },

@@ -109,3 +109,3 @@ import { immutable, circular, excludedInJSON, action } from '../decorators';

}
this.plainAssign(result);
this.deepPick(result, ['id']);

@@ -112,0 +112,0 @@ // const schemaRef = `#/${source.serviceId}/${result.id}`;

@@ -69,3 +69,3 @@ import { immutable, circular, excludedInJSON, action } from '../decorators';

@immutable()
public readonly serviceType: 'micro' = undefined;
public readonly serviceType: 'micro' | 'entity' = undefined;
/**

@@ -77,2 +77,6 @@ * Service Id

/**
* 所属实体 Id
*/
public readonly entityId: string = undefined;
/**
* Service 名称

@@ -140,25 +144,7 @@ */

async create() {
const logic = new Logic({
name: this.name,
description: '',
moduleType: 'microService',
moduleId: this.service.id,
interface: this,
// definition: {
// params: [],
// returns: [],
// variables: [],
// body: [
// { level: 'logicNode', type: 'Start', label: '开始' },
// { level: 'logicNode', type: 'End', label: '结束' },
// ],
// playground: [],
// },
});
await logic.create();
await this.logic.create();
this.assign({
path: '/' + this.name,
logicId: logic.id,
logic,
logicId: this.logic.id,
// key: this.service.name + '/' + this.name,

@@ -168,3 +154,3 @@ });

const body = this.toJSON();
body.logicId = logic.id;
body.logicId = this.logic.id;
utils.logger.debug('添加接口', body);

@@ -184,2 +170,5 @@ const result: Interface = await interfaceService.create({

async delete() {
if (this.logic)
await this.logic.delete();
if (this.id) {

@@ -186,0 +175,0 @@ await interfaceService.delete({

@@ -113,3 +113,3 @@ import { immutable, circular, excludedInJSON, action } from '../decorators';

convert2RefType(result);
this.plainAssign(result);
this.deepPick(result, ['id']);

@@ -148,4 +148,4 @@ history.push(`添加数据结构"${this.root.name}"属性"${this.name}"`);

});
convert2RefType(result);
this.plainAssign(result);
// convert2RefType(result);
// this.plainAssign(result);

@@ -294,2 +294,7 @@ return this;

/**
* 所属实体 Id
*/
@immutable()
public readonly entityId: string = undefined;
/**
* 所属服务

@@ -346,4 +351,4 @@ */

convert2RefType(result);
this.plainAssign(result);
this.propertyList.forEach((property, index) => property.plainAssign(result.propertyList[index]));
this.deepPick(result, ['id']);
// this.propertyList.forEach((property, index) => property.plainAssign(result.propertyList[index]));

@@ -350,0 +355,0 @@ this.assign({

@@ -24,2 +24,4 @@ export { Vertex } from './common/Vertex';

export { View } from './page/View';
export { ViewParam } from './page/ViewParam';
export { ViewVariable } from './page/ViewVariable';
export { Block } from './page/Block';

@@ -26,0 +28,0 @@ export { Process } from './process/Process';

@@ -5,3 +5,4 @@ import { immutable, excludedInJSON, circular, action } from '../decorators';

import View from '../page/View';
import { LogicItem, LogicNode } from './LogicItem';
import { ExpressionNode, LogicItem, LogicNode } from './LogicItem';
import { convert2SchemaType } from '../data/dataTypes';

@@ -43,2 +44,17 @@ /**

/**
* serviceId 或者 viewId
*/
@immutable()
public readonly serviceId: string = undefined;
/**
* 值为 view 或者 microService
*/
@immutable()
public readonly serviceType: 'view' | 'entity' | 'microService' = undefined;
/**
* 所属实体 Id
*/
@immutable()
public readonly entityId: string = undefined;
/**
* 输入参数列表

@@ -88,2 +104,5 @@ */

const body = this.toJSON();
body.params.forEach((param: any) => convert2SchemaType(param.schema));
body.returns.forEach((ret: any) => convert2SchemaType(ret.schema));
body.variables.forEach((variable: any) => convert2SchemaType(variable.schema));
utils.logger.debug('添加逻辑', body);

@@ -93,3 +112,3 @@ const result: Logic = await logicService.create({

});
this.plainAssign(result);
this.deepPick(result, ['id']);

@@ -183,3 +202,6 @@ history.push(`添加逻辑"${this.name}"`);

logic.body.forEach((node, index) => {
node = logic.body[index] = new LogicNode(node);
if (node.level === LEVEL_ENUM.logicNode)
node = logic.body[index] = LogicNode.from(node, logic);
else if (node.level === LEVEL_ENUM.expressionNode)
node = logic.body[index] = ExpressionNode.from(node, logic);
node.assign({ parentList: logic.body });

@@ -186,0 +208,0 @@ });

import { immutable, excludedInJSON, circular, action } from '../decorators';
import { config, history, utils, Vertex, LEVEL_ENUM, Interface, Param, Return, Variable, Logic } from '..';
import { config, history, utils, Vertex, LEVEL_ENUM, Interface, Param, Return, Variable, Logic, View } from '..';
import { logicService } from '../../service/logic';
import View from '../page/View';

@@ -12,3 +11,2 @@ export enum LOGIC_TYPE {

}
/**

@@ -124,2 +122,11 @@ * 逻辑项类

public static from(source: any, logic: Logic) {
const keys = ['test', 'left', 'right', 'each', 'item', 'index', 'start', 'end', 'variables', 'taskId', 'processInstanceId', 'startedBy', 'errorMessage', 'params'];
keys.forEach((key) => {
if (source[key] && source[key].level) {
if (source[key].level === LEVEL_ENUM.logicNode)
source[key] = LogicNode.from(source[key], logic);
else if (source[key].level === LEVEL_ENUM.expressionNode)
source[key] = ExpressionNode.from(source[key], logic);
}
})
return new LogicNode(source);

@@ -145,2 +152,19 @@ }

}
public static async append(list: Array<LogicNode>, logicNode: LogicNode, listKey: string, parentNode: LogicNode) {
const index = list.length - 1;
const beforeNode = list[index];
// logicNode = new LogicNode(logicNode);
list.splice(index + 1, 0, logicNode);
logicNode.assign({ parentList: list });
const body = logicNode.toJSON();
body.parentId = beforeNode ? beforeNode.id : parentNode.id;
body.parentAttr = beforeNode ? undefined : listKey;
utils.logger.debug('在该逻辑节点后插入一个节点', body);
const result: LogicNode = await logicService.addItem({
body,
});
logicNode.plainAssign(result);
return logicNode;
}
}

@@ -198,3 +222,3 @@

async insertAt(key: string, logicItem: LogicItem) {
this.assign({ key: logicItem });
this.assign({ [key]: logicItem });

@@ -216,5 +240,14 @@ const body = logicItem.toJSON();

*/
public static from(source: any) {
public static from(source: any, logic: Logic) {
const keys = ['test', 'left', 'right', 'each', 'item', 'index', 'start', 'end', 'variables', 'taskId', 'processInstanceId', 'startedBy', 'errorMessage', 'params'];
keys.forEach((key) => {
if (source[key] && source[key].level) {
if (source[key].level === LEVEL_ENUM.logicNode)
source[key] = LogicNode.from(source[key], logic);
else if (source[key].level === LEVEL_ENUM.expressionNode)
source[key] = ExpressionNode.from(source[key], logic);
}
})
return new ExpressionNode(source);
}
}

@@ -41,3 +41,3 @@ import { immutable, excludedInJSON, action } from '../decorators';

convert2RefType(result.schema);
this.plainAssign(result);
this.deepPick(result, ['id']);

@@ -76,4 +76,4 @@ history.push(`添加逻辑"${this.logic.name}"输入参数"${this.name}"`);

});
convert2RefType(result.schema);
this.plainAssign(result);
// convert2RefType(result.schema);
// this.plainAssign(result);

@@ -80,0 +80,0 @@ return this;

@@ -36,3 +36,3 @@ import { immutable, excludedInJSON, action } from '../decorators';

convert2RefType(result.schema);
this.plainAssign(result);
this.deepPick(result, ['id']);

@@ -71,4 +71,4 @@ history.push(`添加逻辑"${this.logic.name}"输出参数"${this.name}"`);

});
convert2RefType(result.schema);
this.plainAssign(result);
// convert2RefType(result.schema);
// this.plainAssign(result);

@@ -75,0 +75,0 @@ return this;

@@ -36,3 +36,3 @@ import { immutable, excludedInJSON, action } from '../decorators';

convert2RefType(result.schema);
this.plainAssign(result);
this.deepPick(result, ['id']);

@@ -71,4 +71,4 @@ history.push(`添加逻辑"${this.logic.name}"局部变量"${this.name}"`);

});
convert2RefType(result.schema);
this.plainAssign(result);
// convert2RefType(result.schema);
// this.plainAssign(result);

@@ -75,0 +75,0 @@ return this;

@@ -55,2 +55,7 @@ import { immutable, circular, action } from '../decorators';

/**
* views目录路径
*/
@immutable()
public readonly path: string = undefined;
/**
* 所属页面

@@ -157,3 +162,3 @@ */

this.deepPick(result, ['id']);
history.push(`添加子页面"${this.name}${this.title ? `(${this.title})` : ''}"`);

@@ -197,3 +202,3 @@ return this;

async addParam(paramOptions: Param) {
// const id = await
// const id = await
}

@@ -212,4 +217,3 @@

});
// expanded: false,

@@ -242,7 +246,10 @@ // view: this,

const view = new View(source);
const path = parent ? `${parent.path}/${view.name}/views` : `/${page.name}/views`;
view.assign({
path,
});
view.assign({
parent,
page,
children: view.children.map((child) => View.from(child, parent, page)),
children: view.children.map((child) => View.from(child, view, page)),
});

@@ -249,0 +256,0 @@

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

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

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

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc