@blocklet/meta 1.7.13 → 1.7.16
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/fix.js +0 -4
- package/lib/schema.js +32 -16
- package/package.json +13 -13
package/lib/fix.js
CHANGED
package/lib/schema.js
CHANGED
|
@@ -24,14 +24,14 @@ 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 = 24;
|
|
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
32
|
const titleSchema = Joi.string()
|
|
33
33
|
.trim()
|
|
34
|
-
.min(
|
|
34
|
+
.min(1)
|
|
35
35
|
.custom((value) => {
|
|
36
36
|
if (cjkLength(value) > MAX_TITLE_LENGTH) {
|
|
37
37
|
throw new Error(
|
|
@@ -43,6 +43,13 @@ const titleSchema = Joi.string()
|
|
|
43
43
|
});
|
|
44
44
|
const descriptionSchema = Joi.string().trim().min(3).max(160);
|
|
45
45
|
|
|
46
|
+
const blockletNameSchema = Joi.string()
|
|
47
|
+
.custom((value) => {
|
|
48
|
+
validateName(value);
|
|
49
|
+
return value;
|
|
50
|
+
})
|
|
51
|
+
.max(MAX_NAME_LENGTH);
|
|
52
|
+
|
|
46
53
|
const environmentSchema = Joi.object({
|
|
47
54
|
name: Joi.string().trim().required(),
|
|
48
55
|
description: Joi.string().trim().required(),
|
|
@@ -162,10 +169,23 @@ const statsSchema = Joi.object({
|
|
|
162
169
|
});
|
|
163
170
|
|
|
164
171
|
const childrenSchema = Joi.object({
|
|
165
|
-
name:
|
|
172
|
+
name: blockletNameSchema.required(),
|
|
166
173
|
title: titleSchema,
|
|
167
174
|
description: descriptionSchema,
|
|
168
|
-
|
|
175
|
+
mountPoint: Joi.string().trim().min(1), // added in 1.2.3
|
|
176
|
+
services: Joi.array().items(serviceSchema).unique('name'), // added in 1.2.3
|
|
177
|
+
source: Joi.alternatives().try(
|
|
178
|
+
Joi.object({
|
|
179
|
+
url: Joi.alternatives().try(Joi.string().uri(), Joi.array().items(Joi.string().uri()).min(1)).required(),
|
|
180
|
+
}),
|
|
181
|
+
Joi.object({
|
|
182
|
+
store: Joi.alternatives().try(Joi.string().uri(), Joi.array().items(Joi.string().uri()).min(1)).required(),
|
|
183
|
+
name: blockletNameSchema.required(),
|
|
184
|
+
// TODO 目前只能支持锁死的版本号,接下载需要支持自适应的版本号,比如 4.x
|
|
185
|
+
version: Joi.alternatives().try(Joi.string().valid('latest'), Joi.semver().valid()).default('latest'),
|
|
186
|
+
})
|
|
187
|
+
),
|
|
188
|
+
resolved: Joi.alternatives().try(Joi.string().uri(), Joi.string()), // deprecated
|
|
169
189
|
mountPoints: Joi.array() // deprecated
|
|
170
190
|
.items(
|
|
171
191
|
Joi.object({
|
|
@@ -180,11 +200,13 @@ const childrenSchema = Joi.object({
|
|
|
180
200
|
})
|
|
181
201
|
)
|
|
182
202
|
.optional(),
|
|
183
|
-
|
|
184
|
-
services: Joi.array().items(serviceSchema).unique('name'), // added in 1.2.3
|
|
185
|
-
}).custom((value) => {
|
|
203
|
+
}).custom((value, helper) => {
|
|
186
204
|
if (!value.mountPoint && (!value.mountPoints || !value.mountPoints.length)) {
|
|
187
|
-
|
|
205
|
+
return helper.message('child mountPoint is required');
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if (!value.source && !value.resolved) {
|
|
209
|
+
return helper.message('child source is required');
|
|
188
210
|
}
|
|
189
211
|
|
|
190
212
|
return value;
|
|
@@ -233,13 +255,7 @@ const createBlockletSchema = (
|
|
|
233
255
|
return Joi.object({
|
|
234
256
|
did: Joi.DID().trim().required(),
|
|
235
257
|
version: Joi.semver().valid().required(),
|
|
236
|
-
name:
|
|
237
|
-
.custom((value) => {
|
|
238
|
-
validateName(value);
|
|
239
|
-
return value;
|
|
240
|
-
})
|
|
241
|
-
.max(MAX_NAME_LENGTH)
|
|
242
|
-
.required(),
|
|
258
|
+
name: blockletNameSchema.required(),
|
|
243
259
|
description: descriptionSchema.required(),
|
|
244
260
|
group: Joi.string().valid(...BLOCKLET_GROUPS).required(), // prettier-ignore
|
|
245
261
|
main: Joi.when('group', {
|
|
@@ -415,7 +431,7 @@ const createBlockletSchema = (
|
|
|
415
431
|
lastPublishedAt: Joi.string().isoDate().optional(),
|
|
416
432
|
|
|
417
433
|
// blocklet component support
|
|
418
|
-
children: Joi.array().items(childrenSchema).optional().default([]),
|
|
434
|
+
children: Joi.array().items(childrenSchema).unique('name').optional().default([]),
|
|
419
435
|
|
|
420
436
|
// navigation & theme
|
|
421
437
|
navigation: navigationSchema,
|
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.16",
|
|
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.16",
|
|
22
|
+
"@abtnode/util": "1.7.16",
|
|
23
|
+
"@arcblock/did": "^1.16.8",
|
|
24
|
+
"@arcblock/did-ext": "^1.16.8",
|
|
25
|
+
"@arcblock/did-util": "^1.16.8",
|
|
26
|
+
"@arcblock/jwt": "^1.16.8",
|
|
27
|
+
"@arcblock/nft": "^1.16.8",
|
|
28
|
+
"@ocap/asset": "^1.16.8",
|
|
29
|
+
"@ocap/mcrypto": "^1.16.8",
|
|
30
|
+
"@ocap/util": "^1.16.8",
|
|
31
|
+
"@ocap/wallet": "^1.16.8",
|
|
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": "04529c50cd42af0166b776fae82f8f4398834bfa"
|
|
51
51
|
}
|