@blocklet/meta 1.8.69-beta-b0bb2d67 → 1.8.69-beta-76f8a46f
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/did.d.ts +1 -10
- package/lib/did.js +0 -14
- package/lib/index.d.ts +4 -11
- package/lib/name.d.ts +6 -2
- package/lib/name.js +4 -2
- package/lib/parse.js +11 -8
- package/lib/payment/v2.js +4 -1
- package/lib/schema.d.ts +6 -2
- package/lib/schema.js +61 -42
- package/lib/types/schema.d.ts +23 -29
- package/lib/util-meta.js +1 -0
- package/lib/util.d.ts +19 -18
- package/lib/util.js +4 -1
- package/lib/validate.d.ts +3 -1
- package/lib/validate.js +3 -1
- package/lib/wallet.d.ts +2 -2
- package/lib/wallet.js +2 -2
- package/package.json +15 -15
package/lib/did.d.ts
CHANGED
|
@@ -1,12 +1,3 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
declare const toBlockletDid:
|
|
3
|
-
(name: string | Buffer): string;
|
|
4
|
-
toExternalBlocklet(name: string, userDid: string, { didOnly, nameOnly }?: {
|
|
5
|
-
didOnly?: boolean;
|
|
6
|
-
nameOnly?: boolean;
|
|
7
|
-
}): string | {
|
|
8
|
-
did: string;
|
|
9
|
-
name: string;
|
|
10
|
-
};
|
|
11
|
-
};
|
|
2
|
+
declare const toBlockletDid: (name: string | Buffer) => string;
|
|
12
3
|
export = toBlockletDid;
|
package/lib/did.js
CHANGED
|
@@ -9,18 +9,4 @@ const toBlockletDid = (name) => {
|
|
|
9
9
|
const pk = (0, util_1.toHex)(Buffer.from(typeof name === 'string' ? name.trim() : name));
|
|
10
10
|
return (0, did_1.fromPublicKey)(pk, { role: mcrypto_1.types.RoleType.ROLE_ANY });
|
|
11
11
|
};
|
|
12
|
-
toBlockletDid.toExternalBlocklet = (name, userDid, { didOnly, nameOnly } = {}) => {
|
|
13
|
-
const blockletName = `${name}-${userDid.toLowerCase().substring(userDid.length - 6)}`;
|
|
14
|
-
if (nameOnly) {
|
|
15
|
-
return blockletName;
|
|
16
|
-
}
|
|
17
|
-
const blockletDid = toBlockletDid(blockletName);
|
|
18
|
-
if (didOnly) {
|
|
19
|
-
return blockletDid;
|
|
20
|
-
}
|
|
21
|
-
return {
|
|
22
|
-
name: blockletName,
|
|
23
|
-
did: blockletDid,
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
12
|
module.exports = toBlockletDid;
|
package/lib/index.d.ts
CHANGED
|
@@ -50,11 +50,13 @@ declare const _default: {
|
|
|
50
50
|
defaultStoreUrl?: string | ((component: import("./types").TComponent) => string);
|
|
51
51
|
fix?: boolean;
|
|
52
52
|
}) => import("./types").TBlockletMeta;
|
|
53
|
-
validateMeta: (meta: any, { ensureMain, ensureFiles, ensureDist, ensureComponentStore, schemaOptions, }?: {
|
|
53
|
+
validateMeta: (meta: any, { ensureMain, ensureFiles, ensureDist, ensureComponentStore, ensureName, skipValidateDidName, schemaOptions, }?: {
|
|
54
54
|
ensureMain?: boolean;
|
|
55
55
|
ensureFiles?: boolean;
|
|
56
56
|
ensureDist?: boolean;
|
|
57
57
|
ensureComponentStore?: boolean;
|
|
58
|
+
ensureName?: boolean;
|
|
59
|
+
skipValidateDidName?: boolean;
|
|
58
60
|
schemaOptions?: any;
|
|
59
61
|
}) => import("./types").TBlockletMeta;
|
|
60
62
|
fixAndValidateService: (meta: import("./types").TBlockletMeta) => import("./types").TBlockletMeta;
|
|
@@ -64,16 +66,7 @@ declare const _default: {
|
|
|
64
66
|
fixInterfaces: (meta: any, removeMerged?: boolean) => any;
|
|
65
67
|
fixName: (meta: any) => any;
|
|
66
68
|
fixService: (meta: import("./types").TBlockletMeta) => import("./types").TBlockletMeta;
|
|
67
|
-
toBlockletDid:
|
|
68
|
-
(name: string | Buffer): string;
|
|
69
|
-
toExternalBlocklet(name: string, userDid: string, { didOnly, nameOnly }?: {
|
|
70
|
-
didOnly?: boolean;
|
|
71
|
-
nameOnly?: boolean;
|
|
72
|
-
}): string | {
|
|
73
|
-
did: string;
|
|
74
|
-
name: string;
|
|
75
|
-
};
|
|
76
|
-
};
|
|
69
|
+
toBlockletDid: (name: string | Buffer) => string;
|
|
77
70
|
getBlockletWallet: (blockletDid: string, nodeSk?: string, type?: string | import("@arcblock/did").DIDType, index?: number) => import("@ocap/wallet").WalletObject<string>;
|
|
78
71
|
getBlockletInfo: (state: import("@abtnode/client").BlockletState, nodeSk?: string, { returnWallet }?: {
|
|
79
72
|
returnWallet?: boolean;
|
package/lib/name.d.ts
CHANGED
|
@@ -3,9 +3,13 @@
|
|
|
3
3
|
* @param did 需要检查是否为新版 did 的值
|
|
4
4
|
*/
|
|
5
5
|
export declare const validateNewDid: (did: string) => void;
|
|
6
|
-
export declare const validateName: (name: string
|
|
6
|
+
export declare const validateName: (name: string, { checkDid }?: {
|
|
7
|
+
checkDid?: boolean;
|
|
8
|
+
}) => void;
|
|
7
9
|
declare const _default: {
|
|
8
|
-
validateName: (name: string
|
|
10
|
+
validateName: (name: string, { checkDid }?: {
|
|
11
|
+
checkDid?: boolean;
|
|
12
|
+
}) => void;
|
|
9
13
|
validateNewDid: (did: string) => void;
|
|
10
14
|
};
|
|
11
15
|
export default _default;
|
package/lib/name.js
CHANGED
|
@@ -18,10 +18,12 @@ const validateNewDid = (did) => {
|
|
|
18
18
|
}
|
|
19
19
|
};
|
|
20
20
|
exports.validateNewDid = validateNewDid;
|
|
21
|
-
const validateName = (name) => {
|
|
21
|
+
const validateName = (name, { checkDid = true } = {}) => {
|
|
22
22
|
if ((0, did_1.isValid)(name)) {
|
|
23
23
|
// new did mode
|
|
24
|
-
|
|
24
|
+
if (checkDid) {
|
|
25
|
+
(0, exports.validateNewDid)(name);
|
|
26
|
+
}
|
|
25
27
|
}
|
|
26
28
|
else {
|
|
27
29
|
// old did mode
|
package/lib/parse.js
CHANGED
|
@@ -13,6 +13,7 @@ const schema_1 = require("./schema");
|
|
|
13
13
|
const fix_1 = require("./fix");
|
|
14
14
|
const debug = (0, debug_1.default)('@blocklet/meta:parse');
|
|
15
15
|
const { BLOCKLET_META_FILE, BLOCKLET_META_FILE_ALT } = constants_1.default;
|
|
16
|
+
const isSourceFromStore = (source) => 'name' in source || 'did' in source;
|
|
16
17
|
/**
|
|
17
18
|
* Get blocklet meta from blocklet.yml
|
|
18
19
|
* @param {string} dir blocklet directory
|
|
@@ -63,15 +64,17 @@ const parse = (dir, { ensureMain = false, ensureFiles = false, ensureDist = fals
|
|
|
63
64
|
(0, fix_1.fixName)(result);
|
|
64
65
|
(0, fix_1.fixPerson)(result);
|
|
65
66
|
(0, fix_1.fixService)(result);
|
|
66
|
-
|
|
67
|
-
result
|
|
68
|
-
|
|
69
|
-
if (
|
|
70
|
-
x.source.store
|
|
67
|
+
['components', 'staticComponents'].forEach((prop) => {
|
|
68
|
+
if (defaultStoreUrl && result[prop]?.length) {
|
|
69
|
+
result[prop].forEach((x) => {
|
|
70
|
+
if (isSourceFromStore(x.source)) {
|
|
71
|
+
if (!x.source.store) {
|
|
72
|
+
x.source.store = typeof defaultStoreUrl === 'function' ? defaultStoreUrl((0, cloneDeep_1.default)(x)) : defaultStoreUrl;
|
|
73
|
+
}
|
|
71
74
|
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
});
|
|
75
78
|
// We will overwrite did anyway
|
|
76
79
|
result.path = `/${result.group}/${result.name}`;
|
|
77
80
|
// Ensure camelCase
|
package/lib/payment/v2.js
CHANGED
|
@@ -54,7 +54,10 @@ exports.version = VERSION;
|
|
|
54
54
|
const ZeroBN = new util_1.BN(0);
|
|
55
55
|
const defaultDecimals = 1e6; // we only support 6 decimals on share ratio
|
|
56
56
|
const defaultDecimalsBN = new util_1.BN(defaultDecimals);
|
|
57
|
-
const getComponentConfig = (meta) =>
|
|
57
|
+
const getComponentConfig = (meta) => []
|
|
58
|
+
.concat(meta.components || meta.children)
|
|
59
|
+
.concat(meta.staticComponents)
|
|
60
|
+
.filter(Boolean);
|
|
58
61
|
const safeMul = (a, b) => Number((0, util_1.fromUnitToToken)((0, util_1.fromTokenToUnit)(a)
|
|
59
62
|
.mul(new util_1.BN(b * defaultDecimals))
|
|
60
63
|
.div(defaultDecimalsBN)));
|
package/lib/schema.d.ts
CHANGED
|
@@ -23,11 +23,13 @@ declare const navigationSchema: JOI.ArraySchema<any[]>;
|
|
|
23
23
|
declare const themeSchema: JOI.ObjectSchema<any>;
|
|
24
24
|
declare const authConfigSchema: JOI.ObjectSchema<any>;
|
|
25
25
|
declare const blockletMetaSchema: JOI.ObjectSchema<any>;
|
|
26
|
-
declare const createBlockletSchema: (baseDir: string, { ensureMain, ensureFiles, ensureDist, ensureComponentStore, ...schemaOptions }?: {
|
|
26
|
+
declare const createBlockletSchema: (baseDir: string, { ensureMain, ensureFiles, ensureDist, ensureComponentStore, ensureName, skipValidateDidName, ...schemaOptions }?: {
|
|
27
27
|
ensureMain?: boolean;
|
|
28
28
|
ensureFiles?: boolean;
|
|
29
29
|
ensureDist?: boolean;
|
|
30
30
|
ensureComponentStore?: boolean;
|
|
31
|
+
ensureName?: boolean;
|
|
32
|
+
skipValidateDidName?: boolean;
|
|
31
33
|
}) => JOI.ObjectSchema;
|
|
32
34
|
export { blockletMetaSchema, blockletNameSchema, componentSchema, createBlockletSchema, descriptionSchema, distSchema, endpointSchema, engineSchema, environmentSchema, environmentNameSchema, interfaceSchema, logoSchema, mountPointSchema, updateMountPointSchema, navigationItemSchema, navigationSchema, personSchema, scriptsSchema, serviceSchema, signatureSchema, themeSchema, titleSchema, statsSchema, cacheableSchema, authConfigSchema, };
|
|
33
35
|
declare const _default: {
|
|
@@ -35,11 +37,13 @@ declare const _default: {
|
|
|
35
37
|
componentSchema: JOI.ObjectSchema<any>;
|
|
36
38
|
endpointSchema: JOI.ObjectSchema<any>;
|
|
37
39
|
serviceSchema: JOI.ObjectSchema<any>;
|
|
38
|
-
createBlockletSchema: (baseDir: string, { ensureMain, ensureFiles, ensureDist, ensureComponentStore, ...schemaOptions }?: {
|
|
40
|
+
createBlockletSchema: (baseDir: string, { ensureMain, ensureFiles, ensureDist, ensureComponentStore, ensureName, skipValidateDidName, ...schemaOptions }?: {
|
|
39
41
|
ensureMain?: boolean;
|
|
40
42
|
ensureFiles?: boolean;
|
|
41
43
|
ensureDist?: boolean;
|
|
42
44
|
ensureComponentStore?: boolean;
|
|
45
|
+
ensureName?: boolean;
|
|
46
|
+
skipValidateDidName?: boolean;
|
|
43
47
|
}) => JOI.ObjectSchema<any>;
|
|
44
48
|
interfaceSchema: JOI.ObjectSchema<any>;
|
|
45
49
|
environmentSchema: JOI.ObjectSchema<any>;
|
package/lib/schema.js
CHANGED
|
@@ -312,60 +312,75 @@ const statsSchema = Joi.object({
|
|
|
312
312
|
});
|
|
313
313
|
exports.statsSchema = statsSchema;
|
|
314
314
|
const urlListSchema = Joi.alternatives().try(Joi.string().uri(), Joi.array().items(Joi.string().uri()).min(1));
|
|
315
|
-
const
|
|
315
|
+
const componentSourceSchema = Joi.alternatives().try(Joi.object({
|
|
316
|
+
url: urlListSchema.required(),
|
|
317
|
+
// 虽然 url 无法像 store 一样根据 version 获取指定版本的 component, 但是 version 仍然可以用于限制 component 版本
|
|
318
|
+
version: Joi.alternatives().try(Joi.string().valid('latest'), Joi.semverRange().valid()),
|
|
319
|
+
}), Joi.object({
|
|
320
|
+
store: urlListSchema,
|
|
316
321
|
name: blockletNameSchema.required(),
|
|
322
|
+
// TODO 目前只能支持锁死的版本号,接下载需要支持自适应的版本号,比如 4.x
|
|
323
|
+
version: Joi.alternatives().try(Joi.string().valid('latest'), Joi.semverRange().valid()).default('latest'),
|
|
324
|
+
}));
|
|
325
|
+
const componentSchemaProps = {
|
|
326
|
+
source: componentSourceSchema.required(),
|
|
327
|
+
// Can the dynamic component be deleted before I delete myself
|
|
328
|
+
required: Joi.boolean(),
|
|
329
|
+
// These props in dynamic component is for suggestion only and can be changed by user or other dynamic component
|
|
317
330
|
title: titleSchema,
|
|
318
331
|
description: descriptionSchema,
|
|
319
332
|
mountPoint: mountPointSchema,
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
url: urlListSchema.required(),
|
|
323
|
-
}), Joi.object({
|
|
324
|
-
store: urlListSchema,
|
|
325
|
-
name: blockletNameSchema.required(),
|
|
326
|
-
// TODO 目前只能支持锁死的版本号,接下载需要支持自适应的版本号,比如 4.x
|
|
327
|
-
version: Joi.alternatives().try(Joi.string().valid('latest'), Joi.semver().valid()).default('latest'),
|
|
328
|
-
})),
|
|
329
|
-
resolved: Joi.alternatives().try(Joi.string().uri(), Joi.string()),
|
|
330
|
-
mountPoints: Joi.array() // deprecated
|
|
331
|
-
.items(Joi.object({
|
|
332
|
-
root: Joi.object({
|
|
333
|
-
interfaceName: Joi.string().trim().required(),
|
|
334
|
-
prefix: Joi.string().trim().min(1).required(),
|
|
335
|
-
}).required(),
|
|
336
|
-
child: Joi.object({
|
|
337
|
-
interfaceName: Joi.string().trim().required(),
|
|
338
|
-
}).required(),
|
|
339
|
-
services: Joi.array().items(serviceSchema).unique('name'),
|
|
340
|
-
}))
|
|
341
|
-
.optional(),
|
|
333
|
+
// backward compatible, useless
|
|
334
|
+
name: blockletNameSchema,
|
|
342
335
|
};
|
|
343
|
-
const
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
}
|
|
336
|
+
const staticComponentSchemaProps = {
|
|
337
|
+
source: componentSourceSchema.required(),
|
|
338
|
+
name: blockletNameSchema.required(),
|
|
339
|
+
title: titleSchema,
|
|
340
|
+
description: descriptionSchema,
|
|
341
|
+
mountPoint: mountPointSchema.required(),
|
|
342
|
+
};
|
|
343
|
+
const createComponentSchema = (schema, allowEmptyStore) => Joi.object(schema).custom((value, helper) => {
|
|
352
344
|
if (!allowEmptyStore && value.source && value.source.name && !value.source.store) {
|
|
353
345
|
// @ts-expect-error
|
|
354
346
|
return helper.message(`missing 'store' in source of component ${value.name}`);
|
|
355
347
|
}
|
|
356
348
|
return value;
|
|
357
349
|
});
|
|
358
|
-
const componentSchema = createComponentSchema().meta({
|
|
350
|
+
const componentSchema = createComponentSchema(componentSchemaProps).meta({
|
|
359
351
|
className: 'TComponent',
|
|
360
352
|
unknownType: 'any',
|
|
361
353
|
});
|
|
362
354
|
exports.componentSchema = componentSchema;
|
|
363
|
-
const
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
355
|
+
const staticComponentSchema = createComponentSchema(staticComponentSchemaProps).meta({
|
|
356
|
+
className: 'TStaticComponent',
|
|
357
|
+
unknownType: 'any',
|
|
358
|
+
});
|
|
359
|
+
const componentSchemaWithoutStoreCheck = createComponentSchema(componentSchemaProps, true);
|
|
360
|
+
const staticComponentSchemaWithoutStoreCheck = createComponentSchema(staticComponentSchemaProps, true);
|
|
361
|
+
const componentsSchema = ({ isStatic, checkStore } = {}) => {
|
|
362
|
+
const arr = isStatic
|
|
363
|
+
? [staticComponentSchema, staticComponentSchemaWithoutStoreCheck]
|
|
364
|
+
: [componentSchema, componentSchemaWithoutStoreCheck];
|
|
365
|
+
let schema = Joi.array()
|
|
366
|
+
.items(checkStore ? arr[0] : arr[1])
|
|
367
|
+
.optional()
|
|
368
|
+
.custom((value, helper) => {
|
|
369
|
+
if (isStatic) {
|
|
370
|
+
const names = value.map((x) => x.name);
|
|
371
|
+
const duplicateName = names.find((x, i) => names.indexOf(x) !== i);
|
|
372
|
+
if (duplicateName) {
|
|
373
|
+
// @ts-expect-error
|
|
374
|
+
return helper.message(`find duplicate name "${duplicateName}" in components`);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
return value;
|
|
378
|
+
});
|
|
379
|
+
if (!isStatic) {
|
|
380
|
+
schema = schema.default([]);
|
|
381
|
+
}
|
|
382
|
+
return schema;
|
|
383
|
+
};
|
|
369
384
|
const signatureSchema = Joi.object({
|
|
370
385
|
type: Joi.string().required(),
|
|
371
386
|
name: Joi.string().required(),
|
|
@@ -452,7 +467,7 @@ exports.authConfigSchema = authConfigSchema;
|
|
|
452
467
|
const blockletMetaProps = {
|
|
453
468
|
did: Joi.DID().trim().required(),
|
|
454
469
|
version: Joi.semver().valid().required(),
|
|
455
|
-
name:
|
|
470
|
+
name: Joi.string().optional(),
|
|
456
471
|
description: descriptionSchema.required(),
|
|
457
472
|
group: Joi.string()
|
|
458
473
|
.valid(...BLOCKLET_GROUPS)
|
|
@@ -635,6 +650,7 @@ const blockletMetaProps = {
|
|
|
635
650
|
lastPublishedAt: Joi.string().isoDate().optional(),
|
|
636
651
|
// blocklet component support
|
|
637
652
|
components: componentsSchema(),
|
|
653
|
+
staticComponents: componentsSchema({ isStatic: true }),
|
|
638
654
|
// navigation & theme
|
|
639
655
|
navigation: navigationSchema,
|
|
640
656
|
theme: themeSchema,
|
|
@@ -652,7 +668,7 @@ const blockletMetaSchema = Joi.object(blockletMetaProps).options({ stripUnknown:
|
|
|
652
668
|
unknownType: 'any',
|
|
653
669
|
});
|
|
654
670
|
exports.blockletMetaSchema = blockletMetaSchema;
|
|
655
|
-
const createBlockletSchema = (baseDir, { ensureMain = false, ensureFiles = false, ensureDist = false, ensureComponentStore = true, ...schemaOptions } = {}) => {
|
|
671
|
+
const createBlockletSchema = (baseDir, { ensureMain = false, ensureFiles = false, ensureDist = false, ensureComponentStore = true, ensureName = false, skipValidateDidName = false, ...schemaOptions } = {}) => {
|
|
656
672
|
if (!baseDir || !fs_1.default.existsSync(baseDir)) {
|
|
657
673
|
// eslint-disable-next-line no-param-reassign
|
|
658
674
|
ensureFiles = false;
|
|
@@ -673,7 +689,9 @@ const createBlockletSchema = (baseDir, { ensureMain = false, ensureFiles = false
|
|
|
673
689
|
: Joi.string().trim())
|
|
674
690
|
.optional(),
|
|
675
691
|
dist: ensureDist ? distSchema.required() : distSchema.optional(),
|
|
676
|
-
components: componentsSchema(ensureComponentStore),
|
|
692
|
+
components: componentsSchema({ checkStore: ensureComponentStore }),
|
|
693
|
+
staticComponents: componentsSchema({ isStatic: true, checkStore: ensureComponentStore }),
|
|
694
|
+
name: ensureName ? Joi.string().optional() : Joi.string().required(),
|
|
677
695
|
})
|
|
678
696
|
.options({ stripUnknown: true, noDefaults: false, ...schemaOptions })
|
|
679
697
|
.rename('children', 'components')
|
|
@@ -692,6 +710,7 @@ const createBlockletSchema = (baseDir, { ensureMain = false, ensureFiles = false
|
|
|
692
710
|
/* ------------- 兼容旧的逻辑,旧逻辑使用 name 生成一个 did ------------- */
|
|
693
711
|
// 此时 name 必须存在
|
|
694
712
|
if (name) {
|
|
713
|
+
(0, name_1.validateName)(name, { checkDid: !skipValidateDidName });
|
|
695
714
|
const expectDid = (0, did_2.default)(name);
|
|
696
715
|
if (expectDid !== did) {
|
|
697
716
|
// @ts-ignore
|
package/lib/types/schema.d.ts
CHANGED
|
@@ -20,21 +20,11 @@ export interface TBlockletMeta {
|
|
|
20
20
|
components?: {
|
|
21
21
|
description?: TDescription;
|
|
22
22
|
mountPoint?: TMountPoint;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
};
|
|
27
|
-
root: {
|
|
28
|
-
interfaceName: string;
|
|
29
|
-
prefix: string;
|
|
30
|
-
};
|
|
31
|
-
services?: TService[];
|
|
32
|
-
}[];
|
|
33
|
-
name: TBlockletName;
|
|
34
|
-
resolved?: string | string;
|
|
35
|
-
services?: TService[];
|
|
36
|
-
source?: {
|
|
23
|
+
name?: TBlockletName;
|
|
24
|
+
required?: boolean;
|
|
25
|
+
source: {
|
|
37
26
|
url: string | string[];
|
|
27
|
+
version?: 'latest' | string;
|
|
38
28
|
} | {
|
|
39
29
|
name: TBlockletName;
|
|
40
30
|
store?: string | string[];
|
|
@@ -66,7 +56,7 @@ export interface TBlockletMeta {
|
|
|
66
56
|
logoUrl?: string;
|
|
67
57
|
main: string;
|
|
68
58
|
maintainers?: TPerson[];
|
|
69
|
-
name?:
|
|
59
|
+
name?: string;
|
|
70
60
|
navigation?: TNavigation;
|
|
71
61
|
nftFactory?: string;
|
|
72
62
|
path?: string;
|
|
@@ -108,6 +98,20 @@ export interface TBlockletMeta {
|
|
|
108
98
|
scripts?: TScripts;
|
|
109
99
|
signatures?: TSignature[];
|
|
110
100
|
specVersion?: string;
|
|
101
|
+
staticComponents?: {
|
|
102
|
+
description?: TDescription;
|
|
103
|
+
mountPoint: TMountPoint;
|
|
104
|
+
name: TBlockletName;
|
|
105
|
+
source: {
|
|
106
|
+
url: string | string[];
|
|
107
|
+
version?: 'latest' | string;
|
|
108
|
+
} | {
|
|
109
|
+
name: TBlockletName;
|
|
110
|
+
store?: string | string[];
|
|
111
|
+
version?: 'latest' | string;
|
|
112
|
+
};
|
|
113
|
+
title?: TTitle;
|
|
114
|
+
}[];
|
|
111
115
|
stats?: TStats;
|
|
112
116
|
storeId?: string;
|
|
113
117
|
support?: string | string;
|
|
@@ -123,21 +127,11 @@ export type TBlockletName = string;
|
|
|
123
127
|
export interface TComponent {
|
|
124
128
|
description?: TDescription;
|
|
125
129
|
mountPoint?: TMountPoint;
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
};
|
|
130
|
-
root: {
|
|
131
|
-
interfaceName: string;
|
|
132
|
-
prefix: string;
|
|
133
|
-
};
|
|
134
|
-
services?: TService[];
|
|
135
|
-
}[];
|
|
136
|
-
name: TBlockletName;
|
|
137
|
-
resolved?: string | string;
|
|
138
|
-
services?: TService[];
|
|
139
|
-
source?: {
|
|
130
|
+
name?: TBlockletName;
|
|
131
|
+
required?: boolean;
|
|
132
|
+
source: {
|
|
140
133
|
url: string | string[];
|
|
134
|
+
version?: 'latest' | string;
|
|
141
135
|
} | {
|
|
142
136
|
name: TBlockletName;
|
|
143
137
|
store?: string | string[];
|
package/lib/util-meta.js
CHANGED
|
@@ -126,6 +126,7 @@ const getSourceUrlsFromConfig = (config) => {
|
|
|
126
126
|
return [config.source.url].flat();
|
|
127
127
|
}
|
|
128
128
|
const { store, version, name } = config.source;
|
|
129
|
+
// FIXME: @linchen the format or version is semverRange, blocklet store should support it
|
|
129
130
|
return [store]
|
|
130
131
|
.flat()
|
|
131
132
|
.map((x) => (0, url_join_1.default)(x, BLOCKLET_STORE_API_BLOCKLET_PREFIX, (0, did_1.default)(name), !version || version === 'latest' ? '' : version, 'blocklet.json'));
|
package/lib/util.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type { TBlockletMeta, TEnvironment } from './types';
|
|
|
4
4
|
type TConfig = TEnvironment & {
|
|
5
5
|
key: string;
|
|
6
6
|
};
|
|
7
|
+
type Component = BlockletState | ComponentState;
|
|
7
8
|
declare const getComponentId: (component?: {
|
|
8
9
|
meta?: {
|
|
9
10
|
did?: string;
|
|
@@ -54,20 +55,20 @@ declare const forEachBlocklet: (blocklet: BlockletState | ComponentState, cb: Fu
|
|
|
54
55
|
declare const forEachBlockletSync: (blocklet: any, cb: Function) => Promise<unknown>;
|
|
55
56
|
declare const forEachChild: (blocklet: any, cb: Function, params?: any) => Promise<any>;
|
|
56
57
|
declare const forEachChildSync: (blocklet: BlockletState, cb: Function) => Promise<any>;
|
|
57
|
-
declare const findComponent: (blocklet:
|
|
58
|
-
ancestors: Array<
|
|
58
|
+
declare const findComponent: (blocklet: Component, isEqualFn: (component: Component, context: {
|
|
59
|
+
ancestors: Array<Component>;
|
|
59
60
|
}) => boolean, { _ancestors, returnAncestors, }?: {
|
|
60
|
-
_ancestors?: Array<
|
|
61
|
+
_ancestors?: Array<Component>;
|
|
61
62
|
returnAncestors?: boolean;
|
|
62
|
-
}) =>
|
|
63
|
-
component:
|
|
64
|
-
ancestors: Array<
|
|
63
|
+
}) => Component | {
|
|
64
|
+
component: Component;
|
|
65
|
+
ancestors: Array<Component>;
|
|
65
66
|
};
|
|
66
67
|
declare const findComponentById: (blocklet: BlockletState | ComponentState, componentId: string | Array<string>, { returnAncestors, }?: {
|
|
67
68
|
returnAncestors?: boolean;
|
|
68
|
-
}) =>
|
|
69
|
-
component:
|
|
70
|
-
ancestors: Array<
|
|
69
|
+
}) => Component | {
|
|
70
|
+
component: Component;
|
|
71
|
+
ancestors: Array<Component>;
|
|
71
72
|
};
|
|
72
73
|
declare const isEnvShareable: (env?: TConfig) => boolean;
|
|
73
74
|
declare const getSharedConfigObj: (component: BlockletState, ancestors?: any[]) => any;
|
|
@@ -170,20 +171,20 @@ declare const _default: {
|
|
|
170
171
|
version: string;
|
|
171
172
|
};
|
|
172
173
|
}) => string;
|
|
173
|
-
findComponent: (blocklet:
|
|
174
|
-
ancestors:
|
|
174
|
+
findComponent: (blocklet: Component, isEqualFn: (component: Component, context: {
|
|
175
|
+
ancestors: Component[];
|
|
175
176
|
}) => boolean, { _ancestors, returnAncestors, }?: {
|
|
176
|
-
_ancestors?:
|
|
177
|
+
_ancestors?: Component[];
|
|
177
178
|
returnAncestors?: boolean;
|
|
178
|
-
}) =>
|
|
179
|
-
component:
|
|
180
|
-
ancestors:
|
|
179
|
+
}) => Component | {
|
|
180
|
+
component: Component;
|
|
181
|
+
ancestors: Component[];
|
|
181
182
|
};
|
|
182
183
|
findComponentById: (blocklet: BlockletState | ComponentState, componentId: string | string[], { returnAncestors, }?: {
|
|
183
184
|
returnAncestors?: boolean;
|
|
184
|
-
}) =>
|
|
185
|
-
component:
|
|
186
|
-
ancestors:
|
|
185
|
+
}) => Component | {
|
|
186
|
+
component: Component;
|
|
187
|
+
ancestors: Component[];
|
|
187
188
|
};
|
|
188
189
|
getParentComponentName: (name?: string) => string;
|
|
189
190
|
getConnectAppUrl: ({ request, baseUrl }: {
|
package/lib/util.js
CHANGED
|
@@ -216,7 +216,10 @@ const isPreferenceKey = (x) => x.key.startsWith(BLOCKLET_PREFERENCE_PREFIX) ===
|
|
|
216
216
|
exports.isPreferenceKey = isPreferenceKey;
|
|
217
217
|
const getAppMissingConfigs = (blocklet = {}) => {
|
|
218
218
|
const missingConfigs = [];
|
|
219
|
-
forEachBlockletSync(blocklet, (b, { ancestors }) => {
|
|
219
|
+
forEachBlockletSync(blocklet, (b, { ancestors, level }) => {
|
|
220
|
+
if (level === 0 && b.meta?.group === BlockletGroup.gateway) {
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
220
223
|
const configs = b.configs || [];
|
|
221
224
|
const sharedConfigObj = getSharedConfigObj(b, ancestors);
|
|
222
225
|
configs.forEach((item) => {
|
package/lib/validate.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { TBlockletMeta } from './types';
|
|
2
2
|
declare const fixAndValidateService: (meta: TBlockletMeta) => TBlockletMeta;
|
|
3
|
-
declare const validateMeta: (meta: any, { ensureMain, ensureFiles, ensureDist, ensureComponentStore, schemaOptions, }?: {
|
|
3
|
+
declare const validateMeta: (meta: any, { ensureMain, ensureFiles, ensureDist, ensureComponentStore, ensureName, skipValidateDidName, schemaOptions, }?: {
|
|
4
4
|
ensureMain?: boolean;
|
|
5
5
|
ensureFiles?: boolean;
|
|
6
6
|
ensureDist?: boolean;
|
|
7
7
|
ensureComponentStore?: boolean;
|
|
8
|
+
ensureName?: boolean;
|
|
9
|
+
skipValidateDidName?: boolean;
|
|
8
10
|
schemaOptions?: any;
|
|
9
11
|
}) => TBlockletMeta;
|
|
10
12
|
export default validateMeta;
|
package/lib/validate.js
CHANGED
|
@@ -20,12 +20,14 @@ const fixAndValidateService = (meta) => {
|
|
|
20
20
|
return meta;
|
|
21
21
|
};
|
|
22
22
|
exports.fixAndValidateService = fixAndValidateService;
|
|
23
|
-
const validateMeta = (meta, { ensureMain = false, ensureFiles = false, ensureDist = false, ensureComponentStore = true, schemaOptions = {}, } = {}) => {
|
|
23
|
+
const validateMeta = (meta, { ensureMain = false, ensureFiles = false, ensureDist = false, ensureComponentStore = true, ensureName = false, skipValidateDidName = false, schemaOptions = {}, } = {}) => {
|
|
24
24
|
const schema = (0, schema_1.createBlockletSchema)(null, {
|
|
25
25
|
ensureMain,
|
|
26
26
|
ensureFiles,
|
|
27
27
|
ensureDist,
|
|
28
28
|
ensureComponentStore,
|
|
29
|
+
ensureName,
|
|
30
|
+
skipValidateDidName,
|
|
29
31
|
...schemaOptions,
|
|
30
32
|
});
|
|
31
33
|
const { value, error } = schema.validate(meta);
|
package/lib/wallet.d.ts
CHANGED
|
@@ -5,5 +5,5 @@ import { DIDType } from '@arcblock/did';
|
|
|
5
5
|
*
|
|
6
6
|
* Spec: https://github.com/ArcBlock/ABT-DID-Protocol#request-did-authentication
|
|
7
7
|
*/
|
|
8
|
-
declare const
|
|
9
|
-
export =
|
|
8
|
+
declare const getApplicationWallet: (blockletDid: string, nodeSk?: string, type?: DIDType | string, index?: number) => WalletObject;
|
|
9
|
+
export = getApplicationWallet;
|
package/lib/wallet.js
CHANGED
|
@@ -8,7 +8,7 @@ const did_ext_1 = require("@arcblock/did-ext");
|
|
|
8
8
|
*
|
|
9
9
|
* Spec: https://github.com/ArcBlock/ABT-DID-Protocol#request-did-authentication
|
|
10
10
|
*/
|
|
11
|
-
const
|
|
11
|
+
const getApplicationWallet = (blockletDid, nodeSk, type, index) => {
|
|
12
12
|
const t = type || { role: mcrypto_1.types.RoleType.ROLE_APPLICATION };
|
|
13
13
|
if (!(0, did_1.isValid)(blockletDid)) {
|
|
14
14
|
try {
|
|
@@ -23,4 +23,4 @@ const getBlockletWallet = (blockletDid, nodeSk, type, index) => {
|
|
|
23
23
|
}
|
|
24
24
|
return (0, did_ext_1.fromAppDid)(blockletDid, nodeSk, t, index || 0);
|
|
25
25
|
};
|
|
26
|
-
module.exports =
|
|
26
|
+
module.exports = getApplicationWallet;
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.8.69-beta-
|
|
6
|
+
"version": "1.8.69-beta-76f8a46f",
|
|
7
7
|
"description": "Library to parse/validate/fix blocklet meta",
|
|
8
8
|
"main": "./lib/index.js",
|
|
9
9
|
"typings": "./lib/index.d.ts",
|
|
@@ -24,19 +24,19 @@
|
|
|
24
24
|
"author": "wangshijun <wangshijun2020@gmail.com> (http://github.com/wangshijun)",
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@abtnode/client": "1.8.69-beta-
|
|
28
|
-
"@abtnode/constant": "1.8.69-beta-
|
|
29
|
-
"@abtnode/util": "1.8.69-beta-
|
|
30
|
-
"@arcblock/did": "1.18.
|
|
31
|
-
"@arcblock/did-ext": "1.18.
|
|
32
|
-
"@arcblock/did-util": "1.18.
|
|
33
|
-
"@arcblock/jwt": "1.18.
|
|
34
|
-
"@blocklet/constant": "1.8.69-beta-
|
|
35
|
-
"@ocap/asset": "1.18.
|
|
36
|
-
"@ocap/mcrypto": "1.18.
|
|
37
|
-
"@ocap/types": "1.18.
|
|
38
|
-
"@ocap/util": "1.18.
|
|
39
|
-
"@ocap/wallet": "1.18.
|
|
27
|
+
"@abtnode/client": "1.8.69-beta-76f8a46f",
|
|
28
|
+
"@abtnode/constant": "1.8.69-beta-76f8a46f",
|
|
29
|
+
"@abtnode/util": "1.8.69-beta-76f8a46f",
|
|
30
|
+
"@arcblock/did": "1.18.58",
|
|
31
|
+
"@arcblock/did-ext": "1.18.58",
|
|
32
|
+
"@arcblock/did-util": "1.18.58",
|
|
33
|
+
"@arcblock/jwt": "1.18.58",
|
|
34
|
+
"@blocklet/constant": "1.8.69-beta-76f8a46f",
|
|
35
|
+
"@ocap/asset": "1.18.58",
|
|
36
|
+
"@ocap/mcrypto": "1.18.58",
|
|
37
|
+
"@ocap/types": "1.18.58",
|
|
38
|
+
"@ocap/util": "1.18.58",
|
|
39
|
+
"@ocap/wallet": "1.18.58",
|
|
40
40
|
"ajv": "^8.11.0",
|
|
41
41
|
"axios": "^0.27.2",
|
|
42
42
|
"cjk-length": "^1.0.0",
|
|
@@ -81,5 +81,5 @@
|
|
|
81
81
|
"ts-node": "^10.9.1",
|
|
82
82
|
"typescript": "^4.8.4"
|
|
83
83
|
},
|
|
84
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "07415e674443b85648ea80b734f7a3690abfc15e"
|
|
85
85
|
}
|