@abtnode/core 1.16.10 → 1.16.11-beta-8e4c6e5c

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.
@@ -104,6 +104,7 @@ const {
104
104
  updateBlockletFallbackLogo,
105
105
  ensureAppLogo,
106
106
  getBlockletDidDomainList,
107
+ shouldCleanExpiredBlocklet,
107
108
  } = require('../../util/blocklet');
108
109
  const states = require('../../states');
109
110
  const BaseBlockletManager = require('./base');
@@ -2850,13 +2851,22 @@ class BlockletManager extends BaseBlockletManager {
2850
2851
  return;
2851
2852
  }
2852
2853
 
2853
- const tasks = blockletExtras.map(async ({ appDid, did, meta }) => {
2854
+ const tasks = blockletExtras.map(async ({ appDid, did, meta, controller }) => {
2854
2855
  const blocklet = await this.getBlocklet(did);
2855
2856
  if (blocklet) {
2856
2857
  logger.error('skip cleaning the blocklet which is not deleted', { blockletDid: did });
2857
2858
  return;
2858
2859
  }
2859
2860
 
2861
+ const assetState = await util.getNFTState(controller.chainHost, controller.nftId);
2862
+ const expirationDate = getNftExpirationDate(assetState);
2863
+
2864
+ if (!shouldCleanExpiredBlocklet(expirationDate)) {
2865
+ logger.error('skip cleaning the blocklet which is not expired', { blockletDid: did, expirationDate });
2866
+ await blockletExtras.updateExpireInfo({ did, expiredAt: expirationDate });
2867
+ return;
2868
+ }
2869
+
2860
2870
  let blockletMeta = meta;
2861
2871
  if (isEmpty(blockletMeta)) {
2862
2872
  // 旧版本的 blocklet 没有 meta 信息,这里补充一下
@@ -74,6 +74,7 @@ const installApplicationFromBackup = async ({
74
74
  'createdAt',
75
75
  'updatedAt',
76
76
  'controller',
77
+ 'expiredAt',
77
78
  ]);
78
79
 
79
80
  if (blockletState.meta.did !== extra.did) {
@@ -2,6 +2,7 @@
2
2
 
3
3
  const fs = require('fs-extra');
4
4
  const path = require('path');
5
+ const dayjs = require('dayjs');
5
6
  const joinURL = require('url-join');
6
7
  const shelljs = require('shelljs');
7
8
  const os = require('os');
@@ -43,6 +44,7 @@ const {
43
44
  BLOCKLET_INSTALL_TYPE,
44
45
  BLOCKLET_STORE_DEV,
45
46
  APP_STRUCT_VERSION,
47
+ EXPIRED_BLOCKLET_DATA_RETENTION_DAYS,
46
48
  } = require('@abtnode/constant');
47
49
  const formatBackSlash = require('@abtnode/util/lib/format-back-slash');
48
50
  const { toSvg: createDidLogo } =
@@ -1929,6 +1931,10 @@ const getBlockletDidDomainList = (blocklet, nodeInfo) => {
1929
1931
  return domainAliases;
1930
1932
  };
1931
1933
 
1934
+ const shouldCleanExpiredBlocklet = (expirationDate) => {
1935
+ return dayjs().diff(dayjs(expirationDate), 'day') > EXPIRED_BLOCKLET_DATA_RETENTION_DAYS;
1936
+ };
1937
+
1932
1938
  module.exports = {
1933
1939
  updateBlockletFallbackLogo,
1934
1940
  consumeServerlessNFT,
@@ -1987,4 +1993,5 @@ module.exports = {
1987
1993
  getFixedBundleSource,
1988
1994
  ensureAppLogo,
1989
1995
  getBlockletDidDomainList,
1996
+ shouldCleanExpiredBlocklet,
1990
1997
  };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.16.10",
6
+ "version": "1.16.11-beta-8e4c6e5c",
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": "Apache-2.0",
21
21
  "dependencies": {
22
- "@abtnode/auth": "1.16.10",
23
- "@abtnode/certificate-manager": "1.16.10",
24
- "@abtnode/constant": "1.16.10",
25
- "@abtnode/cron": "1.16.10",
26
- "@abtnode/logger": "1.16.10",
27
- "@abtnode/models": "1.16.10",
28
- "@abtnode/queue": "1.16.10",
29
- "@abtnode/rbac": "1.16.10",
30
- "@abtnode/router-provider": "1.16.10",
31
- "@abtnode/static-server": "1.16.10",
32
- "@abtnode/timemachine": "1.16.10",
33
- "@abtnode/util": "1.16.10",
22
+ "@abtnode/auth": "1.16.11-beta-8e4c6e5c",
23
+ "@abtnode/certificate-manager": "1.16.11-beta-8e4c6e5c",
24
+ "@abtnode/constant": "1.16.11-beta-8e4c6e5c",
25
+ "@abtnode/cron": "1.16.11-beta-8e4c6e5c",
26
+ "@abtnode/logger": "1.16.11-beta-8e4c6e5c",
27
+ "@abtnode/models": "1.16.11-beta-8e4c6e5c",
28
+ "@abtnode/queue": "1.16.11-beta-8e4c6e5c",
29
+ "@abtnode/rbac": "1.16.11-beta-8e4c6e5c",
30
+ "@abtnode/router-provider": "1.16.11-beta-8e4c6e5c",
31
+ "@abtnode/static-server": "1.16.11-beta-8e4c6e5c",
32
+ "@abtnode/timemachine": "1.16.11-beta-8e4c6e5c",
33
+ "@abtnode/util": "1.16.11-beta-8e4c6e5c",
34
34
  "@arcblock/did": "1.18.80",
35
35
  "@arcblock/did-auth": "1.18.80",
36
36
  "@arcblock/did-ext": "^1.18.80",
@@ -41,9 +41,9 @@
41
41
  "@arcblock/pm2-events": "^0.0.5",
42
42
  "@arcblock/validator": "^1.18.80",
43
43
  "@arcblock/vc": "1.18.80",
44
- "@blocklet/constant": "1.16.10",
45
- "@blocklet/meta": "1.16.10",
46
- "@blocklet/sdk": "1.16.10",
44
+ "@blocklet/constant": "1.16.11-beta-8e4c6e5c",
45
+ "@blocklet/meta": "1.16.11-beta-8e4c6e5c",
46
+ "@blocklet/sdk": "1.16.11-beta-8e4c6e5c",
47
47
  "@did-space/client": "^0.2.99",
48
48
  "@fidm/x509": "^1.2.1",
49
49
  "@ocap/mcrypto": "1.18.80",
@@ -96,5 +96,5 @@
96
96
  "express": "^4.18.2",
97
97
  "jest": "^27.5.1"
98
98
  },
99
- "gitHead": "8f1d613ed04b1bd4a16a2b4109ac86a7848803a5"
99
+ "gitHead": "bd1beb1fb79e075d31359f438a263ee9077d3cd9"
100
100
  }