@blocklet/meta 1.6.27 → 1.6.30
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/util.js +19 -25
- package/package.json +10 -10
package/lib/util.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable no-await-in-loop */
|
|
2
2
|
const get = require('lodash/get');
|
|
3
3
|
|
|
4
|
-
const { BlockletGroup } = require('./constants');
|
|
4
|
+
const { BlockletGroup, fromBlockletStatus, fromBlockletSource } = require('./constants');
|
|
5
5
|
|
|
6
6
|
const forEachBlocklet = (blocklet, cb, { parallel = false, sync } = {}) => {
|
|
7
7
|
// sync
|
|
@@ -47,33 +47,12 @@ const forEachBlocklet = (blocklet, cb, { parallel = false, sync } = {}) => {
|
|
|
47
47
|
|
|
48
48
|
const forEachBlockletSync = (blocklet, cb) => forEachBlocklet(blocklet, cb, { sync: true });
|
|
49
49
|
|
|
50
|
-
const isAuthServiceEnabled = (blocklet) => {
|
|
51
|
-
const interfaces = get(blocklet, 'meta.interfaces') || [];
|
|
52
|
-
const isRootEnabled = interfaces.some((x) => {
|
|
53
|
-
const services = get(x, 'services') || [];
|
|
54
|
-
return services.some((s) => s.name === '@abtnode/auth-service');
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
if (isRootEnabled) {
|
|
58
|
-
return true;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const children = get(blocklet, 'children') || [];
|
|
62
|
-
for (const child of children) {
|
|
63
|
-
if (isAuthServiceEnabled(child)) {
|
|
64
|
-
return true;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return false;
|
|
69
|
-
};
|
|
70
|
-
|
|
71
50
|
const getRequiredMissingConfigs = (blocklet) => {
|
|
72
51
|
const missingConfigs = [];
|
|
73
52
|
const configs = blocklet.configs || [];
|
|
74
53
|
configs.forEach((item) => {
|
|
75
54
|
if (item.required && !item.value) {
|
|
76
|
-
missingConfigs.push({ did: blocklet.meta.did, key: item.key });
|
|
55
|
+
missingConfigs.push({ did: blocklet.meta.did, key: item.key, description: item.description });
|
|
77
56
|
}
|
|
78
57
|
});
|
|
79
58
|
|
|
@@ -84,7 +63,7 @@ const getRequiredMissingConfigs = (blocklet) => {
|
|
|
84
63
|
// or value of configProp in root blocklet config is empty.
|
|
85
64
|
childConfigs.forEach((x) => {
|
|
86
65
|
if (x.required && !x.value && !configs.some((y) => y.key === x.key && y.value)) {
|
|
87
|
-
missingConfigs.push({ did: child.meta.did, key: x.key });
|
|
66
|
+
missingConfigs.push({ did: child.meta.did, key: x.key, description: x.description });
|
|
88
67
|
}
|
|
89
68
|
});
|
|
90
69
|
}
|
|
@@ -176,15 +155,30 @@ const getDisplayName = (blocklet, onlyUseMeta = false) => {
|
|
|
176
155
|
return displayName || meta.title || meta.name;
|
|
177
156
|
};
|
|
178
157
|
|
|
158
|
+
const fixBlockletStatus = (blocklet) => {
|
|
159
|
+
if (!blocklet) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
blocklet.status = fromBlockletStatus(blocklet.status);
|
|
164
|
+
blocklet.source = fromBlockletSource(blocklet.source);
|
|
165
|
+
(blocklet.children || []).forEach((child) => {
|
|
166
|
+
child.status = fromBlockletStatus(child.status);
|
|
167
|
+
if (child.source !== undefined) {
|
|
168
|
+
child.source = fromBlockletSource(child.source);
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
};
|
|
172
|
+
|
|
179
173
|
module.exports = {
|
|
180
174
|
isFreeBlocklet,
|
|
181
175
|
isComponentBlocklet,
|
|
182
176
|
forEachBlockletSync,
|
|
183
177
|
isDeletableBlocklet,
|
|
184
178
|
forEachBlocklet,
|
|
185
|
-
isAuthServiceEnabled,
|
|
186
179
|
getRequiredMissingConfigs,
|
|
187
180
|
wipeSensitiveData,
|
|
188
181
|
hasRunnableComponent,
|
|
189
182
|
getDisplayName,
|
|
183
|
+
fixBlockletStatus,
|
|
190
184
|
};
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.6.
|
|
6
|
+
"version": "1.6.30",
|
|
7
7
|
"description": "Library to parse/validate/fix blocklet meta",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -18,14 +18,14 @@
|
|
|
18
18
|
"author": "wangshijun <wangshijun2020@gmail.com> (http://github.com/wangshijun)",
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@arcblock/did": "^1.14.
|
|
22
|
-
"@arcblock/did-ext": "^1.14.
|
|
23
|
-
"@arcblock/did-util": "^1.14.
|
|
24
|
-
"@arcblock/nft": "^1.14.
|
|
25
|
-
"@ocap/asset": "^1.14.
|
|
26
|
-
"@ocap/mcrypto": "^1.14.
|
|
27
|
-
"@ocap/util": "^1.14.
|
|
28
|
-
"@ocap/wallet": "^1.14.
|
|
21
|
+
"@arcblock/did": "^1.14.20",
|
|
22
|
+
"@arcblock/did-ext": "^1.14.20",
|
|
23
|
+
"@arcblock/did-util": "^1.14.20",
|
|
24
|
+
"@arcblock/nft": "^1.14.20",
|
|
25
|
+
"@ocap/asset": "^1.14.20",
|
|
26
|
+
"@ocap/mcrypto": "^1.14.20",
|
|
27
|
+
"@ocap/util": "^1.14.20",
|
|
28
|
+
"@ocap/wallet": "^1.14.20",
|
|
29
29
|
"ajv": "^7.0.3",
|
|
30
30
|
"cjk-length": "^1.0.0",
|
|
31
31
|
"debug": "^4.3.3",
|
|
@@ -43,5 +43,5 @@
|
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"jest": "^27.4.5"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "d8ea64b807f7852186cd4bf544193496fbb31e7c"
|
|
47
47
|
}
|