@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.
Files changed (299) hide show
  1. package/out/automate/engine/index.d.ts +1 -0
  2. package/out/automate/engine/index.js +34 -12
  3. package/out/automate/engine/index.js.map +1 -1
  4. package/out/automate/engine/operators.d.ts +10 -2
  5. package/out/automate/engine/operators.js +105 -7
  6. package/out/automate/engine/operators.js.map +1 -1
  7. package/out/automate/engine/uniqueName.d.ts +8 -2
  8. package/out/automate/engine/uniqueName.js +72 -4
  9. package/out/automate/engine/uniqueName.js.map +1 -1
  10. package/out/automate/engine/utils.d.ts +1 -0
  11. package/out/automate/engine/utils.js +92 -67
  12. package/out/automate/engine/utils.js.map +1 -1
  13. package/out/automate/template/process.d.ts +9 -0
  14. package/out/automate/template/process.js +10976 -0
  15. package/out/automate/template/process.js.map +1 -0
  16. package/out/bak/translator.js +1 -0
  17. package/out/bak/translator.js.map +1 -1
  18. package/out/common/BaseNode.d.ts +5 -0
  19. package/out/common/BaseNode.js +24 -3
  20. package/out/common/BaseNode.js.map +1 -1
  21. package/out/concepts/App__.d.ts +51 -49
  22. package/out/concepts/App__.js +86 -53
  23. package/out/concepts/App__.js.map +1 -1
  24. package/out/concepts/BindAttribute__.js +2 -2
  25. package/out/concepts/BindAttribute__.js.map +1 -1
  26. package/out/concepts/BindDirective__.js +10 -3
  27. package/out/concepts/BindDirective__.js.map +1 -1
  28. package/out/concepts/BindEvent__.js +15 -6
  29. package/out/concepts/BindEvent__.js.map +1 -1
  30. package/out/concepts/BooleanLiteral__.d.ts +4 -0
  31. package/out/concepts/BooleanLiteral__.js +11 -0
  32. package/out/concepts/BooleanLiteral__.js.map +1 -1
  33. package/out/concepts/CallFunction__.js +8 -2
  34. package/out/concepts/CallFunction__.js.map +1 -1
  35. package/out/concepts/CallLogic__.js +48 -30
  36. package/out/concepts/CallLogic__.js.map +1 -1
  37. package/out/concepts/CallQueryComponent__.d.ts +8 -7
  38. package/out/concepts/CallQueryComponent__.js +86 -76
  39. package/out/concepts/CallQueryComponent__.js.map +1 -1
  40. package/out/concepts/Comment__.js +1 -1
  41. package/out/concepts/Comment__.js.map +1 -1
  42. package/out/concepts/ConfigGroup__.d.ts +1 -0
  43. package/out/concepts/ConfigGroup__.js +7 -0
  44. package/out/concepts/ConfigGroup__.js.map +1 -1
  45. package/out/concepts/ConfigProperty__.d.ts +1 -0
  46. package/out/concepts/ConfigProperty__.js +3 -0
  47. package/out/concepts/ConfigProperty__.js.map +1 -1
  48. package/out/concepts/Configuration__.d.ts +1 -0
  49. package/out/concepts/Configuration__.js +3 -0
  50. package/out/concepts/Configuration__.js.map +1 -1
  51. package/out/concepts/DataSource__.d.ts +143 -0
  52. package/out/concepts/DataSource__.js +318 -0
  53. package/out/concepts/DataSource__.js.map +1 -0
  54. package/out/concepts/Destination__.js +8 -8
  55. package/out/concepts/Destination__.js.map +1 -1
  56. package/out/concepts/End__.js +2 -2
  57. package/out/concepts/End__.js.map +1 -1
  58. package/out/concepts/EntityIndex__.d.ts +5 -0
  59. package/out/concepts/EntityIndex__.js +6 -0
  60. package/out/concepts/EntityIndex__.js.map +1 -1
  61. package/out/concepts/EntityProperty__.d.ts +9 -0
  62. package/out/concepts/EntityProperty__.js +19 -2
  63. package/out/concepts/EntityProperty__.js.map +1 -1
  64. package/out/concepts/Entity__.d.ts +5 -0
  65. package/out/concepts/Entity__.js +20 -10
  66. package/out/concepts/Entity__.js.map +1 -1
  67. package/out/concepts/Enum__.js +12 -6
  68. package/out/concepts/Enum__.js.map +1 -1
  69. package/out/concepts/ForEachStatement__.js +2 -2
  70. package/out/concepts/ForEachStatement__.js.map +1 -1
  71. package/out/concepts/Function__.d.ts +18 -0
  72. package/out/concepts/Function__.js +96 -1
  73. package/out/concepts/Function__.js.map +1 -1
  74. package/out/concepts/Identifier__.js +6 -15
  75. package/out/concepts/Identifier__.js.map +1 -1
  76. package/out/concepts/IfStatement__.js +8 -8
  77. package/out/concepts/IfStatement__.js.map +1 -1
  78. package/out/concepts/Interface__.js +19 -12
  79. package/out/concepts/Interface__.js.map +1 -1
  80. package/out/concepts/JSBlock__.js +3 -5
  81. package/out/concepts/JSBlock__.js.map +1 -1
  82. package/out/concepts/Logic__.js +44 -44
  83. package/out/concepts/Logic__.js.map +1 -1
  84. package/out/concepts/Module__.d.ts +116 -194
  85. package/out/concepts/Module__.js +31 -114
  86. package/out/concepts/Module__.js.map +1 -1
  87. package/out/concepts/Namespace__.d.ts +0 -86
  88. package/out/concepts/Namespace__.js +1 -108
  89. package/out/concepts/Namespace__.js.map +1 -1
  90. package/out/concepts/Param__.d.ts +2 -1
  91. package/out/concepts/Param__.js +1 -1
  92. package/out/concepts/Param__.js.map +1 -1
  93. package/out/concepts/ProcessElement__.js +30 -10
  94. package/out/concepts/ProcessElement__.js.map +1 -1
  95. package/out/concepts/Process__.d.ts +1 -1
  96. package/out/concepts/Process__.js +17 -10
  97. package/out/concepts/Process__.js.map +1 -1
  98. package/out/concepts/QueryFieldExpression__.js +8 -1
  99. package/out/concepts/QueryFieldExpression__.js.map +1 -1
  100. package/out/concepts/QueryFromExpression__.d.ts +4 -0
  101. package/out/concepts/QueryFromExpression__.js +13 -2
  102. package/out/concepts/QueryFromExpression__.js.map +1 -1
  103. package/out/concepts/QueryJoinExpression__.d.ts +4 -0
  104. package/out/concepts/QueryJoinExpression__.js +14 -3
  105. package/out/concepts/QueryJoinExpression__.js.map +1 -1
  106. package/out/concepts/Return__.js +1 -1
  107. package/out/concepts/Return__.js.map +1 -1
  108. package/out/concepts/Role__.js +10 -3
  109. package/out/concepts/Role__.js.map +1 -1
  110. package/out/concepts/SqlQueryComponent__.d.ts +14 -0
  111. package/out/concepts/SqlQueryComponent__.js +48 -5
  112. package/out/concepts/SqlQueryComponent__.js.map +1 -1
  113. package/out/concepts/StringLiteral__.d.ts +1 -1
  114. package/out/concepts/StringLiteral__.js +1 -1
  115. package/out/concepts/StructureProperty__.js +6 -5
  116. package/out/concepts/StructureProperty__.js.map +1 -1
  117. package/out/concepts/Structure__.js +19 -12
  118. package/out/concepts/Structure__.js.map +1 -1
  119. package/out/concepts/SwitchCase__.d.ts +1 -1
  120. package/out/concepts/SwitchCase__.js +23 -25
  121. package/out/concepts/SwitchCase__.js.map +1 -1
  122. package/out/concepts/SwitchStatement__.js +1 -6
  123. package/out/concepts/SwitchStatement__.js.map +1 -1
  124. package/out/concepts/TypeAnnotation__.d.ts +8 -0
  125. package/out/concepts/TypeAnnotation__.js +44 -2
  126. package/out/concepts/TypeAnnotation__.js.map +1 -1
  127. package/out/concepts/Variable__.js +1 -1
  128. package/out/concepts/Variable__.js.map +1 -1
  129. package/out/concepts/ViewElement__.js +25 -20
  130. package/out/concepts/ViewElement__.js.map +1 -1
  131. package/out/concepts/View__.d.ts +0 -2
  132. package/out/concepts/View__.js +27 -32
  133. package/out/concepts/View__.js.map +1 -1
  134. package/out/concepts/WhileStatement__.js +4 -4
  135. package/out/concepts/WhileStatement__.js.map +1 -1
  136. package/out/concepts/basics/stdlib/nasl.auth.js +20 -0
  137. package/out/concepts/basics/stdlib/nasl.auth.js.map +1 -1
  138. package/out/concepts/basics/stdlib/nasl.process.d.ts +4 -0
  139. package/out/concepts/basics/stdlib/nasl.process.js +410 -0
  140. package/out/concepts/basics/stdlib/nasl.process.js.map +1 -1
  141. package/out/concepts/basics/stdlib/nasl.ui.js +1 -11
  142. package/out/concepts/basics/stdlib/nasl.ui.js.map +1 -1
  143. package/out/concepts/basics/stdlib/nasl.util.js +280 -2
  144. package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
  145. package/out/concepts/basics/types/index.d.ts +1 -0
  146. package/out/concepts/basics/types/index.js +4 -1
  147. package/out/concepts/basics/types/index.js.map +1 -1
  148. package/out/concepts/index__.d.ts +1 -0
  149. package/out/concepts/index__.js +1 -0
  150. package/out/concepts/index__.js.map +1 -1
  151. package/out/generator/genBundleFiles.d.ts +3 -1
  152. package/out/generator/genBundleFiles.js +23 -5
  153. package/out/generator/genBundleFiles.js.map +1 -1
  154. package/out/generator/genMetaData.d.ts +1 -0
  155. package/out/generator/genMetaData.js +20 -12
  156. package/out/generator/genMetaData.js.map +1 -1
  157. package/out/index.d.ts +1 -1
  158. package/out/index.js +2 -1
  159. package/out/index.js.map +1 -1
  160. package/out/server/createUiTs.js +1 -0
  161. package/out/server/createUiTs.js.map +1 -1
  162. package/out/server/getLogics.js +27 -1
  163. package/out/server/getLogics.js.map +1 -1
  164. package/out/server/getMemberIdentifier.js +5 -0
  165. package/out/server/getMemberIdentifier.js.map +1 -1
  166. package/out/server/getProcesses.d.ts +4 -0
  167. package/out/server/getProcesses.js +69 -1
  168. package/out/server/getProcesses.js.map +1 -1
  169. package/out/server/naslServer.d.ts +1 -0
  170. package/out/server/naslServer.js +223 -26
  171. package/out/server/naslServer.js.map +1 -1
  172. package/out/server/process2LogicNamespace.js +10 -1
  173. package/out/server/process2LogicNamespace.js.map +1 -1
  174. package/out/server/translator.js +37 -1
  175. package/out/server/translator.js.map +1 -1
  176. package/out/service/creator/errHandles.js +5 -0
  177. package/out/service/creator/errHandles.js.map +1 -1
  178. package/out/service/storage/init.d.ts +1 -0
  179. package/out/service/storage/init.js +95 -84
  180. package/out/service/storage/init.js.map +1 -1
  181. package/out/templator/genCreateBlock.js +34 -24
  182. package/out/templator/genCreateBlock.js.map +1 -1
  183. package/out/templator/genCurdEditMultipleKeyBlock.js +28 -18
  184. package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
  185. package/out/templator/genCurdMultipleKeyBlock.js +45 -29
  186. package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
  187. package/out/templator/genEditTableBlock.js +15 -13
  188. package/out/templator/genEditTableBlock.js.map +1 -1
  189. package/out/templator/genEnumSelectBlock.js +1 -1
  190. package/out/templator/genEnumSelectBlock.js.map +1 -1
  191. package/out/templator/genGridViewBlock.js +29 -24
  192. package/out/templator/genGridViewBlock.js.map +1 -1
  193. package/out/templator/genListViewBlock.js +7 -5
  194. package/out/templator/genListViewBlock.js.map +1 -1
  195. package/out/templator/genQueryComponent.js +25 -26
  196. package/out/templator/genQueryComponent.js.map +1 -1
  197. package/out/templator/genSelectBlock.js +8 -7
  198. package/out/templator/genSelectBlock.js.map +1 -1
  199. package/out/templator/genTableBlock.js +31 -21
  200. package/out/templator/genTableBlock.js.map +1 -1
  201. package/out/templator/genUpdateBlock.js +34 -24
  202. package/out/templator/genUpdateBlock.js.map +1 -1
  203. package/out/templator/utils.d.ts +2 -2
  204. package/out/templator/utils.js.map +1 -1
  205. package/out/test/integration/connect-file.js +6 -6
  206. package/out/test/integration/connect-file.js.map +1 -1
  207. package/out/translator/index.js +1 -1
  208. package/out/translator/index.js.map +1 -1
  209. package/out/utils/index.d.ts +5 -0
  210. package/out/utils/index.js +50 -1
  211. package/out/utils/index.js.map +1 -1
  212. package/package.json +1 -1
  213. package/src/automate/engine/index.js +33 -8
  214. package/src/automate/engine/operators.js +114 -17
  215. package/src/automate/engine/uniqueName.js +77 -9
  216. package/src/automate/engine/utils.js +95 -68
  217. package/src/automate/template/process.js +10999 -0
  218. package/src/bak/translator.js +1 -0
  219. package/src/common/BaseNode.ts +21 -4
  220. package/src/concepts/App__.ts +128 -94
  221. package/src/concepts/BindAttribute__.ts +2 -2
  222. package/src/concepts/BindDirective__.ts +9 -7
  223. package/src/concepts/BindEvent__.ts +14 -6
  224. package/src/concepts/BooleanLiteral__.ts +12 -0
  225. package/src/concepts/CallFunction__.ts +6 -2
  226. package/src/concepts/CallLogic__.ts +47 -32
  227. package/src/concepts/CallQueryComponent__.ts +92 -81
  228. package/src/concepts/Comment__.ts +1 -1
  229. package/src/concepts/ConfigGroup__.ts +3 -1
  230. package/src/concepts/ConfigProperty__.ts +4 -0
  231. package/src/concepts/Configuration__.ts +3 -0
  232. package/src/concepts/DataSource__.ts +391 -0
  233. package/src/concepts/Destination__.ts +24 -8
  234. package/src/concepts/End__.ts +2 -2
  235. package/src/concepts/EntityIndex__.ts +7 -0
  236. package/src/concepts/EntityProperty__.ts +20 -2
  237. package/src/concepts/Entity__.ts +23 -11
  238. package/src/concepts/Enum__.ts +25 -6
  239. package/src/concepts/ForEachStatement__.ts +2 -2
  240. package/src/concepts/Function__.ts +95 -1
  241. package/src/concepts/Identifier__.ts +15 -15
  242. package/src/concepts/IfStatement__.ts +9 -9
  243. package/src/concepts/Interface__.ts +20 -12
  244. package/src/concepts/JSBlock__.ts +3 -12
  245. package/src/concepts/Logic__.ts +45 -79
  246. package/src/concepts/Module__.ts +141 -342
  247. package/src/concepts/Namespace__.ts +1 -204
  248. package/src/concepts/Param__.ts +3 -2
  249. package/src/concepts/ProcessElement__.ts +33 -12
  250. package/src/concepts/Process__.ts +18 -12
  251. package/src/concepts/QueryFieldExpression__.ts +9 -1
  252. package/src/concepts/QueryFromExpression__.ts +13 -2
  253. package/src/concepts/QueryJoinExpression__.ts +14 -3
  254. package/src/concepts/Return__.ts +1 -1
  255. package/src/concepts/Role__.ts +10 -4
  256. package/src/concepts/SqlQueryComponent__.ts +47 -11
  257. package/src/concepts/StringLiteral__.ts +1 -1
  258. package/src/concepts/StructureProperty__.ts +6 -9
  259. package/src/concepts/Structure__.ts +19 -11
  260. package/src/concepts/SwitchCase__.ts +23 -27
  261. package/src/concepts/SwitchStatement__.ts +1 -5
  262. package/src/concepts/TypeAnnotation__.ts +43 -2
  263. package/src/concepts/Variable__.ts +1 -1
  264. package/src/concepts/ViewElement__.ts +26 -39
  265. package/src/concepts/View__.ts +29 -34
  266. package/src/concepts/WhileStatement__.ts +4 -4
  267. package/src/concepts/basics/stdlib/nasl.auth.ts +20 -0
  268. package/src/concepts/basics/stdlib/nasl.process.ts +406 -0
  269. package/src/concepts/basics/stdlib/nasl.ui.ts +1 -11
  270. package/src/concepts/basics/stdlib/nasl.util.ts +281 -2
  271. package/src/concepts/basics/types/index.ts +1 -0
  272. package/src/concepts/index__.ts +1 -0
  273. package/src/generator/genBundleFiles.ts +28 -7
  274. package/src/generator/genMetaData.ts +22 -13
  275. package/src/index.ts +1 -1
  276. package/src/server/createUiTs.ts +1 -0
  277. package/src/server/getLogics.ts +29 -4
  278. package/src/server/getMemberIdentifier.ts +4 -0
  279. package/src/server/getProcesses.ts +68 -0
  280. package/src/server/naslServer.ts +227 -30
  281. package/src/server/process2LogicNamespace.ts +29 -19
  282. package/src/server/translator.ts +39 -1
  283. package/src/service/creator/errHandles.js +6 -0
  284. package/src/service/storage/init.ts +97 -86
  285. package/src/templator/genCreateBlock.ts +35 -26
  286. package/src/templator/genCurdEditMultipleKeyBlock.ts +29 -21
  287. package/src/templator/genCurdMultipleKeyBlock.ts +46 -31
  288. package/src/templator/genEditTableBlock.ts +17 -14
  289. package/src/templator/genEnumSelectBlock.ts +1 -1
  290. package/src/templator/genGridViewBlock.ts +30 -25
  291. package/src/templator/genListViewBlock.ts +10 -7
  292. package/src/templator/genQueryComponent.ts +28 -27
  293. package/src/templator/genSelectBlock.ts +9 -8
  294. package/src/templator/genTableBlock.ts +32 -23
  295. package/src/templator/genUpdateBlock.ts +35 -25
  296. package/src/templator/utils.ts +2 -2
  297. package/src/test/integration/connect-file.ts +6 -6
  298. package/src/translator/index.ts +1 -1
  299. package/src/utils/index.ts +51 -0
@@ -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')}
@@ -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 && sourceItem instanceof objectRefCtor) {
167
- sourceItem.parentNode = this;
168
- sourceItem.parentKey = key;
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
 
@@ -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 Entity from './Entity__';
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('Entity')
116
- entities: Array<Entity> = [];
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
- getEntityExistingNames(excludedList: Array<Entity> = []) {
238
+ getDataSourceExistingNames(excludedList: Array<DataSource> = []) {
239
239
  const excludedSet = new Set(excludedList);
240
- return (this.entities || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
240
+ return (this.dataSources || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
241
241
  }
242
- getEntityUniqueName(name = 'Entity1') {
243
- return utils.unique(name, this.getEntityExistingNames(), undefined, true);
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
- _insertEntityAt(name: string, index: number): Entity;
251
+ _insertDataSourceAt(name: string, index: number): DataSource;
252
252
 
253
253
  /**
254
- * 插入实体
254
+ * 插入数据源
255
255
  * @internal
256
- * @param entityOptions 实体参数
256
+ * @param dataSourceOptions 数据源参数
257
257
  */
258
- _insertEntityAt(entityOptions: Partial<Entity>, index: number): Entity;
258
+ _insertDataSourceAt(dataSourceOptions: Partial<DataSource>, index: number): DataSource;
259
259
 
260
260
  /**
261
- * 插入实体
261
+ * 插入数据源
262
262
  * @internal
263
- * @param entity 已有的实体实例
263
+ * @param dataSource 已有的数据源实例
264
264
  */
265
- _insertEntityAt(entity: Entity, index: number): Entity;
265
+ _insertDataSourceAt(dataSource: DataSource, index: number): DataSource;
266
266
 
267
- _insertEntityAt(options: string | Partial<Entity> | Entity, index: number) {
268
- const entityOptions: any = {};
269
- const relationOptions = { parentNode: this, parentKey: 'entities' };
270
- let entity: Entity;
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
- entity = Entity.from({
273
- ...entityOptions,
274
- name: this.getEntityUniqueName(),
275
- }, this, 'entities');
272
+ dataSource = DataSource.from({
273
+ ...dataSourceOptions,
274
+ name: this.getDataSourceUniqueName(),
275
+ }, this, 'dataSources');
276
276
  } else if (typeof options === 'string') {
277
- entity = Entity.from({
278
- ...entityOptions,
277
+ dataSource = DataSource.from({
278
+ ...dataSourceOptions,
279
279
  name: options,
280
- }, this, 'entities');
281
- } else if (options instanceof Entity) {
280
+ }, this, 'dataSources');
281
+ } else if (options instanceof DataSource) {
282
282
  options.ensureDelete(); // 同一实例不支持多处存在
283
- entity = options;
284
- Object.assign(entity, relationOptions);
283
+ dataSource = options;
284
+ Object.assign(dataSource, relationOptions);
285
285
  } else {
286
- entity = Entity.from({
287
- ...entityOptions,
286
+ dataSource = DataSource.from({
287
+ ...dataSourceOptions,
288
288
  ...options,
289
- }, this, 'entities');
289
+ }, this, 'dataSources');
290
290
  }
291
- this.entities.splice(index, 0, entity);
292
- return entity;
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
- insertEntityAt(name: string, index: number): Entity;
299
+ insertDataSourceAt(name: string, index: number): DataSource;
300
300
 
301
301
  /**
302
- * 插入实体
303
- * @param entityOptions 实体参数
302
+ * 插入数据源
303
+ * @param dataSourceOptions 数据源参数
304
304
  */
305
- insertEntityAt(entityOptions: Partial<Entity>, index: number): Entity;
305
+ insertDataSourceAt(dataSourceOptions: Partial<DataSource>, index: number): DataSource;
306
306
 
307
307
  /**
308
- * 插入实体
309
- * @param entity 已有的实体实例
308
+ * 插入数据源
309
+ * @param dataSource 已有的数据源实例
310
310
  */
311
- insertEntityAt(entity: Entity, index: number): Entity;
311
+ insertDataSourceAt(dataSource: DataSource, index: number): DataSource;
312
312
 
313
- insertEntityAt(options: string | Partial<Entity> | Entity, index: number) {
314
- const node = this._insertEntityAt(options as any, index);
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: 'entities',
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
- _addEntity(name?: string): Entity;
328
+ _addDataSource(name?: string): DataSource;
329
329
 
330
330
  /**
331
- * 添加实体
331
+ * 添加数据源
332
332
  * @internal
333
- * @param entityOptions 实体参数
333
+ * @param dataSourceOptions 数据源参数
334
334
  */
335
- _addEntity(entityOptions: Partial<Entity>): Entity;
335
+ _addDataSource(dataSourceOptions: Partial<DataSource>): DataSource;
336
336
 
337
337
  /**
338
- * 添加实体
338
+ * 添加数据源
339
339
  * @internal
340
- * @param entity 已有的实体实例
340
+ * @param dataSource 已有的数据源实例
341
341
  */
342
- _addEntity(entity: Entity): Entity;
342
+ _addDataSource(dataSource: DataSource): DataSource;
343
343
 
344
- _addEntity(options?: string | Partial<Entity> | Entity) {
345
- const index = 0;
346
- return this._insertEntityAt(options as any, index);
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
- addEntity(name?: string): Entity;
354
+ addDataSource(name?: string): DataSource;
355
355
 
356
356
  /**
357
- * 添加实体
358
- * @param entityOptions 实体参数
357
+ * 添加数据源
358
+ * @param dataSourceOptions 数据源参数
359
359
  */
360
- addEntity(entityOptions: Partial<Entity>): Entity;
360
+ addDataSource(dataSourceOptions: Partial<DataSource>): DataSource;
361
361
 
362
362
  /**
363
- * 添加实体
364
- * @param entity 已有的实体实例
363
+ * 添加数据源
364
+ * @param dataSource 已有的数据源实例
365
365
  */
366
- addEntity(entity: Entity): Entity;
366
+ addDataSource(dataSource: DataSource): DataSource;
367
367
 
368
- addEntity(options?: string | Partial<Entity> | Entity) {
369
- const node = this._addEntity(options as any);
370
- const index = this.entities.indexOf(node);
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: 'entities',
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
- removeEntity(name: string): void;
1777
+ removeDataSource(name: string): void;
1778
1778
 
1779
1779
  /**
1780
- * 删除实体
1781
- * @param entity 已有的实体实例
1780
+ * 删除数据源
1781
+ * @param dataSource 已有的数据源实例
1782
1782
  */
1783
- removeEntity(entity: Entity): void;
1783
+ removeDataSource(dataSource: DataSource): void;
1784
1784
 
1785
- removeEntity(options: string | Entity) {
1786
- let entity: Entity;
1785
+ removeDataSource(options: string | DataSource) {
1786
+ let dataSource: DataSource;
1787
1787
  if (typeof options === 'string') {
1788
- entity = this.entities.find((item) => item.name === options);
1789
- if (!entity) {
1790
- throw new Error('找不到实体 ' + options);
1788
+ dataSource = this.dataSources.find((item) => item.name === options);
1789
+ if (!dataSource) {
1790
+ throw new Error('找不到数据源 ' + options);
1791
1791
  }
1792
1792
  } else {
1793
- entity = options;
1793
+ dataSource = options;
1794
1794
  }
1795
- return entity.delete();
1795
+ return dataSource.delete();
1796
1796
  }
1797
1797
 
1798
- __removeEntity(entity: Entity) {
1799
- const parentKey = entity.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: entity,
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(entity);
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] === entity) {
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
- findEntityByName(name: string) {
2360
- return this.entities.find((entity) => entity.name === name);
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 `app`;
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.tabSize + 1 }));
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.tabSize + 1 }));
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
- Object.keys(this.modifiers || {}).forEach((key) => {
212
- const value = (this.modifiers as any)[key];
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['BindDirective'] = BindDirective;
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.tabSize + 1);
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.tabSize);
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.tabSize + 1);
361
+ // code += indent((state?.tabSize || 0) + 1);
358
362
  // code += `${this.calleeKey}()`;
359
363
  // code += '\n';
360
- // code += indent(state.tabSize);
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: logic.getNamespace(),
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.arguments?.length - 1)
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
  });