@blocklet/meta 1.16.6-beta-4562aa60 → 1.16.6-beta-eaa4d39d
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 +30 -4
- package/package.json +14 -14
package/lib/util.js
CHANGED
|
@@ -12,7 +12,7 @@ const p_limit_1 = __importDefault(require("p-limit"));
|
|
|
12
12
|
const constant_1 = __importDefault(require("@abtnode/constant"));
|
|
13
13
|
const constants_1 = __importDefault(require("./constants"));
|
|
14
14
|
const { NODE_SERVICES, SLOT_FOR_IP_DNS_SITE, WHO_CAN_ACCESS, WHO_CAN_ACCESS_PREFIX_ROLES } = constant_1.default;
|
|
15
|
-
const { BlockletGroup, BlockletStatus, fromBlockletStatus, fromBlockletSource, BLOCKLET_INTERFACE_TYPE_WEB, BLOCKLET_CONFIGURABLE_KEY, CHAIN_INFO_CONFIG, BLOCKLET_PREFERENCE_PREFIX, BLOCKLET_INTERFACE_TYPE_SERVICE, } = constants_1.default;
|
|
15
|
+
const { BlockletGroup, BlockletStatus, fromBlockletStatus, fromBlockletSource, BLOCKLET_INTERFACE_TYPE_WEB, BLOCKLET_CONFIGURABLE_KEY, CHAIN_INFO_CONFIG, CHAIN_PROP_MAP, BLOCKLET_PREFERENCE_PREFIX, BLOCKLET_INTERFACE_TYPE_SERVICE, } = constants_1.default;
|
|
16
16
|
const getComponentId = (component, ancestors = []) => `${ancestors.map((x) => (x && x.meta ? x.meta.did : '')).join('/')}${ancestors.length ? '/' : ''}${component && component.meta ? component.meta.did : ''}`;
|
|
17
17
|
exports.getComponentId = getComponentId;
|
|
18
18
|
const getComponentName = (component, ancestors = []) => `${ancestors.map((x) => (x && x.meta ? x.meta.name : '')).join('/')}${ancestors.length ? '/' : ''}${component && component.meta ? component.meta.name : ''}`;
|
|
@@ -188,7 +188,7 @@ const isEnvShareable = (env) => {
|
|
|
188
188
|
exports.isEnvShareable = isEnvShareable;
|
|
189
189
|
const getSharedConfigObj = (component, ancestors) => {
|
|
190
190
|
const res = {};
|
|
191
|
-
if (!ancestors) {
|
|
191
|
+
if (!ancestors || !ancestors.length) {
|
|
192
192
|
return res;
|
|
193
193
|
}
|
|
194
194
|
for (let i = ancestors.length - 1; i >= 0; i--) {
|
|
@@ -209,11 +209,37 @@ const getSharedConfigObj = (component, ancestors) => {
|
|
|
209
209
|
});
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
|
+
// share blocklet app chain config
|
|
213
|
+
const ancestor = ancestors[0];
|
|
214
|
+
(ancestor.configs || []).forEach(({ key, value }) => {
|
|
215
|
+
if (![
|
|
216
|
+
BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_CHAIN_HOST,
|
|
217
|
+
BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_CHAIN_ID,
|
|
218
|
+
BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_CHAIN_TYPE,
|
|
219
|
+
].includes(key)) {
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
res[CHAIN_PROP_MAP[key]] = value;
|
|
223
|
+
});
|
|
212
224
|
return res;
|
|
213
225
|
};
|
|
214
226
|
exports.getSharedConfigObj = getSharedConfigObj;
|
|
215
227
|
const isPreferenceKey = (x) => x.key.startsWith(BLOCKLET_PREFERENCE_PREFIX) === true;
|
|
216
228
|
exports.isPreferenceKey = isPreferenceKey;
|
|
229
|
+
const isConfigMissing = (item, sharedConfigObj) => {
|
|
230
|
+
if (item.required) {
|
|
231
|
+
if (
|
|
232
|
+
// if the value and the shared value are both empty
|
|
233
|
+
(!item.value && !sharedConfigObj[item.key]) ||
|
|
234
|
+
// if CHAIN_HOST, CHAIN_ID, CHAIN_TYPE in sharedConfigObj and the shared value is empty
|
|
235
|
+
(Object.values(CHAIN_PROP_MAP).includes(item.key) &&
|
|
236
|
+
Object.keys(sharedConfigObj).includes(item.key) &&
|
|
237
|
+
!sharedConfigObj[item.key])) {
|
|
238
|
+
return true;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return false;
|
|
242
|
+
};
|
|
217
243
|
const getAppMissingConfigs = (blocklet = {}) => {
|
|
218
244
|
const missingConfigs = [];
|
|
219
245
|
forEachBlockletSync(blocklet, (b, { ancestors, level }) => {
|
|
@@ -223,7 +249,7 @@ const getAppMissingConfigs = (blocklet = {}) => {
|
|
|
223
249
|
const configs = b.configs || [];
|
|
224
250
|
const sharedConfigObj = getSharedConfigObj(b, ancestors);
|
|
225
251
|
configs.forEach((item) => {
|
|
226
|
-
if (item
|
|
252
|
+
if (isConfigMissing(item, sharedConfigObj)) {
|
|
227
253
|
missingConfigs.push({ did: b.meta.did, key: item.key, description: item.description });
|
|
228
254
|
}
|
|
229
255
|
});
|
|
@@ -236,7 +262,7 @@ const getComponentMissingConfigs = (component = {}, ancestors = []) => {
|
|
|
236
262
|
const configs = component.configs || [];
|
|
237
263
|
const sharedConfigObj = getSharedConfigObj(component, ancestors);
|
|
238
264
|
configs.forEach((item) => {
|
|
239
|
-
if (item
|
|
265
|
+
if (isConfigMissing(item, sharedConfigObj)) {
|
|
240
266
|
missingConfigs.push({ did: component.meta.did, key: item.key, description: item.description });
|
|
241
267
|
}
|
|
242
268
|
});
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.16.6-beta-
|
|
6
|
+
"version": "1.16.6-beta-eaa4d39d",
|
|
7
7
|
"description": "Library to parse/validate/fix blocklet meta",
|
|
8
8
|
"main": "./lib/index.js",
|
|
9
9
|
"typings": "./lib/index.d.ts",
|
|
@@ -24,18 +24,18 @@
|
|
|
24
24
|
"author": "wangshijun <wangshijun2020@gmail.com> (http://github.com/wangshijun)",
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@abtnode/constant": "1.16.6-beta-
|
|
28
|
-
"@abtnode/util": "1.16.6-beta-
|
|
29
|
-
"@arcblock/did": "1.18.
|
|
30
|
-
"@arcblock/did-ext": "1.18.
|
|
31
|
-
"@arcblock/did-util": "1.18.
|
|
32
|
-
"@arcblock/jwt": "1.18.
|
|
33
|
-
"@blocklet/constant": "1.16.6-beta-
|
|
34
|
-
"@ocap/asset": "1.18.
|
|
35
|
-
"@ocap/mcrypto": "1.18.
|
|
36
|
-
"@ocap/types": "1.18.
|
|
37
|
-
"@ocap/util": "1.18.
|
|
38
|
-
"@ocap/wallet": "1.18.
|
|
27
|
+
"@abtnode/constant": "1.16.6-beta-eaa4d39d",
|
|
28
|
+
"@abtnode/util": "1.16.6-beta-eaa4d39d",
|
|
29
|
+
"@arcblock/did": "1.18.73",
|
|
30
|
+
"@arcblock/did-ext": "1.18.73",
|
|
31
|
+
"@arcblock/did-util": "1.18.73",
|
|
32
|
+
"@arcblock/jwt": "1.18.73",
|
|
33
|
+
"@blocklet/constant": "1.16.6-beta-eaa4d39d",
|
|
34
|
+
"@ocap/asset": "1.18.73",
|
|
35
|
+
"@ocap/mcrypto": "1.18.73",
|
|
36
|
+
"@ocap/types": "1.18.73",
|
|
37
|
+
"@ocap/util": "1.18.73",
|
|
38
|
+
"@ocap/wallet": "1.18.73",
|
|
39
39
|
"ajv": "^8.11.0",
|
|
40
40
|
"axios": "^0.27.2",
|
|
41
41
|
"cjk-length": "^1.0.0",
|
|
@@ -79,5 +79,5 @@
|
|
|
79
79
|
"ts-node": "^10.9.1",
|
|
80
80
|
"typescript": "^4.8.4"
|
|
81
81
|
},
|
|
82
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "0d2ab99f67109e989f8182fc70bc3ee9fa430585"
|
|
83
83
|
}
|