@blocklet/meta 1.8.10 → 1.8.13

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.
@@ -1,4 +1,5 @@
1
1
  const get = require('lodash/get');
2
+ const cloneDeep = require('lodash/cloneDeep');
2
3
  const isEqual = require('lodash/isEqual');
3
4
  const normalizePathPrefix = require('@abtnode/util/lib/normalize-path-prefix');
4
5
 
@@ -16,6 +17,29 @@ const parseLink = (input, prefix) => {
16
17
  return parseLinkString(input, prefix);
17
18
  };
18
19
 
20
+ const getGroups = (navigation) => {
21
+ const groups = {};
22
+ for (const nav of navigation) {
23
+ const sections = !nav.section || !nav.section.length ? ['__undefined__'] : nav.section;
24
+ for (const sec of sections) {
25
+ if (!groups[sec]) {
26
+ groups[sec] = [];
27
+ }
28
+
29
+ const item = {
30
+ ...nav,
31
+ };
32
+
33
+ if (nav.section) {
34
+ item.section = sec === '__undefined__' ? [] : [sec];
35
+ }
36
+
37
+ groups[sec].push(item);
38
+ }
39
+ }
40
+ return Object.values(groups);
41
+ };
42
+
19
43
  /**
20
44
  * @param {*} navigation src
21
45
  * @param {*} blocklet
@@ -37,7 +61,7 @@ const doParseNavigation = (navigation, blocklet, prefix = '/', _level = 1) => {
37
61
  title: nav.title,
38
62
  };
39
63
 
40
- if (_level === 1 && nav.section) {
64
+ if (nav.section) {
41
65
  item.section = nav.section;
42
66
  }
43
67
 
@@ -77,50 +101,76 @@ const doParseNavigation = (navigation, blocklet, prefix = '/', _level = 1) => {
77
101
  }
78
102
  const childTitle = child.meta.title || child.meta.name;
79
103
 
80
- const item = {
104
+ const itemProto = {
81
105
  title: nav.title || childTitle,
82
106
  };
83
107
 
84
- if (_level === 1 && nav.section) {
85
- item.section = nav.section;
108
+ if (nav.section) {
109
+ itemProto.section = nav.section;
86
110
  }
87
111
 
88
112
  if (nav.icon) {
89
- item.icon = nav.icon;
113
+ itemProto.icon = nav.icon;
90
114
  }
91
115
 
92
116
  if (nav.role) {
93
- item.role = nav.role;
117
+ itemProto.role = nav.role;
94
118
  }
95
119
 
96
- const childNavigation = get(child, 'meta.navigation', []);
97
- if (!childNavigation.length) {
120
+ // get groups by section
121
+ const groups = getGroups(get(child, 'meta.navigation', []));
122
+
123
+ if (!groups.length) {
98
124
  // child does not declares menu
125
+ const item = cloneDeep(itemProto);
99
126
  item.link = parseLink(child.mountPoint || '/', prefix);
100
127
  result.push(item);
101
- } else if (childNavigation.length === 1) {
102
- // child declares one menu
103
- item.title = nav.title || childNavigation[0].title || childTitle;
104
- item.link = parseLink(childNavigation[0].link || '/', normalizePathPrefix(`${prefix}${child.mountPoint}`));
105
- result.push(item);
106
128
  } else {
107
- // child declares multiple menus
108
- const list = doParseNavigation(
109
- childNavigation,
110
- child,
111
- normalizePathPrefix(`${prefix}${child.mountPoint}`),
112
- _level + 1
113
- );
114
-
115
- if (_level === 1) { // eslint-disable-line
116
- // primary menu
117
- result.push({
118
- ...item,
119
- items: list,
120
- });
121
- } else {
122
- // secondary menu
123
- result.push(...list);
129
+ for (const childNavigation of groups) {
130
+ if (childNavigation.length === 1) {
131
+ // child declares one menu
132
+ const childNav = childNavigation[0];
133
+
134
+ const item = cloneDeep(itemProto);
135
+
136
+ item.title = nav.title || childNav.title || childTitle;
137
+
138
+ if (childNav.icon) {
139
+ item.icon = item.icon || childNav.icon;
140
+ }
141
+
142
+ if (childNav.role) {
143
+ item.role = item.icon || childNav.role;
144
+ }
145
+
146
+ if (childNav.section) {
147
+ item.section = item.section || childNav.section;
148
+ }
149
+
150
+ item.link = parseLink(childNavigation[0].link || '/', normalizePathPrefix(`${prefix}${child.mountPoint}`));
151
+ result.push(item);
152
+ } else {
153
+ // child declares multiple menus
154
+ const list = doParseNavigation(
155
+ childNavigation,
156
+ child,
157
+ normalizePathPrefix(`${prefix}${child.mountPoint}`),
158
+ _level + 1
159
+ );
160
+
161
+ if (_level === 1) { // eslint-disable-line
162
+ // primary menu
163
+ const item = cloneDeep(itemProto);
164
+ item.items = list;
165
+ result.push({
166
+ ...item,
167
+ items: list,
168
+ });
169
+ } else {
170
+ // secondary menu
171
+ result.push(...list);
172
+ }
173
+ }
124
174
  }
125
175
  }
126
176
  });
package/lib/payment.js CHANGED
@@ -72,9 +72,10 @@ const createNftFactoryItx = ({ meta, tokens, shares, issuers, serviceUrl }) => {
72
72
  ],
73
73
  };
74
74
 
75
+ itx.address = toFactoryAddress(itx);
76
+
75
77
  isValidFactory(itx, true);
76
78
 
77
- itx.address = toFactoryAddress(itx);
78
79
  return itx;
79
80
  };
80
81
 
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.8.10",
6
+ "version": "1.8.13",
7
7
  "description": "Library to parse/validate/fix blocklet meta",
8
8
  "main": "lib/index.js",
9
9
  "files": [
@@ -18,16 +18,16 @@
18
18
  "author": "wangshijun <wangshijun2020@gmail.com> (http://github.com/wangshijun)",
19
19
  "license": "MIT",
20
20
  "dependencies": {
21
- "@abtnode/constant": "1.8.10",
22
- "@abtnode/util": "1.8.10",
23
- "@arcblock/did": "1.17.11",
24
- "@arcblock/did-ext": "1.17.11",
25
- "@arcblock/did-util": "1.17.11",
26
- "@arcblock/jwt": "1.17.11",
27
- "@ocap/asset": "1.17.11",
28
- "@ocap/mcrypto": "1.17.11",
29
- "@ocap/util": "1.17.11",
30
- "@ocap/wallet": "1.17.11",
21
+ "@abtnode/constant": "1.8.13",
22
+ "@abtnode/util": "1.8.13",
23
+ "@arcblock/did": "1.17.15",
24
+ "@arcblock/did-ext": "1.17.15",
25
+ "@arcblock/did-util": "1.17.15",
26
+ "@arcblock/jwt": "1.17.15",
27
+ "@ocap/asset": "1.17.15",
28
+ "@ocap/mcrypto": "1.17.15",
29
+ "@ocap/util": "1.17.15",
30
+ "@ocap/wallet": "1.17.15",
31
31
  "ajv": "^8.11.0",
32
32
  "cjk-length": "^1.0.0",
33
33
  "debug": "^4.3.4",
@@ -46,5 +46,5 @@
46
46
  "devDependencies": {
47
47
  "jest": "^27.5.1"
48
48
  },
49
- "gitHead": "84f655bd7b8d55fde2656fac8671faad3c3bde28"
49
+ "gitHead": "028f33d8a3a4f999456bfe8e7bd2e1a53b664b47"
50
50
  }