@lcap/nasl 1.0.2 → 2.12.0
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/index.d.ts +1 -0
- package/out/automate/engine/index.js +34 -12
- package/out/automate/engine/index.js.map +1 -1
- package/out/automate/engine/operators.d.ts +10 -2
- package/out/automate/engine/operators.js +105 -7
- package/out/automate/engine/operators.js.map +1 -1
- package/out/automate/engine/uniqueName.d.ts +8 -2
- package/out/automate/engine/uniqueName.js +72 -4
- package/out/automate/engine/uniqueName.js.map +1 -1
- package/out/automate/engine/utils.d.ts +1 -0
- package/out/automate/engine/utils.js +92 -67
- package/out/automate/engine/utils.js.map +1 -1
- package/out/automate/template/process.d.ts +9 -0
- package/out/automate/template/process.js +10976 -0
- package/out/automate/template/process.js.map +1 -0
- package/out/bak/translator.js +1 -0
- package/out/bak/translator.js.map +1 -1
- package/out/common/BaseNode.d.ts +5 -0
- package/out/common/BaseNode.js +24 -3
- package/out/common/BaseNode.js.map +1 -1
- package/out/concepts/App__.d.ts +51 -49
- package/out/concepts/App__.js +86 -53
- package/out/concepts/App__.js.map +1 -1
- package/out/concepts/BindAttribute__.js +2 -2
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindDirective__.js +10 -3
- package/out/concepts/BindDirective__.js.map +1 -1
- package/out/concepts/BindEvent__.js +15 -6
- package/out/concepts/BindEvent__.js.map +1 -1
- package/out/concepts/BooleanLiteral__.d.ts +4 -0
- package/out/concepts/BooleanLiteral__.js +11 -0
- package/out/concepts/BooleanLiteral__.js.map +1 -1
- package/out/concepts/CallFunction__.js +8 -2
- package/out/concepts/CallFunction__.js.map +1 -1
- package/out/concepts/CallLogic__.js +48 -30
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/CallQueryComponent__.d.ts +8 -7
- package/out/concepts/CallQueryComponent__.js +86 -76
- package/out/concepts/CallQueryComponent__.js.map +1 -1
- package/out/concepts/Comment__.js +1 -1
- package/out/concepts/Comment__.js.map +1 -1
- package/out/concepts/ConfigGroup__.d.ts +1 -0
- package/out/concepts/ConfigGroup__.js +7 -0
- package/out/concepts/ConfigGroup__.js.map +1 -1
- package/out/concepts/ConfigProperty__.d.ts +1 -0
- package/out/concepts/ConfigProperty__.js +3 -0
- package/out/concepts/ConfigProperty__.js.map +1 -1
- package/out/concepts/Configuration__.d.ts +1 -0
- package/out/concepts/Configuration__.js +3 -0
- package/out/concepts/Configuration__.js.map +1 -1
- package/out/concepts/DataSource__.d.ts +143 -0
- package/out/concepts/DataSource__.js +318 -0
- package/out/concepts/DataSource__.js.map +1 -0
- package/out/concepts/Destination__.js +8 -8
- package/out/concepts/Destination__.js.map +1 -1
- package/out/concepts/End__.js +2 -2
- package/out/concepts/End__.js.map +1 -1
- package/out/concepts/EntityIndex__.d.ts +5 -0
- package/out/concepts/EntityIndex__.js +6 -0
- package/out/concepts/EntityIndex__.js.map +1 -1
- package/out/concepts/EntityProperty__.d.ts +9 -0
- package/out/concepts/EntityProperty__.js +19 -2
- package/out/concepts/EntityProperty__.js.map +1 -1
- package/out/concepts/Entity__.d.ts +5 -0
- package/out/concepts/Entity__.js +20 -10
- package/out/concepts/Entity__.js.map +1 -1
- package/out/concepts/Enum__.js +12 -6
- package/out/concepts/Enum__.js.map +1 -1
- package/out/concepts/ForEachStatement__.js +2 -2
- package/out/concepts/ForEachStatement__.js.map +1 -1
- package/out/concepts/Function__.d.ts +18 -0
- package/out/concepts/Function__.js +96 -1
- package/out/concepts/Function__.js.map +1 -1
- package/out/concepts/Identifier__.js +6 -15
- package/out/concepts/Identifier__.js.map +1 -1
- package/out/concepts/IfStatement__.js +8 -8
- package/out/concepts/IfStatement__.js.map +1 -1
- package/out/concepts/Interface__.js +19 -12
- package/out/concepts/Interface__.js.map +1 -1
- package/out/concepts/JSBlock__.js +3 -5
- package/out/concepts/JSBlock__.js.map +1 -1
- package/out/concepts/Logic__.js +44 -44
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/Module__.d.ts +116 -194
- package/out/concepts/Module__.js +31 -114
- package/out/concepts/Module__.js.map +1 -1
- package/out/concepts/Namespace__.d.ts +0 -86
- package/out/concepts/Namespace__.js +1 -108
- package/out/concepts/Namespace__.js.map +1 -1
- package/out/concepts/Param__.d.ts +2 -1
- package/out/concepts/Param__.js +1 -1
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/ProcessElement__.js +30 -10
- package/out/concepts/ProcessElement__.js.map +1 -1
- package/out/concepts/Process__.d.ts +1 -1
- package/out/concepts/Process__.js +17 -10
- package/out/concepts/Process__.js.map +1 -1
- package/out/concepts/QueryFieldExpression__.js +8 -1
- package/out/concepts/QueryFieldExpression__.js.map +1 -1
- package/out/concepts/QueryFromExpression__.d.ts +4 -0
- package/out/concepts/QueryFromExpression__.js +13 -2
- package/out/concepts/QueryFromExpression__.js.map +1 -1
- package/out/concepts/QueryJoinExpression__.d.ts +4 -0
- package/out/concepts/QueryJoinExpression__.js +14 -3
- package/out/concepts/QueryJoinExpression__.js.map +1 -1
- package/out/concepts/Return__.js +1 -1
- package/out/concepts/Return__.js.map +1 -1
- package/out/concepts/Role__.js +10 -3
- package/out/concepts/Role__.js.map +1 -1
- package/out/concepts/SqlQueryComponent__.d.ts +14 -0
- package/out/concepts/SqlQueryComponent__.js +48 -5
- package/out/concepts/SqlQueryComponent__.js.map +1 -1
- package/out/concepts/StringLiteral__.d.ts +1 -1
- package/out/concepts/StringLiteral__.js +1 -1
- package/out/concepts/StructureProperty__.js +6 -5
- package/out/concepts/StructureProperty__.js.map +1 -1
- package/out/concepts/Structure__.js +19 -12
- package/out/concepts/Structure__.js.map +1 -1
- package/out/concepts/SwitchCase__.d.ts +1 -1
- package/out/concepts/SwitchCase__.js +23 -25
- package/out/concepts/SwitchCase__.js.map +1 -1
- package/out/concepts/SwitchStatement__.js +1 -6
- package/out/concepts/SwitchStatement__.js.map +1 -1
- package/out/concepts/TypeAnnotation__.d.ts +8 -0
- package/out/concepts/TypeAnnotation__.js +44 -2
- package/out/concepts/TypeAnnotation__.js.map +1 -1
- package/out/concepts/Variable__.js +1 -1
- package/out/concepts/Variable__.js.map +1 -1
- package/out/concepts/ViewElement__.js +25 -20
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.d.ts +0 -2
- package/out/concepts/View__.js +27 -32
- package/out/concepts/View__.js.map +1 -1
- package/out/concepts/WhileStatement__.js +4 -4
- package/out/concepts/WhileStatement__.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.auth.js +20 -0
- package/out/concepts/basics/stdlib/nasl.auth.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.process.d.ts +4 -0
- package/out/concepts/basics/stdlib/nasl.process.js +410 -0
- package/out/concepts/basics/stdlib/nasl.process.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.ui.js +1 -11
- package/out/concepts/basics/stdlib/nasl.ui.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.util.js +280 -2
- package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
- package/out/concepts/basics/types/index.d.ts +1 -0
- package/out/concepts/basics/types/index.js +4 -1
- package/out/concepts/basics/types/index.js.map +1 -1
- package/out/concepts/index__.d.ts +1 -0
- package/out/concepts/index__.js +1 -0
- package/out/concepts/index__.js.map +1 -1
- package/out/generator/genBundleFiles.d.ts +3 -1
- package/out/generator/genBundleFiles.js +23 -5
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/generator/genMetaData.d.ts +1 -0
- package/out/generator/genMetaData.js +20 -12
- package/out/generator/genMetaData.js.map +1 -1
- package/out/index.d.ts +1 -1
- package/out/index.js +2 -1
- package/out/index.js.map +1 -1
- package/out/server/createUiTs.js +1 -0
- package/out/server/createUiTs.js.map +1 -1
- package/out/server/getLogics.js +27 -1
- package/out/server/getLogics.js.map +1 -1
- package/out/server/getMemberIdentifier.js +5 -0
- package/out/server/getMemberIdentifier.js.map +1 -1
- package/out/server/getProcesses.d.ts +4 -0
- package/out/server/getProcesses.js +69 -1
- package/out/server/getProcesses.js.map +1 -1
- package/out/server/naslServer.d.ts +1 -0
- package/out/server/naslServer.js +223 -26
- package/out/server/naslServer.js.map +1 -1
- package/out/server/process2LogicNamespace.js +10 -1
- package/out/server/process2LogicNamespace.js.map +1 -1
- package/out/server/translator.js +37 -1
- package/out/server/translator.js.map +1 -1
- package/out/service/creator/errHandles.js +5 -0
- package/out/service/creator/errHandles.js.map +1 -1
- package/out/service/storage/init.d.ts +1 -0
- package/out/service/storage/init.js +95 -84
- package/out/service/storage/init.js.map +1 -1
- package/out/templator/genCreateBlock.js +34 -24
- package/out/templator/genCreateBlock.js.map +1 -1
- package/out/templator/genCurdEditMultipleKeyBlock.js +28 -18
- package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
- package/out/templator/genCurdMultipleKeyBlock.js +45 -29
- package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
- package/out/templator/genEditTableBlock.js +15 -13
- package/out/templator/genEditTableBlock.js.map +1 -1
- package/out/templator/genEnumSelectBlock.js +1 -1
- package/out/templator/genEnumSelectBlock.js.map +1 -1
- package/out/templator/genGridViewBlock.js +29 -24
- package/out/templator/genGridViewBlock.js.map +1 -1
- package/out/templator/genListViewBlock.js +7 -5
- package/out/templator/genListViewBlock.js.map +1 -1
- package/out/templator/genQueryComponent.js +25 -26
- package/out/templator/genQueryComponent.js.map +1 -1
- package/out/templator/genSelectBlock.js +8 -7
- package/out/templator/genSelectBlock.js.map +1 -1
- package/out/templator/genTableBlock.js +31 -21
- package/out/templator/genTableBlock.js.map +1 -1
- package/out/templator/genUpdateBlock.js +34 -24
- package/out/templator/genUpdateBlock.js.map +1 -1
- package/out/templator/utils.d.ts +2 -2
- package/out/templator/utils.js.map +1 -1
- package/out/test/integration/connect-file.js +6 -6
- package/out/test/integration/connect-file.js.map +1 -1
- package/out/translator/index.js +1 -1
- package/out/translator/index.js.map +1 -1
- package/out/utils/index.d.ts +5 -0
- package/out/utils/index.js +50 -1
- package/out/utils/index.js.map +1 -1
- package/package.json +1 -1
- package/src/automate/engine/index.js +33 -8
- package/src/automate/engine/operators.js +114 -17
- package/src/automate/engine/uniqueName.js +77 -9
- package/src/automate/engine/utils.js +95 -68
- package/src/automate/template/process.js +10999 -0
- package/src/bak/translator.js +1 -0
- package/src/common/BaseNode.ts +21 -4
- package/src/concepts/App__.ts +128 -94
- package/src/concepts/BindAttribute__.ts +2 -2
- package/src/concepts/BindDirective__.ts +9 -7
- package/src/concepts/BindEvent__.ts +14 -6
- package/src/concepts/BooleanLiteral__.ts +12 -0
- package/src/concepts/CallFunction__.ts +6 -2
- package/src/concepts/CallLogic__.ts +47 -32
- package/src/concepts/CallQueryComponent__.ts +92 -81
- package/src/concepts/Comment__.ts +1 -1
- package/src/concepts/ConfigGroup__.ts +3 -1
- package/src/concepts/ConfigProperty__.ts +4 -0
- package/src/concepts/Configuration__.ts +3 -0
- package/src/concepts/DataSource__.ts +391 -0
- package/src/concepts/Destination__.ts +24 -8
- package/src/concepts/End__.ts +2 -2
- package/src/concepts/EntityIndex__.ts +7 -0
- package/src/concepts/EntityProperty__.ts +20 -2
- package/src/concepts/Entity__.ts +23 -11
- package/src/concepts/Enum__.ts +25 -6
- package/src/concepts/ForEachStatement__.ts +2 -2
- package/src/concepts/Function__.ts +95 -1
- package/src/concepts/Identifier__.ts +15 -15
- package/src/concepts/IfStatement__.ts +9 -9
- package/src/concepts/Interface__.ts +20 -12
- package/src/concepts/JSBlock__.ts +3 -12
- package/src/concepts/Logic__.ts +45 -79
- package/src/concepts/Module__.ts +141 -342
- package/src/concepts/Namespace__.ts +1 -204
- package/src/concepts/Param__.ts +3 -2
- package/src/concepts/ProcessElement__.ts +33 -12
- package/src/concepts/Process__.ts +18 -12
- package/src/concepts/QueryFieldExpression__.ts +9 -1
- package/src/concepts/QueryFromExpression__.ts +13 -2
- package/src/concepts/QueryJoinExpression__.ts +14 -3
- package/src/concepts/Return__.ts +1 -1
- package/src/concepts/Role__.ts +10 -4
- package/src/concepts/SqlQueryComponent__.ts +47 -11
- package/src/concepts/StringLiteral__.ts +1 -1
- package/src/concepts/StructureProperty__.ts +6 -9
- package/src/concepts/Structure__.ts +19 -11
- package/src/concepts/SwitchCase__.ts +23 -27
- package/src/concepts/SwitchStatement__.ts +1 -5
- package/src/concepts/TypeAnnotation__.ts +43 -2
- package/src/concepts/Variable__.ts +1 -1
- package/src/concepts/ViewElement__.ts +26 -39
- package/src/concepts/View__.ts +29 -34
- package/src/concepts/WhileStatement__.ts +4 -4
- package/src/concepts/basics/stdlib/nasl.auth.ts +20 -0
- package/src/concepts/basics/stdlib/nasl.process.ts +406 -0
- package/src/concepts/basics/stdlib/nasl.ui.ts +1 -11
- package/src/concepts/basics/stdlib/nasl.util.ts +281 -2
- package/src/concepts/basics/types/index.ts +1 -0
- package/src/concepts/index__.ts +1 -0
- package/src/generator/genBundleFiles.ts +28 -7
- package/src/generator/genMetaData.ts +22 -13
- package/src/index.ts +1 -1
- package/src/server/createUiTs.ts +1 -0
- package/src/server/getLogics.ts +29 -4
- package/src/server/getMemberIdentifier.ts +4 -0
- package/src/server/getProcesses.ts +68 -0
- package/src/server/naslServer.ts +227 -30
- package/src/server/process2LogicNamespace.ts +29 -19
- package/src/server/translator.ts +39 -1
- package/src/service/creator/errHandles.js +6 -0
- package/src/service/storage/init.ts +97 -86
- package/src/templator/genCreateBlock.ts +35 -26
- package/src/templator/genCurdEditMultipleKeyBlock.ts +29 -21
- package/src/templator/genCurdMultipleKeyBlock.ts +46 -31
- package/src/templator/genEditTableBlock.ts +17 -14
- package/src/templator/genEnumSelectBlock.ts +1 -1
- package/src/templator/genGridViewBlock.ts +30 -25
- package/src/templator/genListViewBlock.ts +10 -7
- package/src/templator/genQueryComponent.ts +28 -27
- package/src/templator/genSelectBlock.ts +9 -8
- package/src/templator/genTableBlock.ts +32 -23
- package/src/templator/genUpdateBlock.ts +35 -25
- package/src/templator/utils.ts +2 -2
- package/src/test/integration/connect-file.ts +6 -6
- package/src/translator/index.ts +1 -1
- package/src/utils/index.ts +51 -0
package/src/bak/translator.js
CHANGED
|
@@ -113,6 +113,7 @@ export default function (definition) {
|
|
|
113
113
|
title: ${JSON.stringify(definition.title)},
|
|
114
114
|
crumb: ${JSON.stringify(definition.crumb)},
|
|
115
115
|
first: ${JSON.stringify(definition.first)},
|
|
116
|
+
auth: ${JSON.stringify(definition.auth)},
|
|
116
117
|
});
|
|
117
118
|
|
|
118
119
|
${events.join('\n\n')}
|
package/src/common/BaseNode.ts
CHANGED
|
@@ -48,6 +48,13 @@ export class BaseNode extends EventEmitter {
|
|
|
48
48
|
*/
|
|
49
49
|
@property()
|
|
50
50
|
branchName: string = undefined;
|
|
51
|
+
/**
|
|
52
|
+
* 合并代码相关
|
|
53
|
+
*/
|
|
54
|
+
@property()
|
|
55
|
+
workingCopy: object = undefined;
|
|
56
|
+
@property()
|
|
57
|
+
branch: object = undefined;
|
|
51
58
|
/**
|
|
52
59
|
* 父节点
|
|
53
60
|
*/
|
|
@@ -159,13 +166,23 @@ export class BaseNode extends EventEmitter {
|
|
|
159
166
|
const property = propertyMap.get(key);
|
|
160
167
|
const sourceItem = (source as any)[key] !== undefined ? (source as any)[key] : (this as any)[key];
|
|
161
168
|
const { objectRef: propertyObjectRef } = property;
|
|
162
|
-
let objectRefCtor;
|
|
169
|
+
let objectRefCtor: any;
|
|
163
170
|
try {
|
|
164
171
|
if (propertyObjectRef) {
|
|
165
172
|
objectRefCtor = getConceptConstructor(propertyObjectRef);
|
|
166
|
-
if (objectRefCtor
|
|
167
|
-
sourceItem
|
|
168
|
-
sourceItem.
|
|
173
|
+
if (objectRefCtor) {
|
|
174
|
+
// if (Array.isArray(sourceItem)) {
|
|
175
|
+
// sourceItem.forEach((item) => {
|
|
176
|
+
// if (item instanceof objectRefCtor) {
|
|
177
|
+
// item.parentNode = this;
|
|
178
|
+
// item.parentKey = key;
|
|
179
|
+
// }
|
|
180
|
+
// });
|
|
181
|
+
// } else
|
|
182
|
+
if (sourceItem instanceof objectRefCtor) {
|
|
183
|
+
sourceItem.parentNode = this;
|
|
184
|
+
sourceItem.parentKey = key;
|
|
185
|
+
}
|
|
169
186
|
}
|
|
170
187
|
}
|
|
171
188
|
|
package/src/concepts/App__.ts
CHANGED
|
@@ -14,7 +14,7 @@ import * as utils from '../utils';
|
|
|
14
14
|
import { v4 as uuidv4 } from 'uuid';
|
|
15
15
|
import BaseNode from '../common/BaseNode';
|
|
16
16
|
import classMap from '../common/classMap';
|
|
17
|
-
import
|
|
17
|
+
import DataSource from './DataSource__';
|
|
18
18
|
import Structure from './Structure__';
|
|
19
19
|
import Enum from './Enum__';
|
|
20
20
|
import Logic from './Logic__';
|
|
@@ -110,10 +110,10 @@ export class App extends BaseNode {
|
|
|
110
110
|
hasAuth: boolean = undefined;
|
|
111
111
|
|
|
112
112
|
/**
|
|
113
|
-
*
|
|
113
|
+
* 数据源列表
|
|
114
114
|
*/
|
|
115
|
-
@property('
|
|
116
|
-
|
|
115
|
+
@property('DataSource')
|
|
116
|
+
dataSources: Array<DataSource> = [];
|
|
117
117
|
|
|
118
118
|
/**
|
|
119
119
|
* 数据结构列表
|
|
@@ -235,143 +235,143 @@ export class App extends BaseNode {
|
|
|
235
235
|
});
|
|
236
236
|
}
|
|
237
237
|
|
|
238
|
-
|
|
238
|
+
getDataSourceExistingNames(excludedList: Array<DataSource> = []) {
|
|
239
239
|
const excludedSet = new Set(excludedList);
|
|
240
|
-
return (this.
|
|
240
|
+
return (this.dataSources || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
|
|
241
241
|
}
|
|
242
|
-
|
|
243
|
-
return utils.unique(name, this.
|
|
242
|
+
getDataSourceUniqueName(name = 'dataSource1') {
|
|
243
|
+
return utils.unique(name, this.getDataSourceExistingNames(), undefined, true);
|
|
244
244
|
}
|
|
245
245
|
|
|
246
246
|
/**
|
|
247
|
-
*
|
|
247
|
+
* 插入数据源
|
|
248
248
|
* @internal
|
|
249
|
-
* @param name
|
|
249
|
+
* @param name 数据源名称,如果不填会自动生成一个唯一名称
|
|
250
250
|
*/
|
|
251
|
-
|
|
251
|
+
_insertDataSourceAt(name: string, index: number): DataSource;
|
|
252
252
|
|
|
253
253
|
/**
|
|
254
|
-
*
|
|
254
|
+
* 插入数据源
|
|
255
255
|
* @internal
|
|
256
|
-
* @param
|
|
256
|
+
* @param dataSourceOptions 数据源参数
|
|
257
257
|
*/
|
|
258
|
-
|
|
258
|
+
_insertDataSourceAt(dataSourceOptions: Partial<DataSource>, index: number): DataSource;
|
|
259
259
|
|
|
260
260
|
/**
|
|
261
|
-
*
|
|
261
|
+
* 插入数据源
|
|
262
262
|
* @internal
|
|
263
|
-
* @param
|
|
263
|
+
* @param dataSource 已有的数据源实例
|
|
264
264
|
*/
|
|
265
|
-
|
|
265
|
+
_insertDataSourceAt(dataSource: DataSource, index: number): DataSource;
|
|
266
266
|
|
|
267
|
-
|
|
268
|
-
const
|
|
269
|
-
const relationOptions = { parentNode: this, parentKey: '
|
|
270
|
-
let
|
|
267
|
+
_insertDataSourceAt(options: string | Partial<DataSource> | DataSource, index: number) {
|
|
268
|
+
const dataSourceOptions: any = {};
|
|
269
|
+
const relationOptions = { parentNode: this, parentKey: 'dataSources' };
|
|
270
|
+
let dataSource: DataSource;
|
|
271
271
|
if (!options) {
|
|
272
|
-
|
|
273
|
-
...
|
|
274
|
-
name: this.
|
|
275
|
-
}, this, '
|
|
272
|
+
dataSource = DataSource.from({
|
|
273
|
+
...dataSourceOptions,
|
|
274
|
+
name: this.getDataSourceUniqueName(),
|
|
275
|
+
}, this, 'dataSources');
|
|
276
276
|
} else if (typeof options === 'string') {
|
|
277
|
-
|
|
278
|
-
...
|
|
277
|
+
dataSource = DataSource.from({
|
|
278
|
+
...dataSourceOptions,
|
|
279
279
|
name: options,
|
|
280
|
-
}, this, '
|
|
281
|
-
} else if (options instanceof
|
|
280
|
+
}, this, 'dataSources');
|
|
281
|
+
} else if (options instanceof DataSource) {
|
|
282
282
|
options.ensureDelete(); // 同一实例不支持多处存在
|
|
283
|
-
|
|
284
|
-
Object.assign(
|
|
283
|
+
dataSource = options;
|
|
284
|
+
Object.assign(dataSource, relationOptions);
|
|
285
285
|
} else {
|
|
286
|
-
|
|
287
|
-
...
|
|
286
|
+
dataSource = DataSource.from({
|
|
287
|
+
...dataSourceOptions,
|
|
288
288
|
...options,
|
|
289
|
-
}, this, '
|
|
289
|
+
}, this, 'dataSources');
|
|
290
290
|
}
|
|
291
|
-
this.
|
|
292
|
-
return
|
|
291
|
+
this.dataSources.splice(index, 0, dataSource);
|
|
292
|
+
return dataSource;
|
|
293
293
|
}
|
|
294
294
|
|
|
295
295
|
/**
|
|
296
|
-
*
|
|
297
|
-
* @param name
|
|
296
|
+
* 插入数据源
|
|
297
|
+
* @param name 数据源名称,如果不填会自动生成一个唯一名称
|
|
298
298
|
*/
|
|
299
|
-
|
|
299
|
+
insertDataSourceAt(name: string, index: number): DataSource;
|
|
300
300
|
|
|
301
301
|
/**
|
|
302
|
-
*
|
|
303
|
-
* @param
|
|
302
|
+
* 插入数据源
|
|
303
|
+
* @param dataSourceOptions 数据源参数
|
|
304
304
|
*/
|
|
305
|
-
|
|
305
|
+
insertDataSourceAt(dataSourceOptions: Partial<DataSource>, index: number): DataSource;
|
|
306
306
|
|
|
307
307
|
/**
|
|
308
|
-
*
|
|
309
|
-
* @param
|
|
308
|
+
* 插入数据源
|
|
309
|
+
* @param dataSource 已有的数据源实例
|
|
310
310
|
*/
|
|
311
|
-
|
|
311
|
+
insertDataSourceAt(dataSource: DataSource, index: number): DataSource;
|
|
312
312
|
|
|
313
|
-
|
|
314
|
-
const node = this.
|
|
313
|
+
insertDataSourceAt(options: string | Partial<DataSource> | DataSource, index: number) {
|
|
314
|
+
const node = this._insertDataSourceAt(options as any, index);
|
|
315
315
|
node.create({
|
|
316
316
|
index,
|
|
317
317
|
parentNode: this,
|
|
318
|
-
parentKey: '
|
|
318
|
+
parentKey: 'dataSources',
|
|
319
319
|
});
|
|
320
320
|
return node;
|
|
321
321
|
}
|
|
322
322
|
|
|
323
323
|
/**
|
|
324
|
-
*
|
|
324
|
+
* 添加数据源
|
|
325
325
|
* @internal
|
|
326
|
-
* @param name
|
|
326
|
+
* @param name 数据源名称,如果不填会自动生成一个唯一名称
|
|
327
327
|
*/
|
|
328
|
-
|
|
328
|
+
_addDataSource(name?: string): DataSource;
|
|
329
329
|
|
|
330
330
|
/**
|
|
331
|
-
*
|
|
331
|
+
* 添加数据源
|
|
332
332
|
* @internal
|
|
333
|
-
* @param
|
|
333
|
+
* @param dataSourceOptions 数据源参数
|
|
334
334
|
*/
|
|
335
|
-
|
|
335
|
+
_addDataSource(dataSourceOptions: Partial<DataSource>): DataSource;
|
|
336
336
|
|
|
337
337
|
/**
|
|
338
|
-
*
|
|
338
|
+
* 添加数据源
|
|
339
339
|
* @internal
|
|
340
|
-
* @param
|
|
340
|
+
* @param dataSource 已有的数据源实例
|
|
341
341
|
*/
|
|
342
|
-
|
|
342
|
+
_addDataSource(dataSource: DataSource): DataSource;
|
|
343
343
|
|
|
344
|
-
|
|
345
|
-
const index =
|
|
346
|
-
return this.
|
|
344
|
+
_addDataSource(options?: string | Partial<DataSource> | DataSource) {
|
|
345
|
+
const index = this.dataSources.length;
|
|
346
|
+
return this._insertDataSourceAt(options as any, index);
|
|
347
347
|
}
|
|
348
348
|
|
|
349
349
|
/**
|
|
350
|
-
*
|
|
350
|
+
* 添加数据源
|
|
351
351
|
* @internal
|
|
352
|
-
* @param name
|
|
352
|
+
* @param name 数据源名称,如果不填会自动生成一个唯一名称
|
|
353
353
|
*/
|
|
354
|
-
|
|
354
|
+
addDataSource(name?: string): DataSource;
|
|
355
355
|
|
|
356
356
|
/**
|
|
357
|
-
*
|
|
358
|
-
* @param
|
|
357
|
+
* 添加数据源
|
|
358
|
+
* @param dataSourceOptions 数据源参数
|
|
359
359
|
*/
|
|
360
|
-
|
|
360
|
+
addDataSource(dataSourceOptions: Partial<DataSource>): DataSource;
|
|
361
361
|
|
|
362
362
|
/**
|
|
363
|
-
*
|
|
364
|
-
* @param
|
|
363
|
+
* 添加数据源
|
|
364
|
+
* @param dataSource 已有的数据源实例
|
|
365
365
|
*/
|
|
366
|
-
|
|
366
|
+
addDataSource(dataSource: DataSource): DataSource;
|
|
367
367
|
|
|
368
|
-
|
|
369
|
-
const node = this.
|
|
370
|
-
const index = this.
|
|
368
|
+
addDataSource(options?: string | Partial<DataSource> | DataSource) {
|
|
369
|
+
const node = this._addDataSource(options as any);
|
|
370
|
+
const index = this.dataSources.indexOf(node);
|
|
371
371
|
node.create({
|
|
372
372
|
index,
|
|
373
373
|
parentNode: this,
|
|
374
|
-
parentKey: '
|
|
374
|
+
parentKey: 'dataSources',
|
|
375
375
|
});
|
|
376
376
|
return node;
|
|
377
377
|
}
|
|
@@ -1771,46 +1771,46 @@ export class App extends BaseNode {
|
|
|
1771
1771
|
}
|
|
1772
1772
|
|
|
1773
1773
|
/**
|
|
1774
|
-
*
|
|
1775
|
-
* @param name
|
|
1774
|
+
* 删除数据源
|
|
1775
|
+
* @param name 数据源名称
|
|
1776
1776
|
*/
|
|
1777
|
-
|
|
1777
|
+
removeDataSource(name: string): void;
|
|
1778
1778
|
|
|
1779
1779
|
/**
|
|
1780
|
-
*
|
|
1781
|
-
* @param
|
|
1780
|
+
* 删除数据源
|
|
1781
|
+
* @param dataSource 已有的数据源实例
|
|
1782
1782
|
*/
|
|
1783
|
-
|
|
1783
|
+
removeDataSource(dataSource: DataSource): void;
|
|
1784
1784
|
|
|
1785
|
-
|
|
1786
|
-
let
|
|
1785
|
+
removeDataSource(options: string | DataSource) {
|
|
1786
|
+
let dataSource: DataSource;
|
|
1787
1787
|
if (typeof options === 'string') {
|
|
1788
|
-
|
|
1789
|
-
if (!
|
|
1790
|
-
throw new Error('
|
|
1788
|
+
dataSource = this.dataSources.find((item) => item.name === options);
|
|
1789
|
+
if (!dataSource) {
|
|
1790
|
+
throw new Error('找不到数据源 ' + options);
|
|
1791
1791
|
}
|
|
1792
1792
|
} else {
|
|
1793
|
-
|
|
1793
|
+
dataSource = options;
|
|
1794
1794
|
}
|
|
1795
|
-
return
|
|
1795
|
+
return dataSource.delete();
|
|
1796
1796
|
}
|
|
1797
1797
|
|
|
1798
|
-
|
|
1799
|
-
const parentKey =
|
|
1798
|
+
__removeDataSource(dataSource: DataSource) {
|
|
1799
|
+
const parentKey = dataSource.parentKey;
|
|
1800
1800
|
const params: Params = {
|
|
1801
1801
|
parentNode: this,
|
|
1802
1802
|
parentKey,
|
|
1803
1803
|
index: -1,
|
|
1804
1804
|
object: null,
|
|
1805
|
-
oldObject:
|
|
1805
|
+
oldObject: dataSource,
|
|
1806
1806
|
};
|
|
1807
1807
|
if (parentKey) {
|
|
1808
1808
|
params.parentKey = parentKey;
|
|
1809
1809
|
if (Array.isArray((this as any)[parentKey])) {
|
|
1810
|
-
const index = (this as any)[parentKey].indexOf(
|
|
1810
|
+
const index = (this as any)[parentKey].indexOf(dataSource);
|
|
1811
1811
|
~index && (this as any)[parentKey].splice(index, 1);
|
|
1812
1812
|
params.index = index;
|
|
1813
|
-
} else if ((this as any)[parentKey] ===
|
|
1813
|
+
} else if ((this as any)[parentKey] === dataSource) {
|
|
1814
1814
|
params.index = 0;
|
|
1815
1815
|
(this as any)[parentKey] = undefined;
|
|
1816
1816
|
}
|
|
@@ -2356,8 +2356,12 @@ export class App extends BaseNode {
|
|
|
2356
2356
|
return this.componentDependencies.find((componentDependency) => componentDependency.name === name);
|
|
2357
2357
|
}
|
|
2358
2358
|
|
|
2359
|
-
|
|
2360
|
-
return this.
|
|
2359
|
+
findDataSourceByName(name: string) {
|
|
2360
|
+
return this.dataSources.find((dataSourceItem) => dataSourceItem.name === name);
|
|
2361
|
+
}
|
|
2362
|
+
|
|
2363
|
+
get defaultDS() {
|
|
2364
|
+
return this.dataSources?.find((dataSource) => dataSource.name === 'defaultDS');
|
|
2361
2365
|
}
|
|
2362
2366
|
|
|
2363
2367
|
findEnumByName(name: string) {
|
|
@@ -2430,7 +2434,7 @@ export class App extends BaseNode {
|
|
|
2430
2434
|
* 获取命名空间
|
|
2431
2435
|
*/
|
|
2432
2436
|
getNamespace() {
|
|
2433
|
-
return
|
|
2437
|
+
return 'app';
|
|
2434
2438
|
}
|
|
2435
2439
|
|
|
2436
2440
|
getTsNamespace() {
|
|
@@ -2461,6 +2465,36 @@ export class App extends BaseNode {
|
|
|
2461
2465
|
return node;
|
|
2462
2466
|
}
|
|
2463
2467
|
|
|
2468
|
+
findNodeByCompleteName(completeName: string) {
|
|
2469
|
+
const nameArr = completeName?.split('.') || [];
|
|
2470
|
+
const start = nameArr.shift();
|
|
2471
|
+
let node: any = this;
|
|
2472
|
+
const mod = 0;
|
|
2473
|
+
const modulesMap: any = {
|
|
2474
|
+
extensions: node.dependencies,
|
|
2475
|
+
apis: node.interfaceDependencies,
|
|
2476
|
+
components: node.componentDependencies,
|
|
2477
|
+
};
|
|
2478
|
+
const modules = modulesMap[start];
|
|
2479
|
+
if (Array.isArray(modules)) {
|
|
2480
|
+
const moduleName = nameArr.shift();
|
|
2481
|
+
node = modules.find((moduleItem) => moduleItem.name === moduleName);
|
|
2482
|
+
}
|
|
2483
|
+
for (let index = 0; index < nameArr.length; index++) {
|
|
2484
|
+
if (!node) {
|
|
2485
|
+
return null;
|
|
2486
|
+
}
|
|
2487
|
+
const nameItem = nameArr[index];
|
|
2488
|
+
const isKeyword = index % 2 === mod;
|
|
2489
|
+
if (!isKeyword && Array.isArray(node)) {
|
|
2490
|
+
node = node.find(({ name }) => name === nameItem);
|
|
2491
|
+
} else {
|
|
2492
|
+
node = node[nameItem];
|
|
2493
|
+
}
|
|
2494
|
+
}
|
|
2495
|
+
return node;
|
|
2496
|
+
}
|
|
2497
|
+
|
|
2464
2498
|
/**
|
|
2465
2499
|
* @param path 路径
|
|
2466
2500
|
* path 为要查找路径:如 /dashboard/student/list、/dashboard/student/list
|
|
@@ -548,9 +548,9 @@ export class BindAttribute extends BaseNode {
|
|
|
548
548
|
toEmbeddedTS(state?: TranslatorState): string {
|
|
549
549
|
let code = '';
|
|
550
550
|
if (this.name === 'destination') {
|
|
551
|
-
code += this.destination.toEmbeddedTS(shiftState(state, code, { tabSize: state
|
|
551
|
+
code += this.destination.toEmbeddedTS(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
|
|
552
552
|
} else if (this.expression) {
|
|
553
|
-
code += this.expression.toEmbeddedTS(shiftState(state, code, { tabSize: state
|
|
553
|
+
code += this.expression.toEmbeddedTS(shiftState(state, code, { tabSize: (state?.tabSize || 0) + 1 }));
|
|
554
554
|
}
|
|
555
555
|
return code;
|
|
556
556
|
}
|
|
@@ -133,10 +133,6 @@ export class BindDirective extends BaseNode {
|
|
|
133
133
|
});
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
136
|
/**
|
|
141
137
|
* 删除逻辑项
|
|
142
138
|
* @param name 逻辑项名称
|
|
@@ -208,8 +204,14 @@ export class BindDirective extends BaseNode {
|
|
|
208
204
|
*/
|
|
209
205
|
toVue(options?: ElementToVueOptions) {
|
|
210
206
|
let modifiersString = '';
|
|
211
|
-
|
|
212
|
-
|
|
207
|
+
let modifiers = {};
|
|
208
|
+
try {
|
|
209
|
+
modifiers = JSON.parse(this.modifiers || '{}');
|
|
210
|
+
} catch (err) {
|
|
211
|
+
modifiers = {};
|
|
212
|
+
}
|
|
213
|
+
Object.keys(modifiers).forEach((key) => {
|
|
214
|
+
const value = (modifiers as any)[key];
|
|
213
215
|
if (value)
|
|
214
216
|
modifiersString += '.' + key;
|
|
215
217
|
});
|
|
@@ -253,7 +255,7 @@ export class BindDirective extends BaseNode {
|
|
|
253
255
|
//================================================================================
|
|
254
256
|
}
|
|
255
257
|
|
|
256
|
-
classMap
|
|
258
|
+
classMap.BindDirective = BindDirective;
|
|
257
259
|
export default BindDirective;
|
|
258
260
|
//================================================================================
|
|
259
261
|
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
@@ -291,6 +291,10 @@ export class BindEvent extends BaseNode {
|
|
|
291
291
|
//================================================================================
|
|
292
292
|
// 用于logic回填
|
|
293
293
|
get calleewholeKey(): string {
|
|
294
|
+
if (!this.calleeNamespace && this.calleeName) {
|
|
295
|
+
// 页面逻辑单独处理
|
|
296
|
+
return `${this.view.getNamespace()}.${this.view.name}.logics.${this.calleeName}`;
|
|
297
|
+
}
|
|
294
298
|
return this.calleeNamespace + '.' + this.calleeName;
|
|
295
299
|
}
|
|
296
300
|
get tsCalleeNamespace() {
|
|
@@ -338,11 +342,11 @@ export class BindEvent extends BaseNode {
|
|
|
338
342
|
if (isPageCycle) {
|
|
339
343
|
return `${this.calleeKey}();`;
|
|
340
344
|
}
|
|
341
|
-
let code = `${this.toHump(this.name) || '__IDENTIFIER__'}: (event) => [\n`;
|
|
342
|
-
code += indent(state
|
|
345
|
+
let code = `${this.toHump(this.name) || '__IDENTIFIER__'}: (event: any) => [\n`;
|
|
346
|
+
code += indent((state?.tabSize || 0) + 1);
|
|
343
347
|
code += `() => {${this.calleeKey}()}`;
|
|
344
348
|
code += '\n';
|
|
345
|
-
code += indent(state
|
|
349
|
+
code += indent((state?.tabSize || 0));
|
|
346
350
|
code += '],\n';
|
|
347
351
|
return code;
|
|
348
352
|
}
|
|
@@ -354,10 +358,10 @@ export class BindEvent extends BaseNode {
|
|
|
354
358
|
// let code = '';
|
|
355
359
|
// if (this.name) {
|
|
356
360
|
// code = `function ${this.name || '__IDENTIFIER__'} () {\n`;
|
|
357
|
-
// code += indent(state
|
|
361
|
+
// code += indent((state?.tabSize || 0) + 1);
|
|
358
362
|
// code += `${this.calleeKey}()`;
|
|
359
363
|
// code += '\n';
|
|
360
|
-
// code += indent(state
|
|
364
|
+
// code += indent((state?.tabSize || 0));
|
|
361
365
|
// code += '};\n';
|
|
362
366
|
// }
|
|
363
367
|
// return code;
|
|
@@ -367,8 +371,12 @@ export class BindEvent extends BaseNode {
|
|
|
367
371
|
* 设置callee
|
|
368
372
|
*/
|
|
369
373
|
setCallee(logic: Logic) {
|
|
374
|
+
let calleeNamespace = logic.getNamespace();
|
|
375
|
+
if (logic.parentNode instanceof View) {
|
|
376
|
+
calleeNamespace = '';
|
|
377
|
+
}
|
|
370
378
|
const object = {
|
|
371
|
-
calleeNamespace
|
|
379
|
+
calleeNamespace,
|
|
372
380
|
calleeName: logic.name,
|
|
373
381
|
};
|
|
374
382
|
this.update({
|
|
@@ -72,6 +72,18 @@ export class BooleanLiteral extends LogicItem {
|
|
|
72
72
|
toEmbeddedTS(state?: TranslatorState) {
|
|
73
73
|
return this.value;
|
|
74
74
|
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* 设置布尔值内容
|
|
78
|
+
*/
|
|
79
|
+
setValue(value: string) {
|
|
80
|
+
const object = {
|
|
81
|
+
value,
|
|
82
|
+
};
|
|
83
|
+
this.update({
|
|
84
|
+
...object,
|
|
85
|
+
});
|
|
86
|
+
}
|
|
75
87
|
getValue() {
|
|
76
88
|
return this.value;
|
|
77
89
|
}
|
|
@@ -421,10 +421,10 @@ export class CallFunction extends LogicItem {
|
|
|
421
421
|
code += ', ';
|
|
422
422
|
});
|
|
423
423
|
if (this.typeArguments && this.typeArguments.length) {
|
|
424
|
-
code += ', ';
|
|
424
|
+
if (this.arguments?.length) code += ', ';
|
|
425
425
|
this.typeArguments?.forEach((arg, index) => {
|
|
426
426
|
code += arg?.toJS(shiftState(state, code));
|
|
427
|
-
if (index !== this.
|
|
427
|
+
if (index !== this.typeArguments?.length - 1)
|
|
428
428
|
code += ', ';
|
|
429
429
|
});
|
|
430
430
|
}
|
|
@@ -456,6 +456,10 @@ export class CallFunction extends LogicItem {
|
|
|
456
456
|
if (param.defaultExpression instanceof Identifier) {
|
|
457
457
|
argument.expression = BaseNode.from(param.defaultExpression, argument, 'expression') as Identifier;
|
|
458
458
|
}
|
|
459
|
+
if (param.defaultExpression instanceof Function) {
|
|
460
|
+
(param.defaultExpression as Function).returnExpression = null;
|
|
461
|
+
argument.expression = BaseNode.from(param.defaultExpression, argument, 'expression') as Identifier;
|
|
462
|
+
}
|
|
459
463
|
Object.assign(argument, relationOptions);
|
|
460
464
|
return argument;
|
|
461
465
|
});
|