@lcap/nasl 3.8.0-beta.3 → 3.8.0-beta.5
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/automate/engine/utils.js +1 -2
- package/out/automate/engine/utils.js.map +1 -1
- package/out/bak/translator.js +1 -1
- package/out/bak/translator.js.map +1 -1
- package/out/common/BaseNode.js +7 -2
- package/out/common/BaseNode.js.map +1 -1
- package/out/concepts/App__.js +6 -1
- package/out/concepts/App__.js.map +1 -1
- package/out/concepts/Argument__.js +11 -5
- package/out/concepts/Argument__.js.map +1 -1
- package/out/concepts/AuthLogicForCallInterface__.js +3 -0
- package/out/concepts/AuthLogicForCallInterface__.js.map +1 -1
- package/out/concepts/BinaryExpression__.js +49 -2
- package/out/concepts/BinaryExpression__.js.map +1 -1
- package/out/concepts/BindAttribute__.d.ts +4 -3
- package/out/concepts/BindAttribute__.js +121 -42
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindEvent__.js +5 -42
- package/out/concepts/BindEvent__.js.map +1 -1
- package/out/concepts/BusinessComponent__.d.ts +1 -0
- package/out/concepts/BusinessComponent__.js +16 -0
- package/out/concepts/BusinessComponent__.js.map +1 -1
- package/out/concepts/BusinessLogic__.js +3 -0
- package/out/concepts/BusinessLogic__.js.map +1 -1
- package/out/concepts/CallConnector__.js +1 -1
- package/out/concepts/CallConnector__.js.map +1 -1
- package/out/concepts/CallFunction__.js +1 -1
- package/out/concepts/CallFunction__.js.map +1 -1
- package/out/concepts/CallLogic__.d.ts +6 -1
- package/out/concepts/CallLogic__.js +58 -17
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/Connection__.d.ts +4 -0
- package/out/concepts/Connection__.js +15 -0
- package/out/concepts/Connection__.js.map +1 -1
- package/out/concepts/DatabaseTypeAnnotation__.d.ts +2 -0
- package/out/concepts/DatabaseTypeAnnotation__.js +20 -0
- package/out/concepts/DatabaseTypeAnnotation__.js.map +1 -1
- package/out/concepts/End__.js +5 -1
- package/out/concepts/End__.js.map +1 -1
- package/out/concepts/EntityProperty__.js +2 -0
- package/out/concepts/EntityProperty__.js.map +1 -1
- package/out/concepts/Entity__.d.ts +1 -0
- package/out/concepts/Entity__.js +24 -1
- package/out/concepts/Entity__.js.map +1 -1
- package/out/concepts/EnumItem__.d.ts +12 -0
- package/out/concepts/EnumItem__.js +49 -5
- package/out/concepts/EnumItem__.js.map +1 -1
- package/out/concepts/Enum__.js +4 -1
- package/out/concepts/Enum__.js.map +1 -1
- package/out/concepts/ForEachStatement__.js +1 -1
- package/out/concepts/ForEachStatement__.js.map +1 -1
- package/out/concepts/FrontendLibrary__.d.ts +46 -46
- package/out/concepts/FrontendLibrary__.js +34 -36
- package/out/concepts/FrontendLibrary__.js.map +1 -1
- package/out/concepts/I18nInfo__.d.ts +1 -0
- package/out/concepts/I18nInfo__.js +7 -0
- package/out/concepts/I18nInfo__.js.map +1 -1
- package/out/concepts/IfStatement__.js +2 -2
- package/out/concepts/IfStatement__.js.map +1 -1
- package/out/concepts/Interface__.js +4 -1
- package/out/concepts/Interface__.js.map +1 -1
- package/out/concepts/Logic__.d.ts +2 -3
- package/out/concepts/Logic__.js +33 -8
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/MatchCase__.d.ts +2 -2
- package/out/concepts/MatchCase__.js +7 -7
- package/out/concepts/MatchCase__.js.map +1 -1
- package/out/concepts/NewComposite__.js +2 -1
- package/out/concepts/NewComposite__.js.map +1 -1
- package/out/concepts/NewList__.js +2 -1
- package/out/concepts/NewList__.js.map +1 -1
- package/out/concepts/NewMap__.js +2 -1
- package/out/concepts/NewMap__.js.map +1 -1
- package/out/concepts/OqlQueryComponent__.js +3 -11
- package/out/concepts/OqlQueryComponent__.js.map +1 -1
- package/out/concepts/OverriddenLogic__.js +7 -0
- package/out/concepts/OverriddenLogic__.js.map +1 -1
- package/out/concepts/Param__.js +2 -1
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/ProcessElementV2__.d.ts +4 -5
- package/out/concepts/ProcessElementV2__.js +12 -17
- package/out/concepts/ProcessElementV2__.js.map +1 -1
- package/out/concepts/ProcessElement__.d.ts +3 -4
- package/out/concepts/ProcessElement__.js +44 -46
- package/out/concepts/ProcessElement__.js.map +1 -1
- package/out/concepts/ProcessV2__.d.ts +5 -0
- package/out/concepts/ProcessV2__.js +30 -2
- package/out/concepts/ProcessV2__.js.map +1 -1
- package/out/concepts/Process__.d.ts +5 -0
- package/out/concepts/Process__.js +28 -0
- package/out/concepts/Process__.js.map +1 -1
- package/out/concepts/QueryFromExpression__.js +2 -2
- package/out/concepts/QueryFromExpression__.js.map +1 -1
- package/out/concepts/QueryJoinExpression__.js +2 -2
- package/out/concepts/QueryJoinExpression__.js.map +1 -1
- package/out/concepts/Return__.d.ts +1 -1
- package/out/concepts/Return__.js +2 -1
- package/out/concepts/Return__.js.map +1 -1
- package/out/concepts/StaticString__.d.ts +4 -0
- package/out/concepts/StaticString__.js +11 -0
- package/out/concepts/StaticString__.js.map +1 -1
- package/out/concepts/StructureProperty__.js +5 -2
- package/out/concepts/StructureProperty__.js.map +1 -1
- package/out/concepts/Structure__.js +9 -3
- package/out/concepts/Structure__.js.map +1 -1
- package/out/concepts/SubLogic__.d.ts +1 -3
- package/out/concepts/SubLogic__.js +14 -8
- package/out/concepts/SubLogic__.js.map +1 -1
- package/out/concepts/Transactional__.d.ts +1 -0
- package/out/concepts/Transactional__.js +7 -0
- package/out/concepts/Transactional__.js.map +1 -1
- package/out/concepts/TypeParam__.d.ts +4 -0
- package/out/concepts/TypeParam__.js +3 -0
- package/out/concepts/TypeParam__.js.map +1 -1
- package/out/concepts/ValidationRule__.d.ts +1 -6
- package/out/concepts/ValidationRule__.js +9 -6
- package/out/concepts/ValidationRule__.js.map +1 -1
- package/out/concepts/Variable__.d.ts +1 -1
- package/out/concepts/Variable__.js +7 -2
- package/out/concepts/Variable__.js.map +1 -1
- package/out/concepts/ViewElement__.d.ts +2 -0
- package/out/concepts/ViewElement__.js +130 -47
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.d.ts +8 -0
- package/out/concepts/View__.js +123 -7
- package/out/concepts/View__.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.processV2.js +2 -2
- package/out/concepts/basics/stdlib/nasl.processV2.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.ui.js +1 -1
- package/out/concepts/basics/stdlib/nasl.ui.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.validation.js +110 -4
- package/out/concepts/basics/stdlib/nasl.validation.js.map +1 -1
- package/out/generator/genBundleFiles.d.ts +2 -0
- package/out/generator/genBundleFiles.js +51 -37
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/generator/genMetaData.js +20 -26
- package/out/generator/genMetaData.js.map +1 -1
- package/out/generator/release-body/body.js +8 -6
- package/out/generator/release-body/body.js.map +1 -1
- package/out/generator/release-body/index.d.ts +1 -0
- package/out/generator/release-body/index.js +1 -0
- package/out/generator/release-body/index.js.map +1 -1
- package/out/generator/release-body/utils.js +1 -1
- package/out/generator/release-body/utils.js.map +1 -1
- package/out/natural/genNaturalTS.d.ts +56 -24
- package/out/natural/genNaturalTS.js +182 -112
- package/out/natural/genNaturalTS.js.map +1 -1
- package/out/natural/getContext/getUILib.js +4 -2
- package/out/natural/getContext/getUILib.js.map +1 -1
- package/out/natural/getContext/index.d.ts +34 -25
- package/out/natural/getContext/index.js +304 -157
- package/out/natural/getContext/index.js.map +1 -1
- package/out/natural/index.d.ts +1 -0
- package/out/natural/index.js +1 -0
- package/out/natural/index.js.map +1 -1
- package/out/natural/tools.d.ts +11 -0
- package/out/natural/tools.js +155 -0
- package/out/natural/tools.js.map +1 -0
- package/out/natural/transformTS2UI.js +84 -22
- package/out/natural/transformTS2UI.js.map +1 -1
- package/out/natural/transformTSCode.js +83 -22
- package/out/natural/transformTSCode.js.map +1 -1
- package/out/server/formatTsUtils.js +17 -1
- package/out/server/formatTsUtils.js.map +1 -1
- package/out/server/getLogics.js +1 -4
- package/out/server/getLogics.js.map +1 -1
- package/out/server/naslServer.js +285 -32
- package/out/server/naslServer.js.map +1 -1
- package/out/server/translator.js +5 -1
- package/out/server/translator.js.map +1 -1
- package/out/templator/genCreateBlock.js +5 -18
- package/out/templator/genCreateBlock.js.map +1 -1
- package/out/templator/genCurdMultipleKeyBlock.js +11 -32
- package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
- package/out/templator/genGetBlock.js +1 -2
- package/out/templator/genGetBlock.js.map +1 -1
- package/out/templator/genListViewBlock.js +6 -4
- package/out/templator/genListViewBlock.js.map +1 -1
- package/out/templator/genSelectBlock.js +82 -59
- package/out/templator/genSelectBlock.js.map +1 -1
- package/out/templator/genTableBlock.js +4 -4
- package/out/templator/genTableBlock.js.map +1 -1
- package/out/templator/genUpdateBlock.js +2 -15
- package/out/templator/genUpdateBlock.js.map +1 -1
- package/out/templator/utils.d.ts +1 -1
- package/out/templator/utils.js +1 -1
- package/out/templator/utils.js.map +1 -1
- package/out/translator/types.d.ts +4 -0
- package/out/translator/utils.d.ts +1 -0
- package/out/translator/utils.js +6 -1
- package/out/translator/utils.js.map +1 -1
- package/out/utils/env.d.ts +4 -0
- package/out/utils/env.js +6 -3
- package/out/utils/env.js.map +1 -1
- package/out/utils/index.d.ts +19 -0
- package/out/utils/index.js +61 -1
- package/out/utils/index.js.map +1 -1
- package/out/utils/language-cache/constant.d.ts +18 -0
- package/out/utils/language-cache/constant.js +35 -0
- package/out/utils/language-cache/constant.js.map +1 -0
- package/out/utils/language-cache/index.d.ts +2 -0
- package/out/utils/language-cache/index.js +19 -0
- package/out/utils/language-cache/index.js.map +1 -0
- package/out/utils/language-cache/nasl.d.ts +10 -0
- package/out/utils/language-cache/nasl.js +98 -0
- package/out/utils/language-cache/nasl.js.map +1 -0
- package/out/utils/language-cache/types.d.ts +44 -0
- package/out/utils/language-cache/types.js +4 -0
- package/out/utils/language-cache/types.js.map +1 -0
- package/out/utils/time-slicing/controller.js.map +1 -1
- package/out/utils/types.d.ts +17 -0
- package/package.json +3 -2
- package/sandbox/stdlib/nasl.core.ts +15 -11
- package/sandbox/stdlib/nasl.oql.ts +5 -1
- package/sandbox/stdlib/nasl.processV2.ts +5 -4
- package/sandbox/stdlib/nasl.ui.components.pc.ts +225 -225
- package/sandbox/stdlib/nasl.ui.ts +10 -0
- package/sandbox/stdlib/nasl.util.ts +11 -0
- package/sandbox/stdlib/nasl.validation.ts +3 -2
- package/sandbox-natural/stdlib/nasl.ui.pre.d.ts +1 -1
- package/sandbox-natural/stdlib/nasl.ui.ts +2 -2
- package/sandbox-natural/stdlib/nasl.util.ts +2 -2
- package/src/automate/engine/utils.js +1 -2
- package/src/bak/translator.js +1 -1
- package/src/common/BaseNode.ts +7 -3
- package/src/concepts/App__.ts +9 -1
- package/src/concepts/Argument__.ts +10 -5
- package/src/concepts/AuthLogicForCallInterface__.ts +3 -0
- package/src/concepts/BinaryExpression__.ts +46 -2
- package/src/concepts/BindAttribute__.ts +144 -46
- package/src/concepts/BindEvent__.ts +8 -47
- package/src/concepts/BusinessComponent__.ts +17 -0
- package/src/concepts/BusinessLogic__.ts +3 -0
- package/src/concepts/CallConnector__.ts +1 -1
- package/src/concepts/CallFunction__.ts +1 -1
- package/src/concepts/CallLogic__.ts +63 -17
- package/src/concepts/Connection__.ts +16 -0
- package/src/concepts/DatabaseTypeAnnotation__.ts +11 -0
- package/src/concepts/End__.ts +5 -1
- package/src/concepts/EntityProperty__.ts +5 -0
- package/src/concepts/Entity__.ts +29 -1
- package/src/concepts/EnumItem__.ts +64 -1
- package/src/concepts/Enum__.ts +6 -1
- package/src/concepts/ForEachStatement__.ts +1 -1
- package/src/concepts/FrontendLibrary__.ts +78 -80
- package/src/concepts/I18nInfo__.ts +5 -0
- package/src/concepts/IfStatement__.ts +2 -2
- package/src/concepts/Interface__.ts +6 -1
- package/src/concepts/Logic__.ts +39 -10
- package/src/concepts/MatchCase__.ts +8 -9
- package/src/concepts/NewComposite__.ts +2 -1
- package/src/concepts/NewList__.ts +2 -1
- package/src/concepts/NewMap__.ts +2 -1
- package/src/concepts/OqlQueryComponent__.ts +3 -11
- package/src/concepts/OverriddenLogic__.ts +7 -0
- package/src/concepts/Param__.ts +1 -0
- package/src/concepts/ProcessElementV2__.ts +14 -16
- package/src/concepts/ProcessElement__.ts +16 -16
- package/src/concepts/ProcessV2__.ts +39 -3
- package/src/concepts/Process__.ts +36 -0
- package/src/concepts/QueryFromExpression__.ts +2 -2
- package/src/concepts/QueryJoinExpression__.ts +2 -2
- package/src/concepts/Return__.ts +2 -1
- package/src/concepts/StaticString__.ts +12 -0
- package/src/concepts/StructureProperty__.ts +7 -2
- package/src/concepts/Structure__.ts +11 -3
- package/src/concepts/SubLogic__.ts +15 -9
- package/src/concepts/Transactional__.ts +5 -0
- package/src/concepts/TypeParam__.ts +6 -0
- package/src/concepts/ValidationRule__.ts +7 -6
- package/src/concepts/Variable__.ts +7 -2
- package/src/concepts/ViewElement__.ts +130 -47
- package/src/concepts/View__.ts +157 -8
- package/src/concepts/basics/stdlib/nasl.processV2.ts +2 -2
- package/src/concepts/basics/stdlib/nasl.ui.ts +1 -1
- package/src/concepts/basics/stdlib/nasl.validation.ts +111 -4
- package/src/generator/genBundleFiles.ts +53 -39
- package/src/generator/genMetaData.ts +21 -26
- package/src/generator/release-body/body.ts +9 -6
- package/src/generator/release-body/index.ts +1 -0
- package/src/generator/release-body/utils.ts +4 -2
- package/src/natural/genNaturalTS.ts +327 -141
- package/src/natural/getContext/getUILib.ts +4 -2
- package/src/natural/getContext/index.ts +348 -171
- package/src/natural/index.ts +1 -0
- package/src/natural/tools.ts +130 -0
- package/src/natural/transformTS2UI.ts +84 -22
- package/src/natural/transformTSCode.ts +83 -22
- package/src/server/formatTsUtils.ts +21 -1
- package/src/server/getLogics.ts +1 -4
- package/src/server/naslServer.ts +302 -33
- package/src/server/translator.ts +5 -1
- package/src/templator/genCreateBlock.ts +5 -18
- package/src/templator/genCurdMultipleKeyBlock.ts +14 -32
- package/src/templator/genGetBlock.ts +2 -4
- package/src/templator/genListViewBlock.ts +6 -4
- package/src/templator/genSelectBlock.ts +88 -61
- package/src/templator/genTableBlock.ts +4 -4
- package/src/templator/genUpdateBlock.ts +2 -15
- package/src/templator/utils.ts +1 -1
- package/src/translator/types.ts +4 -0
- package/src/translator/utils.ts +6 -0
- package/src/utils/env.ts +5 -4
- package/src/utils/index.ts +50 -1
- package/src/utils/language-cache/constant.ts +37 -0
- package/src/utils/language-cache/index.ts +2 -0
- package/src/utils/language-cache/nasl.ts +83 -0
- package/src/utils/language-cache/types.ts +48 -0
- package/src/utils/time-slicing/controller.ts +0 -1
- package/src/utils/types.ts +20 -0
- package/test/concepts/call-logic/__snapshots__/getQuickInfoOffset.spec.ts.snap +13 -13
- package/test/concepts/call-logic/__snapshots__/toEmbeddedTS.spec.ts.snap +12 -12
- package/test/concepts/validation-rule/__snapshots__/toEmbeddedTS.spec.ts.snap +1 -2
- package/test/concepts/view-element/__snapshots__/toEmbeddedTS.spec.ts.snap +221 -217
- package/ts-worker/bundle.js +1 -1
- package/ts-worker/src/index.js +0 -1
- package/out/utils/delay/index.d.ts +0 -0
- package/out/utils/delay/index.js +0 -1
- package/out/utils/delay/index.js.map +0 -1
- package/src/utils/delay/index.ts +0 -0
|
@@ -56,9 +56,7 @@ export function genH5GetTemplate(entity: Entity, nameGroup: NameGroup) {
|
|
|
56
56
|
${properties
|
|
57
57
|
.map((property) => {
|
|
58
58
|
const temptitle = property.label || property.name;
|
|
59
|
-
let formItem = ` <van-cell isLink
|
|
60
|
-
|
|
61
|
-
formItem += ' :value="' + `${nameGroup.viewVariableEntity}.${property.name}` + '">';
|
|
59
|
+
let formItem = ` <van-cell isLink>`;
|
|
62
60
|
formItem += `<template #title>${temptitle}</template>`;
|
|
63
61
|
formItem += `{{ ${`${nameGroup.viewVariableEntity}.${property.name}`} }} </van-cell>\n`;
|
|
64
62
|
return formItem;
|
|
@@ -67,7 +65,7 @@ export function genH5GetTemplate(entity: Entity, nameGroup: NameGroup) {
|
|
|
67
65
|
</van-cell-group>`;
|
|
68
66
|
}
|
|
69
67
|
|
|
70
|
-
export function genGetBlock(entity: Entity, oldNode: ViewElement,
|
|
68
|
+
export function genGetBlock(entity: Entity, oldNode: ViewElement,
|
|
71
69
|
getGetTemplate: (entity: Entity, nameGroup: NameGroup) => string) {
|
|
72
70
|
const likeComponent = oldNode?.likeComponent;
|
|
73
71
|
const isBusinessComponent = likeComponent.concept === 'BusinessComponent';
|
|
@@ -13,8 +13,9 @@ export function genListViewTemplate(property: EntityProperty, nameGroup: NameGro
|
|
|
13
13
|
return `<u-list-view ref="${nameGroup.viewElementMainView}" :dataSource="${dataSourceValue}" dataSchema="${nameGroup.structure}"
|
|
14
14
|
:pageSize="50"
|
|
15
15
|
:pageNumber="1"
|
|
16
|
-
textField="${
|
|
17
|
-
valueField="${lowerEntityName}.
|
|
16
|
+
textField="${lowerEntityName}.${property.name}"
|
|
17
|
+
valueField="${lowerEntityName}.${entity.properties.find((p) => p.primaryKey)?.name || 'id'}"
|
|
18
|
+
:pageable="true" :remotePaging="true">
|
|
18
19
|
<template #item="current">
|
|
19
20
|
<u-linear-layout>
|
|
20
21
|
<u-text :text="${valueExpression}"></u-text>
|
|
@@ -32,8 +33,9 @@ export function genH5ListViewTemplate(property: EntityProperty, nameGroup: NameG
|
|
|
32
33
|
return `<van-list-view ref="${nameGroup.viewElementMainView}" :dataSource="${dataSourceValue}" dataSchema="${nameGroup.structure}"
|
|
33
34
|
:pageSize="50"
|
|
34
35
|
:pageNumber="1"
|
|
35
|
-
textField="${
|
|
36
|
-
valueField="${lowerEntityName}.
|
|
36
|
+
textField="${lowerEntityName}.${property.name}"
|
|
37
|
+
valueField="${lowerEntityName}.${entity.properties.find((p) => p.primaryKey)?.name || 'id'}"
|
|
38
|
+
pageable="auto-more" :remotePaging="true">
|
|
37
39
|
<template #item="current">
|
|
38
40
|
<van-cell :value="${valueExpression}" isLink>
|
|
39
41
|
<template #title>{{ ${valueExpression} }}</template>
|
|
@@ -182,14 +182,14 @@ export function genSelectItemAddLogic(entity: Entity, nameGroup: NameGroup, view
|
|
|
182
182
|
const callLogics = [];
|
|
183
183
|
const variableName = view.getVariableUniqueName('itemVariable1');
|
|
184
184
|
const itemVariable1Snapshot = view.getVariableUniqueName(`${variableName}Snapshot`);
|
|
185
|
-
|
|
185
|
+
let variables = [
|
|
186
186
|
NaslNode.Variable({
|
|
187
187
|
name: variableName,
|
|
188
188
|
typeAnnotation: null,
|
|
189
189
|
}),
|
|
190
190
|
];
|
|
191
191
|
const itemExpression = genLogicParam(`item`, `${variableName}.${nameGroup.textField}`);
|
|
192
|
-
if (entity && entity.getNamespace) {
|
|
192
|
+
if (entity && entity.getNamespace) { // item是实体或者数据结构
|
|
193
193
|
callLogics.push(
|
|
194
194
|
NaslLogicItem.Assignment({
|
|
195
195
|
left: NaslLogicItem.Identifier({
|
|
@@ -215,57 +215,51 @@ export function genSelectItemAddLogic(entity: Entity, nameGroup: NameGroup, view
|
|
|
215
215
|
})
|
|
216
216
|
);
|
|
217
217
|
} else {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
218
|
+
// item是基本类型
|
|
219
|
+
if(nameGroup.schemaRef === 'nasl.core.String'){
|
|
220
|
+
callLogics.push(
|
|
221
|
+
NaslLogicItem.Assignment({
|
|
222
|
+
left: NaslLogicItem.Identifier({
|
|
223
|
+
name: variableName,
|
|
224
|
+
}),
|
|
225
|
+
right: NaslLogicItem.Identifier({
|
|
226
|
+
name: nameGroup.itemInputVariableName,
|
|
227
|
+
}),
|
|
228
|
+
})
|
|
229
|
+
);
|
|
230
|
+
} else if (['nasl.core.Long', 'nasl.core.Decimal'].includes(nameGroup.schemaRef)) {
|
|
231
|
+
const typeAnnotation ={
|
|
232
|
+
concept: 'TypeAnnotation',
|
|
233
|
+
typeKind: 'primitive',
|
|
234
|
+
typeNamespace: 'nasl.core',
|
|
235
|
+
typeName: nameGroup.schemaRef.replace('nasl.core.', ''),
|
|
236
|
+
};
|
|
237
|
+
callLogics.push(
|
|
238
|
+
NaslLogicItem.Assignment({
|
|
239
|
+
left: NaslLogicItem.Identifier({
|
|
240
|
+
name: variableName,
|
|
241
|
+
}),
|
|
242
|
+
right: NaslLogicItem.CallFunction({
|
|
243
|
+
calleeName: 'Convert',
|
|
244
|
+
typeArguments: [typeAnnotation],
|
|
245
|
+
arguments: [
|
|
246
|
+
NaslLogicItem.Argument({
|
|
247
|
+
keyword: 'value',
|
|
248
|
+
expression: NaslLogicItem.Identifier({
|
|
249
|
+
name: nameGroup.itemInputVariableName,
|
|
250
|
+
}),
|
|
251
|
+
}),
|
|
235
252
|
],
|
|
236
|
-
},
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
name: '',
|
|
247
|
-
expression: {
|
|
248
|
-
concept: 'StringLiteral',
|
|
249
|
-
name: '',
|
|
250
|
-
value: '',
|
|
251
|
-
},
|
|
252
|
-
members: [],
|
|
253
|
-
},
|
|
254
|
-
],
|
|
255
|
-
assignmentLines: [
|
|
256
|
-
{
|
|
257
|
-
concept: 'AssignmentLine',
|
|
258
|
-
name: '',
|
|
259
|
-
leftIndex: [0, 0],
|
|
260
|
-
rightIndex: [0],
|
|
261
|
-
},
|
|
262
|
-
],
|
|
263
|
-
hideProperties: false,
|
|
264
|
-
hideDefaults: false,
|
|
265
|
-
autoConnection: true,
|
|
266
|
-
},
|
|
267
|
-
})
|
|
268
|
-
);
|
|
253
|
+
}),
|
|
254
|
+
})
|
|
255
|
+
);
|
|
256
|
+
} else {
|
|
257
|
+
callLogics.push({
|
|
258
|
+
concept: 'Comment',
|
|
259
|
+
name: '',
|
|
260
|
+
value: '存储输入框的值做处理',
|
|
261
|
+
});
|
|
262
|
+
}
|
|
269
263
|
}
|
|
270
264
|
|
|
271
265
|
// 该属性可能不是String类型,如Integer,需要转换下,否则问题处会报错
|
|
@@ -287,7 +281,7 @@ export function genSelectItemAddLogic(entity: Entity, nameGroup: NameGroup, view
|
|
|
287
281
|
}),
|
|
288
282
|
})
|
|
289
283
|
);
|
|
290
|
-
} else {
|
|
284
|
+
} else if (entity && entity.getNamespace) {
|
|
291
285
|
callLogics.push(
|
|
292
286
|
NaslLogicItem.Assignment({
|
|
293
287
|
left: itemExpression.expression,
|
|
@@ -343,6 +337,10 @@ export function genSelectItemAddLogic(entity: Entity, nameGroup: NameGroup, view
|
|
|
343
337
|
{
|
|
344
338
|
concept: 'StructureProperty',
|
|
345
339
|
name: nameGroup.prefixField,
|
|
340
|
+
typeAnnotation: NaslTypeAnnotation.Reference({
|
|
341
|
+
typeNamespace: entity.getNamespace(),
|
|
342
|
+
typeName: entity.name,
|
|
343
|
+
})
|
|
346
344
|
},
|
|
347
345
|
],
|
|
348
346
|
},
|
|
@@ -392,6 +390,42 @@ export function genSelectItemAddLogic(entity: Entity, nameGroup: NameGroup, view
|
|
|
392
390
|
value: '调用后端接口保存数据',
|
|
393
391
|
});
|
|
394
392
|
}
|
|
393
|
+
const argumentsTemp = [];
|
|
394
|
+
if(variables.length >= 2) { // 实体
|
|
395
|
+
argumentsTemp.push(
|
|
396
|
+
NaslLogicItem.Argument({
|
|
397
|
+
keyword: 'item',
|
|
398
|
+
expression: NaslLogicItem.Identifier({
|
|
399
|
+
name: itemVariable1Snapshot,
|
|
400
|
+
}),
|
|
401
|
+
})
|
|
402
|
+
);
|
|
403
|
+
} else {
|
|
404
|
+
if(entity && entity.getNamespace || ['nasl.core.String', 'nasl.core.Long', 'nasl.core.Decimal'].includes(nameGroup.schemaRef)) {
|
|
405
|
+
argumentsTemp.push(
|
|
406
|
+
NaslLogicItem.Argument({
|
|
407
|
+
keyword: 'item',
|
|
408
|
+
expression: NaslLogicItem.Identifier({
|
|
409
|
+
name: variableName,
|
|
410
|
+
}),
|
|
411
|
+
})
|
|
412
|
+
);
|
|
413
|
+
} else {
|
|
414
|
+
// 其他类型就置空
|
|
415
|
+
variables = [];
|
|
416
|
+
callLogics.push({
|
|
417
|
+
concept: 'Comment',
|
|
418
|
+
name: '',
|
|
419
|
+
value: '如下调用addItem将数据添加到下拉框里,item参数填上值',
|
|
420
|
+
});
|
|
421
|
+
argumentsTemp.push(
|
|
422
|
+
NaslLogicItem.Argument({
|
|
423
|
+
keyword: 'item',
|
|
424
|
+
expression: null,
|
|
425
|
+
})
|
|
426
|
+
);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
395
429
|
return NaslNode.Logic({
|
|
396
430
|
name: nameGroup.viewLogicAddItem,
|
|
397
431
|
params: [],
|
|
@@ -400,14 +434,7 @@ export function genSelectItemAddLogic(entity: Entity, nameGroup: NameGroup, view
|
|
|
400
434
|
body: [
|
|
401
435
|
NaslLogicItem.Start,
|
|
402
436
|
...callLogics,
|
|
403
|
-
genCallComponentLogic(nameGroup.viewElementMainView, 'addItem',
|
|
404
|
-
NaslLogicItem.Argument({
|
|
405
|
-
keyword: 'item',
|
|
406
|
-
expression: NaslLogicItem.Identifier({
|
|
407
|
-
name: variables.length >= 2 ? itemVariable1Snapshot : variableName,
|
|
408
|
-
}),
|
|
409
|
-
}),
|
|
410
|
-
]),
|
|
437
|
+
genCallComponentLogic(nameGroup.viewElementMainView, 'addItem', argumentsTemp),
|
|
411
438
|
NaslLogicItem.End,
|
|
412
439
|
],
|
|
413
440
|
playground: [] as Array<any>,
|
|
@@ -89,7 +89,7 @@ export function genTableTemplate(entity: Entity, nameGroup: NameGroup, newLogic:
|
|
|
89
89
|
|
|
90
90
|
${properties.map((property) => `${genTableColumnTemplate(property, currentName)}\n`).join('')}
|
|
91
91
|
|
|
92
|
-
<u-table-view-column
|
|
92
|
+
<u-table-view-column>
|
|
93
93
|
<template #title><u-text text="操作"></u-text></template>
|
|
94
94
|
<template #cell="current">
|
|
95
95
|
<u-linear-layout gap="small">
|
|
@@ -380,7 +380,7 @@ export function genTableTemplateTableDesigner(
|
|
|
380
380
|
:pagination="true" :showSizer="true" :pageSize="20" :pageNumber="1" style="margin-top: 12px">
|
|
381
381
|
<u-table-view-column type="index" width="60"><template #title><u-text text="序号"></u-text></template><template #cell="current"></template></u-table-view-column>
|
|
382
382
|
${properties.map((property) => `${genTableColumnTemplateTableDesigner(property, currentName, optionsMap, dataSourcesMap)}\n`).join('')}
|
|
383
|
-
<u-table-view-column
|
|
383
|
+
<u-table-view-column>
|
|
384
384
|
<template #title><u-text text="操作"></u-text></template>
|
|
385
385
|
<template #cell="current">
|
|
386
386
|
<u-link style="margin-right:5px;" @click="${nameGroup.viewLogicPreview}">详情</u-link>
|
|
@@ -416,7 +416,7 @@ export const genTableColumnTemplateTableDesigner = (property: EntityProperty, cu
|
|
|
416
416
|
if (hasOptions) {
|
|
417
417
|
const options = optionsMap[property.name];
|
|
418
418
|
return `
|
|
419
|
-
<u-select style="height: auto;" :preview="true" :value="${valueExpression}" placeholder="--" ${multiple ? 'multiple tags-overflow="visible" ' : ''}>
|
|
419
|
+
<u-select style="height: auto;" :preview="true" :value="${valueExpression}" placeholder="--" ${multiple ? ':multiple="true" tags-overflow="visible" ' : ''}>
|
|
420
420
|
${options.map((option: any) => `<u-select-item value="${option.value}"><u-text text="${option.label}"></u-text></u-select-item>`)}
|
|
421
421
|
</u-select>
|
|
422
422
|
`;
|
|
@@ -429,7 +429,7 @@ export const genTableColumnTemplateTableDesigner = (property: EntityProperty, cu
|
|
|
429
429
|
const { dataSource, multiple, textField, valueField } = dataSourcesMap[property.name];
|
|
430
430
|
return `
|
|
431
431
|
<u-select :preview="true" :value.sync="${valueExpression}" placeholder="--" ${
|
|
432
|
-
multiple ? 'multiple tags-overflow="visible" ' : ''
|
|
432
|
+
multiple ? ':multiple="true" tags-overflow="visible" ' : ''
|
|
433
433
|
} :dataSource="(params)=>${dataSource?.calleeName}(params)" :textField="${textField}" :valueField="${valueField}"></u-select>`;
|
|
434
434
|
}
|
|
435
435
|
return `<u-text :text="${valueExpression}"></u-text>`;
|
|
@@ -230,25 +230,12 @@ function genSubmitLogic(updateLogic: Logic, nameGroup: NameGroup) {
|
|
|
230
230
|
name: nameGroup.viewLogicSubmit,
|
|
231
231
|
params: [] as any,
|
|
232
232
|
returns: [] as any,
|
|
233
|
-
variables: [
|
|
234
|
-
NaslNode.Variable({
|
|
235
|
-
name: 'validateResult',
|
|
236
|
-
typeAnnotation: NaslUITypeAnnotation.ValidateEvent,
|
|
237
|
-
}),
|
|
238
|
-
],
|
|
233
|
+
variables: [],
|
|
239
234
|
body: [
|
|
240
235
|
NaslLogicItem.Start,
|
|
241
|
-
NaslLogicItem.Assignment({
|
|
242
|
-
left: NaslLogicItem.Identifier({
|
|
243
|
-
name: 'validateResult',
|
|
244
|
-
}),
|
|
245
|
-
right: genCallComponentLogic(nameGroup.viewElementMainView, 'validate'),
|
|
246
|
-
}),
|
|
247
236
|
NaslLogicItem.IfStatement({
|
|
248
237
|
test: NaslLogicItem.MemberExpression({
|
|
249
|
-
object:
|
|
250
|
-
name: 'validateResult',
|
|
251
|
-
}),
|
|
238
|
+
object: genCallComponentLogic(nameGroup.viewElementMainView, 'validate'),
|
|
252
239
|
property: NaslLogicItem.Identifier({
|
|
253
240
|
name: 'valid',
|
|
254
241
|
}),
|
package/src/templator/utils.ts
CHANGED
|
@@ -217,7 +217,7 @@ export const NaslUITypeAnnotation = {
|
|
|
217
217
|
SliderEvent: genNaslUITypeAnnotation('SliderEvent'),
|
|
218
218
|
DateEvent: genNaslUITypeAnnotation('DateEvent'),
|
|
219
219
|
OperatorItemEvent: genNaslUITypeAnnotation('OperatorItemEvent'),
|
|
220
|
-
|
|
220
|
+
ValidateResult: genNaslUITypeAnnotation('ValidateResult'),
|
|
221
221
|
PaginationEvent: genNaslUITypeAnnotation('PaginationEvent'),
|
|
222
222
|
DurationEvent: genNaslUITypeAnnotation('DurationEvent'),
|
|
223
223
|
TransferEvent: genNaslUITypeAnnotation('TransferEvent'),
|
package/src/translator/types.ts
CHANGED
package/src/translator/utils.ts
CHANGED
|
@@ -255,6 +255,12 @@ export function transfromUnionTypeAnnotation(expTypeAnnotation: TypeAnnotation,
|
|
|
255
255
|
}
|
|
256
256
|
}
|
|
257
257
|
|
|
258
|
+
export function createDescriptionComment<T extends BaseNode>(state: TranslatorState, node: T, properties: Array<keyof T>) {
|
|
259
|
+
const content = properties.map((prop) => node[prop]).filter((value) => !!value).join(' ');
|
|
260
|
+
|
|
261
|
+
return content.trim() ? `/** ${content} */\n${indent(state.tabSize)}` : '';
|
|
262
|
+
}
|
|
263
|
+
|
|
258
264
|
export function createDecoratorCode<T extends BaseNode>(state: TranslatorState, node: T, properties: Array<keyof T>, options?: {
|
|
259
265
|
'@'?: boolean;
|
|
260
266
|
concept?: boolean;
|
package/src/utils/env.ts
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
export const isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
3
3
|
/** Node 环境 */
|
|
4
4
|
export const isNode = process.env.BUILD_TARGET === 'node' || !globalThis.window;
|
|
5
|
+
/** 本地模式 */
|
|
6
|
+
export const isLocalMode = isBrowser && location.hostname.includes('localhost');
|
|
7
|
+
/** 调试模式 */
|
|
8
|
+
export const isDebugMode = isBrowser && (/[?&]debug=true/.test(location.search) || isLocalMode);
|
|
5
9
|
/** 是否是浏览器测试环境 */
|
|
6
|
-
export const isTestBrowser = isBrowser && (
|
|
7
|
-
/codewave-(test|dev)\.163yun\.com$/.test(location.hostname) ||
|
|
8
|
-
location.hostname.includes('localhost')
|
|
9
|
-
);
|
|
10
|
+
export const isTestBrowser = isBrowser && (/codewave-(test|dev)\.163yun\.com$/.test(location.hostname) || isLocalMode);
|
package/src/utils/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { compare } from 'compare-versions';
|
|
2
|
-
import { BaseNode, LogicItem, AnonymousFunction, Param } from '..';
|
|
2
|
+
import { BaseNode, LogicItem, AnonymousFunction, Param, SubLogic } from '..';
|
|
3
3
|
import type { ForEachStatement, Logic, TypeAnnotation, View, ViewElement } from '..';
|
|
4
4
|
import * as types from '../concepts/utils/types';
|
|
5
5
|
import { getConceptPropertyMap } from '../decorators/index';
|
|
@@ -16,6 +16,8 @@ export * from './env';
|
|
|
16
16
|
export * from './file';
|
|
17
17
|
export * from './time-slicing';
|
|
18
18
|
|
|
19
|
+
export * as LsCache from './language-cache';
|
|
20
|
+
|
|
19
21
|
// 查找最近的模块
|
|
20
22
|
export function findClosestModule(node: BaseNode) {
|
|
21
23
|
let moduleNode = node;
|
|
@@ -298,8 +300,10 @@ export function getAncestorExistingParamNames(baseNode: types.SyntaxNode) {
|
|
|
298
300
|
names.add((node as ForEachStatement).item?.name);
|
|
299
301
|
names.add((node as ForEachStatement).index?.name);
|
|
300
302
|
break;
|
|
303
|
+
case 'Interface':
|
|
301
304
|
case 'Logic':
|
|
302
305
|
case 'View':
|
|
306
|
+
case 'SubLogic':
|
|
303
307
|
const varList = [
|
|
304
308
|
...((node as Logic | View).params || []),
|
|
305
309
|
];
|
|
@@ -312,6 +316,30 @@ export function getAncestorExistingParamNames(baseNode: types.SyntaxNode) {
|
|
|
312
316
|
return names;
|
|
313
317
|
}
|
|
314
318
|
|
|
319
|
+
/**
|
|
320
|
+
* 父链上存在的返回值名字
|
|
321
|
+
* @returns
|
|
322
|
+
*/
|
|
323
|
+
export function getAncestorExistingReturnNames(baseNode: types.SyntaxNode) {
|
|
324
|
+
let node: BaseNode = baseNode;
|
|
325
|
+
const names: Set<string> = new Set();
|
|
326
|
+
while (node) {
|
|
327
|
+
node = node.parentNode;
|
|
328
|
+
switch (node?.concept) {
|
|
329
|
+
case 'Logic':
|
|
330
|
+
case 'SubLogic':
|
|
331
|
+
const varList = [
|
|
332
|
+
...((node as Logic | SubLogic).returns || []),
|
|
333
|
+
];
|
|
334
|
+
varList?.forEach((variable) => {
|
|
335
|
+
names.add(variable?.name);
|
|
336
|
+
});
|
|
337
|
+
break;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
return names;
|
|
341
|
+
}
|
|
342
|
+
|
|
315
343
|
|
|
316
344
|
/**
|
|
317
345
|
* 父链上存在的变量名字
|
|
@@ -510,3 +538,24 @@ export function getDescription(title: string, description: string) {
|
|
|
510
538
|
}
|
|
511
539
|
return desc;
|
|
512
540
|
}
|
|
541
|
+
|
|
542
|
+
/**
|
|
543
|
+
* 将url转换为正则的
|
|
544
|
+
* @param url
|
|
545
|
+
* @returns
|
|
546
|
+
*/
|
|
547
|
+
export function transAssetsToRegx(assets: any[], key: string) {
|
|
548
|
+
return new RegExp(assets.map((asset) => {
|
|
549
|
+
return `(https?:)?` + asset[key]?.replace(/^(?:https?:)?/i, '')?.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
|
550
|
+
}).join('|'), 'g');
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
/**
|
|
554
|
+
* 获取Asset
|
|
555
|
+
* @param assetsMap
|
|
556
|
+
* @param url
|
|
557
|
+
* @returns
|
|
558
|
+
*/
|
|
559
|
+
export function getAssetFromAssetsMap(assetsMap: Map<string, any>, url: string) {
|
|
560
|
+
return assetsMap?.get(url) || assetsMap?.get(`http:${url}`) || assetsMap?.get(`https:${url}`);
|
|
561
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { isBrowser } from '../env';
|
|
2
|
+
|
|
3
|
+
/** 数据库名称 */
|
|
4
|
+
export const DbName = 'language-cache';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 缓存时长
|
|
8
|
+
*
|
|
9
|
+
* @description 3 天时间
|
|
10
|
+
*/
|
|
11
|
+
export const NaslCacheLimit = 3 * 24 * 60 * 60 * 1000;
|
|
12
|
+
|
|
13
|
+
/** 数据库储存表 */
|
|
14
|
+
export enum StoreName {
|
|
15
|
+
Nasl = 'Nasl',
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* 标签页 ID
|
|
20
|
+
*
|
|
21
|
+
* @description 应用初始化时通过 sessionStorage 获取,Tab 页刷新时不会变化,tab 页关闭后消失
|
|
22
|
+
*/
|
|
23
|
+
export const tabId = (() => {
|
|
24
|
+
if (!isBrowser) {
|
|
25
|
+
return 0;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const tabId = sessionStorage.getItem('tabId');
|
|
29
|
+
|
|
30
|
+
if (tabId) {
|
|
31
|
+
return Number(tabId);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const newId = Date.now();
|
|
35
|
+
sessionStorage.setItem('tabId', String(newId));
|
|
36
|
+
return newId;
|
|
37
|
+
})();
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { isNode } from '../env';
|
|
2
|
+
import { StoreName, DbName, NaslCacheLimit, tabId } from './constant';
|
|
3
|
+
import { LanguageDatabase, NaslCacheData, NaslCacheUpdateData } from './types';
|
|
4
|
+
|
|
5
|
+
/** 缓存数据库 */
|
|
6
|
+
const database = isNode
|
|
7
|
+
? undefined
|
|
8
|
+
: import('idb').then((idb) => idb.openDB<LanguageDatabase>(DbName, 1, {
|
|
9
|
+
upgrade(db) {
|
|
10
|
+
db.createObjectStore(StoreName.Nasl);
|
|
11
|
+
},
|
|
12
|
+
blocked(currentVersion, blockedVersion, event) {
|
|
13
|
+
// TODO: 超出容量限制
|
|
14
|
+
},
|
|
15
|
+
}));
|
|
16
|
+
|
|
17
|
+
export async function canUseNaslCache(appId: string, globalChangedTime: number) {
|
|
18
|
+
const data = await getNaslCacheWithoutCheck(appId);
|
|
19
|
+
const now = Date.now();
|
|
20
|
+
|
|
21
|
+
if (!data || data.forceUpdate || ((now - data.createdTime) > NaslCacheLimit)) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// 缓存等于服务端,则表示可以使用缓存
|
|
26
|
+
return data.updatedTime === globalChangedTime;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* 取出缓存
|
|
31
|
+
*
|
|
32
|
+
* @description 只是取出缓存,并不校验缓存的有效性
|
|
33
|
+
*/
|
|
34
|
+
export async function getNaslCacheWithoutCheck(appId: string) {
|
|
35
|
+
if (isNode) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const db = await database;
|
|
40
|
+
const data = await db.get(StoreName.Nasl, appId);
|
|
41
|
+
return data;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export async function clearCache(appId: string) {
|
|
45
|
+
if (isNode) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const db = await database;
|
|
50
|
+
await db.delete(StoreName.Nasl, appId);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export async function updateNaslCache(appId: string, data: NaslCacheUpdateData) {
|
|
54
|
+
if (isNode) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const db = await database;
|
|
59
|
+
const cache = await db.get(StoreName.Nasl, appId);
|
|
60
|
+
|
|
61
|
+
// 数据库中数据为新的,不更新缓存
|
|
62
|
+
if (cache && (data.globalChangedTime <= cache.updatedTime)) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const newData: NaslCacheData = {
|
|
67
|
+
id: appId,
|
|
68
|
+
tabId: tabId,
|
|
69
|
+
data: data.getData(),
|
|
70
|
+
updatedTime: data.globalChangedTime,
|
|
71
|
+
forceUpdate: cache
|
|
72
|
+
? (
|
|
73
|
+
cache.forceUpdate ||
|
|
74
|
+
data.preGlobalChangedTime !== cache.updatedTime ||
|
|
75
|
+
tabId !== cache.tabId
|
|
76
|
+
)
|
|
77
|
+
: false,
|
|
78
|
+
createdTime: cache?.createdTime ?? Date.now(),
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
// await db.delete(StoreName.Nasl, appId);
|
|
82
|
+
await db.put(StoreName.Nasl, newData, appId);
|
|
83
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { DBSchema } from 'idb';
|
|
2
|
+
import { StoreName } from './constant';
|
|
3
|
+
|
|
4
|
+
export type NaslData = object;
|
|
5
|
+
|
|
6
|
+
export interface NaslCacheData {
|
|
7
|
+
/** 应用编号 appId */
|
|
8
|
+
id: string;
|
|
9
|
+
/** 开始缓存的时间 */
|
|
10
|
+
createdTime: number;
|
|
11
|
+
/**
|
|
12
|
+
* 变更时间
|
|
13
|
+
*
|
|
14
|
+
* @description 后端为空时,默认为当前时间
|
|
15
|
+
*/
|
|
16
|
+
updatedTime: number;
|
|
17
|
+
/**
|
|
18
|
+
* 强制弃用缓存标志位
|
|
19
|
+
*
|
|
20
|
+
* 在某些特殊情况下,比如 A、B 两个人,A 先改了页面 PageA,然后 B 改了页面 PageB,再然后 A 又修改了页面 PageA。
|
|
21
|
+
* 此时 A 的电脑上标志位是最新的,所以他刷新页面是会走缓存,而不会走后端。
|
|
22
|
+
* 此时两个后端的 Nasl 已经不同,但是因为两个人改的是不同的页面,所以继续走缓存也没关系。
|
|
23
|
+
* 当 A 进入 B 页面的时候,后端会判定产生互锁,让 A 强制刷新页面,此时 A 的标志位是最新的,所以 A 即便刷新页面也会走缓存,
|
|
24
|
+
* 所以这里就需要另外的标志位来让 A 强制不走缓存。
|
|
25
|
+
*/
|
|
26
|
+
forceUpdate: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* 当前标签页编号
|
|
29
|
+
*/
|
|
30
|
+
tabId: number;
|
|
31
|
+
/** 应用 Nasl 数据 */
|
|
32
|
+
data: NaslData;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface NaslCacheUpdateData {
|
|
36
|
+
preGlobalChangedTime: number;
|
|
37
|
+
globalChangedTime: number;
|
|
38
|
+
getData: () => NaslData;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface LanguageDatabase extends DBSchema {
|
|
42
|
+
/** Nasl 缓存数据库 */
|
|
43
|
+
[StoreName.Nasl]: {
|
|
44
|
+
/** AppId 为键名 */
|
|
45
|
+
key: string;
|
|
46
|
+
value: NaslCacheData;
|
|
47
|
+
};
|
|
48
|
+
}
|
package/src/utils/types.ts
CHANGED
|
@@ -15,3 +15,23 @@ export interface FileNode extends BaseNode {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export type EmbeddedTSFileGenerator = Generator<void, EmbeddedTSFileResult, string>;
|
|
18
|
+
|
|
19
|
+
export interface FullResponse<D> {
|
|
20
|
+
headers: Record<string, string>;
|
|
21
|
+
data: {
|
|
22
|
+
code: number;
|
|
23
|
+
msg: string;
|
|
24
|
+
success: boolean;
|
|
25
|
+
result: D[];
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface BreakpointStatus {
|
|
30
|
+
path: string;
|
|
31
|
+
breakpointStatus: null | 'ENABLED' | 'DISABLED'
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface BatchInstructResult {
|
|
35
|
+
globalChangedTime: number;
|
|
36
|
+
preGlobalChangedTime: number;
|
|
37
|
+
}
|