@lcap/nasl 0.3.10 → 0.3.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/service/app/api.d.ts +1 -15
- package/out/service/app/api.js +7 -17
- package/out/service/app/api.js.map +1 -1
- package/out/service/create/errHandles.js +19 -2
- package/out/service/create/errHandles.js.map +1 -1
- package/out/service/create/index.js +5 -0
- package/out/service/create/index.js.map +1 -1
- package/out/service/logic/logic.d.ts +50 -14
- package/out/service/logic/logic.js +26 -0
- package/out/service/logic/logic.js.map +1 -1
- package/out/service/page/element.d.ts +9 -0
- package/out/service/page/element.js +6 -0
- package/out/service/page/element.js.map +1 -1
- package/out/service/permission/api.d.ts +57 -0
- package/out/service/permission/api.js +41 -0
- package/out/service/permission/api.js.map +1 -0
- package/out/service/permission/index.d.ts +2 -0
- package/out/service/permission/index.js +17 -0
- package/out/service/permission/index.js.map +1 -0
- package/out/service/webFile/index.js +5 -0
- package/out/service/webFile/index.js.map +1 -1
- package/out/types/app/App.d.ts +13 -0
- package/out/types/app/App.js +55 -1
- package/out/types/app/App.js.map +1 -1
- package/out/types/app/History.js +3 -2
- package/out/types/app/History.js.map +1 -1
- package/out/types/app/Service.d.ts +5 -2
- package/out/types/app/Service.js +42 -9
- package/out/types/app/Service.js.map +1 -1
- package/out/types/cache.d.ts +6 -0
- package/out/types/cache.js +54 -0
- package/out/types/cache.js.map +1 -0
- package/out/types/cacheData.js.map +1 -1
- package/out/types/common/Vertex.d.ts +25 -0
- package/out/types/common/Vertex.js +42 -1
- package/out/types/common/Vertex.js.map +1 -1
- package/out/types/data/Entity.d.ts +4 -0
- package/out/types/data/Entity.js +9 -0
- package/out/types/data/Entity.js.map +1 -1
- package/out/types/data/EntityProperty.d.ts +5 -0
- package/out/types/data/EntityProperty.js +16 -0
- package/out/types/data/EntityProperty.js.map +1 -1
- package/out/types/data/Enum.d.ts +5 -0
- package/out/types/data/Enum.js +5 -0
- package/out/types/data/Enum.js.map +1 -1
- package/out/types/data/GlobalLogicNode.js +8 -1
- package/out/types/data/GlobalLogicNode.js.map +1 -1
- package/out/types/data/Interface.js +5 -3
- package/out/types/data/Interface.js.map +1 -1
- package/out/types/data/dataTypes.js +1 -1
- package/out/types/data/dataTypes.js.map +1 -1
- package/out/types/data/genBlock/genCreateBlock.js +5 -5
- package/out/types/data/genBlock/genCreateBlock.js.map +1 -1
- package/out/types/data/genBlock/genCurdBlock.js +3 -3
- package/out/types/data/genBlock/genCurdBlock.js.map +1 -1
- package/out/types/data/genBlock/genCurdEditTableBlock.d.ts +3 -0
- package/out/types/data/genBlock/genCurdEditTableBlock.js +578 -0
- package/out/types/data/genBlock/genCurdEditTableBlock.js.map +1 -0
- package/out/types/data/genBlock/genEditTableBlock.d.ts +234 -0
- package/out/types/data/genBlock/genEditTableBlock.js +419 -0
- package/out/types/data/genBlock/genEditTableBlock.js.map +1 -0
- package/out/types/data/genBlock/genEnumSelectBlock.d.ts +1 -1
- package/out/types/data/genBlock/genEnumSelectBlock.js +2 -2
- package/out/types/data/genBlock/genEnumSelectBlock.js.map +1 -1
- package/out/types/data/genBlock/genGridViewBlock.js +12 -1
- package/out/types/data/genBlock/genGridViewBlock.js.map +1 -1
- package/out/types/data/genBlock/genListViewBlock.js +2 -2
- package/out/types/data/genBlock/genQueryComponent.d.ts +20 -0
- package/out/types/data/genBlock/genQueryComponent.js +57 -1
- package/out/types/data/genBlock/genQueryComponent.js.map +1 -1
- package/out/types/data/genBlock/genSelectBlock.js +2 -2
- package/out/types/data/genBlock/genTableBlock.js +23 -8
- package/out/types/data/genBlock/genTableBlock.js.map +1 -1
- package/out/types/data/genBlock/genUpdateBlock.js +5 -5
- package/out/types/data/genBlock/genUpdateBlock.js.map +1 -1
- package/out/types/data/genBlock/index.d.ts +2 -0
- package/out/types/data/genBlock/index.js +2 -0
- package/out/types/data/genBlock/index.js.map +1 -1
- package/out/types/data/genBlock/utils.d.ts +7 -0
- package/out/types/data/genBlock/utils.js +38 -1
- package/out/types/data/genBlock/utils.js.map +1 -1
- package/out/types/data/systemTypes.js +47 -0
- package/out/types/data/systemTypes.js.map +1 -1
- package/out/types/enum.d.ts +6 -0
- package/out/types/enum.js +11 -0
- package/out/types/enum.js.map +1 -0
- package/out/types/generator/hotReload.d.ts +2 -0
- package/out/types/generator/hotReload.js +12 -1
- package/out/types/generator/hotReload.js.map +1 -1
- package/out/types/index.d.ts +5 -1
- package/out/types/index.js +8 -2
- package/out/types/index.js.map +1 -1
- package/out/types/logic/Logic.d.ts +32 -0
- package/out/types/logic/Logic.js +151 -41
- package/out/types/logic/Logic.js.map +1 -1
- package/out/types/logic/LogicItem.d.ts +1 -0
- package/out/types/logic/LogicItem.js +49 -32
- package/out/types/logic/LogicItem.js.map +1 -1
- package/out/types/logic/Param.d.ts +1 -0
- package/out/types/logic/Param.js +43 -33
- package/out/types/logic/Param.js.map +1 -1
- package/out/types/logic/Return.js +17 -30
- package/out/types/logic/Return.js.map +1 -1
- package/out/types/logic/Variable.js +17 -25
- package/out/types/logic/Variable.js.map +1 -1
- package/out/types/logic/translator.js +39 -10
- package/out/types/logic/translator.js.map +1 -1
- package/out/types/nuims/Nuims.d.ts +1 -1
- package/out/types/nuims/Nuims.js +11 -4
- package/out/types/nuims/Nuims.js.map +1 -1
- package/out/types/page/Element.d.ts +24 -0
- package/out/types/page/Element.js +198 -134
- package/out/types/page/Element.js.map +1 -1
- package/out/types/page/Event.js.map +1 -1
- package/out/types/page/Page.d.ts +5 -0
- package/out/types/page/Page.js +66 -27
- package/out/types/page/Page.js.map +1 -1
- package/out/types/page/View.d.ts +19 -1
- package/out/types/page/View.js +150 -40
- package/out/types/page/View.js.map +1 -1
- package/out/types/page/ViewParam.d.ts +1 -0
- package/out/types/page/ViewParam.js +23 -4
- package/out/types/page/ViewParam.js.map +1 -1
- package/out/types/page/ViewVariable.js +13 -24
- package/out/types/page/ViewVariable.js.map +1 -1
- package/out/types/permission/Permission.d.ts +41 -0
- package/out/types/permission/Permission.js +122 -0
- package/out/types/permission/Permission.js.map +1 -0
- package/out/types/process/ProcessParam.js +3 -1
- package/out/types/process/ProcessParam.js.map +1 -1
- package/out/types/utils/index.d.ts +1 -0
- package/out/types/utils/index.js +16 -7
- package/out/types/utils/index.js.map +1 -1
- package/package.json +1 -2
- package/src/service/app/api.js +8 -17
- package/src/service/create/errHandles.js +18 -2
- package/src/service/create/index.js +6 -0
- package/src/service/developPermission/api.js +37 -0
- package/src/service/developPermission/index.js +13 -0
- package/src/service/logic/logic.js +26 -0
- package/src/service/page/element.js +6 -0
- package/src/service/permission/api.js +38 -0
- package/src/service/permission/index.js +13 -0
- package/src/service/webFile/index.js +6 -1
- package/src/types/app/App.ts +58 -2
- package/src/types/app/History.ts +3 -2
- package/src/types/app/Service.ts +48 -10
- package/src/types/cache.ts +50 -0
- package/src/types/cacheData.ts +7 -7
- package/src/types/common/Vertex.ts +32 -1
- package/src/types/data/Entity.ts +8 -0
- package/src/types/data/EntityProperty.ts +12 -0
- package/src/types/data/Enum.ts +5 -0
- package/src/types/data/GlobalLogicNode.ts +8 -1
- package/src/types/data/Interface.ts +4 -3
- package/src/types/data/dataTypes.ts +1 -1
- package/src/types/data/genBlock/genCreateBlock.ts +5 -5
- package/src/types/data/genBlock/genCurdBlock.ts +3 -3
- package/src/types/data/genBlock/genCurdEditTableBlock.ts +581 -0
- package/src/types/data/genBlock/genEditTableBlock.ts +470 -0
- package/src/types/data/genBlock/genEnumSelectBlock.ts +2 -2
- package/src/types/data/genBlock/genGridViewBlock.ts +12 -1
- package/src/types/data/genBlock/genListViewBlock.ts +2 -2
- package/src/types/data/genBlock/genQueryComponent.ts +56 -0
- package/src/types/data/genBlock/genSelectBlock.ts +2 -2
- package/src/types/data/genBlock/genTableBlock.ts +28 -13
- package/src/types/data/genBlock/genUpdateBlock.ts +5 -5
- package/src/types/data/genBlock/index.ts +2 -0
- package/src/types/data/genBlock/utils.ts +38 -0
- package/src/types/data/systemTypes.ts +47 -0
- package/src/types/enum.ts +6 -0
- package/src/types/generator/hotReload.ts +10 -0
- package/src/types/index.ts +5 -1
- package/src/types/logic/Logic.ts +148 -39
- package/src/types/logic/LogicItem.ts +55 -38
- package/src/types/logic/Param.ts +43 -35
- package/src/types/logic/Return.ts +21 -34
- package/src/types/logic/Variable.ts +21 -27
- package/src/types/logic/translator.js +41 -14
- package/src/types/logic/translator_backup.js +5 -16
- package/src/types/nuims/Nuims.ts +11 -5
- package/src/types/page/Element.ts +212 -138
- package/src/types/page/Event.ts +0 -3
- package/src/types/page/Page.ts +80 -40
- package/src/types/page/View.ts +154 -39
- package/src/types/page/ViewParam.ts +22 -3
- package/src/types/page/ViewVariable.ts +16 -26
- package/src/types/page/dist/View.js +727 -0
- package/src/types/permission/Permission.ts +112 -0
- package/src/types/process/ProcessParam.ts +4 -1
- package/src/types/utils/index.ts +16 -7
- package/out/test/units/config.spec.d.ts +0 -1
- package/out/test/units/config.spec.js +0 -12
- package/out/test/units/config.spec.js.map +0 -1
|
@@ -34,10 +34,21 @@ export function genTableColumnTemplate(property: EntityProperty) {
|
|
|
34
34
|
} else
|
|
35
35
|
expression = getExpression(property, `scope.item.${lowerEntityName}.${property.name}`);
|
|
36
36
|
|
|
37
|
+
const getText = (property: EntityProperty) => {
|
|
38
|
+
if (property.typeKey === '#/basicTypes/Boolean') {
|
|
39
|
+
return `
|
|
40
|
+
<u-text v-if="${expression}" text="是"></u-text>
|
|
41
|
+
<u-text v-if="!${expression}" text="否"></u-text>
|
|
42
|
+
`;
|
|
43
|
+
} else {
|
|
44
|
+
return `<u-text :text="${expression}"></u-text>`;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
37
48
|
return `<u-table-view-column title="${title}">
|
|
38
49
|
<template #cell="scope">
|
|
39
50
|
<u-linear-layout gap="small">
|
|
40
|
-
|
|
51
|
+
${getText(property)}
|
|
41
52
|
</u-linear-layout>
|
|
42
53
|
</template>
|
|
43
54
|
</u-table-view-column>`;
|
|
@@ -54,7 +65,7 @@ export function genTableTemplate(entity: Entity, nameGroup: NameGroup) {
|
|
|
54
65
|
|
|
55
66
|
return `<u-table-view ref="tableView" :data-source="${nameGroup.load}" data-schema="${nameGroup.structure}"
|
|
56
67
|
value-field="${nameGroup.lowerEntity}.id"
|
|
57
|
-
pageable remote-paging>
|
|
68
|
+
:pageable="true" :remote-paging="true" :show-sizer="true">
|
|
58
69
|
<u-table-view-column type="index" width="60" title="序号"></u-table-view-column>
|
|
59
70
|
|
|
60
71
|
${propertyList.map((property) => genTableColumnTemplate(property) + '\n').join('')}
|
|
@@ -157,9 +168,7 @@ export function genTableRemoveLogic(entity: Entity, nameGroup: NameGroup) {
|
|
|
157
168
|
const scopeStructureSchema = genGenericTypeSchema('ScopeOf', { T: { $ref: nameGroup.structure } });
|
|
158
169
|
const deleteResolver = entity.resolvers.find((resolver) => resolver.name === 'delete');
|
|
159
170
|
const deleteInterface = deleteResolver.interface;
|
|
160
|
-
const
|
|
161
|
-
const idProperty = entity.propertyList.find((property) => property.primaryKey || property.name === 'id');
|
|
162
|
-
|
|
171
|
+
const idPropertys = entity.propertyList.filter((property) => property.primaryKey);
|
|
163
172
|
return {
|
|
164
173
|
level: 'logic',
|
|
165
174
|
name: nameGroup.remove,
|
|
@@ -180,13 +189,19 @@ export function genTableRemoveLogic(entity: Entity, nameGroup: NameGroup) {
|
|
|
180
189
|
type: 'Start',
|
|
181
190
|
label: '开始',
|
|
182
191
|
},
|
|
183
|
-
genCallInterface(deleteInterface,
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
192
|
+
genCallInterface(deleteInterface,
|
|
193
|
+
idPropertys.map((idProperty) => {
|
|
194
|
+
let paramFromResolver = getParamFromResolver(deleteResolver, idProperty.name);
|
|
195
|
+
// 如果旧逻辑,但是新导入表中,id的name 不是id 的话,就直接使用名称叫id的
|
|
196
|
+
if (!paramFromResolver) {
|
|
197
|
+
paramFromResolver = getParamFromResolver(deleteResolver, 'id');
|
|
198
|
+
}
|
|
199
|
+
return genInterParam(paramFromResolver.id,
|
|
200
|
+
`scope.item.${nameGroup.lowerEntity}.id`,
|
|
201
|
+
['', '', `${nameGroup.structure}.${nameGroup.lowerEntity}`, idProperty.id],
|
|
202
|
+
)
|
|
203
|
+
}),
|
|
204
|
+
),
|
|
190
205
|
genCallComponentLogic('tableView', 'reload'),
|
|
191
206
|
{
|
|
192
207
|
level: 'logicNode',
|
|
@@ -281,7 +296,7 @@ export function genTableColumnBlock(property: EntityProperty, view: View) {
|
|
|
281
296
|
|
|
282
297
|
return `
|
|
283
298
|
<template>
|
|
284
|
-
<u-table-view ref="tableView" :data-source="${nameGroup.load}" pageable remote-paging data-schema="${nameGroup.structure}">
|
|
299
|
+
<u-table-view ref="tableView" :data-source="${nameGroup.load}" :pageable="true" :remote-paging="true" :show-sizer="true" data-schema="${nameGroup.structure}">
|
|
285
300
|
${propertyList.map((property) => genTableColumnTemplate(property) + '\n').join('')}
|
|
286
301
|
</u-table-view>
|
|
287
302
|
</template>
|
|
@@ -40,7 +40,7 @@ export function genUpdateFormTemplate(
|
|
|
40
40
|
const lowerEntityName = utils.firstLowerCase(relationEntity.name);
|
|
41
41
|
formItem += `
|
|
42
42
|
<u-select clearable placeholder="请选择${label}" :data-source="${selectNameGroupMap.get(relationEntity.id).load}"
|
|
43
|
-
text-field="${lowerEntityName}.${displayedProperty.name}" value-field="${lowerEntityName}.${relationProperty.name}" pageable remote-paging v-model="${nameGroup.model}.${property.name}">
|
|
43
|
+
text-field="${lowerEntityName}.${displayedProperty.name}" value-field="${lowerEntityName}.${relationProperty.name}" :pageable="true" :remote-paging="true" v-model="${nameGroup.model}.${property.name}">
|
|
44
44
|
</u-select>
|
|
45
45
|
`;
|
|
46
46
|
} else
|
|
@@ -62,7 +62,7 @@ export function genUpdateFormTemplate(
|
|
|
62
62
|
} else if (property.typeKey === '#/basicTypes/DateTime') {
|
|
63
63
|
formItem += `<u-date-time-picker clearable :date.sync="${nameGroup.model}.${property.name}" placeholder="请输入${label}"></u-date-time-picker>`;
|
|
64
64
|
} else if (dataTypesMap[property.typeKey].type === 'enum') {
|
|
65
|
-
formItem += genEnumSelectBlock(dataTypesMap[property.typeKey] as Enum, `${nameGroup.model}.${property.name}`, '', `请选择${label}
|
|
65
|
+
formItem += genEnumSelectBlock(dataTypesMap[property.typeKey] as Enum, `${nameGroup.model}.${property.name}`, '', `请选择${label}`, true);
|
|
66
66
|
} else {
|
|
67
67
|
formItem += `<u-input v-model="${nameGroup.model}.${property.name}" placeholder="请输入${label}"></u-input>`;
|
|
68
68
|
}
|
|
@@ -105,7 +105,7 @@ export function genH5UpdateFormTemplate(entity: Entity, nameGroup: NameGroup, se
|
|
|
105
105
|
<template #input><van-cascader title="请选择${label}" placeholder="请选择${label}"
|
|
106
106
|
v-model="${nameGroup.model}.${property.name}" :data-source="${selectNameGroupMap.get(relationEntity.id).load}"
|
|
107
107
|
text-field="${lowerEntityName}.${displayedProperty.name}" value-field="${lowerEntityName}.${relationProperty.name}"
|
|
108
|
-
pageable remote-paging></van-cascader></template>
|
|
108
|
+
:pageable="true" :remote-paging="true"></van-cascader></template>
|
|
109
109
|
`;
|
|
110
110
|
} else
|
|
111
111
|
return '';
|
|
@@ -125,9 +125,9 @@ export function genH5UpdateFormTemplate(entity: Entity, nameGroup: NameGroup, se
|
|
|
125
125
|
} else if (property.typeKey === '#/basicTypes/Date') {
|
|
126
126
|
formItem += `<template #input><van-calendar clearable :date.sync="${nameGroup.model}.${property.name}" placeholder="请输入${label}"></van-calendar></template>`;
|
|
127
127
|
} else if (property.typeKey === '#/basicTypes/Time') {
|
|
128
|
-
formItem += `<template #input><van-datetime-picker type="time" v-model="${nameGroup.model}.${property.name}" title="
|
|
128
|
+
formItem += `<template #input><van-datetime-picker type="time" v-model="${nameGroup.model}.${property.name}" title="请选择${label}" label-field=""></van-datetime-picker></template>`;
|
|
129
129
|
} else if (property.typeKey === '#/basicTypes/DateTime') {
|
|
130
|
-
formItem += `<template #input><van-datetime-picker type="datetime" v-model="${nameGroup.model}.${property.name}" title="
|
|
130
|
+
formItem += `<template #input><van-datetime-picker type="datetime" v-model="${nameGroup.model}.${property.name}" title="请选择${label}" label-field=""></van-datetime-picker></template>`;
|
|
131
131
|
} else if (dataTypesMap[property.typeKey].type === 'enum') {
|
|
132
132
|
formItem += '<template #input>' + genEnumSelectBlock(dataTypesMap[property.typeKey] as Enum, `${nameGroup.model}.${property.name}`, '', `请选择${label}`) + '</template>';
|
|
133
133
|
} else {
|
|
@@ -13,6 +13,8 @@ export * from './genSelectBlock';
|
|
|
13
13
|
export * from './genCurdBlock';
|
|
14
14
|
export * from './genListViewBlock';
|
|
15
15
|
export * from './genGridViewBlock';
|
|
16
|
+
export * from './genEditTableBlock';
|
|
17
|
+
export * from './genCurdEditTableBlock';
|
|
16
18
|
|
|
17
19
|
// eslint-disable-next-line prefer-const
|
|
18
20
|
export let dragSource: Entity | EntityProperty = null;
|
|
@@ -169,6 +169,44 @@ export function genInterParam(paramIdOrName: string, expression: string, schemaR
|
|
|
169
169
|
};
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
+
/**
|
|
173
|
+
* 生成接口 Param
|
|
174
|
+
* @param paramIdOrName 参数 id 或引用名称
|
|
175
|
+
* @param expression 表达式
|
|
176
|
+
* @param schemaChildren 数据结构
|
|
177
|
+
*/
|
|
178
|
+
export function genMemberExpression(expression: string, schemaRefs: Array<string> = []) {
|
|
179
|
+
const arr = expression.split('.');
|
|
180
|
+
|
|
181
|
+
let expressionNode: any;
|
|
182
|
+
arr.forEach((name, index) => {
|
|
183
|
+
const currentNode = {
|
|
184
|
+
level: LEVEL_ENUM.expressionNode,
|
|
185
|
+
type: 'Identifier',
|
|
186
|
+
name,
|
|
187
|
+
schemaRef: schemaRefs[index],
|
|
188
|
+
};
|
|
189
|
+
if (expressionNode) {
|
|
190
|
+
expressionNode = {
|
|
191
|
+
level: LEVEL_ENUM.expressionNode,
|
|
192
|
+
type: 'MemberExpression',
|
|
193
|
+
object: expressionNode,
|
|
194
|
+
property: {
|
|
195
|
+
level: LEVEL_ENUM.expressionNode,
|
|
196
|
+
type: 'Identifier',
|
|
197
|
+
name,
|
|
198
|
+
schemaRef: schemaRefs[index],
|
|
199
|
+
code: schemaRefs[index] === '' ? '' : undefined,
|
|
200
|
+
},
|
|
201
|
+
};
|
|
202
|
+
} else {
|
|
203
|
+
expressionNode = currentNode;
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
return expressionNode;
|
|
208
|
+
}
|
|
209
|
+
|
|
172
210
|
/**
|
|
173
211
|
* 命名组,主要承载一次 mergeBlock 中的逻辑名称
|
|
174
212
|
*/
|
|
@@ -23,6 +23,7 @@ export const systemTypeList = [
|
|
|
23
23
|
{ kind: 'systemType', text: 'UploadEvent', value: '#/systemTypes/UploadEvent' },
|
|
24
24
|
{ kind: 'systemType', text: 'UploadErrorEvent', value: '#/systemTypes/UploadErrorEvent' },
|
|
25
25
|
{ kind: 'systemType', text: 'SortEvent', value: '#/systemTypes/SortEvent' },
|
|
26
|
+
{ kind: 'systemType', text: 'PoiInfo', value: '#/systemTypes/PoiInfo' },
|
|
26
27
|
];
|
|
27
28
|
|
|
28
29
|
export const systemTypeMap: { [name: string]: ObjectSchema } = {
|
|
@@ -1512,4 +1513,50 @@ export const systemTypeMap: { [name: string]: ObjectSchema } = {
|
|
|
1512
1513
|
},
|
|
1513
1514
|
],
|
|
1514
1515
|
},
|
|
1516
|
+
'#/systemTypes/PoiInfo': {
|
|
1517
|
+
name: 'PoiInfo',
|
|
1518
|
+
type: 'object',
|
|
1519
|
+
propertyList: [
|
|
1520
|
+
{
|
|
1521
|
+
typeKey: '#/basicTypes/String',
|
|
1522
|
+
type: 'string',
|
|
1523
|
+
format: '',
|
|
1524
|
+
name: 'source',
|
|
1525
|
+
description: '信息来源',
|
|
1526
|
+
isLeaf: true,
|
|
1527
|
+
},
|
|
1528
|
+
{
|
|
1529
|
+
typeKey: '#/basicTypes/String',
|
|
1530
|
+
type: 'string',
|
|
1531
|
+
format: '',
|
|
1532
|
+
name: 'id',
|
|
1533
|
+
description: 'POI点的id',
|
|
1534
|
+
isLeaf: true,
|
|
1535
|
+
},
|
|
1536
|
+
{
|
|
1537
|
+
typeKey: '#/basicTypes/String',
|
|
1538
|
+
type: 'string',
|
|
1539
|
+
format: '',
|
|
1540
|
+
name: 'name',
|
|
1541
|
+
description: '名称',
|
|
1542
|
+
isLeaf: true,
|
|
1543
|
+
},
|
|
1544
|
+
{
|
|
1545
|
+
typeKey: '#/basicTypes/String',
|
|
1546
|
+
type: 'string',
|
|
1547
|
+
format: '',
|
|
1548
|
+
name: 'location',
|
|
1549
|
+
description: '经纬度',
|
|
1550
|
+
isLeaf: true,
|
|
1551
|
+
},
|
|
1552
|
+
{
|
|
1553
|
+
typeKey: '#/basicTypes/String',
|
|
1554
|
+
type: 'string',
|
|
1555
|
+
format: '',
|
|
1556
|
+
name: 'address',
|
|
1557
|
+
description: '地址',
|
|
1558
|
+
isLeaf: true,
|
|
1559
|
+
},
|
|
1560
|
+
],
|
|
1561
|
+
},
|
|
1515
1562
|
};
|
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
import webFileService from '../../service/webFile';
|
|
2
2
|
|
|
3
|
+
let saveLastModifiedEnabled = true;
|
|
4
|
+
export function enableSaveLastModified() {
|
|
5
|
+
saveLastModifiedEnabled = true;
|
|
6
|
+
}
|
|
7
|
+
export function disableSaveLastModified() {
|
|
8
|
+
saveLastModifiedEnabled = false;
|
|
9
|
+
}
|
|
10
|
+
|
|
3
11
|
/**
|
|
4
12
|
* 生成上次修改的缓存
|
|
5
13
|
* @param serviceId
|
|
6
14
|
* @param path
|
|
7
15
|
*/
|
|
8
16
|
export function saveLastModified(serviceId: string, path?: string) {
|
|
17
|
+
if(!saveLastModifiedEnabled) return;
|
|
18
|
+
|
|
9
19
|
return webFileService.saveFile({
|
|
10
20
|
body: {
|
|
11
21
|
serviceId,
|
package/src/types/index.ts
CHANGED
|
@@ -22,7 +22,7 @@ export { Interface } from './data/Interface';
|
|
|
22
22
|
export { Category } from './data/GlobalLogicNode';
|
|
23
23
|
export { Logic } from './logic/Logic';
|
|
24
24
|
export { LogicItem, LogicNode, ExpressionNode, evaluate } from './logic/LogicItem';
|
|
25
|
-
export { BaseVariable, updateVariablesChildrenSchema, updateAllVariablesChildrenSchema } from './logic/BaseVariable';
|
|
25
|
+
export { BaseVariable, updateVariablesChildrenSchema, updateAllVariablesChildrenSchema, variablesMap } from './logic/BaseVariable';
|
|
26
26
|
export { Param } from './logic/Param';
|
|
27
27
|
export { Variable } from './logic/Variable';
|
|
28
28
|
export { Return } from './logic/Return';
|
|
@@ -57,6 +57,7 @@ export { default as login } from './login';
|
|
|
57
57
|
export * as utils from './utils';
|
|
58
58
|
export * as genBlock from './data/genBlock';
|
|
59
59
|
export * as generator from './generator';
|
|
60
|
+
export { Permission } from './permission/Permission';
|
|
60
61
|
|
|
61
62
|
/**
|
|
62
63
|
* 层级枚举
|
|
@@ -75,6 +76,7 @@ export enum LEVEL_ENUM {
|
|
|
75
76
|
|
|
76
77
|
logic = 'logic',
|
|
77
78
|
param = 'param',
|
|
79
|
+
timer = 'timer',
|
|
78
80
|
variable = 'variable',
|
|
79
81
|
return = 'return',
|
|
80
82
|
interface = 'interface',
|
|
@@ -104,6 +106,7 @@ export enum LEVEL_ENUM {
|
|
|
104
106
|
processComponent = 'processComponent',
|
|
105
107
|
processParam = 'processParam',
|
|
106
108
|
processReturn = 'processReturn',
|
|
109
|
+
processTimer = 'processTimer',
|
|
107
110
|
processProperty = 'processProperty',
|
|
108
111
|
processComponentReturn = 'processComponentReturn',
|
|
109
112
|
processComponentVariable = 'processComponentVariable',
|
|
@@ -121,6 +124,7 @@ export const LEVEL_NAME_MAP = {
|
|
|
121
124
|
|
|
122
125
|
logic: '逻辑',
|
|
123
126
|
param: '输入参数',
|
|
127
|
+
timer: '定时任务',
|
|
124
128
|
variable: '局部变量',
|
|
125
129
|
return: '输出参数',
|
|
126
130
|
interface: '接口',
|
package/src/types/logic/Logic.ts
CHANGED
|
@@ -1,10 +1,34 @@
|
|
|
1
1
|
import { immutable, excludedInJSON, circular, action } from '../decorators';
|
|
2
|
-
import { config,
|
|
2
|
+
import { config, utils, Vertex, LEVEL_ENUM, Interface, Param, Return, Variable, vertexsMap, typeCheck, ProcessComponent, ProcessInterface, Process, ActionOptions } from '..';
|
|
3
3
|
import { logicService, paramService } from '../../service/logic';
|
|
4
4
|
import View from '../page/View';
|
|
5
5
|
import { ExpressionNode, LogicItem, LogicNode } from './LogicItem';
|
|
6
6
|
import { convert2SchemaType } from '../data/dataTypeUtils';
|
|
7
7
|
import { isPlainObject, throttle } from 'lodash';
|
|
8
|
+
import { refreshInterfaces, refreshView, refreshPages } from '../cache';
|
|
9
|
+
import { BusinessCode } from '../enum';
|
|
10
|
+
|
|
11
|
+
export function catchFn(logic: Logic) {
|
|
12
|
+
return async (err: any) => {
|
|
13
|
+
const code = err?.code;
|
|
14
|
+
if ([BusinessCode.ElementExist, BusinessCode.ElementNotExist].includes(code)) {
|
|
15
|
+
if (logic.interface) {
|
|
16
|
+
await refreshInterfaces();
|
|
17
|
+
} else if (logic.view) {
|
|
18
|
+
await refreshView(logic.view);
|
|
19
|
+
}
|
|
20
|
+
} else if (code === BusinessCode.ParentElementNotExist) { // 父节点不存在。视图添加逻辑,发现视图不存在
|
|
21
|
+
if (logic.view) {
|
|
22
|
+
await refreshPages();
|
|
23
|
+
}
|
|
24
|
+
} else
|
|
25
|
+
config.defaultApp?.emit('saved', err);
|
|
26
|
+
|
|
27
|
+
config.defaultApp?.history.load();
|
|
28
|
+
|
|
29
|
+
throw err;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
8
32
|
|
|
9
33
|
/**
|
|
10
34
|
* 逻辑类
|
|
@@ -123,6 +147,19 @@ export class Logic extends Vertex {
|
|
|
123
147
|
/**
|
|
124
148
|
* @param source 需要合并的部分参数
|
|
125
149
|
*/
|
|
150
|
+
/**
|
|
151
|
+
* 逻辑配置的cron表达式
|
|
152
|
+
*/
|
|
153
|
+
@immutable()
|
|
154
|
+
public cron: string = undefined;
|
|
155
|
+
/**
|
|
156
|
+
* 定时类型,当前只能是cronTrigger
|
|
157
|
+
*/
|
|
158
|
+
@immutable()
|
|
159
|
+
public triggerType: string = undefined;
|
|
160
|
+
/**
|
|
161
|
+
* 定时任务
|
|
162
|
+
*/
|
|
126
163
|
constructor(source?: Partial<Logic>) {
|
|
127
164
|
super();
|
|
128
165
|
source && this.assign(source);
|
|
@@ -141,18 +178,16 @@ export class Logic extends Vertex {
|
|
|
141
178
|
config.defaultApp?.emit('saving');
|
|
142
179
|
|
|
143
180
|
const body = this.toJSON();
|
|
144
|
-
// body.params.forEach((param: any) => convert2SchemaType(param.schema));
|
|
145
|
-
// body.returns.forEach((ret: any) => convert2SchemaType(ret.schema));
|
|
146
|
-
// body.variables.forEach((variable: any) => convert2SchemaType(variable.schema));
|
|
147
181
|
utils.logger.debug('添加逻辑', body);
|
|
148
182
|
const result: Logic = await logicService.create({
|
|
149
183
|
headers: {
|
|
184
|
+
moduleType: this.moduleType,
|
|
150
185
|
appId: config.defaultApp?.id,
|
|
151
186
|
operationAction: actionOptions?.actionName || 'Logic.create',
|
|
152
187
|
operationDesc: actionOptions?.actionDesc || `添加逻辑"${this.name}"`,
|
|
153
188
|
},
|
|
154
189
|
body,
|
|
155
|
-
});
|
|
190
|
+
}).catch(catchFn(this));
|
|
156
191
|
this.deepPick(result, ['id']);
|
|
157
192
|
this.pick(result, ['playgroundId']);
|
|
158
193
|
this.assign({ body: result.body.map((logicNode) => LogicNode.from(logicNode, this, null)) });
|
|
@@ -180,9 +215,8 @@ export class Logic extends Vertex {
|
|
|
180
215
|
*/
|
|
181
216
|
@action('删除逻辑')
|
|
182
217
|
async delete(none?: void, actionOptions?: ActionOptions) {
|
|
183
|
-
config.defaultApp?.emit('saving');
|
|
184
|
-
|
|
185
218
|
if (this.id) {
|
|
219
|
+
config.defaultApp?.emit('saving');
|
|
186
220
|
const body = this.toPlainJSON();
|
|
187
221
|
if (this.view) {
|
|
188
222
|
body.moduleId = this.view.id;
|
|
@@ -191,19 +225,16 @@ export class Logic extends Vertex {
|
|
|
191
225
|
body.moduleId = this.interface.service.id;
|
|
192
226
|
body.moduleType = 'microService';
|
|
193
227
|
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
}
|
|
204
|
-
await config.defaultApp?.history.load();
|
|
205
|
-
throw err;
|
|
206
|
-
}
|
|
228
|
+
|
|
229
|
+
await logicService.delete({
|
|
230
|
+
headers: {
|
|
231
|
+
moduleType: this.moduleType,
|
|
232
|
+
appId: config.defaultApp?.id,
|
|
233
|
+
operationAction: actionOptions?.actionName || 'Logic.delete',
|
|
234
|
+
operationDesc: actionOptions?.actionDesc || `删除逻辑"${this.name}"`,
|
|
235
|
+
},
|
|
236
|
+
body,
|
|
237
|
+
}).catch(catchFn(this));
|
|
207
238
|
|
|
208
239
|
if (this.view) {
|
|
209
240
|
const { logics } = this.view.$def;
|
|
@@ -216,7 +247,6 @@ export class Logic extends Vertex {
|
|
|
216
247
|
typeCheck.delete(node.id);
|
|
217
248
|
});
|
|
218
249
|
|
|
219
|
-
// const index =
|
|
220
250
|
this.destroy();
|
|
221
251
|
if (this.view) {
|
|
222
252
|
this.view.page.service.emit('pageTreeChange');
|
|
@@ -242,20 +272,50 @@ export class Logic extends Vertex {
|
|
|
242
272
|
|
|
243
273
|
const body = this.toPlainJSON();
|
|
244
274
|
utils.logger.debug('修改逻辑', body);
|
|
245
|
-
|
|
275
|
+
await logicService.update({
|
|
246
276
|
headers: {
|
|
277
|
+
moduleType: this.moduleType,
|
|
247
278
|
appId: config.defaultApp?.id,
|
|
248
279
|
operationAction: actionOptions?.actionName || 'Logic.update',
|
|
249
280
|
operationDesc: actionOptions?.actionDesc || `修改逻辑"${this.name}"`,
|
|
250
281
|
},
|
|
251
282
|
body,
|
|
252
|
-
});
|
|
283
|
+
}).catch(catchFn(this));
|
|
253
284
|
|
|
254
285
|
await then?.();
|
|
255
286
|
await config.defaultApp?.history.load();
|
|
256
287
|
config.defaultApp?.emit('saved');
|
|
257
288
|
return this;
|
|
258
289
|
}
|
|
290
|
+
/**
|
|
291
|
+
* 更新所有调用了此Logic的LogicNode
|
|
292
|
+
*/
|
|
293
|
+
async callLogicUpdate(actionOptions?: ActionOptions) {
|
|
294
|
+
config.defaultApp?.emit('saving');
|
|
295
|
+
|
|
296
|
+
const body = this.toPlainJSON();
|
|
297
|
+
body.params = this.params;
|
|
298
|
+
const result = await logicService.callLogicUpdate({
|
|
299
|
+
headers: {
|
|
300
|
+
appId: config.defaultApp?.id,
|
|
301
|
+
operationAction: actionOptions?.actionName || 'Logic.callLogicUpdate',
|
|
302
|
+
operationDesc: actionOptions?.actionDesc || `修改调用逻辑"${this.name}"`,
|
|
303
|
+
},
|
|
304
|
+
body,
|
|
305
|
+
}).catch((err: Error) => console.log(err)); // 报错不应影响参数的添加流程
|
|
306
|
+
|
|
307
|
+
(result || []).forEach(async (item: LogicNode) => {
|
|
308
|
+
if (vertexsMap.has(item.id)) {
|
|
309
|
+
const logicNode = vertexsMap.get(item.id) as LogicNode;
|
|
310
|
+
await logicNode.logic.load();
|
|
311
|
+
await logicNode.checkType();
|
|
312
|
+
}
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
// await config.defaultApp?.history.load();
|
|
316
|
+
config.defaultApp?.emit('saved');
|
|
317
|
+
return this;
|
|
318
|
+
}
|
|
259
319
|
/**
|
|
260
320
|
* 设置逻辑名称
|
|
261
321
|
*/
|
|
@@ -296,7 +356,7 @@ export class Logic extends Vertex {
|
|
|
296
356
|
/**
|
|
297
357
|
* 按当前 id 加载逻辑数据
|
|
298
358
|
*/
|
|
299
|
-
|
|
359
|
+
load() {
|
|
300
360
|
if (!this.id)
|
|
301
361
|
return;
|
|
302
362
|
|
|
@@ -305,17 +365,16 @@ export class Logic extends Vertex {
|
|
|
305
365
|
return this.contentPromise;
|
|
306
366
|
|
|
307
367
|
return this.contentPromise = (async () => {
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
} catch (err) {}
|
|
368
|
+
const result = await logicService.loadDetail({
|
|
369
|
+
query: {
|
|
370
|
+
moduleId: this.moduleId,
|
|
371
|
+
moduleType: this.moduleType,
|
|
372
|
+
id: this.id,
|
|
373
|
+
},
|
|
374
|
+
config: { noErrorTip: true },
|
|
375
|
+
}).catch(catchFn(this));
|
|
376
|
+
const newLogic = Logic.from(result, this.interface || this.view || this.processComponent, this);
|
|
377
|
+
this.assign(newLogic);
|
|
319
378
|
return this;
|
|
320
379
|
})().finally(() => this.contentPromise = undefined);
|
|
321
380
|
}
|
|
@@ -333,6 +392,10 @@ export class Logic extends Vertex {
|
|
|
333
392
|
});
|
|
334
393
|
|
|
335
394
|
const results = await paramService.addList({
|
|
395
|
+
headers: {
|
|
396
|
+
moduleType: this.moduleType,
|
|
397
|
+
appId: config.defaultApp?.id,
|
|
398
|
+
},
|
|
336
399
|
body,
|
|
337
400
|
});
|
|
338
401
|
params.forEach((param, index) => param.pick(results[index], ['id']));
|
|
@@ -346,10 +409,6 @@ export class Logic extends Vertex {
|
|
|
346
409
|
if (isPlainObject(item)) {
|
|
347
410
|
item = LogicItem.from(item, this, null);
|
|
348
411
|
}
|
|
349
|
-
// if (!this.children.includes(child)) {
|
|
350
|
-
// const index = child._posIndex === undefined ? this.children.length : child._posIndex;
|
|
351
|
-
// this.children.splice(index, 0, child);
|
|
352
|
-
// }
|
|
353
412
|
const parent = item.parentAttr ? vertexsMap.get(item.parentId) as LogicItem : undefined;
|
|
354
413
|
return item.create({
|
|
355
414
|
parent,
|
|
@@ -437,6 +496,56 @@ export class Logic extends Vertex {
|
|
|
437
496
|
|
|
438
497
|
return logic;
|
|
439
498
|
}
|
|
499
|
+
/**
|
|
500
|
+
* 更新定时任务
|
|
501
|
+
*/
|
|
502
|
+
@action('更新定时任务')
|
|
503
|
+
async updateTimer(cron: string) {
|
|
504
|
+
this.assign({ cron });
|
|
505
|
+
this.triggerType = 'cronTrigger';
|
|
506
|
+
await this.update(undefined, {
|
|
507
|
+
actionDesc: `设置定时任务"为"${cron}"`,
|
|
508
|
+
});
|
|
509
|
+
|
|
510
|
+
if (this.view) {
|
|
511
|
+
this.view.page.service.emit('pageTreeChange');
|
|
512
|
+
this.emit('change');
|
|
513
|
+
}
|
|
514
|
+
return this;
|
|
515
|
+
}
|
|
516
|
+
/**
|
|
517
|
+
* 验证表达式正确与否
|
|
518
|
+
*/
|
|
519
|
+
async validateTimer() {
|
|
520
|
+
const body = this.toPlainJSON();
|
|
521
|
+
const result = await logicService.validateTimer({
|
|
522
|
+
body,
|
|
523
|
+
config: {
|
|
524
|
+
noErrorTip: true,
|
|
525
|
+
},
|
|
526
|
+
});
|
|
527
|
+
return result;
|
|
528
|
+
}
|
|
529
|
+
/**
|
|
530
|
+
* 输出最近十次运行结果
|
|
531
|
+
*/
|
|
532
|
+
async testTimer() {
|
|
533
|
+
const body = this.toPlainJSON();
|
|
534
|
+
const result = await logicService.testTimer({
|
|
535
|
+
body,
|
|
536
|
+
});
|
|
537
|
+
return result;
|
|
538
|
+
}
|
|
539
|
+
/**
|
|
540
|
+
* 更新接口缓存
|
|
541
|
+
*/
|
|
542
|
+
async updateCronCache() {
|
|
543
|
+
const body = this.toPlainJSON();
|
|
544
|
+
const result = await logicService.updateCronCache({
|
|
545
|
+
body,
|
|
546
|
+
});
|
|
547
|
+
return result;
|
|
548
|
+
}
|
|
440
549
|
}
|
|
441
550
|
|
|
442
551
|
export default Logic;
|