@blocklet/meta 1.7.11 → 1.7.14
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/constants.js +3 -2
- package/lib/schema.js +22 -26
- package/lib/util.js +12 -0
- package/package.json +14 -13
package/lib/constants.js
CHANGED
|
@@ -22,6 +22,7 @@ const BlockletStatus = Object.freeze({
|
|
|
22
22
|
restarting: 11, // Deprecated
|
|
23
23
|
corrupted: 12,
|
|
24
24
|
waiting: 13,
|
|
25
|
+
deleted: 14,
|
|
25
26
|
});
|
|
26
27
|
|
|
27
28
|
const fromBlockletStatus = fromEntry(BlockletStatus);
|
|
@@ -173,8 +174,8 @@ module.exports = Object.freeze({
|
|
|
173
174
|
|
|
174
175
|
BLOCKLET_DEFAULT_VERSION: '1.0.0',
|
|
175
176
|
|
|
176
|
-
BLOCKLET_LATEST_SPEC_VERSION: '1.2.
|
|
177
|
-
BLOCKLET_LATEST_REQUIREMENT_SERVER: '>=1.
|
|
177
|
+
BLOCKLET_LATEST_SPEC_VERSION: '1.2.7',
|
|
178
|
+
BLOCKLET_LATEST_REQUIREMENT_SERVER: '>=1.7.0',
|
|
178
179
|
BLOCKLET_LATEST_REQUIREMENT_ABTNODE: '>=1.5.15', // Deprecated
|
|
179
180
|
|
|
180
181
|
BLOCKLET_CONFIGURABLE_KEY: {
|
package/lib/schema.js
CHANGED
|
@@ -24,11 +24,25 @@ const {
|
|
|
24
24
|
} = require('./constants');
|
|
25
25
|
|
|
26
26
|
const WELLKNOWN_PATH_PREFIX = '/.well-known';
|
|
27
|
-
const MAX_TITLE_LENGTH =
|
|
27
|
+
const MAX_TITLE_LENGTH = 22;
|
|
28
28
|
const MAX_NAME_LENGTH = 32;
|
|
29
29
|
|
|
30
30
|
const Joi = JOI.extend(semver).extend(semverRange).extend(fileExtension).extend(didExtension);
|
|
31
31
|
|
|
32
|
+
const titleSchema = Joi.string()
|
|
33
|
+
.trim()
|
|
34
|
+
.min(3)
|
|
35
|
+
.custom((value) => {
|
|
36
|
+
if (cjkLength(value) > MAX_TITLE_LENGTH) {
|
|
37
|
+
throw new Error(
|
|
38
|
+
`title length should not exceed ${MAX_TITLE_LENGTH} (see: https://www.npmjs.com/package/cjk-length)`
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return value;
|
|
43
|
+
});
|
|
44
|
+
const descriptionSchema = Joi.string().trim().min(3).max(160);
|
|
45
|
+
|
|
32
46
|
const environmentSchema = Joi.object({
|
|
33
47
|
name: Joi.string().trim().required(),
|
|
34
48
|
description: Joi.string().trim().required(),
|
|
@@ -149,6 +163,8 @@ const statsSchema = Joi.object({
|
|
|
149
163
|
|
|
150
164
|
const childrenSchema = Joi.object({
|
|
151
165
|
name: Joi.string().min(1).required(),
|
|
166
|
+
title: titleSchema,
|
|
167
|
+
description: descriptionSchema,
|
|
152
168
|
resolved: Joi.alternatives().try(Joi.string().uri(), Joi.string()).required(),
|
|
153
169
|
mountPoints: Joi.array() // deprecated
|
|
154
170
|
.items(
|
|
@@ -189,18 +205,6 @@ const signatureSchema = Joi.object({
|
|
|
189
205
|
delegation: Joi.string(),
|
|
190
206
|
});
|
|
191
207
|
|
|
192
|
-
const titleSchema = Joi.string()
|
|
193
|
-
.trim()
|
|
194
|
-
.min(3)
|
|
195
|
-
.custom((value) => {
|
|
196
|
-
if (cjkLength(value) > MAX_TITLE_LENGTH) {
|
|
197
|
-
throw new Error(`Blocklet title is too long. Max length is ${MAX_TITLE_LENGTH}`);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
return value;
|
|
201
|
-
});
|
|
202
|
-
const descriptionSchema = Joi.string().trim().min(3).max(160);
|
|
203
|
-
|
|
204
208
|
const navigationItemSchema = Joi.object({
|
|
205
209
|
title: Joi.string().required(),
|
|
206
210
|
link: Joi.string(),
|
|
@@ -400,12 +404,6 @@ const createBlockletSchema = (
|
|
|
400
404
|
// TODO: this field should be refactored in future version
|
|
401
405
|
engine: Joi.alternatives().try(engineSchema, Joi.array().items(engineSchema)).optional(),
|
|
402
406
|
|
|
403
|
-
// TODO: following fields only exist for backward compatibility
|
|
404
|
-
publicUrl: Joi.string().optional().allow(''),
|
|
405
|
-
adminUrl: Joi.string().optional().allow(''),
|
|
406
|
-
configUrl: Joi.string().optional().allow(''),
|
|
407
|
-
docUrl: Joi.string().optional().allow(''),
|
|
408
|
-
|
|
409
407
|
// NOTE: following fields are appended by registry or bundling process
|
|
410
408
|
screenshots: Joi.array().items(Joi.string().min(1)).optional().default([]),
|
|
411
409
|
logoUrl: Joi.string().optional().allow(''),
|
|
@@ -422,13 +420,11 @@ const createBlockletSchema = (
|
|
|
422
420
|
// navigation & theme
|
|
423
421
|
navigation: navigationSchema,
|
|
424
422
|
theme: themeSchema,
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
.
|
|
428
|
-
.
|
|
429
|
-
|
|
430
|
-
.rename('requiredEnvironments', 'environments', { ignoreUndefined: true, override: true })
|
|
431
|
-
.options({ stripUnknown: true, noDefaults: false, ...schemaOptions });
|
|
423
|
+
|
|
424
|
+
// NOTE: following fields only exist in blocklet server and cannot be set manually
|
|
425
|
+
bundleName: Joi.string(),
|
|
426
|
+
bundleDid: Joi.DID().trim(),
|
|
427
|
+
}).options({ stripUnknown: true, noDefaults: false, ...schemaOptions });
|
|
432
428
|
};
|
|
433
429
|
|
|
434
430
|
module.exports = {
|
package/lib/util.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/* eslint-disable no-await-in-loop */
|
|
2
2
|
const get = require('lodash/get');
|
|
3
|
+
const slugify = require('slugify');
|
|
3
4
|
|
|
4
5
|
const { NODE_SERVICES, SLOT_FOR_IP_DNS_SITE, WHO_CAN_ACCESS } = require('@abtnode/constant');
|
|
5
6
|
|
|
@@ -170,6 +171,14 @@ const fixBlockletStatus = (blocklet) => {
|
|
|
170
171
|
child.source = fromBlockletSource(child.source);
|
|
171
172
|
}
|
|
172
173
|
});
|
|
174
|
+
if (blocklet.settings) {
|
|
175
|
+
(blocklet.settings.children || []).forEach((child) => {
|
|
176
|
+
child.status = fromBlockletStatus(child.status);
|
|
177
|
+
if (child.source !== undefined) {
|
|
178
|
+
child.source = fromBlockletSource(child.source);
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
}
|
|
173
182
|
};
|
|
174
183
|
|
|
175
184
|
const findWebInterface = (blocklet) => {
|
|
@@ -223,6 +232,8 @@ const getWhoCanAccess = (blocklet) => {
|
|
|
223
232
|
|
|
224
233
|
const replaceSlotToIp = (url, ip) => (url || '').replace(SLOT_FOR_IP_DNS_SITE, (ip || '').replace(/\./g, '-'));
|
|
225
234
|
|
|
235
|
+
const urlFriendly = (name) => slugify(name.replace(/^[@./-]/, '').replace(/[@./_]/g, '-'));
|
|
236
|
+
|
|
226
237
|
module.exports = {
|
|
227
238
|
isFreeBlocklet,
|
|
228
239
|
isComponentBlocklet,
|
|
@@ -238,4 +249,5 @@ module.exports = {
|
|
|
238
249
|
findServiceFromMeta,
|
|
239
250
|
getWhoCanAccess,
|
|
240
251
|
replaceSlotToIp,
|
|
252
|
+
urlFriendly,
|
|
241
253
|
};
|
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.14",
|
|
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": "^1.16.
|
|
24
|
-
"@arcblock/did-ext": "^1.16.
|
|
25
|
-
"@arcblock/did-util": "^1.16.
|
|
26
|
-
"@arcblock/jwt": "^1.16.
|
|
27
|
-
"@arcblock/nft": "^1.16.
|
|
28
|
-
"@ocap/asset": "^1.16.
|
|
29
|
-
"@ocap/mcrypto": "^1.16.
|
|
30
|
-
"@ocap/util": "^1.16.
|
|
31
|
-
"@ocap/wallet": "^1.16.
|
|
21
|
+
"@abtnode/constant": "1.7.14",
|
|
22
|
+
"@abtnode/util": "1.7.14",
|
|
23
|
+
"@arcblock/did": "^1.16.6",
|
|
24
|
+
"@arcblock/did-ext": "^1.16.6",
|
|
25
|
+
"@arcblock/did-util": "^1.16.6",
|
|
26
|
+
"@arcblock/jwt": "^1.16.6",
|
|
27
|
+
"@arcblock/nft": "^1.16.6",
|
|
28
|
+
"@ocap/asset": "^1.16.6",
|
|
29
|
+
"@ocap/mcrypto": "^1.16.6",
|
|
30
|
+
"@ocap/util": "^1.16.6",
|
|
31
|
+
"@ocap/wallet": "^1.16.6",
|
|
32
32
|
"ajv": "^8.11.0",
|
|
33
33
|
"cjk-length": "^1.0.0",
|
|
34
34
|
"debug": "^4.3.3",
|
|
@@ -40,11 +40,12 @@
|
|
|
40
40
|
"js-yaml": "^4.1.0",
|
|
41
41
|
"json-stable-stringify": "^1.0.1",
|
|
42
42
|
"lodash": "^4.17.21",
|
|
43
|
+
"slugify": "^1.4.6",
|
|
43
44
|
"url-join": "^4.0.1",
|
|
44
45
|
"validate-npm-package-name": "^3.0.0"
|
|
45
46
|
},
|
|
46
47
|
"devDependencies": {
|
|
47
48
|
"jest": "^27.4.5"
|
|
48
49
|
},
|
|
49
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "1f3855e6dc8b6d6c91526264e2f63215df6b962c"
|
|
50
51
|
}
|