@abtnode/core 1.16.0-beta-b16cb035 → 1.16.0-beta-8ee536d7

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.
@@ -4,6 +4,7 @@ const fs = require('fs-extra');
4
4
  const path = require('path');
5
5
  const flat = require('flat');
6
6
  const get = require('lodash/get');
7
+ const uniq = require('lodash/uniq');
7
8
  const merge = require('lodash/merge');
8
9
  const pick = require('lodash/pick');
9
10
  const cloneDeep = require('lodash/cloneDeep');
@@ -989,7 +990,7 @@ class BlockletManager extends BaseBlockletManager {
989
990
  throw new Error('configs list is not an array');
990
991
  }
991
992
 
992
- const dids = Array.isArray(did) ? did : [did];
993
+ const dids = Array.isArray(did) ? uniq(did) : [did];
993
994
  const [rootDid, ...childDids] = dids;
994
995
  logger.info('config blocklet', { dids });
995
996
 
@@ -325,16 +325,16 @@ const migrateApplicationToStructV2 = async ({ did, appSk: newAppSk, context = {}
325
325
  Object.entries(sharedConfigObj).forEach(([key, value]) => {
326
326
  if (!extraData.configs.some((x) => x.key === key)) {
327
327
  logger.info('add shared config to container configs', { did, key, value });
328
- extraData.configs.push({ key, value });
328
+ extraData.configs.push({ key, value, secure: false, shared: true });
329
329
  }
330
330
  });
331
331
  }
332
332
 
333
333
  // move component data dir
334
334
  const src = component.env.dataDir;
335
- const dist = path.join(dataDirSrc, component.meta.bundleName);
336
- if (src !== dist) {
337
- dataMoveList.push({ src: component.env.dataDir, dist: path.join(dataDirDist, component.meta.bundleName) });
335
+ const dist = path.join(dataDirDist, component.meta.bundleName);
336
+ if (fs.existsSync(src)) {
337
+ dataMoveList.push({ src, dist });
338
338
  }
339
339
  });
340
340
 
@@ -204,6 +204,7 @@ const ensureLatestNodeInfo = async (sites = [], { withDefaultCors = true } = {})
204
204
  * set rule.to.target by interface.path and interface.prefix
205
205
  */
206
206
  const ensureLatestInterfaceInfo = async (sites = []) => {
207
+ // FIXME @linchen groupAllInterfaces() may have performance issue
207
208
  const interfaces = await states.blocklet.groupAllInterfaces();
208
209
  return sites.map((site) => {
209
210
  if (!Array.isArray(site.rules)) {
@@ -223,10 +224,10 @@ const ensureLatestInterfaceInfo = async (sites = []) => {
223
224
  return rule;
224
225
  }
225
226
 
226
- const { did, interfaceName } = rule.to;
227
- if (interfaces[did] && interfaces[did][interfaceName]) {
227
+ const { componentId, interfaceName } = rule.to;
228
+ if (interfaces[componentId] && interfaces[componentId][interfaceName]) {
228
229
  // eslint-disable-next-line no-shadow
229
- const { path, prefix } = interfaces[did][interfaceName];
230
+ const { path, prefix } = interfaces[componentId][interfaceName];
230
231
  if (prefix === BLOCKLET_DYNAMIC_PATH_PREFIX) {
231
232
  rule.to.target = path;
232
233
  } else {
@@ -5,6 +5,7 @@ const logger = require('@abtnode/logger')('state-blocklet-extras');
5
5
  const { EXPIRED_BLOCKLET_DATA_RETENTION_DAYS } = require('@abtnode/constant');
6
6
  const camelCase = require('lodash/camelCase');
7
7
  const get = require('lodash/get');
8
+ const uniq = require('lodash/uniq');
8
9
  const dayjs = require('dayjs');
9
10
 
10
11
  const BaseState = require('./base');
@@ -127,7 +128,7 @@ class BlockletExtrasState extends BaseState {
127
128
  generateGetFn(extra) {
128
129
  return async (dids, path, defaultValue) => {
129
130
  // eslint-disable-next-line no-param-reassign
130
- dids = [].concat(dids);
131
+ dids = uniq([].concat(dids));
131
132
  const [rootDid, ...childDids] = dids;
132
133
  const { dek } = this.config;
133
134
  const { name, afterGet = noop('data') } = extra;
@@ -149,7 +150,7 @@ class BlockletExtrasState extends BaseState {
149
150
  generateSetFn(extra) {
150
151
  return async (dids, data) => {
151
152
  // eslint-disable-next-line no-param-reassign
152
- dids = [].concat(dids);
153
+ dids = uniq([].concat(dids));
153
154
  const [rootDid, ...childDids] = dids;
154
155
  const { dek } = this.config;
155
156
  const { name, beforeSet = noop('cur') } = extra;
@@ -189,7 +190,7 @@ class BlockletExtrasState extends BaseState {
189
190
  generateDelFn(extra) {
190
191
  return async (dids) => {
191
192
  // eslint-disable-next-line no-param-reassign
192
- dids = [].concat(dids);
193
+ dids = uniq([].concat(dids));
193
194
  const [rootDid, ...childDids] = dids;
194
195
  const { name } = extra;
195
196
  const item = await this.findOne({ did: rootDid });
@@ -509,17 +509,21 @@ class BlockletState extends BaseState {
509
509
  * @return {Object} { <did> : { interfaceName } }
510
510
  */
511
511
  async groupAllInterfaces() {
512
- const blocklets = await this.getBlocklets({}, { meta: 1 });
512
+ const blocklets = await this.getBlocklets({}, { meta: 1, children: 1 });
513
513
  const result = {};
514
- blocklets.forEach((blocklet) => {
515
- const { did, interfaces } = blocklet.meta;
516
- if (typeof result[did] === 'undefined') {
517
- result[did] = {};
514
+ const fillResult = (component, { id }) => {
515
+ const { interfaces } = component.meta;
516
+ if (typeof result[id] === 'undefined') {
517
+ result[id] = {};
518
518
  }
519
519
 
520
520
  (interfaces || []).forEach((x) => {
521
- result[did][x.name] = x;
521
+ result[id][x.name] = x;
522
522
  });
523
+ };
524
+
525
+ blocklets.forEach((blocklet) => {
526
+ forEachBlockletSync(blocklet, fillResult);
523
527
  });
524
528
 
525
529
  return result;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.16.0-beta-b16cb035",
6
+ "version": "1.16.0-beta-8ee536d7",
7
7
  "description": "",
8
8
  "main": "lib/index.js",
9
9
  "files": [
@@ -19,34 +19,34 @@
19
19
  "author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
20
20
  "license": "MIT",
21
21
  "dependencies": {
22
- "@abtnode/auth": "1.16.0-beta-b16cb035",
23
- "@abtnode/certificate-manager": "1.16.0-beta-b16cb035",
24
- "@abtnode/constant": "1.16.0-beta-b16cb035",
25
- "@abtnode/cron": "1.16.0-beta-b16cb035",
26
- "@abtnode/db": "1.16.0-beta-b16cb035",
27
- "@abtnode/logger": "1.16.0-beta-b16cb035",
28
- "@abtnode/queue": "1.16.0-beta-b16cb035",
29
- "@abtnode/rbac": "1.16.0-beta-b16cb035",
30
- "@abtnode/router-provider": "1.16.0-beta-b16cb035",
31
- "@abtnode/static-server": "1.16.0-beta-b16cb035",
32
- "@abtnode/timemachine": "1.16.0-beta-b16cb035",
33
- "@abtnode/util": "1.16.0-beta-b16cb035",
34
- "@arcblock/did": "1.18.59",
22
+ "@abtnode/auth": "1.16.0-beta-8ee536d7",
23
+ "@abtnode/certificate-manager": "1.16.0-beta-8ee536d7",
24
+ "@abtnode/constant": "1.16.0-beta-8ee536d7",
25
+ "@abtnode/cron": "1.16.0-beta-8ee536d7",
26
+ "@abtnode/db": "1.16.0-beta-8ee536d7",
27
+ "@abtnode/logger": "1.16.0-beta-8ee536d7",
28
+ "@abtnode/queue": "1.16.0-beta-8ee536d7",
29
+ "@abtnode/rbac": "1.16.0-beta-8ee536d7",
30
+ "@abtnode/router-provider": "1.16.0-beta-8ee536d7",
31
+ "@abtnode/static-server": "1.16.0-beta-8ee536d7",
32
+ "@abtnode/timemachine": "1.16.0-beta-8ee536d7",
33
+ "@abtnode/util": "1.16.0-beta-8ee536d7",
34
+ "@arcblock/did": "1.18.62",
35
35
  "@arcblock/did-motif": "^1.1.10",
36
- "@arcblock/did-util": "1.18.59",
37
- "@arcblock/event-hub": "1.18.59",
38
- "@arcblock/jwt": "^1.18.59",
36
+ "@arcblock/did-util": "1.18.62",
37
+ "@arcblock/event-hub": "1.18.62",
38
+ "@arcblock/jwt": "^1.18.62",
39
39
  "@arcblock/pm2-events": "^0.0.5",
40
- "@arcblock/vc": "1.18.59",
41
- "@blocklet/constant": "1.16.0-beta-b16cb035",
42
- "@blocklet/meta": "1.16.0-beta-b16cb035",
43
- "@blocklet/sdk": "1.16.0-beta-b16cb035",
40
+ "@arcblock/vc": "1.18.62",
41
+ "@blocklet/constant": "1.16.0-beta-8ee536d7",
42
+ "@blocklet/meta": "1.16.0-beta-8ee536d7",
43
+ "@blocklet/sdk": "1.16.0-beta-8ee536d7",
44
44
  "@did-space/client": "^0.2.33",
45
45
  "@fidm/x509": "^1.2.1",
46
- "@ocap/client": "1.18.59",
47
- "@ocap/mcrypto": "1.18.59",
48
- "@ocap/util": "1.18.59",
49
- "@ocap/wallet": "1.18.59",
46
+ "@ocap/client": "1.18.62",
47
+ "@ocap/mcrypto": "1.18.62",
48
+ "@ocap/util": "1.18.62",
49
+ "@ocap/wallet": "1.18.62",
50
50
  "@slack/webhook": "^5.0.4",
51
51
  "archiver": "^5.3.1",
52
52
  "axios": "^0.27.2",
@@ -91,5 +91,5 @@
91
91
  "express": "^4.18.2",
92
92
  "jest": "^27.5.1"
93
93
  },
94
- "gitHead": "138bd91aee5a35b28c2de4e1e924c44932efaf3a"
94
+ "gitHead": "57d0c45be311a5fbc1c0fffa2814b62c1a3ee34c"
95
95
  }