@blocklet/meta 1.7.24 → 1.7.27
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/lib/has-reserved-key.js +14 -0
- package/lib/parse-navigation.js +26 -9
- package/lib/schema.js +25 -4
- package/package.json +13 -13
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const { BLOCKLET_CONFIGURABLE_KEY } = require('./constants');
|
|
2
|
+
|
|
3
|
+
const hasReservedKey = (environments) =>
|
|
4
|
+
environments.some((x) => {
|
|
5
|
+
const key = (x.key || x.name || '').toString();
|
|
6
|
+
|
|
7
|
+
if (key.startsWith('ABT_NODE_')) {
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
return !!(key.startsWith('BLOCKLET_') && !BLOCKLET_CONFIGURABLE_KEY[key]);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
module.exports = hasReservedKey;
|
package/lib/parse-navigation.js
CHANGED
|
@@ -22,6 +22,14 @@ const parseNavigation = (navigation, blocklet, prefix = '/', _level = 1) => {
|
|
|
22
22
|
title: nav.title,
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
+
if (_level === 1 && nav.section) {
|
|
26
|
+
item.section = nav.section;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (nav.icon) {
|
|
30
|
+
item.icon = nav.icon;
|
|
31
|
+
}
|
|
32
|
+
|
|
25
33
|
if (nav.link) {
|
|
26
34
|
item.link = nav.link.startsWith('/') ? normalizePathPrefix(`${prefix}${nav.link || '/'}`) : nav.link;
|
|
27
35
|
} else {
|
|
@@ -50,19 +58,28 @@ const parseNavigation = (navigation, blocklet, prefix = '/', _level = 1) => {
|
|
|
50
58
|
}
|
|
51
59
|
const childTitle = child.meta.title || child.meta.name;
|
|
52
60
|
|
|
61
|
+
const item = {
|
|
62
|
+
title: nav.title || childTitle,
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
if (_level === 1 && nav.section) {
|
|
66
|
+
item.section = nav.section;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (nav.icon) {
|
|
70
|
+
item.icon = nav.icon;
|
|
71
|
+
}
|
|
72
|
+
|
|
53
73
|
const childNavigation = get(child, 'meta.navigation', []);
|
|
54
74
|
if (!childNavigation.length) {
|
|
55
75
|
// child does not declares menu
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
link: normalizePathPrefix(`${prefix}${child.mountPoint || '/'}`),
|
|
59
|
-
});
|
|
76
|
+
item.link = normalizePathPrefix(`${prefix}${child.mountPoint || '/'}`);
|
|
77
|
+
result.push(item);
|
|
60
78
|
} else if (childNavigation.length === 1) {
|
|
61
79
|
// child declares one menu
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
});
|
|
80
|
+
item.title = nav.title || childNavigation[0].title || childTitle;
|
|
81
|
+
item.link = normalizePathPrefix(`${prefix}${child.mountPoint}${childNavigation[0].link || '/'}`);
|
|
82
|
+
result.push(item);
|
|
66
83
|
} else {
|
|
67
84
|
// child declares multiple menus
|
|
68
85
|
const list = parseNavigation(
|
|
@@ -75,7 +92,7 @@ const parseNavigation = (navigation, blocklet, prefix = '/', _level = 1) => {
|
|
|
75
92
|
if (_level === 1) { // eslint-disable-line
|
|
76
93
|
// primary menu
|
|
77
94
|
result.push({
|
|
78
|
-
|
|
95
|
+
...item,
|
|
79
96
|
items: list,
|
|
80
97
|
});
|
|
81
98
|
} else {
|
package/lib/schema.js
CHANGED
|
@@ -228,9 +228,19 @@ const signatureSchema = Joi.object({
|
|
|
228
228
|
});
|
|
229
229
|
|
|
230
230
|
const navigationItemSchema = Joi.object({
|
|
231
|
-
title: Joi.
|
|
232
|
-
|
|
233
|
-
|
|
231
|
+
title: Joi.alternatives()
|
|
232
|
+
.try(
|
|
233
|
+
Joi.string(),
|
|
234
|
+
Joi.object({
|
|
235
|
+
zh: Joi.string(),
|
|
236
|
+
en: Joi.string(),
|
|
237
|
+
}).min(1)
|
|
238
|
+
)
|
|
239
|
+
.required(),
|
|
240
|
+
link: Joi.string().min(1),
|
|
241
|
+
child: Joi.string().min(1), // child name or child did
|
|
242
|
+
section: Joi.array().items(Joi.string().min(1)).single(),
|
|
243
|
+
icon: Joi.string().min(1),
|
|
234
244
|
});
|
|
235
245
|
|
|
236
246
|
const navigationSchema = Joi.array().items(
|
|
@@ -240,7 +250,14 @@ const navigationSchema = Joi.array().items(
|
|
|
240
250
|
);
|
|
241
251
|
|
|
242
252
|
const themeSchema = Joi.object({
|
|
243
|
-
background: Joi.
|
|
253
|
+
background: Joi.alternatives().try(
|
|
254
|
+
Joi.string().min(1),
|
|
255
|
+
Joi.object({
|
|
256
|
+
header: Joi.string().min(1),
|
|
257
|
+
footer: Joi.string().min(1),
|
|
258
|
+
default: Joi.string().min(1),
|
|
259
|
+
}).min(1)
|
|
260
|
+
),
|
|
244
261
|
});
|
|
245
262
|
|
|
246
263
|
const createBlockletSchema = (
|
|
@@ -436,6 +453,10 @@ const createBlockletSchema = (
|
|
|
436
453
|
// navigation & theme
|
|
437
454
|
navigation: navigationSchema,
|
|
438
455
|
theme: themeSchema,
|
|
456
|
+
copyright: Joi.object({
|
|
457
|
+
owner: Joi.string().min(1),
|
|
458
|
+
year: Joi.alternatives().try(Joi.string(), Joi.number()),
|
|
459
|
+
}),
|
|
439
460
|
|
|
440
461
|
// NOTE: following fields only exist in blocklet server and cannot be set manually
|
|
441
462
|
bundleName: Joi.string(),
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.7.
|
|
6
|
+
"version": "1.7.27",
|
|
7
7
|
"description": "Library to parse/validate/fix blocklet meta",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -18,17 +18,17 @@
|
|
|
18
18
|
"author": "wangshijun <wangshijun2020@gmail.com> (http://github.com/wangshijun)",
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@abtnode/constant": "1.7.
|
|
22
|
-
"@abtnode/util": "1.7.
|
|
23
|
-
"@arcblock/did": "
|
|
24
|
-
"@arcblock/did-ext": "
|
|
25
|
-
"@arcblock/did-util": "
|
|
26
|
-
"@arcblock/jwt": "
|
|
27
|
-
"@arcblock/nft": "
|
|
28
|
-
"@ocap/asset": "
|
|
29
|
-
"@ocap/mcrypto": "
|
|
30
|
-
"@ocap/util": "
|
|
31
|
-
"@ocap/wallet": "
|
|
21
|
+
"@abtnode/constant": "1.7.27",
|
|
22
|
+
"@abtnode/util": "1.7.27",
|
|
23
|
+
"@arcblock/did": "1.17.0",
|
|
24
|
+
"@arcblock/did-ext": "1.17.0",
|
|
25
|
+
"@arcblock/did-util": "1.17.0",
|
|
26
|
+
"@arcblock/jwt": "1.17.0",
|
|
27
|
+
"@arcblock/nft": "1.17.0",
|
|
28
|
+
"@ocap/asset": "1.17.0",
|
|
29
|
+
"@ocap/mcrypto": "1.17.0",
|
|
30
|
+
"@ocap/util": "1.17.0",
|
|
31
|
+
"@ocap/wallet": "1.17.0",
|
|
32
32
|
"ajv": "^8.11.0",
|
|
33
33
|
"cjk-length": "^1.0.0",
|
|
34
34
|
"debug": "^4.3.3",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"jest": "^27.4.5"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "81a5492df66389b0aede13f033d1e493450833bc"
|
|
51
51
|
}
|