@blocklet/meta 1.7.14 → 1.7.17

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.
Files changed (3) hide show
  1. package/lib/fix.js +0 -4
  2. package/lib/schema.js +32 -16
  3. package/package.json +13 -13
package/lib/fix.js CHANGED
@@ -54,10 +54,6 @@ const fixRequired = (data, dir) => {
54
54
  data.group = 'static';
55
55
  }
56
56
  }
57
-
58
- if (!data.specVersion && !data.public_url && !data.admin_url) {
59
- data.public_url = '/';
60
- }
61
57
  };
62
58
 
63
59
  const fixRepository = (data) => {
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 = 22;
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(3)
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: Joi.string().min(1).required(),
172
+ name: blockletNameSchema.required(),
166
173
  title: titleSchema,
167
174
  description: descriptionSchema,
168
- resolved: Joi.alternatives().try(Joi.string().uri(), Joi.string()).required(),
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
- mountPoint: Joi.string().trim().min(1), // added in 1.2.3
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
- throw new Error('mountPoint is required');
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: Joi.string()
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.14",
6
+ "version": "1.7.17",
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.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",
21
+ "@abtnode/constant": "1.7.17",
22
+ "@abtnode/util": "1.7.17",
23
+ "@arcblock/did": "^1.16.9",
24
+ "@arcblock/did-ext": "^1.16.9",
25
+ "@arcblock/did-util": "^1.16.9",
26
+ "@arcblock/jwt": "^1.16.9",
27
+ "@arcblock/nft": "^1.16.9",
28
+ "@ocap/asset": "^1.16.9",
29
+ "@ocap/mcrypto": "^1.16.9",
30
+ "@ocap/util": "^1.16.9",
31
+ "@ocap/wallet": "^1.16.9",
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": "1f3855e6dc8b6d6c91526264e2f63215df6b962c"
50
+ "gitHead": "142a5b1e83ea03647ef9bea8de9bb269c9c82928"
51
51
  }