@lcap/nasl 0.3.12-beta.3 → 0.3.12

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lcap/nasl",
3
3
  "description": "NetEase Application Specific Language",
4
- "version": "0.3.12-beta.3",
4
+ "version": "0.3.12",
5
5
  "author": "Forrest <rainforest92@126.com>",
6
6
  "scripts": {
7
7
  "dev": "tsc -watch -p ./",
@@ -20,12 +20,32 @@ export const dataTypesMap: { [name: string]: Schema } = {
20
20
  };
21
21
 
22
22
  export function updateDataTypeList() {
23
- dataTypeList[1].children = Object.keys(dataTypesMap)
23
+ const typeMap: any = {};
24
+ Object.keys(dataTypesMap)
24
25
  .filter((key) => !key.includes('#/basicTypes') && !key.includes('#/systemTypes') && !key.includes('#/genericTypes'))
25
- .map((key) => {
26
- const dataType = dataTypesMap[key];
27
- return { kind: (dataType as any).level, text: dataType.name, value: key };
26
+ .forEach((key) => {
27
+ const { level, name, createdTime }: any = dataTypesMap[key];
28
+ // 数据分类
29
+ if (!typeMap[level]) {
30
+ typeMap[level] = [];
31
+ }
32
+
33
+ typeMap[level].push({ kind: level, text: name, value: key, createdTime });
34
+ });
35
+
36
+ // 实体按创建时间排序
37
+ if (typeMap.entity) {
38
+ typeMap.entity.sort((a: any, b: any) => {
39
+ // 刚创建的实体createdTime没有值。。。
40
+ if (!a.createdTime) {
41
+ return -1;
42
+ }
43
+ return b.createdTime - a.createdTime;
28
44
  });
45
+ }
46
+
47
+ const children = Object.keys(typeMap).reduce((result, type) => result.concat(typeMap[type]), []);
48
+ dataTypeList[1].children = children;
29
49
  }
30
50
 
31
51
  export function properties2PropertyList(definition: any) {