@lcap/nasl 2.18.0 → 2.19.0-beta.1

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 (283) hide show
  1. package/out/automate/template/myProcess.js +1 -1
  2. package/out/automate/template/myProcess.js.map +1 -1
  3. package/out/bak/translator.js +2 -1
  4. package/out/bak/translator.js.map +1 -1
  5. package/out/common/BaseNode.js +1 -0
  6. package/out/common/BaseNode.js.map +1 -1
  7. package/out/common/Command.d.ts +1 -0
  8. package/out/common/Command.js +5 -1
  9. package/out/common/Command.js.map +1 -1
  10. package/out/concepts/AnonymousFunction__.d.ts +1 -0
  11. package/out/concepts/AnonymousFunction__.js +40 -2
  12. package/out/concepts/AnonymousFunction__.js.map +1 -1
  13. package/out/concepts/App__.d.ts +10 -0
  14. package/out/concepts/App__.js +132 -0
  15. package/out/concepts/App__.js.map +1 -1
  16. package/out/concepts/Assignee__.js +4 -3
  17. package/out/concepts/Assignee__.js.map +1 -1
  18. package/out/concepts/BatchAssignment__.d.ts +2 -0
  19. package/out/concepts/BatchAssignment__.js +108 -47
  20. package/out/concepts/BatchAssignment__.js.map +1 -1
  21. package/out/concepts/BindAttribute__.js +8 -1
  22. package/out/concepts/BindAttribute__.js.map +1 -1
  23. package/out/concepts/CallFunction__.js +51 -18
  24. package/out/concepts/CallFunction__.js.map +1 -1
  25. package/out/concepts/CallInterface__.js +6 -4
  26. package/out/concepts/CallInterface__.js.map +1 -1
  27. package/out/concepts/CallLogic__.d.ts +2 -1
  28. package/out/concepts/CallLogic__.js +113 -26
  29. package/out/concepts/CallLogic__.js.map +1 -1
  30. package/out/concepts/CallQueryComponent__.js +4 -1
  31. package/out/concepts/CallQueryComponent__.js.map +1 -1
  32. package/out/concepts/DataSource__.d.ts +2 -0
  33. package/out/concepts/DataSource__.js +55 -1
  34. package/out/concepts/DataSource__.js.map +1 -1
  35. package/out/concepts/Destination__.d.ts +2 -1
  36. package/out/concepts/Destination__.js +90 -22
  37. package/out/concepts/Destination__.js.map +1 -1
  38. package/out/concepts/ForEachStatement__.js +2 -0
  39. package/out/concepts/ForEachStatement__.js.map +1 -1
  40. package/out/concepts/Identifier__.d.ts +1 -0
  41. package/out/concepts/Identifier__.js +18 -7
  42. package/out/concepts/Identifier__.js.map +1 -1
  43. package/out/concepts/LogicItem__.d.ts +1 -1
  44. package/out/concepts/LogicItem__.js.map +1 -1
  45. package/out/concepts/Logic__.d.ts +1 -0
  46. package/out/concepts/Logic__.js +33 -21
  47. package/out/concepts/Logic__.js.map +1 -1
  48. package/out/concepts/Match__.js +13 -8
  49. package/out/concepts/Match__.js.map +1 -1
  50. package/out/concepts/NewComposite__.d.ts +345 -0
  51. package/out/concepts/NewComposite__.js +1067 -0
  52. package/out/concepts/NewComposite__.js.map +1 -0
  53. package/out/concepts/NewList__.d.ts +130 -0
  54. package/out/concepts/NewList__.js +353 -0
  55. package/out/concepts/NewList__.js.map +1 -0
  56. package/out/concepts/NewMap__.d.ts +221 -0
  57. package/out/concepts/NewMap__.js +492 -0
  58. package/out/concepts/NewMap__.js.map +1 -0
  59. package/out/concepts/New__.d.ts +19 -0
  60. package/out/concepts/New__.js +66 -0
  61. package/out/concepts/New__.js.map +1 -0
  62. package/out/concepts/Param__.d.ts +2 -0
  63. package/out/concepts/Param__.js +40 -3
  64. package/out/concepts/Param__.js.map +1 -1
  65. package/out/concepts/ProcessElement__.js +31 -10
  66. package/out/concepts/ProcessElement__.js.map +1 -1
  67. package/out/concepts/ProcessOutcome__.js +1 -1
  68. package/out/concepts/ProcessOutcome__.js.map +1 -1
  69. package/out/concepts/ProcessOutcomes__.d.ts +30 -0
  70. package/out/concepts/{ConstructArgument__.js → ProcessOutcomes__.js} +27 -48
  71. package/out/concepts/ProcessOutcomes__.js.map +1 -0
  72. package/out/concepts/Return__.js +2 -1
  73. package/out/concepts/Return__.js.map +1 -1
  74. package/out/concepts/SelectMembers__.js +3 -3
  75. package/out/concepts/SelectMembers__.js.map +1 -1
  76. package/out/concepts/StringInterpolation__.js +12 -2
  77. package/out/concepts/StringInterpolation__.js.map +1 -1
  78. package/out/concepts/TypeAnnotation__.d.ts +4 -0
  79. package/out/concepts/TypeAnnotation__.js +66 -12
  80. package/out/concepts/TypeAnnotation__.js.map +1 -1
  81. package/out/concepts/ValidationRule__.js +1 -1
  82. package/out/concepts/ValidationRule__.js.map +1 -1
  83. package/out/concepts/Variable__.js +2 -1
  84. package/out/concepts/Variable__.js.map +1 -1
  85. package/out/concepts/ViewElement__.js +13 -1
  86. package/out/concepts/ViewElement__.js.map +1 -1
  87. package/out/concepts/View__.d.ts +1 -0
  88. package/out/concepts/View__.js +13 -0
  89. package/out/concepts/View__.js.map +1 -1
  90. package/out/concepts/basics/stdlib/nasl.auth.js +1 -1
  91. package/out/concepts/basics/stdlib/nasl.auth.js.map +1 -1
  92. package/out/concepts/basics/stdlib/nasl.logging.js +5 -0
  93. package/out/concepts/basics/stdlib/nasl.logging.js.map +1 -1
  94. package/out/concepts/basics/stdlib/nasl.ui.js +2 -0
  95. package/out/concepts/basics/stdlib/nasl.ui.js.map +1 -1
  96. package/out/concepts/basics/stdlib/nasl.util.js +151 -19
  97. package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
  98. package/out/concepts/index__.d.ts +5 -0
  99. package/out/concepts/index__.js +5 -0
  100. package/out/concepts/index__.js.map +1 -1
  101. package/out/enums/KEYWORDS.js +1 -0
  102. package/out/enums/KEYWORDS.js.map +1 -1
  103. package/out/generator/genBundleFiles.js +32 -182
  104. package/out/generator/genBundleFiles.js.map +1 -1
  105. package/out/generator/genMetaData.d.ts +1 -10
  106. package/out/generator/genMetaData.js +184 -50
  107. package/out/generator/genMetaData.js.map +1 -1
  108. package/out/generator/genReleaseBody.d.ts +2 -0
  109. package/out/generator/genReleaseBody.js +29 -3
  110. package/out/generator/genReleaseBody.js.map +1 -1
  111. package/out/generator/index.d.ts +1 -0
  112. package/out/generator/index.js +1 -0
  113. package/out/generator/index.js.map +1 -1
  114. package/out/generator/permission.d.ts +9 -0
  115. package/out/generator/permission.js +235 -0
  116. package/out/generator/permission.js.map +1 -0
  117. package/out/index.d.ts +1 -1
  118. package/out/index.js +2 -1
  119. package/out/index.js.map +1 -1
  120. package/out/server/entity2LogicNamespace.js +69 -9
  121. package/out/server/entity2LogicNamespace.js.map +1 -1
  122. package/out/server/extendBaseNode.js +10 -20
  123. package/out/server/extendBaseNode.js.map +1 -1
  124. package/out/server/formatTsUtils.d.ts +1 -2
  125. package/out/server/formatTsUtils.js +36 -47
  126. package/out/server/formatTsUtils.js.map +1 -1
  127. package/out/server/getLogics.d.ts +2 -1
  128. package/out/server/getLogics.js +11 -0
  129. package/out/server/getLogics.js.map +1 -1
  130. package/out/server/getMemberIdentifier.js +1 -1
  131. package/out/server/getMemberIdentifier.js.map +1 -1
  132. package/out/server/getProcesses.js +1 -1
  133. package/out/server/getProcesses.js.map +1 -1
  134. package/out/server/naslServer.d.ts +1 -1
  135. package/out/server/naslServer.js +181 -35
  136. package/out/server/naslServer.js.map +1 -1
  137. package/out/server/process2LogicNamespace.js +8 -0
  138. package/out/server/process2LogicNamespace.js.map +1 -1
  139. package/out/server/translator.js +66 -6
  140. package/out/server/translator.js.map +1 -1
  141. package/out/service/creator/add.configs.js +4 -0
  142. package/out/service/creator/add.configs.js.map +1 -1
  143. package/out/service/datasource/api.d.ts +12 -0
  144. package/out/service/datasource/api.js +14 -0
  145. package/out/service/datasource/api.js.map +1 -0
  146. package/out/service/datasource/index.d.ts +2 -0
  147. package/out/service/datasource/index.js +10 -0
  148. package/out/service/datasource/index.js.map +1 -0
  149. package/out/service/storage/init.js +8 -1
  150. package/out/service/storage/init.js.map +1 -1
  151. package/out/templator/genEditTableBlock.js +4 -5
  152. package/out/templator/genEditTableBlock.js.map +1 -1
  153. package/out/templator/genGetBlock.js +4 -3
  154. package/out/templator/genGetBlock.js.map +1 -1
  155. package/out/templator/genGridViewBlock.js +16 -14
  156. package/out/templator/genGridViewBlock.js.map +1 -1
  157. package/out/templator/genListViewBlock.js +5 -5
  158. package/out/templator/genListViewBlock.js.map +1 -1
  159. package/out/templator/genTableBlock.js +6 -10
  160. package/out/templator/genTableBlock.js.map +1 -1
  161. package/package.json +1 -1
  162. package/sandbox/stdlib/dist/nasl.logging.js +0 -0
  163. package/sandbox/stdlib/dist/nasl.util.js +0 -0
  164. package/sandbox/stdlib/nasl.auth.ts +1 -1
  165. package/sandbox/stdlib/nasl.core.ts +4 -0
  166. package/sandbox/stdlib/nasl.logging.ts +4 -4
  167. package/sandbox/stdlib/nasl.util.ts +14 -5
  168. package/src/automate/template/myProcess.js +1 -1
  169. package/src/bak/translator.js +4 -1
  170. package/src/common/BaseNode.ts +1 -0
  171. package/src/common/Command.ts +4 -0
  172. package/src/concepts/AnonymousFunction__.ts +48 -2
  173. package/src/concepts/App__.ts +140 -41
  174. package/src/concepts/Assignee__.ts +4 -3
  175. package/src/concepts/BatchAssignment__.ts +111 -51
  176. package/src/concepts/BindAttribute__.ts +9 -2
  177. package/src/concepts/CallFunction__.ts +65 -31
  178. package/src/concepts/CallInterface__.ts +6 -22
  179. package/src/concepts/CallLogic__.ts +88 -24
  180. package/src/concepts/CallQueryComponent__.ts +4 -1
  181. package/src/concepts/DataSource__.ts +56 -1
  182. package/src/concepts/Destination__.ts +92 -22
  183. package/src/concepts/ForEachStatement__.ts +2 -0
  184. package/src/concepts/Identifier__.ts +18 -7
  185. package/src/concepts/LogicItem__.ts +1 -1
  186. package/src/concepts/Logic__.ts +54 -39
  187. package/src/concepts/Match__.ts +12 -8
  188. package/src/concepts/NewComposite__.ts +1356 -0
  189. package/src/concepts/NewList__.ts +444 -0
  190. package/src/concepts/NewMap__.ts +678 -0
  191. package/src/concepts/New__.ts +73 -0
  192. package/src/concepts/Param__.ts +238 -199
  193. package/src/concepts/ProcessElement__.ts +32 -10
  194. package/src/concepts/ProcessOutcome__.ts +1 -1
  195. package/src/concepts/ProcessOutcomes__.ts +90 -0
  196. package/src/concepts/Return__.ts +4 -1
  197. package/src/concepts/SelectMembers__.ts +3 -3
  198. package/src/concepts/StringInterpolation__.ts +21 -11
  199. package/src/concepts/TypeAnnotation__.ts +71 -50
  200. package/src/concepts/ValidationRule__.ts +19 -1
  201. package/src/concepts/Variable__.ts +4 -1
  202. package/src/concepts/ViewElement__.ts +23 -7
  203. package/src/concepts/View__.ts +16 -2
  204. package/src/concepts/basics/stdlib/dist/nasl.util.js +1602 -0
  205. package/src/concepts/basics/stdlib/nasl.auth.ts +1 -1
  206. package/src/concepts/basics/stdlib/nasl.logging.ts +5 -0
  207. package/src/concepts/basics/stdlib/nasl.ui.ts +2 -0
  208. package/src/concepts/basics/stdlib/nasl.util.ts +153 -19
  209. package/src/concepts/dist/BindAttribute__.js +760 -0
  210. package/src/concepts/dist/BindEvent__.js +732 -0
  211. package/src/concepts/dist/CallFunction__.js +82 -28
  212. package/src/concepts/dist/CallLogic__.js +95 -27
  213. package/src/concepts/dist/Identifier__.js +311 -0
  214. package/src/concepts/dist/StringInterpolation__.js +231 -0
  215. package/src/concepts/dist/TypeAnnotation__.js +834 -0
  216. package/src/concepts/dist/ViewElement__.js +1692 -0
  217. package/src/concepts/dist/View__.js +1601 -0
  218. package/src/concepts/index__.ts +5 -0
  219. package/src/enums/KEYWORDS.ts +1 -0
  220. package/src/generator/dist/genBundleFiles.js +23 -176
  221. package/src/generator/dist/genMetaData.js +245 -0
  222. package/src/generator/dist/permission.js +392 -0
  223. package/src/generator/genBundleFiles.ts +34 -219
  224. package/src/generator/genMetaData.ts +177 -77
  225. package/src/generator/genReleaseBody.ts +30 -5
  226. package/src/generator/index.ts +1 -0
  227. package/src/generator/permission.ts +271 -0
  228. package/src/index.ts +1 -1
  229. package/src/server/dist/naslServer.js +443 -249
  230. package/src/server/entity2LogicNamespace.ts +70 -10
  231. package/src/server/extendBaseNode.ts +10 -21
  232. package/src/server/formatTsUtils.ts +36 -46
  233. package/src/server/getLogics.ts +13 -1
  234. package/src/server/getMemberIdentifier.ts +1 -1
  235. package/src/server/getProcesses.ts +1 -1
  236. package/src/server/naslServer.ts +181 -42
  237. package/src/server/process2LogicNamespace.ts +8 -0
  238. package/src/server/translator.ts +64 -7
  239. package/src/service/creator/add.configs.js +4 -0
  240. package/src/service/dataSource/api.js +11 -0
  241. package/src/service/dataSource/index.js +6 -0
  242. package/src/service/storage/dist/init.js +48 -10
  243. package/src/service/storage/init.ts +9 -2
  244. package/src/service/video/VideoTranscribe.js +1 -0
  245. package/src/templator/dist/genEditTableBlock.js +204 -0
  246. package/src/templator/dist/genGridViewBlock.js +265 -0
  247. package/src/templator/dist/genListViewBlock.js +84 -0
  248. package/src/templator/dist/genTableBlock.js +209 -0
  249. package/src/templator/dist/utils.js +527 -0
  250. package/src/templator/genEditTableBlock.ts +8 -16
  251. package/src/templator/genGetBlock.ts +18 -19
  252. package/src/templator/genGridViewBlock.ts +18 -18
  253. package/src/templator/genListViewBlock.ts +8 -11
  254. package/src/templator/genTableBlock.ts +6 -10
  255. package/ts-worker/dist/webpack.config.dev.js +3 -1
  256. package/ts-worker/lib/tsserver.js +8 -1
  257. package/out/automate/engine/2.14-components.d.ts +0 -1115
  258. package/out/automate/engine/2.14-components.js +0 -1087
  259. package/out/automate/engine/2.14-components.js.map +0 -1
  260. package/out/concepts/ConstructArgument__.d.ts +0 -40
  261. package/out/concepts/ConstructArgument__.js.map +0 -1
  262. package/out/concepts/Construct__.d.ts +0 -189
  263. package/out/concepts/Construct__.js +0 -340
  264. package/out/concepts/Construct__.js.map +0 -1
  265. package/out/concepts/MatchExpression__.d.ts +0 -97
  266. package/out/concepts/MatchExpression__.js +0 -281
  267. package/out/concepts/MatchExpression__.js.map +0 -1
  268. package/out/templator/sql-parser/index.d.ts +0 -1
  269. package/out/templator/sql-parser/index.js +0 -228
  270. package/out/templator/sql-parser/index.js.map +0 -1
  271. package/out/templator/sql-parser/parser.js +0 -26664
  272. package/out/templator/sql-parser/parser.js.map +0 -1
  273. package/src/concepts/dist/Anchor__.js +0 -179
  274. package/src/concepts/dist/Assignment__.js +0 -301
  275. package/src/concepts/dist/CallInterface__.js +0 -533
  276. package/src/concepts/dist/ForEachStatement__.js +0 -426
  277. package/src/concepts/dist/MatchCase__.js +0 -587
  278. package/src/concepts/dist/MemberExpression__.js +0 -348
  279. package/src/concepts/dist/Param__.js +0 -537
  280. package/src/concepts/dist/Return__.js +0 -493
  281. package/src/server/dist/formatTsUtils.js +0 -683
  282. package/ts-worker/lib/dist/tsserver.dev.js +0 -22953
  283. package/ts-worker/sources/lib/dist/tsserver.dev.js +0 -22912
@@ -1,8 +1,4 @@
1
- import {
2
- App, Module, View, Entity, Structure, Enum,
3
- uiStructures, collectionStructures, interfaceStructures, processStructures,
4
- Logic, Interface, Process,
5
- } from '../concepts';
1
+ import { App, Module, View } from '../concepts';
6
2
  import * as utils from '../utils';
7
3
  import { genHash, RawOptions } from '.';
8
4
  import { compileComponent } from './compileComponent';
@@ -13,6 +9,8 @@ import parserBabel = require('prettier/parser-babel');
13
9
 
14
10
  import * as UglifyJS from 'uglify-js-export';
15
11
 
12
+ import { genMetaData } from './genMetaData';
13
+
16
14
  export interface Route {
17
15
  path?: string;
18
16
  component?: RawOptions; // ExtendedVue<Vue, unknown, unknown, unknown, Record<never, any>>;
@@ -41,42 +39,11 @@ export function genBundleFiles(app: App,
41
39
  const fnLowcodeDomain = config?.envLcpDomain?.[config?.env]?.lcpDomain || config?.lowcodeDomain;
42
40
  const modules: Module[] = [];
43
41
  const views: View[] = [];
44
- const entities: Entity[] = [];
45
- const structures: Structure[] = [];
46
- const enums: Enum[] = [];
47
- const logics: Logic[] = [];
48
- const interfaces: Interface[] = [];
49
- const processes: Process[] = [];
50
-
51
- app.views && views.push(...app.views);
52
- if (Array.isArray(app.dataSources)) {
53
- app.dataSources.forEach((dataSource) => {
54
- if (Array.isArray(dataSource.entities)) {
55
- entities.push(...dataSource.entities);
56
- }
57
- });
58
- }
59
- app.structures && structures.push(...app.structures);
60
- app.enums && enums.push(...app.enums);
61
- app.logics && logics.push(...app.logics);
62
- app.processes && processes.push(...app.processes);
63
-
64
42
  app.dependencies && modules.push(...app.dependencies);
65
43
  app.interfaceDependencies && modules.push(...app.interfaceDependencies);
66
-
44
+ app.views && views.push(...app.views);
67
45
  modules.forEach((module: Module) => {
68
46
  module.views && views.push(...module.views);
69
- module.structures && structures.push(...module.structures);
70
- module.enums && enums.push(...module.enums);
71
- module.logics && logics.push(...module.logics);
72
- module.interfaces && interfaces.push(...module.interfaces);
73
- if (Array.isArray(module.dataSources)) {
74
- module.dataSources.forEach((dataSource) => {
75
- if (Array.isArray(dataSource.entities)) {
76
- entities.push(...dataSource.entities);
77
- }
78
- });
79
- }
80
47
  });
81
48
 
82
49
  const componentMap: {
@@ -95,31 +62,6 @@ export function genBundleFiles(app: App,
95
62
  * vue.config.js page options
96
63
  */
97
64
  const routes: Route[] = [];
98
- const dataTypes: (Entity | Structure | Enum)[] = [];
99
- const dataTypesMap: {
100
- [id: string]: Object;
101
- } = {};
102
- const frontendVariables = app.frontendVariables;
103
- const enumsMap: {
104
- [name: string]: {
105
- [label: string]: string;
106
- };
107
- } = {};
108
- const logicsMap: {
109
- [id: string]: {
110
- config: {
111
- serviceType: string;
112
- };
113
- url: {
114
- method: string;
115
- path: string;
116
- };
117
- };
118
- } = {};
119
- const _custom: {
120
- [id: string]: any;
121
- } = {};
122
- const allLogics: Logic[] = [];
123
65
  // 开启了权限的页面
124
66
  const authResourceViews: View[] = [];
125
67
  const baseResourcePaths: string[] = [];
@@ -218,10 +160,14 @@ export function genBundleFiles(app: App,
218
160
  let content = `{
219
161
  path: '${route.path}',\n`;
220
162
  if (route?.component?.script) {
163
+ let template = route.component.template;
164
+ if (config.env !== 'dev') {
165
+ template = template.replace(/[\t\r\n]/g, '');
166
+ }
221
167
  content += `component: (function(){
222
168
  var componentOptions = ${route.component.script ? '(function(){\n' + route.component.script.trim().replace(/export default |module\.exports +=/, 'return ') + '\n})()' : '{}'};
223
169
  Object.assign(componentOptions, {
224
- template: \`${route.component.template.replace(/[`$]/g, (m) => '\\' + m)}\`,
170
+ template: \`${template.replace(/[`$]/g, (m) => '\\' + m)}\`,
225
171
  });
226
172
  return componentOptions;
227
173
  })(),\n`;
@@ -250,93 +196,6 @@ export function genBundleFiles(app: App,
250
196
  }
251
197
  routesStr += ']';
252
198
 
253
- if (Array.isArray(enums)) {
254
- dataTypes.push(...enums);
255
- enums.forEach((node) => {
256
- let { name, enumItems } = node || {};
257
- if (node.module) {
258
- name = `extensions.${node.module.name}.enums.${name}`;
259
- }
260
- const enumObj: {
261
- [value: string]: string;
262
- } = {};
263
- enumItems.forEach(({ label, value }) => {
264
- enumObj[value] = label;
265
- });
266
- enumsMap[name] = enumObj;
267
- });
268
- }
269
-
270
- if (Array.isArray(entities)) {
271
- dataTypes.push(...entities);
272
- entities.forEach((entity) => {
273
- const ns = entity.ns;
274
- if (Array.isArray(ns?.logics)) {
275
- allLogics.push(...ns.logics);
276
- }
277
- });
278
- }
279
- if (Array.isArray(structures)) {
280
- dataTypes.push(...structures);
281
- }
282
-
283
- dataTypes.forEach((node) => {
284
- const namespace = node.getNamespace();
285
- const id = `${namespace}.${node.name}`;
286
- dataTypesMap[id] = node.toJSON?.();
287
- });
288
-
289
- [
290
- {
291
- namespace: 'nasl.ui',
292
- list: uiStructures,
293
- },
294
- {
295
- namespace: 'nasl.collection',
296
- list: collectionStructures,
297
- },
298
- {
299
- namespace: 'nasl.interface',
300
- list: interfaceStructures,
301
- },
302
- {
303
- namespace: 'nasl.process',
304
- list: processStructures,
305
- },
306
- ].forEach((item) => {
307
- const { namespace, list } = item || {};
308
- if (Array.isArray(list)) {
309
- list.forEach((node) => {
310
- const id = `${namespace}.${node.name}`;
311
- dataTypesMap[id] = node.toJSON?.();
312
- });
313
- }
314
- });
315
-
316
- if (Array.isArray(logics)) {
317
- allLogics.push(...logics);
318
- }
319
-
320
- allLogics.forEach((node) => {
321
- const namespace = node.getNamespace();
322
- const id = namespace ? `${namespace}.${node.name}` : node.name;
323
- logicsMap[id] = node.toService();
324
- });
325
-
326
- processes.forEach((process) => {
327
- if (Array.isArray(process.logics)) {
328
- process.logics.forEach((node) => {
329
- const namespace = node.getNamespace();
330
- const id = namespace ? `${namespace}.${node.name}` : node.name;
331
- logicsMap[id] = node.toProcessService();
332
- });
333
- }
334
- });
335
-
336
- interfaces.forEach((interfaceItem: Interface) => {
337
- _custom[`${interfaceItem.getNamespace()}.${interfaceItem.name}`] = interfaceItem.toService();
338
- });
339
-
340
199
  const platformConfig = JSON5.stringify({
341
200
  appConfig: {
342
201
  project: app.name,
@@ -364,61 +223,8 @@ export function genBundleFiles(app: App,
364
223
  miniEnable: config.miniEnable,
365
224
  }, null, 4);
366
225
 
367
- function collectTypeAnnotation(typeAnnotation: any) {
368
- if (typeAnnotation) {
369
- const { sortedTypeKey, properties, typeArguments } = typeAnnotation || {};
370
- if (!dataTypesMap[sortedTypeKey]) {
371
- dataTypesMap[sortedTypeKey] = typeAnnotation?.toJSON?.();
372
- }
373
- if (Array.isArray(properties)) {
374
- properties.forEach((property) => {
375
- collectTypeAnnotation(property?.typeAnnotation);
376
- });
377
- }
378
- if (Array.isArray(typeArguments)) {
379
- typeArguments.forEach((typeArg) => {
380
- collectTypeAnnotation(typeArg);
381
- });
382
- }
383
- }
384
- }
385
-
386
- utils.traverse((current) => {
387
- const { node } = current || {};
388
- const { concept } = node || {};
389
- let typeAnnotation;
390
- if (['Param', 'Variable', 'Return', 'CallFunction', 'CallInterface', 'CallLogic'].includes(concept)) {
391
- typeAnnotation = node.typeAnnotation || node.__TypeAnnotation;
392
- }
393
- collectTypeAnnotation(typeAnnotation);
394
- }, {
395
- node: {
396
- children: views,
397
- } as any,
398
- }, {
399
- mode: 'anyObject',
400
- excludedKeySet: new Set([
401
- 'parentNode',
402
- 'sourceMap',
403
- 'storageJSON',
404
- 'tsErrorDetail',
405
- 'NaslAnnotatedJSON',
406
- 'calledFrom',
407
- '_events',
408
- '_collectingList',
409
- '_historyList',
410
- ]),
411
- });
412
-
413
- const metaData = JSON5.stringify({
414
- frontendVariables,
415
- dataTypesMap,
416
- enumsMap,
417
- logicsMap,
418
- servicesMap: {
419
- _custom,
420
- },
421
- });
226
+ const metaData = genMetaData(app);
227
+ const metaDataStr = JSON5.stringify(metaData);
422
228
 
423
229
  const assetsInfo = app.genAllAssetsInfo(config.STATIC_URL);
424
230
  const customNames = JSON5.stringify(assetsInfo.custom.names);
@@ -456,7 +262,7 @@ export function genBundleFiles(app: App,
456
262
 
457
263
  content += `
458
264
  var platformConfig = ${platformConfig};
459
- var metaData = ${metaData};
265
+ var metaData = ${metaDataStr};
460
266
  var routes = ${routesStr};
461
267
 
462
268
  window.createLcapApp = () => window.appVM = window.cloudAdminDesigner.init(platformConfig.appConfig, platformConfig, routes, metaData);
@@ -465,19 +271,19 @@ export function genBundleFiles(app: App,
465
271
 
466
272
  if (config.env === 'dev') {
467
273
  // 加载资源js
468
- const domain = fnLowcodeDomain.slice(fnLowcodeDomain.indexOf('.') + 1);
469
- const targetUrl = `${typeof location !== 'undefined' ? location.origin : `http://${config.tenant}.${fnLowcodeDomain}`}/empty?url=${domain}&appid=${config.appid}`;
274
+ // const domain = fnLowcodeDomain.slice(fnLowcodeDomain.indexOf('.') + 1);
275
+ // const targetUrl = `${typeof location !== 'undefined' ? location.origin : `http://${config.tenant}.${fnLowcodeDomain}`}/empty?url=${domain}&appid=${config.appid}`;
276
+ // if(!document.querySelector("iframe[name='iframeEmpty']")){
277
+ // var el = document.createElement('iframe');
278
+ // el.setAttribute('src', "${targetUrl}");
279
+ // el.setAttribute('name', 'iframeEmpty');
280
+ // el.setAttribute('width', 0);
281
+ // el.setAttribute('height', 0);
282
+ // el.style.borderWidth = 0
283
+ // el.style.display= "block"
284
+ // document.getElementsByTagName('body')[0].appendChild(el);
285
+ // document.domain = '${domain}'
470
286
  const str = `
471
- if(!document.querySelector("iframe[name='iframeEmpty']")){
472
- var el = document.createElement('iframe');
473
- el.setAttribute('src', "${targetUrl}");
474
- el.setAttribute('name', 'iframeEmpty');
475
- el.setAttribute('width', 0);
476
- el.setAttribute('height', 0);
477
- el.style.borderWidth = 0
478
- el.style.display= "block"
479
- document.getElementsByTagName('body')[0].appendChild(el);
480
- document.domain = '${domain}'
481
287
  var _div = document.createElement('div');
482
288
  _div.classList = "div-load"
483
289
  _div.innerHTML = "<div class='loading-container'></div><div>正在更新最新发布内容...</div>"
@@ -527,7 +333,16 @@ export function genBundleFiles(app: App,
527
333
  }
528
334
  }\`
529
335
  document.getElementsByTagName('body')[0].appendChild(style);
530
- }
336
+ window.addEventListener('message', function (e) {
337
+ console.log('message:',e)
338
+ if(e.data ==="release-start"){
339
+ showLoading()
340
+ }
341
+ if(e.data==="release-end"){
342
+ hideLoading()
343
+ window.location.reload();
344
+ }
345
+ })
531
346
  `;
532
347
  content += str;
533
348
  }
@@ -1,58 +1,92 @@
1
- import { App, View, BaseNode, Module, Interface, Entity, Structure, Enum, uiStructures, collectionStructures, processStructures, Logic, Process, DataSource } from '../concepts';
2
-
3
- export function genMetaData(app: App,
4
- config: {
5
- tenant: string;
6
- env: string;
7
- nuimsDomain: string;
8
- envNuimsDomain: Object;
9
- STATIC_URL: string;
10
- USER_STATIC_URL: string;
11
- extendedConfig: string;
12
- lowcodeDomain: string;
13
- }) {
1
+ import {
2
+ App, Module, View, Entity, Structure, Enum,
3
+ uiStructures, collectionStructures, interfaceStructures, processStructures,
4
+ Logic, Interface, Process, BaseNode,
5
+ } from '../concepts';
6
+ import * as utils from '../utils';
7
+
8
+ // 生成typeKey
9
+ function genSortedTypeKey(typeAnnotation: any) {
10
+ const {
11
+ typeKind, typeNamespace, typeName,
12
+ typeArguments, properties,
13
+ } = typeAnnotation || {};
14
+ const typeKeyArr = [];
15
+ if (typeKind === 'union') { // 联合类型
16
+ if (Array.isArray(typeArguments)) {
17
+ // 按返回的每个具体项排序
18
+ const childTypeArgs: any = typeArguments.map((typeArg) => genSortedTypeKey(typeArg)).sort((name1, name2) => name1 > name2 ? 1 : -1);
19
+ typeKeyArr.push(childTypeArgs.join(' | '));
20
+ }
21
+ } else if (typeKind === 'anonymousStructure') { // 匿名数据结构
22
+ typeKeyArr.push('{');
23
+ if (Array.isArray(properties)) {
24
+ // 按匿名数据结构的key排序
25
+ const childTypeArgs: any = properties.sort(({ name: name1 }, { name: name2 }) => name1 > name2 ? 1 : -1).map((typeArg) => {
26
+ const { name: typeArgName, typeAnnotation: typeArgTypeAnnotation } = typeArg || {};
27
+ return `${typeArgName}: ${genSortedTypeKey(typeArgTypeAnnotation)}`;
28
+ });
29
+ typeKeyArr.push(childTypeArgs.join(', '));
30
+ }
31
+ typeKeyArr.push('}');
32
+ } else {
33
+ const typeArr = [];
34
+ typeNamespace && typeArr.push(typeNamespace);
35
+ typeName && typeArr.push(typeName);
36
+ const typeKey = typeArr.join('.');
37
+ typeKey && typeKeyArr.push(typeKey);
38
+ if (typeKind === 'generic') {
39
+ typeKeyArr.push('<');
40
+ if (Array.isArray(typeArguments)) {
41
+ // 必须按typeArguments定义的顺序,否则实参位置不对
42
+ const childTypeArgs: any = typeArguments.map((typeArg) => genSortedTypeKey(typeArg));
43
+ typeKeyArr.push(childTypeArgs.join(', '));
44
+ }
45
+ typeKeyArr.push('>');
46
+ }
47
+ }
48
+ return typeKeyArr.join('');
49
+ }
50
+
51
+ export function genMetaData(app: App) {
14
52
  const modules: Module[] = [];
15
53
  const views: View[] = [];
16
- const dataSources: DataSource[] = [];
54
+ const entities: Entity[] = [];
17
55
  const structures: Structure[] = [];
18
56
  const enums: Enum[] = [];
19
57
  const logics: Logic[] = [];
20
58
  const interfaces: Interface[] = [];
21
59
  const processes: Process[] = [];
22
60
 
23
- const {
24
- dataSources: appDataSources = [],
25
- structures: appStructures = [],
26
- enums: appEnums = [],
27
- logics: appLogics = [],
28
- interfaceDependencies: appInterfaceDependencies = [],
29
- dependencies: appDependencies = [],
30
- processes: appProcesses = [],
31
- } = app || {};
32
- dataSources.push(...appDataSources);
33
- structures.push(...appStructures);
34
- enums.push(...appEnums);
35
- logics.push(...appLogics);
36
- processes.push(...appProcesses);
37
- if (Array.isArray(appDependencies)) {
38
- modules.push(...appDependencies);
39
- }
40
- if (Array.isArray(appInterfaceDependencies)) {
41
- modules.push(...appInterfaceDependencies);
61
+ app.views && views.push(...app.views);
62
+ if (Array.isArray(app.dataSources)) {
63
+ app.dataSources.forEach((dataSource) => {
64
+ if (Array.isArray(dataSource.entities)) {
65
+ entities.push(...dataSource.entities);
66
+ }
67
+ });
42
68
  }
69
+ app.structures && structures.push(...app.structures);
70
+ app.enums && enums.push(...app.enums);
71
+ app.logics && logics.push(...app.logics);
72
+ app.processes && processes.push(...app.processes);
73
+
74
+ app.dependencies && modules.push(...app.dependencies);
75
+ app.interfaceDependencies && modules.push(...app.interfaceDependencies);
76
+
43
77
  modules.forEach((module: Module) => {
44
- const {
45
- views: moduleViews = [],
46
- structures: moduleStructures = [],
47
- enums: moduleEnums = [],
48
- logics: moduleLogics = [],
49
- interfaces: moduleInterfaces = [],
50
- } = module;
51
- views.push(...moduleViews);
52
- structures.push(...moduleStructures);
53
- enums.push(...moduleEnums);
54
- logics.push(...moduleLogics);
55
- interfaces.push(...moduleInterfaces);
78
+ module.views && views.push(...module.views);
79
+ module.structures && structures.push(...module.structures);
80
+ module.enums && enums.push(...module.enums);
81
+ module.logics && logics.push(...module.logics);
82
+ module.interfaces && interfaces.push(...module.interfaces);
83
+ if (Array.isArray(module.dataSources)) {
84
+ module.dataSources.forEach((dataSource) => {
85
+ if (Array.isArray(dataSource.entities)) {
86
+ entities.push(...dataSource.entities);
87
+ }
88
+ });
89
+ }
56
90
  });
57
91
  const dataTypes: (Entity | Structure | Enum)[] = [];
58
92
 
@@ -80,6 +114,7 @@ export function genMetaData(app: App,
80
114
  [id: string]: any;
81
115
  } = {};
82
116
  const allLogics: Logic[] = [];
117
+
83
118
  if (Array.isArray(enums)) {
84
119
  dataTypes.push(...enums);
85
120
  enums.forEach((node) => {
@@ -96,17 +131,17 @@ export function genMetaData(app: App,
96
131
  enumsMap[name] = enumObj;
97
132
  });
98
133
  }
99
- if (Array.isArray(dataSources)) {
100
- dataSources.forEach((dataSource) => {
101
- dataSource.entities.forEach((entity) => {
102
- dataTypes.push(entity);
103
- const ns = entity.ns;
104
- if (Array.isArray(ns?.logics)) {
105
- allLogics.push(...ns.logics);
106
- }
107
- });
134
+
135
+ if (Array.isArray(entities)) {
136
+ dataTypes.push(...entities);
137
+ entities.forEach((entity) => {
138
+ const ns = entity.ns;
139
+ if (Array.isArray(ns?.logics)) {
140
+ allLogics.push(...ns.logics);
141
+ }
108
142
  });
109
143
  }
144
+
110
145
  if (Array.isArray(structures)) {
111
146
  dataTypes.push(...structures);
112
147
  }
@@ -114,31 +149,47 @@ export function genMetaData(app: App,
114
149
  dataTypes.forEach((node) => {
115
150
  const namespace = node.getNamespace();
116
151
  const id = `${namespace}.${node.name}`;
117
- dataTypesMap[id] = node;
152
+ dataTypesMap[id] = node.toJSON?.();
153
+ const { properties } = (node) as any;
154
+ if (Array.isArray(properties)) {
155
+ properties.forEach((property) => {
156
+ collectTypeAnnotation(property?.typeAnnotation);
157
+ });
158
+ }
118
159
  });
119
- if (Array.isArray(uiStructures)) {
120
- const namespace = 'nasl.ui';
121
- uiStructures.forEach((node) => {
122
- const id = `${namespace}.${node.name}`;
123
- dataTypesMap[id] = node;
124
- });
125
- }
126
160
 
127
- if (Array.isArray(collectionStructures)) {
128
- const namespace = 'nasl.collection';
129
- collectionStructures.forEach((node) => {
130
- const id = `${namespace}.${node.name}`;
131
- dataTypesMap[id] = node;
132
- });
133
- }
134
-
135
- if (Array.isArray(processStructures)) {
136
- const namespace = 'nasl.process';
137
- processStructures.forEach((node) => {
138
- const id = `${namespace}.${node.name}`;
139
- dataTypesMap[id] = node;
140
- });
141
- }
161
+ [
162
+ {
163
+ namespace: 'nasl.ui',
164
+ list: uiStructures,
165
+ },
166
+ {
167
+ namespace: 'nasl.collection',
168
+ list: collectionStructures,
169
+ },
170
+ {
171
+ namespace: 'nasl.interface',
172
+ list: interfaceStructures,
173
+ },
174
+ {
175
+ namespace: 'nasl.process',
176
+ list: processStructures,
177
+ },
178
+ ].forEach((item) => {
179
+ const { namespace, list } = item || {};
180
+ if (Array.isArray(list)) {
181
+ list.forEach((node) => {
182
+ const id = `${namespace}.${node.name}`;
183
+ dataTypesMap[id] = node.toJSON?.();
184
+ const { properties } = (node) as any;
185
+ if (Array.isArray(properties)) {
186
+ properties.forEach((property) => {
187
+ collectTypeAnnotation(property?.typeAnnotation);
188
+ });
189
+ }
190
+ });
191
+ }
192
+ });
142
193
 
143
194
  if (Array.isArray(logics)) {
144
195
  allLogics.push(...logics);
@@ -164,6 +215,55 @@ export function genMetaData(app: App,
164
215
  _custom[`${interfaceItem.getNamespace()}.${interfaceItem.name}`] = interfaceItem.toService();
165
216
  });
166
217
 
218
+ utils.traverse((current) => {
219
+ const { node } = current || {};
220
+ collectTypeAnnotation(node?.typeAnnotation || node?.__TypeAnnotation);
221
+ }, {
222
+ node: {
223
+ children: views,
224
+ } as any,
225
+ }, {
226
+ mode: 'anyObject',
227
+ excludedKeySet: new Set([
228
+ 'parentNode',
229
+ 'sourceMap',
230
+ 'storageJSON',
231
+ 'tsErrorDetail',
232
+ 'NaslAnnotatedJSON',
233
+ 'calledFrom',
234
+ '_events',
235
+ '_collectingList',
236
+ '_historyList',
237
+ ]),
238
+ });
239
+
240
+ if (Array.isArray(frontendVariables)) {
241
+ frontendVariables.forEach((frontendVariable) => {
242
+ const typeAnnotation = frontendVariable.typeAnnotation || frontendVariable.__TypeAnnotation;
243
+ collectTypeAnnotation(typeAnnotation);
244
+ });
245
+ }
246
+
247
+ function collectTypeAnnotation(typeAnnotation: any) {
248
+ if (typeAnnotation) {
249
+ const sortedTypeKey = genSortedTypeKey(typeAnnotation);
250
+ if (!dataTypesMap[sortedTypeKey]) {
251
+ dataTypesMap[sortedTypeKey] = typeAnnotation?.toJSON?.() ?? typeAnnotation;
252
+ const { properties, typeArguments } = (dataTypesMap[sortedTypeKey] || {}) as any;
253
+ if (Array.isArray(properties)) {
254
+ properties.forEach((property) => {
255
+ collectTypeAnnotation(property?.typeAnnotation);
256
+ });
257
+ }
258
+ if (Array.isArray(typeArguments)) {
259
+ typeArguments.forEach((typeArg) => {
260
+ collectTypeAnnotation(typeArg);
261
+ });
262
+ }
263
+ }
264
+ }
265
+ }
266
+
167
267
  return {
168
268
  frontendVariables,
169
269
  dataTypesMap,