@blocklet/meta 1.16.15-beta-d8e7b6c0 → 1.16.15-beta-375899b6

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.
@@ -0,0 +1,19 @@
1
+ import type { BlockletState, ComponentState } from '@abtnode/client';
2
+ type TComponentInternalInfo = {
3
+ title: string;
4
+ did: string;
5
+ name?: string;
6
+ version: string;
7
+ mountPoint: string;
8
+ status?: number;
9
+ port?: number;
10
+ resources?: string[];
11
+ };
12
+ declare const getComponentResourcesPath: (component: ComponentState) => string[];
13
+ declare const getComponentsInternalInfo: (app: BlockletState) => Array<TComponentInternalInfo>;
14
+ export { getComponentsInternalInfo, getComponentResourcesPath, TComponentInternalInfo };
15
+ declare const _default: {
16
+ getComponentsInternalInfo: (app: BlockletState) => TComponentInternalInfo[];
17
+ getComponentResourcesPath: (component: ComponentState) => string[];
18
+ };
19
+ export default _default;
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getComponentResourcesPath = exports.getComponentsInternalInfo = void 0;
7
+ const path_1 = __importDefault(require("path"));
8
+ const util_1 = require("./util");
9
+ const getComponentResourcesPath = (component) => {
10
+ const appDir = (component.environments || []).find((y) => y.key === 'BLOCKLET_APP_DIR')?.value;
11
+ if (!appDir) {
12
+ return [];
13
+ }
14
+ return (component.meta?.resources || [])
15
+ .map((y) => {
16
+ const res = path_1.default.join(appDir, y);
17
+ if (!res.startsWith(appDir)) {
18
+ // Invalid resource path
19
+ return '';
20
+ }
21
+ return res;
22
+ })
23
+ .filter(Boolean);
24
+ };
25
+ exports.getComponentResourcesPath = getComponentResourcesPath;
26
+ const getComponentsInternalInfo = (app) => {
27
+ const components = [];
28
+ if (!app) {
29
+ return components;
30
+ }
31
+ (0, util_1.forEachComponentV2Sync)(app, (x) => {
32
+ const component = {
33
+ title: x.meta.title,
34
+ did: x.meta.did,
35
+ name: x.meta.name,
36
+ version: x.meta.version,
37
+ mountPoint: x.mountPoint || '',
38
+ status: x.status,
39
+ port: 0,
40
+ resources: getComponentResourcesPath(x),
41
+ };
42
+ const webInterface = (0, util_1.findWebInterface)(x);
43
+ if (webInterface && (x.environments || []).find((y) => y.key === webInterface.port)) {
44
+ component.port = x.environments.find((y) => y.key === webInterface.port).value;
45
+ }
46
+ components.push(component);
47
+ });
48
+ return components;
49
+ };
50
+ exports.getComponentsInternalInfo = getComponentsInternalInfo;
51
+ exports.default = {
52
+ getComponentsInternalInfo,
53
+ getComponentResourcesPath,
54
+ };
package/lib/channel.d.ts CHANGED
@@ -1,32 +1,40 @@
1
1
  declare const getAppPublicChannelRegex: () => RegExp;
2
+ declare const getComponentChannelRegex: () => RegExp;
2
3
  declare const getRelayChannelRegex: () => RegExp;
3
4
  declare const getAppPublicChannel: (appDid: string) => string;
5
+ declare const getComponentChannel: (appDid: string, componentDid: string) => string;
4
6
  declare const getRelayChannel: (appDid: string, topic: string) => string;
5
7
  declare const CHANNEL_TYPE: {
6
8
  DID: string;
7
9
  APP: string;
10
+ COMPONENT: string;
8
11
  RELAY: string;
9
12
  };
10
13
  declare const parseChannel: (channel: string) => {
11
14
  type: string;
12
15
  appDid?: string;
13
16
  topic?: string;
17
+ componentDid?: string;
14
18
  };
15
- export { CHANNEL_TYPE, getAppPublicChannel, getAppPublicChannelRegex, getRelayChannel, getRelayChannelRegex, parseChannel, };
19
+ export { CHANNEL_TYPE, getAppPublicChannel, getAppPublicChannelRegex, getComponentChannel, getComponentChannelRegex, getRelayChannel, getRelayChannelRegex, parseChannel, };
16
20
  declare const _default: {
17
21
  CHANNEL_TYPE: {
18
22
  DID: string;
19
23
  APP: string;
24
+ COMPONENT: string;
20
25
  RELAY: string;
21
26
  };
22
27
  getAppPublicChannel: (appDid: string) => string;
23
28
  getAppPublicChannelRegex: () => RegExp;
29
+ getComponentChannel: (appDid: string, componentDid: string) => string;
30
+ getComponentChannelRegex: () => RegExp;
24
31
  getRelayChannel: (appDid: string, topic: string) => string;
25
32
  getRelayChannelRegex: () => RegExp;
26
33
  parseChannel: (channel: string) => {
27
34
  type: string;
28
35
  appDid?: string;
29
36
  topic?: string;
37
+ componentDid?: string;
30
38
  };
31
39
  };
32
40
  export default _default;
package/lib/channel.js CHANGED
@@ -1,19 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseChannel = exports.getRelayChannelRegex = exports.getRelayChannel = exports.getAppPublicChannelRegex = exports.getAppPublicChannel = exports.CHANNEL_TYPE = void 0;
3
+ exports.parseChannel = exports.getRelayChannelRegex = exports.getRelayChannel = exports.getComponentChannelRegex = exports.getComponentChannel = exports.getAppPublicChannelRegex = exports.getAppPublicChannel = exports.CHANNEL_TYPE = void 0;
4
4
  /* eslint-disable @typescript-eslint/indent */
5
5
  const did_1 = require("@arcblock/did");
6
6
  const getAppPublicChannelRegex = () => /app:(\w+):public/;
7
7
  exports.getAppPublicChannelRegex = getAppPublicChannelRegex;
8
+ const getComponentChannelRegex = () => /component:(\w+):(\w+)/;
9
+ exports.getComponentChannelRegex = getComponentChannelRegex;
8
10
  const getRelayChannelRegex = () => /relay:(\w+):(\w+)/;
9
11
  exports.getRelayChannelRegex = getRelayChannelRegex;
10
12
  const getAppPublicChannel = (appDid) => `app:${appDid}:public`;
11
13
  exports.getAppPublicChannel = getAppPublicChannel;
14
+ const getComponentChannel = (appDid, componentDid) => `component:${appDid}:${componentDid}`;
15
+ exports.getComponentChannel = getComponentChannel;
12
16
  const getRelayChannel = (appDid, topic) => `relay:${appDid}:${topic}`;
13
17
  exports.getRelayChannel = getRelayChannel;
14
18
  const CHANNEL_TYPE = {
15
19
  DID: 'DID',
16
20
  APP: 'APP',
21
+ COMPONENT: 'COMPONENT',
17
22
  RELAY: 'RELAY',
18
23
  };
19
24
  exports.CHANNEL_TYPE = CHANNEL_TYPE;
@@ -36,6 +41,20 @@ const parseChannel = (channel) => {
36
41
  appDid: match[1],
37
42
  };
38
43
  }
44
+ match = getComponentChannelRegex().exec(channel);
45
+ if (match) {
46
+ if (!(0, did_1.isValid)(match[1])) {
47
+ throw Error(`Invalid appDid in component channel: ${match[1]}`);
48
+ }
49
+ if (!(0, did_1.isValid)(match[2])) {
50
+ throw Error(`Invalid componentDid in component channel: ${match[2]}`);
51
+ }
52
+ return {
53
+ type: CHANNEL_TYPE.COMPONENT,
54
+ appDid: match[1],
55
+ componentDid: match[2],
56
+ };
57
+ }
39
58
  if ((0, did_1.isValid)(channel)) {
40
59
  return {
41
60
  type: CHANNEL_TYPE.DID,
@@ -48,6 +67,8 @@ exports.default = {
48
67
  CHANNEL_TYPE,
49
68
  getAppPublicChannel,
50
69
  getAppPublicChannelRegex,
70
+ getComponentChannel,
71
+ getComponentChannelRegex,
51
72
  getRelayChannel,
52
73
  getRelayChannelRegex,
53
74
  parseChannel,
package/lib/entry.js CHANGED
@@ -10,6 +10,9 @@ const get_1 = __importDefault(require("lodash/get"));
10
10
  const constant_1 = require("@blocklet/constant");
11
11
  const validateBlockletEntry = (dir, meta) => {
12
12
  const { main, group } = meta;
13
+ if (!main) {
14
+ return;
15
+ }
13
16
  if (group === constant_1.BlockletGroup.dapp) {
14
17
  // backward compatible
15
18
  if (!fs_1.default.existsSync(path_1.default.join(dir, 'blocklet.js')) &&
@@ -39,17 +42,11 @@ const validateBlockletEntry = (dir, meta) => {
39
42
  }
40
43
  }
41
44
  }
42
- return;
43
45
  }
44
46
  if (group === constant_1.BlockletGroup.static) {
45
47
  if (!fs_1.default.existsSync(path_1.default.join(dir, main))) {
46
48
  throw new Error(`${meta.bundleName} may be corrupted or not properly configured: missing main folder`);
47
49
  }
48
- return;
49
- }
50
- if (group === constant_1.BlockletGroup.gateway) {
51
- return;
52
50
  }
53
- throw new Error(`${meta.bundleName} Unsupported blocklet type ${group}`);
54
51
  };
55
52
  module.exports = validateBlockletEntry;
package/lib/fix.js CHANGED
@@ -27,16 +27,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.fixService = exports.fixInterfaces = exports.parsePerson = exports.formatPerson = exports.fixName = exports.fixTags = exports.fixPerson = exports.fixKeywords = exports.fixFiles = exports.fixRepository = exports.fixRequired = void 0;
30
- const fs_1 = __importDefault(require("fs"));
31
- const path_1 = __importDefault(require("path"));
32
30
  const get_1 = __importDefault(require("lodash/get"));
33
31
  const gitInfo = __importStar(require("hosted-git-info"));
34
- const debug_1 = __importDefault(require("debug"));
35
32
  const constant_1 = require("@blocklet/constant");
36
33
  const validate_1 = require("./validate");
37
34
  Object.defineProperty(exports, "fixService", { enumerable: true, get: function () { return validate_1.fixAndValidateService; } });
38
35
  const name_1 = require("./name");
39
- const debug = (0, debug_1.default)('@blocklet/meta:fix');
40
36
  // Assign sensible defaults: description/main/group/version/public_url
41
37
  const fixRequired = (data, dir) => {
42
38
  if (!data.description) {
@@ -45,30 +41,6 @@ const fixRequired = (data, dir) => {
45
41
  if (!data.version) {
46
42
  data.version = constant_1.BLOCKLET_DEFAULT_VERSION;
47
43
  }
48
- if (!data.main && !data.group) {
49
- debug('guess main and group', dir);
50
- data.group = 'static';
51
- const items = ['.'].concat(fs_1.default.readdirSync(dir));
52
- const item = items.find((x) => fs_1.default.existsSync(path_1.default.resolve(dir, x, 'index.html')) || fs_1.default.existsSync(path_1.default.resolve(dir, x, 'index.htm')));
53
- if (item) {
54
- data.main = item;
55
- }
56
- }
57
- if (!data.group) {
58
- const main = path_1.default.join(dir, data.main);
59
- try {
60
- const stat = fs_1.default.statSync(main);
61
- if (stat.isDirectory()) {
62
- data.group = 'static';
63
- }
64
- else {
65
- data.group = 'dapp';
66
- }
67
- }
68
- catch (err) {
69
- data.group = 'static';
70
- }
71
- }
72
44
  };
73
45
  exports.fixRequired = fixRequired;
74
46
  const fixRepository = (data) => {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  const constant_1 = require("@blocklet/constant");
3
- const hasReservedKey = (environments) => environments.some((x) => {
3
+ const hasReservedKey = (environments) => (environments || []).some((x) => {
4
4
  // @ts-ignore
5
5
  const key = (x.key || x.name || '').toString();
6
6
  if (key.startsWith('ABT_NODE_')) {
package/lib/index.d.ts CHANGED
@@ -40,8 +40,7 @@ declare const _default: {
40
40
  fix?: boolean;
41
41
  }) => void;
42
42
  read: (file: string) => unknown;
43
- parse: (dir: string, { ensureMain, ensureFiles, ensureDist, ensureComponentStore, extraRawAttrs, schemaOptions, defaultStoreUrl, fix, }?: {
44
- ensureMain?: boolean;
43
+ parse: (dir: string, { ensureFiles, ensureDist, ensureComponentStore, extraRawAttrs, schemaOptions, defaultStoreUrl, fix, }?: {
45
44
  ensureFiles?: boolean;
46
45
  ensureDist?: boolean;
47
46
  ensureComponentStore?: boolean;
@@ -52,8 +51,7 @@ declare const _default: {
52
51
  defaultStoreUrl?: string | ((component: import("./types").TComponent) => string);
53
52
  fix?: boolean;
54
53
  }) => import("./types").TBlockletMeta;
55
- validateMeta: (meta: any, { ensureMain, ensureFiles, ensureDist, ensureComponentStore, ensureName, skipValidateDidName, schemaOptions, }?: {
56
- ensureMain?: boolean;
54
+ validateMeta: (meta: any, { ensureFiles, ensureDist, ensureComponentStore, ensureName, skipValidateDidName, schemaOptions, }?: {
57
55
  ensureFiles?: boolean;
58
56
  ensureDist?: boolean;
59
57
  ensureComponentStore?: boolean;
@@ -69,7 +67,7 @@ declare const _default: {
69
67
  fixName: (meta: any) => any;
70
68
  fixService: (meta: import("./types").TBlockletMeta) => import("./types").TBlockletMeta;
71
69
  toBlockletDid: (name: string | Buffer) => string;
72
- getBlockletWallet: (didOrSk: string, nodeSk?: string, type?: "default" | "eth" | "ethereum" | import("@arcblock/did").DIDType, index?: number) => import("@ocap/wallet").WalletObject<string>;
70
+ getBlockletWallet: (didOrSk: string, nodeSk?: string, type?: "ethereum" | "default" | "eth" | import("@arcblock/did").DIDType, index?: number) => import("@ocap/wallet").WalletObject<string>;
73
71
  getBlockletInfo: (state: import("@abtnode/client").BlockletState, nodeSk?: string, { returnWallet }?: {
74
72
  returnWallet?: boolean;
75
73
  }) => {
package/lib/parse.d.ts CHANGED
@@ -3,12 +3,10 @@ import { TBlockletMeta, TComponent } from './types';
3
3
  * Get blocklet meta from blocklet.yml
4
4
  * @param {string} dir blocklet directory
5
5
  * @param {object} options.extraRawAttrs extra attributes, will be used as base attributes
6
- * @param {boolean} options.ensureMain should we verify that main exists
7
6
  * @param {boolean} options.ensureDist should we verify that dist exists
8
7
  * @param {boolean} options.ensureFiles should we verify that logo and files exists
9
8
  */
10
- declare const parse: (dir: string, { ensureMain, ensureFiles, ensureDist, ensureComponentStore, extraRawAttrs, schemaOptions, defaultStoreUrl, fix, }?: {
11
- ensureMain?: boolean;
9
+ declare const parse: (dir: string, { ensureFiles, ensureDist, ensureComponentStore, extraRawAttrs, schemaOptions, defaultStoreUrl, fix, }?: {
12
10
  ensureFiles?: boolean;
13
11
  ensureDist?: boolean;
14
12
  ensureComponentStore?: boolean;
package/lib/parse.js CHANGED
@@ -17,11 +17,10 @@ const isSourceFromStore = (source) => 'name' in source || 'did' in source;
17
17
  * Get blocklet meta from blocklet.yml
18
18
  * @param {string} dir blocklet directory
19
19
  * @param {object} options.extraRawAttrs extra attributes, will be used as base attributes
20
- * @param {boolean} options.ensureMain should we verify that main exists
21
20
  * @param {boolean} options.ensureDist should we verify that dist exists
22
21
  * @param {boolean} options.ensureFiles should we verify that logo and files exists
23
22
  */
24
- const parse = (dir, { ensureMain = false, ensureFiles = false, ensureDist = false, ensureComponentStore = true, extraRawAttrs = {}, schemaOptions = {}, defaultStoreUrl, fix = true, } = {}) => {
23
+ const parse = (dir, { ensureFiles = false, ensureDist = false, ensureComponentStore = true, extraRawAttrs = {}, schemaOptions = {}, defaultStoreUrl, fix = true, } = {}) => {
25
24
  let result;
26
25
  const blockletMetaFile = path_1.default.join(dir, constant_1.BLOCKLET_META_FILE);
27
26
  const blockletMetaFileAlt = path_1.default.join(dir, constant_1.BLOCKLET_META_FILE_ALT);
@@ -74,8 +73,6 @@ const parse = (dir, { ensureMain = false, ensureFiles = false, ensureDist = fals
74
73
  });
75
74
  }
76
75
  });
77
- // We will overwrite did anyway
78
- result.path = `/${result.group}/${result.name}`;
79
76
  // Ensure camelCase
80
77
  result = Object.keys(result).reduce((acc, k) => {
81
78
  acc[(0, camelCase_1.default)(k)] = result[k];
@@ -84,7 +81,6 @@ const parse = (dir, { ensureMain = false, ensureFiles = false, ensureDist = fals
84
81
  debug('fix', result);
85
82
  // Validate and cleanup
86
83
  const schema = (0, schema_1.createBlockletSchema)(dir, {
87
- ensureMain,
88
84
  ensureFiles,
89
85
  ensureDist,
90
86
  ensureComponentStore,
@@ -1,7 +1,7 @@
1
1
  import v2 from './v2';
2
2
  export declare const createNftFactoryItx: ({ meta, tokens, shares, issuers, serviceUrl, }: {
3
3
  meta: import("../types").TBlockletMeta;
4
- tokens: Pick<import("@abtnode/client").BlockletPaymentPrice, "address" | "value">[];
4
+ tokens: Pick<import("@abtnode/client").BlockletPaymentPrice, "value" | "address">[];
5
5
  shares: {
6
6
  value: number;
7
7
  address: string;
@@ -15,7 +15,7 @@ export declare const createNftFactoryItx: ({ meta, tokens, shares, issuers, serv
15
15
  limit: number;
16
16
  trustedIssuers: string[];
17
17
  input: {
18
- tokens: Pick<import("@abtnode/client").BlockletPaymentPrice, "address" | "value">[];
18
+ tokens: Pick<import("@abtnode/client").BlockletPaymentPrice, "value" | "address">[];
19
19
  assets: any[];
20
20
  variables: any[];
21
21
  };
@@ -85,7 +85,7 @@ export { v2 };
85
85
  declare const _default: {
86
86
  createNftFactoryItx: ({ meta, tokens, shares, issuers, serviceUrl, }: {
87
87
  meta: import("../types").TBlockletMeta;
88
- tokens: Pick<import("@abtnode/client").BlockletPaymentPrice, "address" | "value">[];
88
+ tokens: Pick<import("@abtnode/client").BlockletPaymentPrice, "value" | "address">[];
89
89
  shares: {
90
90
  value: number;
91
91
  address: string;
@@ -99,7 +99,7 @@ declare const _default: {
99
99
  limit: number;
100
100
  trustedIssuers: string[];
101
101
  input: {
102
- tokens: Pick<import("@abtnode/client").BlockletPaymentPrice, "address" | "value">[];
102
+ tokens: Pick<import("@abtnode/client").BlockletPaymentPrice, "value" | "address">[];
103
103
  assets: any[];
104
104
  variables: any[];
105
105
  };
@@ -23,7 +23,7 @@ declare const createNftFactoryItx: ({ meta, tokens, shares, issuers, serviceUrl,
23
23
  limit: number;
24
24
  trustedIssuers: string[];
25
25
  input: {
26
- tokens: Pick<BlockletPaymentPrice, "address" | "value">[];
26
+ tokens: Pick<BlockletPaymentPrice, "value" | "address">[];
27
27
  assets: any[];
28
28
  variables: any[];
29
29
  };
@@ -93,7 +93,7 @@ export { createShareContract };
93
93
  export { createNftFactoryItx };
94
94
  declare const _default: {
95
95
  createShareContract: ({ tokens, shares, }: {
96
- tokens?: Pick<BlockletPaymentPrice, "address" | "value">[];
96
+ tokens?: Pick<BlockletPaymentPrice, "value" | "address">[];
97
97
  shares: {
98
98
  value: number;
99
99
  address: string;
@@ -101,7 +101,7 @@ declare const _default: {
101
101
  }) => string;
102
102
  createNftFactoryItx: ({ meta, tokens, shares, issuers, serviceUrl, }: {
103
103
  meta: TBlockletMeta;
104
- tokens: Pick<BlockletPaymentPrice, "address" | "value">[];
104
+ tokens: Pick<BlockletPaymentPrice, "value" | "address">[];
105
105
  shares: {
106
106
  value: number;
107
107
  address: string;
@@ -115,7 +115,7 @@ declare const _default: {
115
115
  limit: number;
116
116
  trustedIssuers: string[];
117
117
  input: {
118
- tokens: Pick<BlockletPaymentPrice, "address" | "value">[];
118
+ tokens: Pick<BlockletPaymentPrice, "value" | "address">[];
119
119
  assets: any[];
120
120
  variables: any[];
121
121
  };
package/lib/schema.d.ts CHANGED
@@ -23,8 +23,7 @@ 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, ensureName, skipValidateDidName, ...schemaOptions }?: {
27
- ensureMain?: boolean;
26
+ declare const createBlockletSchema: (baseDir: string, { ensureFiles, ensureDist, ensureComponentStore, ensureName, skipValidateDidName, ...schemaOptions }?: {
28
27
  ensureFiles?: boolean;
29
28
  ensureDist?: boolean;
30
29
  ensureComponentStore?: boolean;
@@ -37,8 +36,7 @@ declare const _default: {
37
36
  componentSchema: JOI.ObjectSchema<any>;
38
37
  endpointSchema: JOI.ObjectSchema<any>;
39
38
  serviceSchema: JOI.ObjectSchema<any>;
40
- createBlockletSchema: (baseDir: string, { ensureMain, ensureFiles, ensureDist, ensureComponentStore, ensureName, skipValidateDidName, ...schemaOptions }?: {
41
- ensureMain?: boolean;
39
+ createBlockletSchema: (baseDir: string, { ensureFiles, ensureDist, ensureComponentStore, ensureName, skipValidateDidName, ...schemaOptions }?: {
42
40
  ensureFiles?: boolean;
43
41
  ensureDist?: boolean;
44
42
  ensureComponentStore?: boolean;
package/lib/schema.js CHANGED
@@ -471,10 +471,8 @@ const blockletMetaProps = {
471
471
  version: Joi.semver().valid().required(),
472
472
  name: Joi.string().optional(),
473
473
  description: descriptionSchema.required(),
474
- group: Joi.string()
475
- .valid(...constant_2.BLOCKLET_GROUPS)
476
- .required(),
477
- main: Joi.string().trim().required(),
474
+ group: Joi.string().valid(...constant_2.BLOCKLET_GROUPS),
475
+ main: Joi.string().trim(),
478
476
  title: titleSchema.optional().allow(''),
479
477
  logo: Joi.string().trim().optional(),
480
478
  specVersion: Joi.semver().valid().gte('1.0.0').optional(),
@@ -590,7 +588,6 @@ const blockletMetaProps = {
590
588
  interfaces: Joi.array()
591
589
  .items(interfaceSchema)
592
590
  .unique('name')
593
- .min(1)
594
591
  .custom((value, helper) => {
595
592
  const webItems = value.filter((x) => x.type === constant_2.BLOCKLET_INTERFACE_TYPE_WEB);
596
593
  if (webItems.length > 1) {
@@ -648,6 +645,7 @@ const blockletMetaProps = {
648
645
  dist: distSchema.optional(),
649
646
  stats: statsSchema.optional(),
650
647
  htmlAst: Joi.any().optional(),
648
+ // deprecated
651
649
  path: Joi.string().optional(),
652
650
  signatures: Joi.array().items(signatureSchema).optional(),
653
651
  lastPublishedAt: Joi.string().isoDate().optional(),
@@ -671,18 +669,13 @@ const blockletMetaSchema = Joi.object(blockletMetaProps).options({ stripUnknown:
671
669
  unknownType: 'any',
672
670
  });
673
671
  exports.blockletMetaSchema = blockletMetaSchema;
674
- const createBlockletSchema = (baseDir, { ensureMain = false, ensureFiles = false, ensureDist = false, ensureComponentStore = true, ensureName = false, skipValidateDidName = false, ...schemaOptions } = {}) => {
672
+ const createBlockletSchema = (baseDir, { ensureFiles = false, ensureDist = false, ensureComponentStore = true, ensureName = false, skipValidateDidName = false, ...schemaOptions } = {}) => {
675
673
  if (!baseDir || !fs_1.default.existsSync(baseDir)) {
676
674
  // eslint-disable-next-line no-param-reassign
677
675
  ensureFiles = false;
678
676
  }
679
677
  return Joi.object({
680
678
  ...blockletMetaProps,
681
- main: Joi.when('group', {
682
- is: Joi.valid(constant_2.BlockletGroup.gateway),
683
- then: Joi.forbidden(),
684
- otherwise: ensureMain ? Joi.file().exists({ baseDir }).required() : Joi.string().trim().required(),
685
- }),
686
679
  logo: ensureFiles ? Joi.file().trim().exists({ baseDir }).optional() : Joi.string().trim().optional(),
687
680
  // Other contents to be included in the bundle
688
681
  files: Joi.array()
@@ -695,6 +688,7 @@ const createBlockletSchema = (baseDir, { ensureMain = false, ensureFiles = false
695
688
  components: componentsSchema({ checkStore: ensureComponentStore }),
696
689
  staticComponents: componentsSchema({ isStatic: true, checkStore: ensureComponentStore }),
697
690
  name: ensureName ? Joi.string().optional() : Joi.string().required(),
691
+ resources: Joi.array().items(Joi.string().trim().required()),
698
692
  })
699
693
  .options({ stripUnknown: true, noDefaults: false, ...schemaOptions })
700
694
  .rename('children', 'components')
@@ -46,7 +46,7 @@ export interface TBlockletMeta {
46
46
  environments?: TEnvironment[];
47
47
  files?: string[];
48
48
  gitHash?: string;
49
- group: 'dapp' | 'static' | 'gateway';
49
+ group?: 'dapp' | 'static' | 'gateway';
50
50
  homepage?: string;
51
51
  htmlAst?: any;
52
52
  interfaces?: TInterface[];
@@ -55,7 +55,7 @@ export interface TBlockletMeta {
55
55
  license?: string;
56
56
  logo?: string;
57
57
  logoUrl?: string;
58
- main: string;
58
+ main?: string;
59
59
  maintainers?: TPerson[];
60
60
  name?: string;
61
61
  navigation?: TNavigation;
package/lib/util.d.ts CHANGED
@@ -142,16 +142,8 @@ declare const getBlockletServices: (blocklet: Partial<BlockletState>) => Array<{
142
142
  declare const isInProgress: (status: string | number) => boolean;
143
143
  declare const isBeforeInstalled: (status: string | number) => boolean;
144
144
  declare const isRunning: (status: string | number) => boolean;
145
- type TComponentInternalInfo = {
146
- title: string;
147
- did: string;
148
- name: string;
149
- mountPoint: string;
150
- status: number;
151
- port: number;
152
- };
153
- declare const getComponentsInternalInfo: (app: TApp) => Array<TComponentInternalInfo>;
154
- export { isFreeBlocklet, isFreeComponent, isComponentBlocklet, forEachBlocklet, forEachBlockletSync, forEachChild, forEachChildSync, forEachComponentV2, forEachComponentV2Sync, isDeletableBlocklet, getSharedConfigObj, getAppMissingConfigs, getComponentMissingConfigs, isEnvShareable, wipeSensitiveData, hasRunnableComponent, getAppName, getAppName as getDisplayName, getAppDescription, fixBlockletStatus, findWebInterface, findWebInterfacePort, findServiceFromMeta, getWhoCanAccess, getComponentWhoCanAccess, replaceSlotToIp, getComponentId, getComponentName, getComponentBundleId, findComponent, findComponentById, findComponentV2, findComponentByIdV2, filterComponentsV2, getParentComponentName, getConnectAppUrl, getChainInfo, getBlockletChainInfo, isExternalBlocklet, isPreferenceKey, getRolesFromAuthConfig, getBlockletAppIdList, getBlockletServices, isInProgress, isBeforeInstalled, isRunning, getComponentsInternalInfo, TComponentInternalInfo, isGatewayBlocklet, };
145
+ declare const hasStartEngine: (meta: TBlockletMeta) => boolean;
146
+ export { isFreeBlocklet, isFreeComponent, isComponentBlocklet, forEachBlocklet, forEachBlockletSync, forEachChild, forEachChildSync, forEachComponentV2, forEachComponentV2Sync, isDeletableBlocklet, getSharedConfigObj, getAppMissingConfigs, getComponentMissingConfigs, isEnvShareable, wipeSensitiveData, hasRunnableComponent, getAppName, getAppName as getDisplayName, getAppDescription, fixBlockletStatus, findWebInterface, findWebInterfacePort, findServiceFromMeta, getWhoCanAccess, getComponentWhoCanAccess, replaceSlotToIp, getComponentId, getComponentName, getComponentBundleId, findComponent, findComponentById, findComponentV2, findComponentByIdV2, filterComponentsV2, getParentComponentName, getConnectAppUrl, getChainInfo, getBlockletChainInfo, isExternalBlocklet, isPreferenceKey, getRolesFromAuthConfig, getBlockletAppIdList, getBlockletServices, isInProgress, isBeforeInstalled, isRunning, isGatewayBlocklet, hasStartEngine, };
155
147
  declare const _default: {
156
148
  isFreeBlocklet: (meta: TBlockletMeta) => boolean;
157
149
  isFreeComponent: (meta: TBlockletMeta) => boolean;
@@ -257,7 +249,7 @@ declare const _default: {
257
249
  isInProgress: (status: string | number) => boolean;
258
250
  isBeforeInstalled: (status: string | number) => boolean;
259
251
  isRunning: (status: string | number) => boolean;
260
- getComponentsInternalInfo: (app: BlockletState) => TComponentInternalInfo[];
261
252
  isGatewayBlocklet: (meta: TBlockletMeta) => boolean;
253
+ hasStartEngine: (meta: TBlockletMeta) => boolean;
262
254
  };
263
255
  export default _default;
package/lib/util.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.isGatewayBlocklet = exports.getComponentsInternalInfo = exports.isRunning = exports.isBeforeInstalled = exports.isInProgress = exports.getBlockletServices = exports.getBlockletAppIdList = exports.getRolesFromAuthConfig = exports.isPreferenceKey = exports.isExternalBlocklet = exports.getBlockletChainInfo = exports.getChainInfo = exports.getConnectAppUrl = exports.getParentComponentName = exports.filterComponentsV2 = exports.findComponentByIdV2 = exports.findComponentV2 = exports.findComponentById = exports.findComponent = exports.getComponentBundleId = exports.getComponentName = exports.getComponentId = exports.replaceSlotToIp = exports.getComponentWhoCanAccess = exports.getWhoCanAccess = exports.findServiceFromMeta = exports.findWebInterfacePort = exports.findWebInterface = exports.fixBlockletStatus = exports.getAppDescription = exports.getDisplayName = exports.getAppName = exports.hasRunnableComponent = exports.wipeSensitiveData = exports.isEnvShareable = exports.getComponentMissingConfigs = exports.getAppMissingConfigs = exports.getSharedConfigObj = exports.isDeletableBlocklet = exports.forEachComponentV2Sync = exports.forEachComponentV2 = exports.forEachChildSync = exports.forEachChild = exports.forEachBlockletSync = exports.forEachBlocklet = exports.isComponentBlocklet = exports.isFreeComponent = exports.isFreeBlocklet = void 0;
6
+ exports.hasStartEngine = exports.isGatewayBlocklet = exports.isRunning = exports.isBeforeInstalled = exports.isInProgress = exports.getBlockletServices = exports.getBlockletAppIdList = exports.getRolesFromAuthConfig = exports.isPreferenceKey = exports.isExternalBlocklet = exports.getBlockletChainInfo = exports.getChainInfo = exports.getConnectAppUrl = exports.getParentComponentName = exports.filterComponentsV2 = exports.findComponentByIdV2 = exports.findComponentV2 = exports.findComponentById = exports.findComponent = exports.getComponentBundleId = exports.getComponentName = exports.getComponentId = exports.replaceSlotToIp = exports.getComponentWhoCanAccess = exports.getWhoCanAccess = exports.findServiceFromMeta = exports.findWebInterfacePort = exports.findWebInterface = exports.fixBlockletStatus = exports.getAppDescription = exports.getDisplayName = exports.getAppName = exports.hasRunnableComponent = exports.wipeSensitiveData = exports.isEnvShareable = exports.getComponentMissingConfigs = exports.getAppMissingConfigs = exports.getSharedConfigObj = exports.isDeletableBlocklet = exports.forEachComponentV2Sync = exports.forEachComponentV2 = exports.forEachChildSync = exports.forEachChild = exports.forEachBlockletSync = exports.forEachBlocklet = exports.isComponentBlocklet = exports.isFreeComponent = exports.isFreeBlocklet = void 0;
7
7
  /* eslint-disable no-await-in-loop */
8
8
  const get_1 = __importDefault(require("lodash/get"));
9
9
  const uniq_1 = __importDefault(require("lodash/uniq"));
@@ -412,8 +412,9 @@ const isDeletableBlocklet = (blocklet) => {
412
412
  return config.value === 'yes';
413
413
  };
414
414
  exports.isDeletableBlocklet = isDeletableBlocklet;
415
+ const isGatewayBlocklet = (meta) =>
415
416
  // @ts-ignore
416
- const isGatewayBlocklet = (meta) => meta?.group === constant_2.BlockletGroup.gateway || meta?.group === 'gateway';
417
+ meta?.group === constant_2.BlockletGroup.gateway || meta?.group === 'gateway';
417
418
  exports.isGatewayBlocklet = isGatewayBlocklet;
418
419
  const hasRunnableComponent = (blocklet) => {
419
420
  let has = false;
@@ -672,29 +673,8 @@ const isBeforeInstalled = (status) => [
672
673
  exports.isBeforeInstalled = isBeforeInstalled;
673
674
  const isRunning = (status) => [constant_2.BlockletStatus.running, 'running'].includes(status);
674
675
  exports.isRunning = isRunning;
675
- const getComponentsInternalInfo = (app) => {
676
- const components = [];
677
- if (!app) {
678
- return components;
679
- }
680
- forEachComponentV2Sync(app, (x) => {
681
- const component = {
682
- title: x.meta.title,
683
- did: x.meta.did,
684
- name: x.meta.name,
685
- mountPoint: x.mountPoint || '',
686
- status: x.status,
687
- port: 0,
688
- };
689
- const webInterface = findWebInterface(x);
690
- if (webInterface && (x.environments || []).find((y) => y.key === webInterface.port)) {
691
- component.port = x.environments.find((y) => y.key === webInterface.port).value;
692
- }
693
- components.push(component);
694
- });
695
- return components;
696
- };
697
- exports.getComponentsInternalInfo = getComponentsInternalInfo;
676
+ const hasStartEngine = (meta) => !!meta?.main;
677
+ exports.hasStartEngine = hasStartEngine;
698
678
  exports.default = {
699
679
  isFreeBlocklet,
700
680
  isFreeComponent,
@@ -741,6 +721,6 @@ exports.default = {
741
721
  isInProgress,
742
722
  isBeforeInstalled,
743
723
  isRunning,
744
- getComponentsInternalInfo,
745
724
  isGatewayBlocklet,
725
+ hasStartEngine,
746
726
  };
package/lib/validate.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import { TBlockletMeta } from './types';
2
2
  declare const fixAndValidateService: (meta: TBlockletMeta) => TBlockletMeta;
3
- declare const validateMeta: (meta: any, { ensureMain, ensureFiles, ensureDist, ensureComponentStore, ensureName, skipValidateDidName, schemaOptions, }?: {
4
- ensureMain?: boolean;
3
+ declare const validateMeta: (meta: any, { ensureFiles, ensureDist, ensureComponentStore, ensureName, skipValidateDidName, schemaOptions, }?: {
5
4
  ensureFiles?: boolean;
6
5
  ensureDist?: boolean;
7
6
  ensureComponentStore?: boolean;
package/lib/validate.js CHANGED
@@ -20,9 +20,8 @@ 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, ensureName = false, skipValidateDidName = false, schemaOptions = {}, } = {}) => {
23
+ const validateMeta = (meta, { ensureFiles = false, ensureDist = false, ensureComponentStore = true, ensureName = false, skipValidateDidName = false, schemaOptions = {}, } = {}) => {
24
24
  const schema = (0, schema_1.createBlockletSchema)(null, {
25
- ensureMain,
26
25
  ensureFiles,
27
26
  ensureDist,
28
27
  ensureComponentStore,
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.16.15-beta-d8e7b6c0",
6
+ "version": "1.16.15-beta-375899b6",
7
7
  "description": "Library to parse/validate/fix blocklet meta",
8
8
  "main": "./lib/index.js",
9
9
  "typings": "./lib/index.d.ts",
@@ -24,13 +24,13 @@
24
24
  "author": "wangshijun <wangshijun2020@gmail.com> (http://github.com/wangshijun)",
25
25
  "license": "Apache-2.0",
26
26
  "dependencies": {
27
- "@abtnode/constant": "1.16.15-beta-d8e7b6c0",
28
- "@abtnode/util": "1.16.15-beta-d8e7b6c0",
27
+ "@abtnode/constant": "1.16.15-beta-375899b6",
28
+ "@abtnode/util": "1.16.15-beta-375899b6",
29
29
  "@arcblock/did": "1.18.89",
30
30
  "@arcblock/did-ext": "1.18.89",
31
31
  "@arcblock/did-util": "1.18.89",
32
32
  "@arcblock/jwt": "1.18.89",
33
- "@blocklet/constant": "1.16.15-beta-d8e7b6c0",
33
+ "@blocklet/constant": "1.16.15-beta-375899b6",
34
34
  "@ocap/asset": "1.18.89",
35
35
  "@ocap/mcrypto": "1.18.89",
36
36
  "@ocap/types": "1.18.89",
@@ -78,5 +78,5 @@
78
78
  "ts-node": "^10.9.1",
79
79
  "typescript": "^5.0.4"
80
80
  },
81
- "gitHead": "87ebe2e8267e634e2217d7ca28231d0b01636ae6"
81
+ "gitHead": "c999a7f47ecdca1494eb53fc177d28899b3effc9"
82
82
  }