@abtnode/core 1.16.29 → 1.16.30-beta-958ae719
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/api/team.js +2 -0
- package/lib/blocklet/manager/disk.js +9 -5
- package/lib/states/user.js +1 -1
- package/lib/util/blocklet.js +45 -7
- package/lib/util/launcher.js +3 -2
- package/package.json +23 -23
package/lib/api/team.js
CHANGED
|
@@ -296,6 +296,7 @@ class TeamAPI extends EventEmitter {
|
|
|
296
296
|
'pk',
|
|
297
297
|
'role',
|
|
298
298
|
'email',
|
|
299
|
+
'phone',
|
|
299
300
|
'fullName',
|
|
300
301
|
'approved',
|
|
301
302
|
'createdAt',
|
|
@@ -308,6 +309,7 @@ class TeamAPI extends EventEmitter {
|
|
|
308
309
|
'avatar',
|
|
309
310
|
'locale',
|
|
310
311
|
'tags',
|
|
312
|
+
'url',
|
|
311
313
|
'userSessions',
|
|
312
314
|
// oauth relate fields
|
|
313
315
|
'sourceProvider',
|
|
@@ -1368,7 +1368,10 @@ class DiskBlockletManager extends BaseBlockletManager {
|
|
|
1368
1368
|
}
|
|
1369
1369
|
|
|
1370
1370
|
// Get blocklet by blockletDid or appDid
|
|
1371
|
-
async detail(
|
|
1371
|
+
async detail(
|
|
1372
|
+
{ did, attachConfig = true, attachRuntimeInfo, attachDiskInfo = false, useCache, getOptionalComponents },
|
|
1373
|
+
context
|
|
1374
|
+
) {
|
|
1372
1375
|
if (!did) {
|
|
1373
1376
|
throw new Error('did should not be empty');
|
|
1374
1377
|
}
|
|
@@ -1378,7 +1381,7 @@ class DiskBlockletManager extends BaseBlockletManager {
|
|
|
1378
1381
|
}
|
|
1379
1382
|
|
|
1380
1383
|
if (attachRuntimeInfo) {
|
|
1381
|
-
return this._attachRuntimeInfo({ did, diskInfo:
|
|
1384
|
+
return this._attachRuntimeInfo({ did, diskInfo: !!attachDiskInfo, context, getOptionalComponents });
|
|
1382
1385
|
}
|
|
1383
1386
|
|
|
1384
1387
|
if (useCache && this.cachedBlocklets.has(did)) {
|
|
@@ -3243,7 +3246,7 @@ class DiskBlockletManager extends BaseBlockletManager {
|
|
|
3243
3246
|
return [];
|
|
3244
3247
|
}
|
|
3245
3248
|
|
|
3246
|
-
async _attachRuntimeInfo({ did, diskInfo =
|
|
3249
|
+
async _attachRuntimeInfo({ did, diskInfo = false, context, getOptionalComponents }) {
|
|
3247
3250
|
if (!did) {
|
|
3248
3251
|
throw new Error('did should not be empty');
|
|
3249
3252
|
}
|
|
@@ -4204,14 +4207,15 @@ class DiskBlockletManager extends BaseBlockletManager {
|
|
|
4204
4207
|
for (const data of blockletExtras) {
|
|
4205
4208
|
try {
|
|
4206
4209
|
const { did } = data;
|
|
4207
|
-
const launcherSession = await launcher.getLauncherSession({
|
|
4210
|
+
const { launcherSession } = await launcher.getLauncherSession({
|
|
4208
4211
|
launcherUrl: data.controller.launcherUrl,
|
|
4209
4212
|
launcherSessionId: data.controller.launcherSessionId,
|
|
4210
4213
|
});
|
|
4214
|
+
|
|
4211
4215
|
const isTerminated = launcher.isLaunchSessionTerminated(launcherSession);
|
|
4212
4216
|
|
|
4213
4217
|
if (!isTerminated) {
|
|
4214
|
-
logger.info('skip cleaning the non-
|
|
4218
|
+
logger.info('skip cleaning the non-terminated blocklet', {
|
|
4215
4219
|
blockletDid: did,
|
|
4216
4220
|
controller: data.controller,
|
|
4217
4221
|
launcherSession,
|
package/lib/states/user.js
CHANGED
package/lib/util/blocklet.js
CHANGED
|
@@ -639,7 +639,13 @@ const startBlockletProcess = async (
|
|
|
639
639
|
const clusterSize = Number(blocklet.configObj.BLOCKLET_CLUSTER_SIZE) || +process.env.ABT_NODE_MAX_CLUSTER_SIZE;
|
|
640
640
|
options.execMode = 'cluster';
|
|
641
641
|
options.mergeLogs = true;
|
|
642
|
-
options.instances = Math.min(os.cpus().length, clusterSize);
|
|
642
|
+
options.instances = Math.max(Math.min(os.cpus().length, clusterSize), 1);
|
|
643
|
+
options.env.BLOCKLET_CLUSTER_SIZE = options.instances;
|
|
644
|
+
if (options.instances !== clusterSize) {
|
|
645
|
+
logger.warn(`Fallback cluster size to ${options.instances} for ${processId}, ignore custom ${clusterSize}`);
|
|
646
|
+
}
|
|
647
|
+
} else {
|
|
648
|
+
delete options.env.BLOCKLET_CLUSTER_SIZE;
|
|
643
649
|
}
|
|
644
650
|
|
|
645
651
|
if (b.mode === BLOCKLET_MODES.DEVELOPMENT) {
|
|
@@ -1069,11 +1075,8 @@ const pruneBlockletBundle = async ({ blocklets, installDir, blockletSettings })
|
|
|
1069
1075
|
logger.info('Blocklet source folder has been pruned');
|
|
1070
1076
|
};
|
|
1071
1077
|
|
|
1072
|
-
const
|
|
1073
|
-
|
|
1074
|
-
return { app: 0, cache: 0, log: 0, data: 0 };
|
|
1075
|
-
}
|
|
1076
|
-
|
|
1078
|
+
const _diskInfoTasks = {};
|
|
1079
|
+
const _getDiskInfo = async (blocklet) => {
|
|
1077
1080
|
try {
|
|
1078
1081
|
const { env } = blocklet;
|
|
1079
1082
|
const [app, cache, log, data] = await Promise.all([
|
|
@@ -1084,9 +1087,30 @@ const getDiskInfo = async (blocklet, { useFakeDiskInfo } = {}) => {
|
|
|
1084
1087
|
]);
|
|
1085
1088
|
return { app, cache, log, data };
|
|
1086
1089
|
} catch (error) {
|
|
1087
|
-
logger.error('Get disk info failed', { name: blocklet
|
|
1090
|
+
logger.error('Get disk info failed', { name: getDisplayName(blocklet), error });
|
|
1091
|
+
return { app: 0, cache: 0, log: 0, data: 0 };
|
|
1092
|
+
}
|
|
1093
|
+
};
|
|
1094
|
+
|
|
1095
|
+
const getDiskInfo = (blocklet, { useFakeDiskInfo } = {}) => {
|
|
1096
|
+
if (useFakeDiskInfo) {
|
|
1088
1097
|
return { app: 0, cache: 0, log: 0, data: 0 };
|
|
1089
1098
|
}
|
|
1099
|
+
|
|
1100
|
+
const { appDid } = blocklet;
|
|
1101
|
+
|
|
1102
|
+
// Cache disk info results for 1 minute
|
|
1103
|
+
_diskInfoTasks[appDid] ??= _getDiskInfo(blocklet).finally(() => {
|
|
1104
|
+
setTimeout(() => {
|
|
1105
|
+
delete _diskInfoTasks[appDid];
|
|
1106
|
+
}, 120 * 1000);
|
|
1107
|
+
});
|
|
1108
|
+
|
|
1109
|
+
return new Promise((resolve) => {
|
|
1110
|
+
_diskInfoTasks[appDid].then(resolve).catch(() => {
|
|
1111
|
+
resolve({ app: 0, cache: 0, log: 0, data: 0 });
|
|
1112
|
+
});
|
|
1113
|
+
});
|
|
1090
1114
|
};
|
|
1091
1115
|
|
|
1092
1116
|
const getRuntimeInfo = async (processId) => {
|
|
@@ -1579,6 +1603,20 @@ const validateAppConfig = async (config, states) => {
|
|
|
1579
1603
|
throw new Error(`${x.key}(${x.value}) is not a valid URL`);
|
|
1580
1604
|
}
|
|
1581
1605
|
}
|
|
1606
|
+
|
|
1607
|
+
if (x.key === BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_CLUSTER_SIZE) {
|
|
1608
|
+
if (isEmpty(x.value)) {
|
|
1609
|
+
x.value = '';
|
|
1610
|
+
}
|
|
1611
|
+
|
|
1612
|
+
const v = Number(x.value);
|
|
1613
|
+
if (Number.isNaN(v)) {
|
|
1614
|
+
throw new Error(`${x.key} must be number`);
|
|
1615
|
+
}
|
|
1616
|
+
if (!Number.isInteger(v)) {
|
|
1617
|
+
throw new Error(`${x.key} must be integer`);
|
|
1618
|
+
}
|
|
1619
|
+
}
|
|
1582
1620
|
};
|
|
1583
1621
|
|
|
1584
1622
|
const checkDuplicateAppSk = async ({ sk, did, states }) => {
|
package/lib/util/launcher.js
CHANGED
|
@@ -230,7 +230,7 @@ const setupAppOwner = async ({ node, sessionId, justCreate = false, context }) =
|
|
|
230
230
|
if (!user) {
|
|
231
231
|
throw new Error(`Owner user not found from launcher: ${launcherUrl}`);
|
|
232
232
|
}
|
|
233
|
-
appOwnerProfile = pick(user, ['fullName', 'email', 'avatar']);
|
|
233
|
+
appOwnerProfile = pick(user, ['fullName', 'email', 'avatar', 'phone']);
|
|
234
234
|
const avatarBase64 = await getAvatarByUrl(joinURL(launcherUrl, user.avatar));
|
|
235
235
|
appOwnerProfile.avatar = await extractUserAvatar(avatarBase64, { dataDir });
|
|
236
236
|
logger.info('Create owner from launcher for blocklet', { appDid, ownerDid, ownerPk, sessionId, appOwnerProfile });
|
|
@@ -239,7 +239,7 @@ const setupAppOwner = async ({ node, sessionId, justCreate = false, context }) =
|
|
|
239
239
|
if (!user) {
|
|
240
240
|
throw new Error(`Owner user not found in server: ${userDid}`);
|
|
241
241
|
}
|
|
242
|
-
appOwnerProfile = pick(user, ['fullName', 'email', 'avatar']);
|
|
242
|
+
appOwnerProfile = pick(user, ['fullName', 'email', 'avatar', 'phone']);
|
|
243
243
|
if (user.avatar && user.avatar.startsWith(USER_AVATAR_URL_PREFIX)) {
|
|
244
244
|
const filename = user.avatar.split('/').pop();
|
|
245
245
|
const srcFile = getAvatarFile(serverDataDir, filename);
|
|
@@ -313,6 +313,7 @@ const setupAppOwner = async ({ node, sessionId, justCreate = false, context }) =
|
|
|
313
313
|
did: ownerDid,
|
|
314
314
|
passport,
|
|
315
315
|
role,
|
|
316
|
+
fullName: appOwnerProfile?.fullName,
|
|
316
317
|
secret: appSecret,
|
|
317
318
|
expiresIn: '1d',
|
|
318
319
|
});
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.16.
|
|
6
|
+
"version": "1.16.30-beta-958ae719",
|
|
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.
|
|
23
|
-
"@abtnode/auth": "1.16.
|
|
24
|
-
"@abtnode/certificate-manager": "1.16.
|
|
25
|
-
"@abtnode/constant": "1.16.
|
|
26
|
-
"@abtnode/cron": "1.16.
|
|
27
|
-
"@abtnode/logger": "1.16.
|
|
28
|
-
"@abtnode/models": "1.16.
|
|
29
|
-
"@abtnode/queue": "1.16.
|
|
30
|
-
"@abtnode/rbac": "1.16.
|
|
31
|
-
"@abtnode/router-provider": "1.16.
|
|
32
|
-
"@abtnode/static-server": "1.16.
|
|
33
|
-
"@abtnode/timemachine": "1.16.
|
|
34
|
-
"@abtnode/util": "1.16.
|
|
22
|
+
"@abtnode/analytics": "1.16.30-beta-958ae719",
|
|
23
|
+
"@abtnode/auth": "1.16.30-beta-958ae719",
|
|
24
|
+
"@abtnode/certificate-manager": "1.16.30-beta-958ae719",
|
|
25
|
+
"@abtnode/constant": "1.16.30-beta-958ae719",
|
|
26
|
+
"@abtnode/cron": "1.16.30-beta-958ae719",
|
|
27
|
+
"@abtnode/logger": "1.16.30-beta-958ae719",
|
|
28
|
+
"@abtnode/models": "1.16.30-beta-958ae719",
|
|
29
|
+
"@abtnode/queue": "1.16.30-beta-958ae719",
|
|
30
|
+
"@abtnode/rbac": "1.16.30-beta-958ae719",
|
|
31
|
+
"@abtnode/router-provider": "1.16.30-beta-958ae719",
|
|
32
|
+
"@abtnode/static-server": "1.16.30-beta-958ae719",
|
|
33
|
+
"@abtnode/timemachine": "1.16.30-beta-958ae719",
|
|
34
|
+
"@abtnode/util": "1.16.30-beta-958ae719",
|
|
35
35
|
"@arcblock/did": "1.18.128",
|
|
36
36
|
"@arcblock/did-auth": "1.18.128",
|
|
37
37
|
"@arcblock/did-ext": "^1.18.128",
|
|
@@ -42,13 +42,13 @@
|
|
|
42
42
|
"@arcblock/pm2-events": "^0.0.5",
|
|
43
43
|
"@arcblock/validator": "^1.18.128",
|
|
44
44
|
"@arcblock/vc": "1.18.128",
|
|
45
|
-
"@blocklet/constant": "1.16.
|
|
46
|
-
"@blocklet/env": "1.16.
|
|
47
|
-
"@blocklet/meta": "1.16.
|
|
48
|
-
"@blocklet/resolver": "1.16.
|
|
49
|
-
"@blocklet/sdk": "1.16.
|
|
50
|
-
"@blocklet/store": "1.16.
|
|
51
|
-
"@did-space/client": "^0.5.
|
|
45
|
+
"@blocklet/constant": "1.16.30-beta-958ae719",
|
|
46
|
+
"@blocklet/env": "1.16.30-beta-958ae719",
|
|
47
|
+
"@blocklet/meta": "1.16.30-beta-958ae719",
|
|
48
|
+
"@blocklet/resolver": "1.16.30-beta-958ae719",
|
|
49
|
+
"@blocklet/sdk": "1.16.30-beta-958ae719",
|
|
50
|
+
"@blocklet/store": "1.16.30-beta-958ae719",
|
|
51
|
+
"@did-space/client": "^0.5.17",
|
|
52
52
|
"@fidm/x509": "^1.2.1",
|
|
53
53
|
"@ocap/mcrypto": "1.18.128",
|
|
54
54
|
"@ocap/util": "1.18.128",
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"ssri": "^8.0.1",
|
|
88
88
|
"stream-throttle": "^0.1.3",
|
|
89
89
|
"stream-to-promise": "^3.0.0",
|
|
90
|
-
"systeminformation": "^5.
|
|
90
|
+
"systeminformation": "^5.23.3",
|
|
91
91
|
"tail": "^2.2.4",
|
|
92
92
|
"tar": "^6.1.11",
|
|
93
93
|
"transliteration": "^2.3.5",
|
|
@@ -103,5 +103,5 @@
|
|
|
103
103
|
"jest": "^29.7.0",
|
|
104
104
|
"unzipper": "^0.10.11"
|
|
105
105
|
},
|
|
106
|
-
"gitHead": "
|
|
106
|
+
"gitHead": "75590ff3be51e7fe2a070124541aebc203ed16dc"
|
|
107
107
|
}
|