@blocklet/meta 1.8.25 → 1.8.26
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/file.js +6 -1
- package/lib/parse-navigation.js +4 -2
- package/lib/parse.js +5 -0
- package/lib/payment/v2.js +3 -1
- package/lib/schema.js +6 -4
- package/package.json +4 -4
package/lib/file.js
CHANGED
|
@@ -21,7 +21,12 @@ const select = (dir, { throwOnError = true } = {}) => {
|
|
|
21
21
|
return metaToUpdate;
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
const update = (file, meta) => {
|
|
24
|
+
const update = (file, meta, { fix = true } = {}) => {
|
|
25
|
+
if (!fix) {
|
|
26
|
+
fs.writeFileSync(file, yaml.dump(meta, { sortKeys: false, skipInvalid: true }));
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
|
|
25
30
|
delete meta.path;
|
|
26
31
|
delete meta.folder;
|
|
27
32
|
delete meta.htmlAst;
|
package/lib/parse-navigation.js
CHANGED
|
@@ -40,6 +40,8 @@ const getGroups = (navigation) => {
|
|
|
40
40
|
return Object.values(groups);
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
+
const getChildName = (nav) => nav.component || nav.child;
|
|
44
|
+
|
|
43
45
|
/**
|
|
44
46
|
* @param {*} navigation src
|
|
45
47
|
* @param {*} blocklet
|
|
@@ -50,7 +52,7 @@ const doParseNavigation = (navigation, blocklet, prefix = '/', _level = 1) => {
|
|
|
50
52
|
const result = [];
|
|
51
53
|
|
|
52
54
|
(navigation || []).forEach((nav) => {
|
|
53
|
-
if (!nav
|
|
55
|
+
if (!getChildName(nav)) {
|
|
54
56
|
if (_level > 1 && nav.items?.length) {
|
|
55
57
|
const list = doParseNavigation(nav.items, blocklet, prefix, _level + 1);
|
|
56
58
|
result.push(...list);
|
|
@@ -95,7 +97,7 @@ const doParseNavigation = (navigation, blocklet, prefix = '/', _level = 1) => {
|
|
|
95
97
|
}
|
|
96
98
|
|
|
97
99
|
// parse child
|
|
98
|
-
const child = (blocklet.children || []).find((x) => [x.meta.name, x.meta.did].includes(nav
|
|
100
|
+
const child = (blocklet.children || []).find((x) => [x.meta.name, x.meta.did].includes(getChildName(nav)));
|
|
99
101
|
if (!child) {
|
|
100
102
|
return;
|
|
101
103
|
}
|
package/lib/parse.js
CHANGED
|
@@ -28,6 +28,7 @@ const parse = (
|
|
|
28
28
|
extraRawAttrs = {},
|
|
29
29
|
serviceMetas,
|
|
30
30
|
schemaOptions = {},
|
|
31
|
+
fix = true,
|
|
31
32
|
} = {}
|
|
32
33
|
) => {
|
|
33
34
|
let result = {};
|
|
@@ -57,6 +58,10 @@ const parse = (
|
|
|
57
58
|
result = Object.assign(result, extraRawAttrs);
|
|
58
59
|
}
|
|
59
60
|
|
|
61
|
+
if (!fix) {
|
|
62
|
+
return result;
|
|
63
|
+
}
|
|
64
|
+
|
|
60
65
|
// Fix
|
|
61
66
|
fixRequired(result, dir);
|
|
62
67
|
fixRepository(result);
|
package/lib/payment/v2.js
CHANGED
|
@@ -24,6 +24,8 @@ const ZeroBN = new BN(0);
|
|
|
24
24
|
const defaultDecimals = 1e6; // we only support 6 decimals on share ratio
|
|
25
25
|
const defaultDecimalsBN = new BN(defaultDecimals);
|
|
26
26
|
|
|
27
|
+
const getComponentConfig = (meta) => meta.components || meta.children;
|
|
28
|
+
|
|
27
29
|
const safeMul = (a, b) =>
|
|
28
30
|
Number(
|
|
29
31
|
fromUnitToToken(
|
|
@@ -68,7 +70,7 @@ const _getComponents = async (inputMeta, context = {}) => {
|
|
|
68
70
|
throw new Error('The depth of component should not exceed 40');
|
|
69
71
|
}
|
|
70
72
|
|
|
71
|
-
const configs = inputMeta
|
|
73
|
+
const configs = getComponentConfig(inputMeta);
|
|
72
74
|
|
|
73
75
|
if (!configs || !configs.length) {
|
|
74
76
|
return [];
|
package/lib/schema.js
CHANGED
|
@@ -245,11 +245,11 @@ const navigationItemSchema = Joi.object({
|
|
|
245
245
|
en: Joi.string(),
|
|
246
246
|
}).min(1)
|
|
247
247
|
),
|
|
248
|
-
|
|
248
|
+
component: Joi.string().min(1), // child name or child did
|
|
249
249
|
section: Joi.array().items(Joi.string().min(1)).single(),
|
|
250
250
|
role: Joi.array().items(Joi.string().min(1)).single(),
|
|
251
251
|
icon: Joi.string().min(1),
|
|
252
|
-
});
|
|
252
|
+
}).rename('child', 'component');
|
|
253
253
|
|
|
254
254
|
const navigationSchema = Joi.array().items(
|
|
255
255
|
navigationItemSchema.append({
|
|
@@ -487,7 +487,7 @@ const createBlockletSchema = (
|
|
|
487
487
|
lastPublishedAt: Joi.string().isoDate().optional(),
|
|
488
488
|
|
|
489
489
|
// blocklet component support
|
|
490
|
-
|
|
490
|
+
components: Joi.array().items(childrenSchema).unique('name').optional().default([]),
|
|
491
491
|
|
|
492
492
|
// navigation & theme
|
|
493
493
|
navigation: navigationSchema,
|
|
@@ -501,7 +501,9 @@ const createBlockletSchema = (
|
|
|
501
501
|
bundleName: Joi.string(),
|
|
502
502
|
bundleDid: Joi.DID().trim(),
|
|
503
503
|
storeId: Joi.string(),
|
|
504
|
-
})
|
|
504
|
+
})
|
|
505
|
+
.options({ stripUnknown: true, noDefaults: false, ...schemaOptions })
|
|
506
|
+
.rename('children', 'components');
|
|
505
507
|
};
|
|
506
508
|
|
|
507
509
|
module.exports = {
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.8.
|
|
6
|
+
"version": "1.8.26",
|
|
7
7
|
"description": "Library to parse/validate/fix blocklet meta",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
"author": "wangshijun <wangshijun2020@gmail.com> (http://github.com/wangshijun)",
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@abtnode/constant": "1.8.
|
|
22
|
-
"@abtnode/util": "1.8.
|
|
21
|
+
"@abtnode/constant": "1.8.26",
|
|
22
|
+
"@abtnode/util": "1.8.26",
|
|
23
23
|
"@arcblock/did": "1.17.19",
|
|
24
24
|
"@arcblock/did-ext": "1.17.19",
|
|
25
25
|
"@arcblock/did-util": "1.17.19",
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"express": "^4.18.1",
|
|
54
54
|
"jest": "^27.5.1"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "71937dabc196a98a1bb514789bc32aee44a1e8c4"
|
|
57
57
|
}
|