@abtnode/core 1.16.25-next-0ba03ffc → 1.16.25-next-1e779575
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/blocklet/manager/disk.js +26 -2
- package/lib/util/launcher.js +11 -0
- package/lib/validators/router.js +5 -1
- package/package.json +20 -20
|
@@ -4086,13 +4086,37 @@ class DiskBlockletManager extends BaseBlockletManager {
|
|
|
4086
4086
|
for (const data of blockletExtras) {
|
|
4087
4087
|
try {
|
|
4088
4088
|
const { did } = data;
|
|
4089
|
-
const
|
|
4089
|
+
const launcherSession = await launcher.getLauncherSession({
|
|
4090
|
+
launcherUrl: data.controller.launcherUrl,
|
|
4091
|
+
launcherSessionId: data.controller.launcherSessionId,
|
|
4092
|
+
});
|
|
4093
|
+
const isTerminated = launcher.isLaunchSessionTerminated(launcherSession);
|
|
4090
4094
|
|
|
4091
4095
|
if (!isTerminated) {
|
|
4092
4096
|
logger.info('skip cleaning the non-exceed redemption blocklet', {
|
|
4093
4097
|
blockletDid: did,
|
|
4098
|
+
controller: data.controller,
|
|
4099
|
+
launcherSession,
|
|
4100
|
+
});
|
|
4101
|
+
continue;
|
|
4102
|
+
}
|
|
4103
|
+
|
|
4104
|
+
if (!launcherSession.terminatedAt) {
|
|
4105
|
+
logger.error('the blocklet launch session does not have terminatedAt, skip', {
|
|
4106
|
+
blockletDid: did,
|
|
4107
|
+
controller: data.controller,
|
|
4108
|
+
launcherSession,
|
|
4109
|
+
});
|
|
4110
|
+
continue;
|
|
4111
|
+
}
|
|
4112
|
+
|
|
4113
|
+
// 订阅终止后需要再保留一段时间数据
|
|
4114
|
+
if (!launcher.isDataRetentionExceeded(launcherSession.terminatedAt)) {
|
|
4115
|
+
logger.info('skip cleaning the non-exceed redemption blocklet', {
|
|
4116
|
+
blockletDid: did,
|
|
4117
|
+
controller: data.controller,
|
|
4118
|
+
launcherSession,
|
|
4094
4119
|
});
|
|
4095
|
-
// eslint-disable-next-line no-continue
|
|
4096
4120
|
continue;
|
|
4097
4121
|
}
|
|
4098
4122
|
|
package/lib/util/launcher.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
2
|
const fs = require('fs-extra');
|
|
3
3
|
const joinUrl = require('url-join');
|
|
4
|
+
const dayjs = require('@abtnode/util/lib/dayjs');
|
|
4
5
|
const pick = require('lodash/pick');
|
|
5
6
|
const uniq = require('lodash/uniq');
|
|
6
7
|
const isEmpty = require('lodash/isEmpty');
|
|
@@ -109,6 +110,7 @@ const consumeLauncherSession = async ({ params, blocklet }) => {
|
|
|
109
110
|
appDid: blocklet.appPid,
|
|
110
111
|
appUrl,
|
|
111
112
|
appName: name,
|
|
113
|
+
installedAt: blocklet.installedAt,
|
|
112
114
|
ownerDid: params.ownerDid,
|
|
113
115
|
componentDids,
|
|
114
116
|
},
|
|
@@ -263,6 +265,7 @@ const getLauncherSession = async ({ launcherUrl, launcherSessionId, external = t
|
|
|
263
265
|
'statusText',
|
|
264
266
|
'subscription',
|
|
265
267
|
'expirationDate',
|
|
268
|
+
'terminatedAt',
|
|
266
269
|
'reservedUntil',
|
|
267
270
|
]);
|
|
268
271
|
}
|
|
@@ -315,17 +318,25 @@ const isBlockletExpired = async (blockletDid, controller) => {
|
|
|
315
318
|
return [LAUNCH_SESSION_STATUS.expired, LAUNCH_SESSION_STATUS.terminated].includes(status);
|
|
316
319
|
};
|
|
317
320
|
|
|
321
|
+
const isLaunchSessionTerminated = (session) => session.status === LAUNCH_SESSION_STATUS.terminated;
|
|
322
|
+
|
|
318
323
|
const isBlockletTerminated = async (blockletDid, controller) => {
|
|
319
324
|
const status = await getLaunchSessionStatus(blockletDid, controller);
|
|
320
325
|
return status === LAUNCH_SESSION_STATUS.terminated;
|
|
321
326
|
};
|
|
322
327
|
|
|
328
|
+
const DATA_RETENTION_DAYS = 30;
|
|
329
|
+
const isDataRetentionExceeded = (terminatedAt) =>
|
|
330
|
+
!!terminatedAt && dayjs().diff(dayjs(terminatedAt), 'days') > DATA_RETENTION_DAYS;
|
|
331
|
+
|
|
323
332
|
module.exports = {
|
|
324
333
|
consumeServerlessNFT,
|
|
325
334
|
consumeLauncherSession,
|
|
326
335
|
reportComponentsEvent,
|
|
327
336
|
setupAppOwner,
|
|
328
337
|
getLauncherSession,
|
|
338
|
+
isDataRetentionExceeded,
|
|
339
|
+
isLaunchSessionTerminated,
|
|
329
340
|
isLauncherSessionConsumed,
|
|
330
341
|
isBlockletExpired,
|
|
331
342
|
isBlockletTerminated,
|
package/lib/validators/router.js
CHANGED
|
@@ -71,7 +71,11 @@ const ruleSchema = {
|
|
|
71
71
|
interfaceName: Joi.string() // root interface
|
|
72
72
|
.label('interface name')
|
|
73
73
|
.when('type', { is: ROUTING_RULE_TYPES.BLOCKLET, then: Joi.required() }),
|
|
74
|
-
response: Joi.object({
|
|
74
|
+
response: Joi.object({
|
|
75
|
+
status: Joi.number().required(),
|
|
76
|
+
contentType: Joi.string(),
|
|
77
|
+
body: Joi.string().max(4096).required(),
|
|
78
|
+
})
|
|
75
79
|
.label('response')
|
|
76
80
|
.when('type', {
|
|
77
81
|
is: ROUTING_RULE_TYPES.DIRECT_RESPONSE,
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.16.25-next-
|
|
6
|
+
"version": "1.16.25-next-1e779575",
|
|
7
7
|
"description": "",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -19,19 +19,19 @@
|
|
|
19
19
|
"author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
|
|
20
20
|
"license": "Apache-2.0",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@abtnode/analytics": "1.16.25-next-
|
|
23
|
-
"@abtnode/auth": "1.16.25-next-
|
|
24
|
-
"@abtnode/certificate-manager": "1.16.25-next-
|
|
25
|
-
"@abtnode/constant": "1.16.25-next-
|
|
26
|
-
"@abtnode/cron": "1.16.25-next-
|
|
27
|
-
"@abtnode/logger": "1.16.25-next-
|
|
28
|
-
"@abtnode/models": "1.16.25-next-
|
|
29
|
-
"@abtnode/queue": "1.16.25-next-
|
|
30
|
-
"@abtnode/rbac": "1.16.25-next-
|
|
31
|
-
"@abtnode/router-provider": "1.16.25-next-
|
|
32
|
-
"@abtnode/static-server": "1.16.25-next-
|
|
33
|
-
"@abtnode/timemachine": "1.16.25-next-
|
|
34
|
-
"@abtnode/util": "1.16.25-next-
|
|
22
|
+
"@abtnode/analytics": "1.16.25-next-1e779575",
|
|
23
|
+
"@abtnode/auth": "1.16.25-next-1e779575",
|
|
24
|
+
"@abtnode/certificate-manager": "1.16.25-next-1e779575",
|
|
25
|
+
"@abtnode/constant": "1.16.25-next-1e779575",
|
|
26
|
+
"@abtnode/cron": "1.16.25-next-1e779575",
|
|
27
|
+
"@abtnode/logger": "1.16.25-next-1e779575",
|
|
28
|
+
"@abtnode/models": "1.16.25-next-1e779575",
|
|
29
|
+
"@abtnode/queue": "1.16.25-next-1e779575",
|
|
30
|
+
"@abtnode/rbac": "1.16.25-next-1e779575",
|
|
31
|
+
"@abtnode/router-provider": "1.16.25-next-1e779575",
|
|
32
|
+
"@abtnode/static-server": "1.16.25-next-1e779575",
|
|
33
|
+
"@abtnode/timemachine": "1.16.25-next-1e779575",
|
|
34
|
+
"@abtnode/util": "1.16.25-next-1e779575",
|
|
35
35
|
"@arcblock/did": "1.18.113",
|
|
36
36
|
"@arcblock/did-auth": "1.18.113",
|
|
37
37
|
"@arcblock/did-ext": "^1.18.113",
|
|
@@ -42,11 +42,11 @@
|
|
|
42
42
|
"@arcblock/pm2-events": "^0.0.5",
|
|
43
43
|
"@arcblock/validator": "^1.18.113",
|
|
44
44
|
"@arcblock/vc": "1.18.113",
|
|
45
|
-
"@blocklet/constant": "1.16.25-next-
|
|
46
|
-
"@blocklet/env": "1.16.25-next-
|
|
47
|
-
"@blocklet/meta": "1.16.25-next-
|
|
48
|
-
"@blocklet/resolver": "1.16.25-next-
|
|
49
|
-
"@blocklet/sdk": "1.16.25-next-
|
|
45
|
+
"@blocklet/constant": "1.16.25-next-1e779575",
|
|
46
|
+
"@blocklet/env": "1.16.25-next-1e779575",
|
|
47
|
+
"@blocklet/meta": "1.16.25-next-1e779575",
|
|
48
|
+
"@blocklet/resolver": "1.16.25-next-1e779575",
|
|
49
|
+
"@blocklet/sdk": "1.16.25-next-1e779575",
|
|
50
50
|
"@did-space/client": "^0.3.69",
|
|
51
51
|
"@fidm/x509": "^1.2.1",
|
|
52
52
|
"@ocap/mcrypto": "1.18.113",
|
|
@@ -102,5 +102,5 @@
|
|
|
102
102
|
"jest": "^29.7.0",
|
|
103
103
|
"unzipper": "^0.10.11"
|
|
104
104
|
},
|
|
105
|
-
"gitHead": "
|
|
105
|
+
"gitHead": "a850cb40b003798c7bf6dbbf7546e2feabd85243"
|
|
106
106
|
}
|