@blocklet/meta 1.8.51 → 1.8.53

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.
@@ -95,7 +95,7 @@ export interface TBlockletMeta {
95
95
  title?: TTitle | '';
96
96
  version: string;
97
97
  }
98
- export declare type TBlockletName = string;
98
+ export type TBlockletName = string;
99
99
  export interface TComponent {
100
100
  description?: TDescription;
101
101
  mountPoint?: TMountPoint;
@@ -121,7 +121,7 @@ export interface TComponent {
121
121
  };
122
122
  title?: TTitle;
123
123
  }
124
- export declare type TDescription = string;
124
+ export type TDescription = string;
125
125
  export interface TDist {
126
126
  integrity: string;
127
127
  size?: number;
@@ -154,7 +154,7 @@ export interface TEnvironment {
154
154
  shared?: boolean;
155
155
  validation?: string;
156
156
  }
157
- export declare type TEnvironmentName = string;
157
+ export type TEnvironmentName = string;
158
158
  export interface TInterface {
159
159
  endpoints?: TEndpoint[];
160
160
  name: string;
@@ -168,9 +168,9 @@ export interface TInterface {
168
168
  services?: TService[];
169
169
  type: 'web' | 'service' | 'wellknown';
170
170
  }
171
- export declare type TLogo = string;
172
- export declare type TMountPoint = string;
173
- export declare type TNavigation = TNavigationItem[];
171
+ export type TLogo = string;
172
+ export type TMountPoint = string;
173
+ export type TNavigation = TNavigationItem[];
174
174
  export interface TNavigationItem {
175
175
  component?: string;
176
176
  icon?: string;
@@ -260,4 +260,4 @@ export interface TTheme {
260
260
  header?: string;
261
261
  };
262
262
  }
263
- export declare type TTitle = string;
263
+ export type TTitle = string;
package/lib/util.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { BlockletState, ComponentState } from '@abtnode/client';
2
2
  import { Request } from 'express';
3
3
  import { TBlockletMeta, TEnvironment } from './types';
4
- declare type TConfig = TEnvironment & {
4
+ type TConfig = TEnvironment & {
5
5
  key: string;
6
6
  };
7
7
  declare const getComponentId: (component?: {
@@ -39,8 +39,9 @@ declare const getComponentBundleId: (component: {
39
39
  * @a/b/@c/d/@e/f => @a/b/@c/d
40
40
  */
41
41
  declare const getParentComponentName: (name?: string) => string;
42
- declare const forEachBlocklet: (blocklet: BlockletState | ComponentState, cb: Function, { parallel, sync, params: inputParams, _parent, _root, _level, _tasks: inputTasks, _ancestors, }?: {
42
+ declare const forEachBlocklet: (blocklet: BlockletState | ComponentState, cb: Function, { parallel, concurrencyLimit, sync, params: inputParams, _parent, _root, _level, _tasks: inputTasks, _ancestors, _limit, }?: {
43
43
  parallel?: boolean;
44
+ concurrencyLimit?: number;
44
45
  sync?: boolean;
45
46
  params?: any;
46
47
  _parent?: any;
@@ -48,6 +49,7 @@ declare const forEachBlocklet: (blocklet: BlockletState | ComponentState, cb: Fu
48
49
  _level?: number;
49
50
  _tasks?: any;
50
51
  _ancestors?: any[];
52
+ _limit?: (fn: () => void) => void;
51
53
  }) => Promise<unknown>;
52
54
  declare const forEachBlockletSync: (blocklet: any, cb: Function) => Promise<unknown>;
53
55
  declare const forEachChild: (blocklet: any, cb: Function, params?: any) => Promise<any>;
@@ -124,8 +126,9 @@ declare const _default: {
124
126
  isFreeBlocklet: (meta: TBlockletMeta) => boolean;
125
127
  isFreeComponent: (meta: TBlockletMeta) => boolean;
126
128
  isComponentBlocklet: (meta?: TBlockletMeta) => boolean;
127
- forEachBlocklet: (blocklet: BlockletState | ComponentState, cb: Function, { parallel, sync, params: inputParams, _parent, _root, _level, _tasks: inputTasks, _ancestors, }?: {
129
+ forEachBlocklet: (blocklet: BlockletState | ComponentState, cb: Function, { parallel, concurrencyLimit, sync, params: inputParams, _parent, _root, _level, _tasks: inputTasks, _ancestors, _limit, }?: {
128
130
  parallel?: boolean;
131
+ concurrencyLimit?: number;
129
132
  sync?: boolean;
130
133
  params?: any;
131
134
  _parent?: any;
@@ -133,6 +136,7 @@ declare const _default: {
133
136
  _level?: number;
134
137
  _tasks?: any;
135
138
  _ancestors?: any[];
139
+ _limit?: (fn: () => void) => void;
136
140
  }) => Promise<unknown>;
137
141
  forEachBlockletSync: (blocklet: any, cb: Function) => Promise<unknown>;
138
142
  forEachChild: (blocklet: any, cb: Function, params?: any) => Promise<any>;
package/lib/util.js CHANGED
@@ -17,6 +17,7 @@ exports.getRolesFromAuthConfig = exports.isPreferenceKey = exports.isExternalBlo
17
17
  const get_1 = __importDefault(require("lodash/get"));
18
18
  const slugify_1 = __importDefault(require("slugify"));
19
19
  const url_join_1 = __importDefault(require("url-join"));
20
+ const p_limit_1 = __importDefault(require("p-limit"));
20
21
  const constant_1 = __importDefault(require("@abtnode/constant"));
21
22
  const constants_1 = __importDefault(require("./constants"));
22
23
  const { NODE_SERVICES, SLOT_FOR_IP_DNS_SITE, WHO_CAN_ACCESS, WHO_CAN_ACCESS_PREFIX_ROLES } = constant_1.default;
@@ -55,7 +56,7 @@ const getParentComponentName = (name) => {
55
56
  return arr.join('/');
56
57
  };
57
58
  exports.getParentComponentName = getParentComponentName;
58
- const forEachBlocklet = (blocklet, cb, { parallel = false, sync, params: inputParams, _parent, _root, _level = 0, _tasks: inputTasks, _ancestors = [], } = {}) => {
59
+ const forEachBlocklet = (blocklet, cb, { parallel = false, concurrencyLimit = 5, sync, params: inputParams, _parent, _root, _level = 0, _tasks: inputTasks, _ancestors = [], _limit, } = {}) => {
59
60
  const root = _root || _parent || blocklet;
60
61
  // id maybe meaningless if no meta in blocklet or _ancestors
61
62
  const id = getComponentId(blocklet, _ancestors);
@@ -116,8 +117,9 @@ const forEachBlocklet = (blocklet, cb, { parallel = false, sync, params: inputPa
116
117
  }));
117
118
  }
118
119
  // parallel
120
+ const limit = _limit || (0, p_limit_1.default)(concurrencyLimit);
119
121
  const tasks = inputTasks || [];
120
- tasks.push(cb(blocklet, { parent: _parent, root, level: _level, ancestors: _ancestors, id }));
122
+ tasks.push(limit(() => cb(blocklet, { parent: _parent, root, level: _level, ancestors: _ancestors, id })));
121
123
  if (blocklet.children) {
122
124
  for (const child of blocklet.children) {
123
125
  forEachBlocklet(child, cb, {
@@ -127,6 +129,7 @@ const forEachBlocklet = (blocklet, cb, { parallel = false, sync, params: inputPa
127
129
  _level: _level + 1,
128
130
  _tasks: tasks,
129
131
  _ancestors: newAncestors,
132
+ _limit: limit,
130
133
  });
131
134
  }
132
135
  }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.8.51",
6
+ "version": "1.8.53",
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.51",
28
- "@abtnode/constant": "1.8.51",
29
- "@abtnode/util": "1.8.51",
30
- "@arcblock/did": "1.18.32",
31
- "@arcblock/did-ext": "1.18.32",
32
- "@arcblock/did-util": "1.18.32",
33
- "@arcblock/jwt": "1.18.32",
34
- "@blocklet/constant": "1.8.51",
35
- "@ocap/asset": "1.18.32",
36
- "@ocap/mcrypto": "1.18.32",
37
- "@ocap/types": "1.18.32",
38
- "@ocap/util": "1.18.32",
39
- "@ocap/wallet": "1.18.32",
27
+ "@abtnode/client": "1.8.53",
28
+ "@abtnode/constant": "1.8.53",
29
+ "@abtnode/util": "1.8.53",
30
+ "@arcblock/did": "1.18.34",
31
+ "@arcblock/did-ext": "1.18.34",
32
+ "@arcblock/did-util": "1.18.34",
33
+ "@arcblock/jwt": "1.18.34",
34
+ "@blocklet/constant": "1.8.53",
35
+ "@ocap/asset": "1.18.34",
36
+ "@ocap/mcrypto": "1.18.34",
37
+ "@ocap/types": "1.18.34",
38
+ "@ocap/util": "1.18.34",
39
+ "@ocap/wallet": "1.18.34",
40
40
  "ajv": "^8.11.0",
41
41
  "axios": "^0.27.2",
42
42
  "cjk-length": "^1.0.0",
@@ -51,6 +51,7 @@
51
51
  "js-yaml": "^4.1.0",
52
52
  "json-stable-stringify": "^1.0.1",
53
53
  "lodash": "^4.17.21",
54
+ "p-limit": "^3.1.0",
54
55
  "promise.any": "^2.0.4",
55
56
  "slugify": "^1.6.5",
56
57
  "url-join": "^4.0.1",
@@ -58,7 +59,7 @@
58
59
  "validate-npm-package-name": "^3.0.0"
59
60
  },
60
61
  "devDependencies": {
61
- "@abtnode/client": "^1.8.49",
62
+ "@abtnode/client": "^1.8.52",
62
63
  "@arcblock/eslint-config-ts": "^0.2.3",
63
64
  "@types/express": "^4.17.14",
64
65
  "@types/jest": "^29.2.2",
@@ -79,5 +80,5 @@
79
80
  "ts-node": "^10.9.1",
80
81
  "typescript": "^4.8.4"
81
82
  },
82
- "gitHead": "30e929da51edaa22104c4de4e3d1661d790c578c"
83
+ "gitHead": "48a5659627cbf21c232514e332d96e3fe8442e0f"
83
84
  }