@abtnode/core 1.17.3-beta-20251121-135300-8e451e6e → 1.17.3-beta-20251123-232619-53258789
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 +28 -16
- package/lib/blocklet/manager/helper/blue-green-start-blocklet.js +5 -1
- package/lib/blocklet/manager/helper/blue-green-upgrade-blocklet.js +44 -8
- package/lib/event/index.js +1 -0
- package/lib/index.js +1 -0
- package/lib/states/notification.js +7 -5
- package/lib/team/manager.js +17 -3
- package/lib/webhook/sender/slack/index.js +0 -1
- package/lib/webhook/sender/wallet/index.js +28 -10
- package/package.json +24 -24
|
@@ -1514,13 +1514,19 @@ class DiskBlockletManager extends BaseBlockletManager {
|
|
|
1514
1514
|
});
|
|
1515
1515
|
|
|
1516
1516
|
const doc = await this._deleteBlocklet({ did, keepData, keepLogsDir, keepConfigs }, context);
|
|
1517
|
-
this._createNotification(
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1517
|
+
this._createNotification(
|
|
1518
|
+
doc.meta.did,
|
|
1519
|
+
{
|
|
1520
|
+
title: 'Blocklet Deleted',
|
|
1521
|
+
description: `Blocklet ${getDisplayName(blocklet)} is deleted.`,
|
|
1522
|
+
entityType: 'blocklet',
|
|
1523
|
+
entityId: doc.meta.did,
|
|
1524
|
+
severity: 'success',
|
|
1525
|
+
},
|
|
1526
|
+
{
|
|
1527
|
+
skipGetBlocklet: true,
|
|
1528
|
+
}
|
|
1529
|
+
);
|
|
1524
1530
|
await removeDockerNetwork(parseDockerName(did, 'docker-network'));
|
|
1525
1531
|
return doc;
|
|
1526
1532
|
} catch (error) {
|
|
@@ -1529,13 +1535,19 @@ class DiskBlockletManager extends BaseBlockletManager {
|
|
|
1529
1535
|
const doc = await this._deleteBlocklet({ did, keepData, keepLogsDir, keepConfigs }, context);
|
|
1530
1536
|
await removeDockerNetwork(parseDockerName(did, 'docker-network'));
|
|
1531
1537
|
|
|
1532
|
-
this._createNotification(
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1538
|
+
this._createNotification(
|
|
1539
|
+
doc.meta.did,
|
|
1540
|
+
{
|
|
1541
|
+
title: 'Blocklet Deleted',
|
|
1542
|
+
description: `Blocklet ${getDisplayName(blocklet)} is deleted.`,
|
|
1543
|
+
entityType: 'blocklet',
|
|
1544
|
+
entityId: doc.meta.did,
|
|
1545
|
+
severity: 'success',
|
|
1546
|
+
},
|
|
1547
|
+
{
|
|
1548
|
+
skipGetBlocklet: true,
|
|
1549
|
+
}
|
|
1550
|
+
);
|
|
1539
1551
|
|
|
1540
1552
|
return doc;
|
|
1541
1553
|
}
|
|
@@ -5111,7 +5123,7 @@ class DiskBlockletManager extends BaseBlockletManager {
|
|
|
5111
5123
|
}
|
|
5112
5124
|
|
|
5113
5125
|
// 目前:Blocklet 的安装消息都会聚合在这里。
|
|
5114
|
-
async _createNotification(did, notification) {
|
|
5126
|
+
async _createNotification(did, notification, { skipGetBlocklet = false } = {}) {
|
|
5115
5127
|
if (isCLI()) {
|
|
5116
5128
|
return undefined;
|
|
5117
5129
|
}
|
|
@@ -5120,7 +5132,7 @@ class DiskBlockletManager extends BaseBlockletManager {
|
|
|
5120
5132
|
let blockletUrl;
|
|
5121
5133
|
let blocklet;
|
|
5122
5134
|
try {
|
|
5123
|
-
blocklet = await this.getBlocklet(did);
|
|
5135
|
+
blocklet = skipGetBlocklet ? null : await this.getBlocklet(did);
|
|
5124
5136
|
if (blocklet) {
|
|
5125
5137
|
const urls = blocklet.site?.domainAliases || [];
|
|
5126
5138
|
const customUrl = urls.find((x) => !x.isProtected)?.value;
|
|
@@ -41,7 +41,7 @@ const { isDockerOnlySingleInstance } = require('../../../util/docker/is-docker-o
|
|
|
41
41
|
* @returns {Promise<Object>} 返回启动后的 blocklet 对象
|
|
42
42
|
*/
|
|
43
43
|
const blueGreenStartBlocklet = async (
|
|
44
|
-
{ did, componentDids, operator: _operator, ignoreErrorNotification },
|
|
44
|
+
{ did, componentDids, operator: _operator, ignoreErrorNotification, onError },
|
|
45
45
|
context,
|
|
46
46
|
manager,
|
|
47
47
|
states
|
|
@@ -418,6 +418,10 @@ const blueGreenStartBlocklet = async (
|
|
|
418
418
|
});
|
|
419
419
|
}
|
|
420
420
|
|
|
421
|
+
if (errorBlockletDids.length && onError) {
|
|
422
|
+
onError(errorBlockletDids);
|
|
423
|
+
}
|
|
424
|
+
|
|
421
425
|
if (throwOnError && errorDescription) {
|
|
422
426
|
throw new Error(errorDescription);
|
|
423
427
|
}
|
|
@@ -28,6 +28,8 @@ const blueGreenUpgradeBlocklet = async (
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
let errorBlockletDids = [];
|
|
32
|
+
|
|
31
33
|
try {
|
|
32
34
|
await states.blocklet.upgradeBlocklet({ meta, source, deployedFrom, children });
|
|
33
35
|
logger.info('updated blocklet for upgrading', { did, componentDids, source, name });
|
|
@@ -81,7 +83,15 @@ const blueGreenUpgradeBlocklet = async (
|
|
|
81
83
|
if (runningDids.length) {
|
|
82
84
|
if (initialized) {
|
|
83
85
|
await blueGreenStartBlocklet(
|
|
84
|
-
{
|
|
86
|
+
{
|
|
87
|
+
did,
|
|
88
|
+
componentDids: runningDids,
|
|
89
|
+
operator: context?.user?.did,
|
|
90
|
+
ignoreErrorNotification: true,
|
|
91
|
+
onError: (dids) => {
|
|
92
|
+
errorBlockletDids = dids;
|
|
93
|
+
},
|
|
94
|
+
},
|
|
85
95
|
context,
|
|
86
96
|
manager,
|
|
87
97
|
states
|
|
@@ -159,18 +169,44 @@ const blueGreenUpgradeBlocklet = async (
|
|
|
159
169
|
} catch (err) {
|
|
160
170
|
logger.error('failed to upgrade blocklet', { did, version, name, error: err });
|
|
161
171
|
const nextBlocklet = await manager.ensureBlocklet(did);
|
|
172
|
+
|
|
173
|
+
// 提取出错的 blocklet did 列表
|
|
174
|
+
let errorDids = [];
|
|
175
|
+
if (Array.isArray(errorBlockletDids) && errorBlockletDids.length > 0) {
|
|
176
|
+
if (typeof errorBlockletDids[0] === 'string') {
|
|
177
|
+
errorDids = errorBlockletDids;
|
|
178
|
+
} else {
|
|
179
|
+
errorDids = errorBlockletDids.map((x) => x.did);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const rollbackBlocklet = { ...oldBlocklet };
|
|
162
184
|
for (const child of nextBlocklet.children) {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
oldChild
|
|
185
|
+
const isErrorBlocklet = errorDids.includes(child.meta.did);
|
|
186
|
+
if (isErrorBlocklet) {
|
|
187
|
+
for (const oldChild of oldBlocklet.children) {
|
|
188
|
+
if (child && oldChild && child.meta.did === oldChild.meta.did) {
|
|
189
|
+
const rollbackChild = rollbackBlocklet.children.find((c) => c.meta.did === child.meta.did);
|
|
190
|
+
if (rollbackChild) {
|
|
191
|
+
rollbackChild.status = oldChild.status;
|
|
192
|
+
rollbackChild.greenStatus = oldChild.greenStatus;
|
|
193
|
+
rollbackChild.ports = oldChild.ports;
|
|
194
|
+
rollbackChild.greenPorts = oldChild.greenPorts;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
} else {
|
|
199
|
+
const rollbackChildIndex = rollbackBlocklet.children.findIndex((c) => c.meta.did === child.meta.did);
|
|
200
|
+
if (rollbackChildIndex !== -1) {
|
|
201
|
+
rollbackBlocklet.children[rollbackChildIndex] = child;
|
|
167
202
|
}
|
|
168
203
|
}
|
|
169
204
|
}
|
|
170
|
-
|
|
171
|
-
|
|
205
|
+
|
|
206
|
+
await states.blocklet.upgradeBlocklet({ ...rollbackBlocklet });
|
|
207
|
+
manager.configSynchronizer.throttledSyncAppConfig(rollbackBlocklet);
|
|
172
208
|
await manager._updateDependents(did);
|
|
173
|
-
manager.emit(BlockletEvents.statusChange, { ...
|
|
209
|
+
manager.emit(BlockletEvents.statusChange, { ...rollbackBlocklet, error: { message: err.message } });
|
|
174
210
|
|
|
175
211
|
const actionName = action === INSTALL_ACTIONS.INSTALL_COMPONENT ? 'install' : 'upgrade';
|
|
176
212
|
const notificationEvent =
|
package/lib/event/index.js
CHANGED
package/lib/index.js
CHANGED
|
@@ -684,6 +684,7 @@ function ABTNode(options) {
|
|
|
684
684
|
if (['deleteBlocklet', 'installBlocklet'].includes(params.action) || teamDid === options.nodeDid) {
|
|
685
685
|
const result = await states.auditLog.create(params, instance);
|
|
686
686
|
// 如果是 installBlocklet, 不需要提前返回, 要将 log 记录在 service 中
|
|
687
|
+
// 如果是 deleteBlocklet, 需要提前返回,因为 deleteBlocklet 会触发 blocklet 的删除,不需要再往 service 的auditLog 表中插入记录了
|
|
687
688
|
if (params.action !== 'installBlocklet') {
|
|
688
689
|
return result;
|
|
689
690
|
}
|
|
@@ -223,7 +223,7 @@ class NotificationState extends BaseState {
|
|
|
223
223
|
});
|
|
224
224
|
return result.length > 0 ? result.map((item) => item.did) : [did];
|
|
225
225
|
} catch (error) {
|
|
226
|
-
logger.
|
|
226
|
+
logger.warn('getUserDids error: ', error);
|
|
227
227
|
return [did];
|
|
228
228
|
}
|
|
229
229
|
}
|
|
@@ -798,16 +798,18 @@ class NotificationState extends BaseState {
|
|
|
798
798
|
},
|
|
799
799
|
};
|
|
800
800
|
|
|
801
|
-
const
|
|
801
|
+
const includeWhere = {};
|
|
802
|
+
if (receiver) {
|
|
803
|
+
const receiverDids = await this.getUserDids(receiver);
|
|
804
|
+
includeWhere.receiver = { [Op.in]: receiverDids };
|
|
805
|
+
}
|
|
802
806
|
|
|
803
807
|
const include = [
|
|
804
808
|
{
|
|
805
809
|
model: this.notificationReceivers.model,
|
|
806
810
|
as: 'receivers',
|
|
807
811
|
attributes: [],
|
|
808
|
-
where:
|
|
809
|
-
receiver: { [Op.in]: receiverDids },
|
|
810
|
-
},
|
|
812
|
+
where: includeWhere,
|
|
811
813
|
required: false,
|
|
812
814
|
},
|
|
813
815
|
];
|
package/lib/team/manager.js
CHANGED
|
@@ -243,9 +243,23 @@ class TeamManager extends EventEmitter {
|
|
|
243
243
|
users = users.concat(roleUsers);
|
|
244
244
|
}
|
|
245
245
|
if (userDids.length > 0) {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
246
|
+
let queryUsers = [];
|
|
247
|
+
if (userDids.includes('*')) {
|
|
248
|
+
queryUsers = await userState.getUsersByDids({
|
|
249
|
+
dids: userDids,
|
|
250
|
+
query: {
|
|
251
|
+
approved: true,
|
|
252
|
+
selection,
|
|
253
|
+
includeConnectedAccounts,
|
|
254
|
+
includePassports: true,
|
|
255
|
+
},
|
|
256
|
+
});
|
|
257
|
+
} else {
|
|
258
|
+
// 使用 getUser 查询的目的是为了避免传入的 receiver 不在user表中而存在于 connected_account 表中
|
|
259
|
+
queryUsers = await Promise.all(
|
|
260
|
+
userDids.map((did) => userState.getUser(did, { includePassports: true, enableConnectedAccount: true }))
|
|
261
|
+
);
|
|
262
|
+
}
|
|
249
263
|
|
|
250
264
|
const validUsers = queryUsers.filter((user, index) => {
|
|
251
265
|
if (!user) {
|
|
@@ -1,19 +1,27 @@
|
|
|
1
1
|
const logger = require('@abtnode/logger')('@abtnode/core:sender:api');
|
|
2
|
-
const {
|
|
3
|
-
const { ROLES, PASSPORT_STATUS } = require('@abtnode/constant');
|
|
2
|
+
const { ROLES, PASSPORT_STATUS, NOTIFICATION_SEND_CHANNEL } = require('@abtnode/constant');
|
|
4
3
|
const BaseSender = require('../base');
|
|
5
4
|
|
|
6
5
|
class WalletSender extends BaseSender {
|
|
7
6
|
async send(params, data = {}) {
|
|
8
|
-
const {
|
|
7
|
+
const {
|
|
8
|
+
id,
|
|
9
|
+
title,
|
|
10
|
+
description,
|
|
11
|
+
nodeInfo,
|
|
12
|
+
node,
|
|
13
|
+
receiver,
|
|
14
|
+
actions,
|
|
15
|
+
attachments,
|
|
16
|
+
message,
|
|
17
|
+
appInfo,
|
|
18
|
+
entityType,
|
|
19
|
+
entityId,
|
|
20
|
+
source,
|
|
21
|
+
teamDid,
|
|
22
|
+
} = data;
|
|
9
23
|
|
|
10
24
|
try {
|
|
11
|
-
const sender = {
|
|
12
|
-
appDid: nodeInfo.did,
|
|
13
|
-
appSk: nodeInfo.sk,
|
|
14
|
-
type: 'server',
|
|
15
|
-
};
|
|
16
|
-
|
|
17
25
|
const _message = message ?? {
|
|
18
26
|
id,
|
|
19
27
|
title,
|
|
@@ -21,6 +29,9 @@ class WalletSender extends BaseSender {
|
|
|
21
29
|
actions,
|
|
22
30
|
attachments,
|
|
23
31
|
appInfo,
|
|
32
|
+
...(entityType ? { entityType } : {}),
|
|
33
|
+
...(entityId ? { entityId } : {}),
|
|
34
|
+
...(source ? { source } : {}),
|
|
24
35
|
};
|
|
25
36
|
|
|
26
37
|
let to = [];
|
|
@@ -48,7 +59,14 @@ class WalletSender extends BaseSender {
|
|
|
48
59
|
if (!to.length) {
|
|
49
60
|
return;
|
|
50
61
|
}
|
|
51
|
-
|
|
62
|
+
|
|
63
|
+
// @FIXME: liushuang 感觉这里不需要创建 notification,只需要发送消息到 wallet 即可
|
|
64
|
+
await node.createNotification({
|
|
65
|
+
teamDid: teamDid || nodeInfo.did,
|
|
66
|
+
..._message,
|
|
67
|
+
receiver: to,
|
|
68
|
+
channels: [NOTIFICATION_SEND_CHANNEL.WALLET],
|
|
69
|
+
});
|
|
52
70
|
} catch (error) {
|
|
53
71
|
delete error.request;
|
|
54
72
|
delete error.response;
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.17.3-beta-
|
|
6
|
+
"version": "1.17.3-beta-20251123-232619-53258789",
|
|
7
7
|
"description": "",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -17,21 +17,21 @@
|
|
|
17
17
|
"author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
|
|
18
18
|
"license": "Apache-2.0",
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@abtnode/analytics": "1.17.3-beta-
|
|
21
|
-
"@abtnode/auth": "1.17.3-beta-
|
|
22
|
-
"@abtnode/certificate-manager": "1.17.3-beta-
|
|
23
|
-
"@abtnode/constant": "1.17.3-beta-
|
|
24
|
-
"@abtnode/cron": "1.17.3-beta-
|
|
25
|
-
"@abtnode/db-cache": "1.17.3-beta-
|
|
26
|
-
"@abtnode/docker-utils": "1.17.3-beta-
|
|
27
|
-
"@abtnode/logger": "1.17.3-beta-
|
|
28
|
-
"@abtnode/models": "1.17.3-beta-
|
|
29
|
-
"@abtnode/queue": "1.17.3-beta-
|
|
30
|
-
"@abtnode/rbac": "1.17.3-beta-
|
|
31
|
-
"@abtnode/router-provider": "1.17.3-beta-
|
|
32
|
-
"@abtnode/static-server": "1.17.3-beta-
|
|
33
|
-
"@abtnode/timemachine": "1.17.3-beta-
|
|
34
|
-
"@abtnode/util": "1.17.3-beta-
|
|
20
|
+
"@abtnode/analytics": "1.17.3-beta-20251123-232619-53258789",
|
|
21
|
+
"@abtnode/auth": "1.17.3-beta-20251123-232619-53258789",
|
|
22
|
+
"@abtnode/certificate-manager": "1.17.3-beta-20251123-232619-53258789",
|
|
23
|
+
"@abtnode/constant": "1.17.3-beta-20251123-232619-53258789",
|
|
24
|
+
"@abtnode/cron": "1.17.3-beta-20251123-232619-53258789",
|
|
25
|
+
"@abtnode/db-cache": "1.17.3-beta-20251123-232619-53258789",
|
|
26
|
+
"@abtnode/docker-utils": "1.17.3-beta-20251123-232619-53258789",
|
|
27
|
+
"@abtnode/logger": "1.17.3-beta-20251123-232619-53258789",
|
|
28
|
+
"@abtnode/models": "1.17.3-beta-20251123-232619-53258789",
|
|
29
|
+
"@abtnode/queue": "1.17.3-beta-20251123-232619-53258789",
|
|
30
|
+
"@abtnode/rbac": "1.17.3-beta-20251123-232619-53258789",
|
|
31
|
+
"@abtnode/router-provider": "1.17.3-beta-20251123-232619-53258789",
|
|
32
|
+
"@abtnode/static-server": "1.17.3-beta-20251123-232619-53258789",
|
|
33
|
+
"@abtnode/timemachine": "1.17.3-beta-20251123-232619-53258789",
|
|
34
|
+
"@abtnode/util": "1.17.3-beta-20251123-232619-53258789",
|
|
35
35
|
"@aigne/aigne-hub": "^0.10.9",
|
|
36
36
|
"@arcblock/did": "^1.27.7",
|
|
37
37
|
"@arcblock/did-connect-js": "^1.27.7",
|
|
@@ -43,15 +43,15 @@
|
|
|
43
43
|
"@arcblock/pm2-events": "^0.0.5",
|
|
44
44
|
"@arcblock/validator": "^1.27.7",
|
|
45
45
|
"@arcblock/vc": "^1.27.7",
|
|
46
|
-
"@blocklet/constant": "1.17.3-beta-
|
|
46
|
+
"@blocklet/constant": "1.17.3-beta-20251123-232619-53258789",
|
|
47
47
|
"@blocklet/did-space-js": "^1.2.4",
|
|
48
|
-
"@blocklet/env": "1.17.3-beta-
|
|
48
|
+
"@blocklet/env": "1.17.3-beta-20251123-232619-53258789",
|
|
49
49
|
"@blocklet/error": "^0.3.3",
|
|
50
|
-
"@blocklet/meta": "1.17.3-beta-
|
|
51
|
-
"@blocklet/resolver": "1.17.3-beta-
|
|
52
|
-
"@blocklet/sdk": "1.17.3-beta-
|
|
53
|
-
"@blocklet/server-js": "1.17.3-beta-
|
|
54
|
-
"@blocklet/store": "1.17.3-beta-
|
|
50
|
+
"@blocklet/meta": "1.17.3-beta-20251123-232619-53258789",
|
|
51
|
+
"@blocklet/resolver": "1.17.3-beta-20251123-232619-53258789",
|
|
52
|
+
"@blocklet/sdk": "1.17.3-beta-20251123-232619-53258789",
|
|
53
|
+
"@blocklet/server-js": "1.17.3-beta-20251123-232619-53258789",
|
|
54
|
+
"@blocklet/store": "1.17.3-beta-20251123-232619-53258789",
|
|
55
55
|
"@blocklet/theme": "^3.2.6",
|
|
56
56
|
"@fidm/x509": "^1.2.1",
|
|
57
57
|
"@ocap/mcrypto": "^1.27.7",
|
|
@@ -116,5 +116,5 @@
|
|
|
116
116
|
"express": "^4.18.2",
|
|
117
117
|
"unzipper": "^0.10.11"
|
|
118
118
|
},
|
|
119
|
-
"gitHead": "
|
|
119
|
+
"gitHead": "d37497a49c982e82ba60249ed06c1b73f340b893"
|
|
120
120
|
}
|