@abtnode/core 1.16.0-beta-ad6df3ae → 1.16.0-beta-58020de5

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.
@@ -150,10 +150,19 @@ const pm2StatusMap = {
150
150
  */
151
151
  const getBlockletEngineNameByPlatform = (blockletMeta) => getBlockletEngine(blockletMeta).interpreter;
152
152
 
153
- const getSkippedProcessIds = ({ newBlocklet, oldBlocklet, context = {} }) => {
153
+ /**
154
+ * @param {{
155
+ * newBlocklet,
156
+ * oldBlocklet,
157
+ * context: { forceStartProcessIds?: string[] },
158
+ * }}
159
+ * @returns {{ installedComponentNames: string[], skippedProcessIds: string[] }}
160
+ */
161
+ const getComponentChangedInfoForUpgrade = ({ newBlocklet, oldBlocklet, context = {} }) => {
154
162
  const { forceStartProcessIds = [] } = context;
155
163
  const idMap = {};
156
- const res = [];
164
+ const skippedProcessIds = [];
165
+ const installedComponentNames = [];
157
166
 
158
167
  forEachBlockletSync(oldBlocklet, (b, { ancestors }) => {
159
168
  if (b.meta.dist?.integrity) {
@@ -164,15 +173,18 @@ const getSkippedProcessIds = ({ newBlocklet, oldBlocklet, context = {} }) => {
164
173
  forEachBlockletSync(newBlocklet, (b, { ancestors }) => {
165
174
  const id = getComponentProcessId(b, ancestors);
166
175
  if (forceStartProcessIds.includes(id)) {
176
+ installedComponentNames.push(b.meta.title);
167
177
  return;
168
178
  }
169
179
 
170
180
  if (!b.meta.dist?.integrity || b.meta.dist.integrity === idMap[id]) {
171
- res.push(id);
181
+ skippedProcessIds.push(id);
182
+ } else {
183
+ installedComponentNames.push(b.meta.title);
172
184
  }
173
185
  });
174
186
 
175
- return res;
187
+ return { skippedProcessIds, installedComponentNames };
176
188
  };
177
189
 
178
190
  // 10s 上报统计一次
@@ -506,7 +518,7 @@ class BlockletManager extends BaseBlockletManager {
506
518
 
507
519
  const error = Array.isArray(err) ? err[0] : err;
508
520
  logger.error('Failed to start blocklet', { error, did, name: blocklet.meta.name });
509
- const description = `Start blocklet ${blocklet.meta.name} failed with error: ${error.message}`;
521
+ const description = `Start blocklet ${blocklet.meta.title} failed with error: ${error.message}`;
510
522
  this._createNotification(did, {
511
523
  title: 'Start Blocklet Failed',
512
524
  description,
@@ -635,7 +647,7 @@ class BlockletManager extends BaseBlockletManager {
635
647
 
636
648
  this._createNotification(did, {
637
649
  title: 'Blocklet Restart Failed',
638
- description: `Blocklet ${did} restart failed with error: ${err.message || 'queue exception'}`,
650
+ description: `Blocklet ${result.meta.title} restart failed with error: ${err.message || 'queue exception'}`,
639
651
  entityType: 'blocklet',
640
652
  entityId: did,
641
653
  severity: 'error',
@@ -686,7 +698,7 @@ class BlockletManager extends BaseBlockletManager {
686
698
  const doc = await this._deleteBlocklet({ did, keepData, keepLogsDir, keepConfigs }, context);
687
699
  this._createNotification(doc.meta.did, {
688
700
  title: 'Blocklet Deleted',
689
- description: `Blocklet ${doc.meta.name}@${doc.meta.version} is deleted.`,
701
+ description: `Blocklet ${doc.meta.title} is deleted.`,
690
702
  entityType: 'blocklet',
691
703
  entityId: doc.meta.did,
692
704
  severity: 'success',
@@ -699,7 +711,7 @@ class BlockletManager extends BaseBlockletManager {
699
711
 
700
712
  this._createNotification(doc.meta.did, {
701
713
  title: 'Blocklet Deleted',
702
- description: `Blocklet ${doc.meta.name}@${doc.meta.version} is deleted.`,
714
+ description: `Blocklet ${doc.meta.title} is deleted.`,
703
715
  entityType: 'blocklet',
704
716
  entityId: doc.meta.did,
705
717
  severity: 'success',
@@ -817,7 +829,7 @@ class BlockletManager extends BaseBlockletManager {
817
829
 
818
830
  this._createNotification(newBlocklet.meta.did, {
819
831
  title: 'Component Deleted',
820
- description: `Component ${child.meta.name} of ${newBlocklet.meta.name} is successfully deleted.`,
832
+ description: `Component ${child.meta.title} of ${newBlocklet.meta.title} is successfully deleted.`,
821
833
  entityType: 'blocklet',
822
834
  entityId: newBlocklet.meta.did,
823
835
  severity: 'success',
@@ -1069,6 +1081,24 @@ class BlockletManager extends BaseBlockletManager {
1069
1081
  await this._updateDidDocument(blocklet);
1070
1082
  }
1071
1083
 
1084
+ // update blocklet meta
1085
+ if (blocklet.structVersion && !childDids.length) {
1086
+ const changedTitle = newConfigs.find((x) => x.key === BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_NAME)?.value;
1087
+ const changedDescription = newConfigs.find(
1088
+ (x) => x.key === BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_DESCRIPTION
1089
+ )?.value;
1090
+
1091
+ if (changedTitle || changedDescription) {
1092
+ await states.blocklet.updateBlocklet(rootDid, {
1093
+ meta: {
1094
+ ...blocklet.meta,
1095
+ title: changedTitle || blocklet.meta.title,
1096
+ description: changedDescription || blocklet.meta.description,
1097
+ },
1098
+ });
1099
+ }
1100
+ }
1101
+
1072
1102
  await this._updateBlockletEnvironment(rootDid);
1073
1103
 
1074
1104
  // response
@@ -1418,7 +1448,7 @@ class BlockletManager extends BaseBlockletManager {
1418
1448
  skipCheckIntegrity,
1419
1449
  } = params;
1420
1450
  const { meta } = blocklet;
1421
- const { name, did, version } = meta;
1451
+ const { title, name, did, version } = meta;
1422
1452
 
1423
1453
  // check status
1424
1454
  if (!skipCheckStatusBeforeDownload) {
@@ -1489,7 +1519,7 @@ class BlockletManager extends BaseBlockletManager {
1489
1519
  });
1490
1520
  this._createNotification(did, {
1491
1521
  title: 'Blocklet Download Failed',
1492
- description: `Blocklet ${name}@${version} download failed with error: ${err.message}`,
1522
+ description: `Blocklet ${title} download failed with error: ${err.message}`,
1493
1523
  entityType: 'blocklet',
1494
1524
  entityId: did,
1495
1525
  severity: 'error',
@@ -1610,7 +1640,7 @@ class BlockletManager extends BaseBlockletManager {
1610
1640
  const blocklet = await this.getBlocklet(did);
1611
1641
 
1612
1642
  const { meta } = blocklet;
1613
- const { name } = meta;
1643
+ const { name, title } = meta;
1614
1644
 
1615
1645
  try {
1616
1646
  // healthy check
@@ -1633,7 +1663,7 @@ class BlockletManager extends BaseBlockletManager {
1633
1663
 
1634
1664
  this._createNotification(did, {
1635
1665
  title: 'Blocklet Start Failed',
1636
- description: `Blocklet ${name} start failed: ${error.message}`,
1666
+ description: `Blocklet ${title} start failed: ${error.message}`,
1637
1667
  entityType: 'blocklet',
1638
1668
  entityId: did,
1639
1669
  severity: 'error',
@@ -1947,7 +1977,7 @@ class BlockletManager extends BaseBlockletManager {
1947
1977
  });
1948
1978
  this._createNotification(did, {
1949
1979
  title: 'Blocklet Install Failed',
1950
- description: `Blocklet ${meta.name}@${meta.version} install failed with error: ${err.message}`,
1980
+ description: `Blocklet ${meta.title} install failed with error: ${err.message}`,
1951
1981
  entityType: 'blocklet',
1952
1982
  entityId: did,
1953
1983
  severity: 'error',
@@ -1962,10 +1992,15 @@ class BlockletManager extends BaseBlockletManager {
1962
1992
 
1963
1993
  async _upgradeBlocklet({ newBlocklet, oldBlocklet, context = {} }) {
1964
1994
  const { meta, source, deployedFrom, children } = newBlocklet;
1965
- const { did, version, name } = meta;
1995
+ const { did, version, name, title } = meta;
1966
1996
 
1967
1997
  // ids
1968
- context.skippedProcessIds = getSkippedProcessIds({ newBlocklet, oldBlocklet, context });
1998
+ const { skippedProcessIds, installedComponentNames } = getComponentChangedInfoForUpgrade({
1999
+ newBlocklet,
2000
+ oldBlocklet,
2001
+ context,
2002
+ });
2003
+ context.skippedProcessIds = skippedProcessIds;
1969
2004
 
1970
2005
  try {
1971
2006
  // delete old process
@@ -2040,9 +2075,7 @@ class BlockletManager extends BaseBlockletManager {
2040
2075
  this.emit(BlockletEvents.upgraded, { blocklet, context });
2041
2076
  this._createNotification(did, {
2042
2077
  title: 'Blocklet Upgrade Success',
2043
- description: `Blocklet ${name}@${version} upgrade successfully. (Source: ${
2044
- deployedFrom || fromBlockletSource(source)
2045
- })`,
2078
+ description: `Blocklet ${title} upgrade successfully. (Component: ${installedComponentNames.join(', ')})`,
2046
2079
  action: `/blocklets/${did}/overview`,
2047
2080
  entityType: 'blocklet',
2048
2081
  entityId: did,
@@ -2071,7 +2104,9 @@ class BlockletManager extends BaseBlockletManager {
2071
2104
 
2072
2105
  this._createNotification(did, {
2073
2106
  title: 'Blocklet Upgrade Failed',
2074
- description: `Blocklet ${name}@${version} upgrade failed with error: ${err.message}`,
2107
+ description: `Blocklet ${title} upgrade failed with error: ${
2108
+ err.message
2109
+ }. (Component: ${installedComponentNames.join(', ')})`,
2075
2110
  entityType: 'blocklet',
2076
2111
  entityId: did,
2077
2112
  severity: 'error',
@@ -66,7 +66,11 @@ const installComponentFromUrl = async ({
66
66
  }
67
67
 
68
68
  if (!isComponentBlocklet(meta)) {
69
- throw new Error('The blocklet cannot be a component');
69
+ throw new Error(
70
+ `The blocklet cannot be a component : ${
71
+ meta.title || meta.name
72
+ }. The reason may be that the developer set capabilities.component to false in blocklet.yml`
73
+ );
70
74
  }
71
75
 
72
76
  if (title) {
@@ -9,7 +9,7 @@ const restoreDirName = 'tmp/restore-disk';
9
9
  const getBackupList = (dataDir) => {
10
10
  const baseBackupDir = path.join(dataDir, backupDirName);
11
11
  const backupList = [];
12
- const appDidList = fs.readdirSync(baseBackupDir);
12
+ const appDidList = fs.existsSync(baseBackupDir) ? fs.readdirSync(baseBackupDir) : [];
13
13
 
14
14
  appDidList.forEach((appDid) => {
15
15
  const metaFile = path.join(baseBackupDir, appDid, 'meta.json');
@@ -814,7 +814,9 @@ const parseComponents = async (component, context = {}) => {
814
814
  validateBlockletMeta(rawMeta, { ensureDist: true });
815
815
 
816
816
  if (!isComponentBlocklet(rawMeta)) {
817
- throw new Error(`The blocklet cannot be a component: ${rawMeta.title}`);
817
+ throw new Error(
818
+ `The blocklet cannot be a component: ${rawMeta.title}. The reason may be that the developer set capabilities.component to false in blocklet.yml`
819
+ );
818
820
  }
819
821
 
820
822
  const webInterface = findWebInterface(rawMeta);
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.16.0-beta-ad6df3ae",
6
+ "version": "1.16.0-beta-58020de5",
7
7
  "description": "",
8
8
  "main": "lib/index.js",
9
9
  "files": [
@@ -19,18 +19,18 @@
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-ad6df3ae",
23
- "@abtnode/certificate-manager": "1.16.0-beta-ad6df3ae",
24
- "@abtnode/constant": "1.16.0-beta-ad6df3ae",
25
- "@abtnode/cron": "1.16.0-beta-ad6df3ae",
26
- "@abtnode/db": "1.16.0-beta-ad6df3ae",
27
- "@abtnode/logger": "1.16.0-beta-ad6df3ae",
28
- "@abtnode/queue": "1.16.0-beta-ad6df3ae",
29
- "@abtnode/rbac": "1.16.0-beta-ad6df3ae",
30
- "@abtnode/router-provider": "1.16.0-beta-ad6df3ae",
31
- "@abtnode/static-server": "1.16.0-beta-ad6df3ae",
32
- "@abtnode/timemachine": "1.16.0-beta-ad6df3ae",
33
- "@abtnode/util": "1.16.0-beta-ad6df3ae",
22
+ "@abtnode/auth": "1.16.0-beta-58020de5",
23
+ "@abtnode/certificate-manager": "1.16.0-beta-58020de5",
24
+ "@abtnode/constant": "1.16.0-beta-58020de5",
25
+ "@abtnode/cron": "1.16.0-beta-58020de5",
26
+ "@abtnode/db": "1.16.0-beta-58020de5",
27
+ "@abtnode/logger": "1.16.0-beta-58020de5",
28
+ "@abtnode/queue": "1.16.0-beta-58020de5",
29
+ "@abtnode/rbac": "1.16.0-beta-58020de5",
30
+ "@abtnode/router-provider": "1.16.0-beta-58020de5",
31
+ "@abtnode/static-server": "1.16.0-beta-58020de5",
32
+ "@abtnode/timemachine": "1.16.0-beta-58020de5",
33
+ "@abtnode/util": "1.16.0-beta-58020de5",
34
34
  "@arcblock/did": "1.18.64",
35
35
  "@arcblock/did-motif": "^1.1.10",
36
36
  "@arcblock/did-util": "1.18.64",
@@ -38,9 +38,9 @@
38
38
  "@arcblock/jwt": "^1.18.64",
39
39
  "@arcblock/pm2-events": "^0.0.5",
40
40
  "@arcblock/vc": "1.18.64",
41
- "@blocklet/constant": "1.16.0-beta-ad6df3ae",
42
- "@blocklet/meta": "1.16.0-beta-ad6df3ae",
43
- "@blocklet/sdk": "1.16.0-beta-ad6df3ae",
41
+ "@blocklet/constant": "1.16.0-beta-58020de5",
42
+ "@blocklet/meta": "1.16.0-beta-58020de5",
43
+ "@blocklet/sdk": "1.16.0-beta-58020de5",
44
44
  "@did-space/client": "^0.2.45",
45
45
  "@fidm/x509": "^1.2.1",
46
46
  "@ocap/client": "1.18.64",
@@ -91,5 +91,5 @@
91
91
  "express": "^4.18.2",
92
92
  "jest": "^27.5.1"
93
93
  },
94
- "gitHead": "8fa60176a00400cd412b308df3c7d6dcd9af2db1"
94
+ "gitHead": "9d3f47f9827acf13e9efea38cd605d3b36f9f523"
95
95
  }