@blocklet/meta 1.16.39-beta-20250222-094928-e54632fa → 1.16.39-beta-20250225-115803-28695007

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/channel.d.ts CHANGED
@@ -1,14 +1,17 @@
1
1
  declare const getAppPublicChannelRegex: () => RegExp;
2
2
  declare const getComponentChannelRegex: () => RegExp;
3
3
  declare const getRelayChannelRegex: () => RegExp;
4
+ declare const getEventBusChannelRegex: () => RegExp;
4
5
  declare const getAppPublicChannel: (appDid: string) => string;
5
6
  declare const getComponentChannel: (appDid: string, componentDid: string) => string;
6
7
  declare const getRelayChannel: (appDid: string, topic: string) => string;
8
+ declare const getEventBusChannel: (appDid: string) => string;
7
9
  declare const CHANNEL_TYPE: {
8
10
  DID: string;
9
11
  APP: string;
10
12
  COMPONENT: string;
11
13
  RELAY: string;
14
+ EVENT_BUS: string;
12
15
  };
13
16
  declare const parseChannel: (channel: string) => {
14
17
  type: string;
@@ -16,13 +19,14 @@ declare const parseChannel: (channel: string) => {
16
19
  topic?: string;
17
20
  componentDid?: string;
18
21
  };
19
- export { CHANNEL_TYPE, getAppPublicChannel, getAppPublicChannelRegex, getComponentChannel, getComponentChannelRegex, getRelayChannel, getRelayChannelRegex, parseChannel, };
22
+ export { CHANNEL_TYPE, getAppPublicChannel, getAppPublicChannelRegex, getComponentChannel, getComponentChannelRegex, getRelayChannel, getRelayChannelRegex, parseChannel, getEventBusChannel, getEventBusChannelRegex, };
20
23
  declare const _default: {
21
24
  CHANNEL_TYPE: {
22
25
  DID: string;
23
26
  APP: string;
24
27
  COMPONENT: string;
25
28
  RELAY: string;
29
+ EVENT_BUS: string;
26
30
  };
27
31
  getAppPublicChannel: (appDid: string) => string;
28
32
  getAppPublicChannelRegex: () => RegExp;
@@ -36,5 +40,7 @@ declare const _default: {
36
40
  topic?: string;
37
41
  componentDid?: string;
38
42
  };
43
+ getEventBusChannel: (appDid: string) => string;
44
+ getEventBusChannelRegex: () => RegExp;
39
45
  };
40
46
  export default _default;
package/lib/channel.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseChannel = exports.getRelayChannelRegex = exports.getRelayChannel = exports.getComponentChannelRegex = exports.getComponentChannel = exports.getAppPublicChannelRegex = exports.getAppPublicChannel = exports.CHANNEL_TYPE = void 0;
3
+ exports.getEventBusChannelRegex = exports.getEventBusChannel = 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/;
@@ -9,17 +9,22 @@ const getComponentChannelRegex = () => /component:(\w+):(\w+)/;
9
9
  exports.getComponentChannelRegex = getComponentChannelRegex;
10
10
  const getRelayChannelRegex = () => /relay:(\w+):(\w+)/;
11
11
  exports.getRelayChannelRegex = getRelayChannelRegex;
12
+ const getEventBusChannelRegex = () => /app:(\w+):event/;
13
+ exports.getEventBusChannelRegex = getEventBusChannelRegex;
12
14
  const getAppPublicChannel = (appDid) => `app:${appDid}:public`;
13
15
  exports.getAppPublicChannel = getAppPublicChannel;
14
16
  const getComponentChannel = (appDid, componentDid) => `component:${appDid}:${componentDid}`;
15
17
  exports.getComponentChannel = getComponentChannel;
16
18
  const getRelayChannel = (appDid, topic) => `relay:${appDid}:${topic}`;
17
19
  exports.getRelayChannel = getRelayChannel;
20
+ const getEventBusChannel = (appDid) => `app:${appDid}:eventbus`;
21
+ exports.getEventBusChannel = getEventBusChannel;
18
22
  const CHANNEL_TYPE = {
19
23
  DID: 'DID',
20
24
  APP: 'APP',
21
25
  COMPONENT: 'COMPONENT',
22
26
  RELAY: 'RELAY',
27
+ EVENT_BUS: 'EVENT_BUS',
23
28
  };
24
29
  exports.CHANNEL_TYPE = CHANNEL_TYPE;
25
30
  const parseChannel = (channel) => {
@@ -34,6 +39,13 @@ const parseChannel = (channel) => {
34
39
  topic: match[2],
35
40
  };
36
41
  }
42
+ match = getEventBusChannelRegex().exec(channel);
43
+ if (match && (0, did_1.isValid)(match[1])) {
44
+ return {
45
+ type: CHANNEL_TYPE.EVENT_BUS,
46
+ appDid: match[1],
47
+ };
48
+ }
37
49
  match = getAppPublicChannelRegex().exec(channel);
38
50
  if (match && (0, did_1.isValid)(match[1])) {
39
51
  return {
@@ -72,4 +84,6 @@ exports.default = {
72
84
  getRelayChannel,
73
85
  getRelayChannelRegex,
74
86
  parseChannel,
87
+ getEventBusChannel,
88
+ getEventBusChannelRegex,
75
89
  };
package/lib/schema.d.ts CHANGED
@@ -28,6 +28,7 @@ declare const navigationSchema: JOI.ArraySchema<any[]>;
28
28
  declare const themeSchema: JOI.ObjectSchema<any>;
29
29
  declare const authConfigSchema: JOI.ObjectSchema<any>;
30
30
  declare const resourceBundleSchema: JOI.ObjectSchema<any>;
31
+ declare const eventsSchema: JOI.ArraySchema<any[]>;
31
32
  declare const blockletMetaSchema: JOI.ObjectSchema<any>;
32
33
  declare const createBlockletSchema: (baseDir: string, { ensureFiles, ensureDist, ensureComponentStore, ensureName, skipValidateDidName, ...schemaOptions }?: {
33
34
  ensureFiles?: boolean;
@@ -36,7 +37,7 @@ declare const createBlockletSchema: (baseDir: string, { ensureFiles, ensureDist,
36
37
  ensureName?: boolean;
37
38
  skipValidateDidName?: boolean;
38
39
  }) => JOI.ObjectSchema;
39
- 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, resourceBundleSchema, installBlockletTitleSchema, installBlockletDescriptionSchema, Joi, };
40
+ 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, resourceBundleSchema, installBlockletTitleSchema, installBlockletDescriptionSchema, eventsSchema, Joi, };
40
41
  declare const _default: {
41
42
  blockletNameSchema: JOI.StringSchema<string>;
42
43
  componentSchema: JOI.ObjectSchema<any>;
@@ -66,6 +67,7 @@ declare const _default: {
66
67
  resourceBundleSchema: JOI.ObjectSchema<any>;
67
68
  installBlockletTitleSchema: JOI.StringSchema<string>;
68
69
  installBlockletDescriptionSchema: JOI.StringSchema<string>;
70
+ eventsSchema: JOI.ArraySchema<any[]>;
69
71
  Joi: JOI.Root & {
70
72
  [key: string]: Function;
71
73
  };
package/lib/schema.js CHANGED
@@ -36,7 +36,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
36
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.Joi = exports.installBlockletDescriptionSchema = exports.installBlockletTitleSchema = exports.resourceBundleSchema = exports.authConfigSchema = exports.cacheableSchema = exports.statsSchema = exports.titleSchema = exports.themeSchema = exports.signatureSchema = exports.serviceSchema = exports.scriptsSchema = exports.personSchema = exports.navigationSchema = exports.navigationItemSchema = exports.updateMountPointSchema = exports.mountPointSchema = exports.logoSchema = exports.interfaceSchema = exports.environmentNameSchema = exports.environmentSchema = exports.engineSchema = exports.endpointSchema = exports.distSchema = exports.descriptionSchema = exports.createBlockletSchema = exports.componentSchema = exports.blockletNameSchema = exports.blockletMetaSchema = void 0;
39
+ exports.Joi = exports.eventsSchema = exports.installBlockletDescriptionSchema = exports.installBlockletTitleSchema = exports.resourceBundleSchema = exports.authConfigSchema = exports.cacheableSchema = exports.statsSchema = exports.titleSchema = exports.themeSchema = exports.signatureSchema = exports.serviceSchema = exports.scriptsSchema = exports.personSchema = exports.navigationSchema = exports.navigationItemSchema = exports.updateMountPointSchema = exports.mountPointSchema = exports.logoSchema = exports.interfaceSchema = exports.environmentNameSchema = exports.environmentSchema = exports.engineSchema = exports.endpointSchema = exports.distSchema = exports.descriptionSchema = exports.createBlockletSchema = exports.componentSchema = exports.blockletNameSchema = exports.blockletMetaSchema = void 0;
40
40
  const fs_1 = __importDefault(require("fs"));
41
41
  const joi_1 = __importDefault(require("joi"));
42
42
  const cjk_length_1 = __importDefault(require("cjk-length"));
@@ -497,6 +497,23 @@ const resourceBundleSchema = Joi.object({
497
497
  unknownType: 'any',
498
498
  });
499
499
  exports.resourceBundleSchema = resourceBundleSchema;
500
+ const eventsSchema = Joi.array()
501
+ .items(Joi.object({
502
+ type: Joi.string()
503
+ .trim()
504
+ .min(1)
505
+ .max(128)
506
+ .pattern(/^(?!blocklet\.)[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/)
507
+ .message('Event type must be in format of "[noun.]verb" like "post.published" or "post.comment.published", and prefix "blocklet." is reserved')
508
+ .required(),
509
+ description: Joi.string().trim().min(1).max(256).required(),
510
+ }))
511
+ .unique('type')
512
+ .meta({
513
+ className: 'TEvent',
514
+ unknownType: 'any',
515
+ });
516
+ exports.eventsSchema = eventsSchema;
500
517
  const blockletMetaProps = {
501
518
  did: Joi.DID().trim().required(),
502
519
  version: Joi.semver().valid().required(),
@@ -705,6 +722,8 @@ const blockletMetaProps = {
705
722
  bundleName: Joi.string(),
706
723
  bundleDid: Joi.DID().trim(),
707
724
  storeId: Joi.string(),
725
+ // open events (within the app) supported by this blocklet
726
+ events: eventsSchema.optional(),
708
727
  };
709
728
  const blockletMetaSchema = Joi.object(blockletMetaProps).options({ stripUnknown: true, noDefaults: false }).meta({
710
729
  className: 'TBlockletMeta',
@@ -828,5 +847,6 @@ exports.default = {
828
847
  resourceBundleSchema,
829
848
  installBlockletTitleSchema,
830
849
  installBlockletDescriptionSchema,
850
+ eventsSchema,
831
851
  Joi,
832
852
  };
@@ -45,6 +45,7 @@ export interface TBlockletMeta {
45
45
  documentation?: string;
46
46
  engine?: TEngine | TEngine[];
47
47
  environments?: TEnvironment[];
48
+ events?: TEvent;
48
49
  files?: string[];
49
50
  gitHash?: string;
50
51
  group?: 'dapp' | 'static' | 'gateway' | 'pack';
@@ -179,6 +180,10 @@ export interface TEnvironment {
179
180
  validation?: string;
180
181
  }
181
182
  export type TEnvironmentName = string;
183
+ export type TEvent = {
184
+ description: string;
185
+ type: string;
186
+ }[];
182
187
  export type TInstallBlockletDescription = string;
183
188
  export type TInstallBlockletTitle = string;
184
189
  export interface TInterface {
package/lib/util.d.ts CHANGED
@@ -149,7 +149,8 @@ declare const hasResourceType: (component: ComponentState, { type, did }?: {
149
149
  }) => boolean;
150
150
  declare const getMountPoints: (blocklet: any) => any[];
151
151
  declare const checkPublicAccess: (securityConfig: any) => boolean;
152
- export { isFreeBlocklet, isFreeComponent, forEachBlocklet, forEachBlockletSync, forEachChild, forEachChildSync, forEachComponentV2, forEachComponentV2Sync, isDeletableBlocklet, getSharedConfigObj, getAppMissingConfigs, getComponentMissingConfigs, isEnvShareableToClient, isEnvShareable, wipeSensitiveData, hasRunnableComponent, getAppName, getAppName as getDisplayName, getAppDescription, fixBlockletStatus, findWebInterface, findWebInterfacePort, findDockerInterface, findServiceFromMeta, checkPublicAccess, replaceSlotToIp, getComponentId, getComponentName, getComponentBundleId, findComponent, findComponentById, findComponentV2, findComponentByIdV2, filterComponentsV2, getParentComponentName, getConnectAppUrl, getChainInfo, getBlockletChainInfo, isExternalBlocklet, isPreferenceKey, getBlockletAppIdList, getBlockletServices, isInProgress, isBeforeInstalled, isRunning, isAccessible, isGatewayBlocklet, isPackBlocklet, hasStartEngine, hasResourceType, getMountPoints, };
152
+ declare const nanoid: (length?: number) => string;
153
+ export { isFreeBlocklet, isFreeComponent, forEachBlocklet, forEachBlockletSync, forEachChild, forEachChildSync, forEachComponentV2, forEachComponentV2Sync, isDeletableBlocklet, getSharedConfigObj, getAppMissingConfigs, getComponentMissingConfigs, isEnvShareableToClient, isEnvShareable, wipeSensitiveData, hasRunnableComponent, getAppName, getAppName as getDisplayName, getAppDescription, fixBlockletStatus, findWebInterface, findWebInterfacePort, findDockerInterface, findServiceFromMeta, checkPublicAccess, replaceSlotToIp, getComponentId, getComponentName, getComponentBundleId, findComponent, findComponentById, findComponentV2, findComponentByIdV2, filterComponentsV2, getParentComponentName, getConnectAppUrl, getChainInfo, getBlockletChainInfo, isExternalBlocklet, isPreferenceKey, getBlockletAppIdList, getBlockletServices, isInProgress, isBeforeInstalled, isRunning, isAccessible, isGatewayBlocklet, isPackBlocklet, hasStartEngine, hasResourceType, getMountPoints, nanoid, };
153
154
  declare const _default: {
154
155
  isFreeBlocklet: (meta: TBlockletMeta) => boolean;
155
156
  isFreeComponent: (meta: TBlockletMeta) => boolean;
@@ -262,5 +263,6 @@ declare const _default: {
262
263
  did: string;
263
264
  }) => boolean;
264
265
  getMountPoints: (blocklet: any) => any[];
266
+ nanoid: (length?: number) => string;
265
267
  };
266
268
  export default _default;
package/lib/util.js CHANGED
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.hasResourceType = exports.hasStartEngine = exports.isPackBlocklet = exports.isGatewayBlocklet = exports.isAccessible = exports.isRunning = exports.isBeforeInstalled = exports.isInProgress = exports.getBlockletServices = exports.getBlockletAppIdList = 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.checkPublicAccess = exports.findServiceFromMeta = exports.findDockerInterface = exports.findWebInterfacePort = exports.findWebInterface = exports.fixBlockletStatus = exports.getAppDescription = exports.getDisplayName = exports.getAppName = exports.hasRunnableComponent = exports.wipeSensitiveData = exports.isEnvShareable = exports.isEnvShareableToClient = exports.getComponentMissingConfigs = exports.getAppMissingConfigs = exports.getSharedConfigObj = exports.isDeletableBlocklet = exports.forEachComponentV2Sync = exports.forEachComponentV2 = exports.forEachChildSync = exports.forEachChild = exports.forEachBlockletSync = exports.forEachBlocklet = exports.isFreeComponent = exports.isFreeBlocklet = void 0;
7
- exports.getMountPoints = void 0;
7
+ exports.nanoid = exports.getMountPoints = void 0;
8
8
  exports.getAppUrl = getAppUrl;
9
9
  /* eslint-disable no-await-in-loop */
10
10
  const get_1 = __importDefault(require("lodash/get"));
@@ -749,6 +749,8 @@ const checkPublicAccess = (securityConfig) => {
749
749
  return false;
750
750
  };
751
751
  exports.checkPublicAccess = checkPublicAccess;
752
+ const nanoid = (length = 16) => [...Array(length)].map(() => Math.random().toString(36)[2]).join('');
753
+ exports.nanoid = nanoid;
752
754
  exports.default = {
753
755
  isFreeBlocklet,
754
756
  isFreeComponent,
@@ -801,4 +803,5 @@ exports.default = {
801
803
  hasStartEngine: engine_1.hasStartEngine,
802
804
  hasResourceType,
803
805
  getMountPoints,
806
+ nanoid,
804
807
  };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.16.39-beta-20250222-094928-e54632fa",
6
+ "version": "1.16.39-beta-20250225-115803-28695007",
7
7
  "description": "Library to parse/validate/fix blocklet meta",
8
8
  "main": "./lib/index.js",
9
9
  "typings": "./lib/index.d.ts",
@@ -25,13 +25,13 @@
25
25
  "author": "wangshijun <wangshijun2020@gmail.com> (http://github.com/wangshijun)",
26
26
  "license": "Apache-2.0",
27
27
  "dependencies": {
28
- "@abtnode/constant": "1.16.39-beta-20250222-094928-e54632fa",
29
- "@abtnode/docker-utils": "1.16.39-beta-20250222-094928-e54632fa",
28
+ "@abtnode/constant": "1.16.39-beta-20250225-115803-28695007",
29
+ "@abtnode/docker-utils": "1.16.39-beta-20250225-115803-28695007",
30
30
  "@arcblock/did": "1.19.10",
31
31
  "@arcblock/did-ext": "1.19.10",
32
32
  "@arcblock/did-util": "1.19.10",
33
33
  "@arcblock/jwt": "1.19.10",
34
- "@blocklet/constant": "1.16.39-beta-20250222-094928-e54632fa",
34
+ "@blocklet/constant": "1.16.39-beta-20250225-115803-28695007",
35
35
  "@ocap/asset": "1.19.10",
36
36
  "@ocap/mcrypto": "1.19.10",
37
37
  "@ocap/types": "1.19.10",
@@ -80,5 +80,5 @@
80
80
  "ts-node": "^10.9.1",
81
81
  "typescript": "^5.6.3"
82
82
  },
83
- "gitHead": "9eefa43edc541ba7b4db529898fb826a7b2a06b5"
83
+ "gitHead": "d6c75e9336becf1eabe733058d030bdda0be9848"
84
84
  }