@abtnode/core 1.16.44-beta-20250520-104453-912ed737 → 1.16.44-beta-20250523-232943-369d21c5

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 CHANGED
@@ -2098,17 +2098,14 @@ class TeamAPI extends EventEmitter {
2098
2098
  extra,
2099
2099
  });
2100
2100
  logger.info('insert userSession successfully', { userDid, ua, lastLoginIp, appPid, passportId, extra });
2101
- // HACK: 某些地方,首次新增 userSession 时不会,携带 ua 信息,这个时候不能发通知
2102
- if (ua) {
2103
- this.emit(BlockletEvents.addUserSession, {
2104
- userSession: data,
2105
- teamDid,
2106
- userDid,
2107
- locale,
2108
- skipNotification,
2109
- origin,
2110
- });
2111
- }
2101
+ this.emit(BlockletEvents.addUserSession, {
2102
+ userSession: data,
2103
+ teamDid,
2104
+ userDid,
2105
+ locale,
2106
+ skipNotification,
2107
+ origin,
2108
+ });
2112
2109
  } else {
2113
2110
  const exist = await state.findOne({ userDid, visitorId, appPid });
2114
2111
  if (exist) {
@@ -2166,16 +2163,14 @@ class TeamAPI extends EventEmitter {
2166
2163
  passportId,
2167
2164
  extra,
2168
2165
  });
2169
- if (ua) {
2170
- this.emit(BlockletEvents.addUserSession, {
2171
- userSession: data,
2172
- teamDid,
2173
- userDid,
2174
- locale,
2175
- skipNotification,
2176
- origin,
2177
- });
2178
- }
2166
+ this.emit(BlockletEvents.addUserSession, {
2167
+ userSession: data,
2168
+ teamDid,
2169
+ userDid,
2170
+ locale,
2171
+ skipNotification,
2172
+ origin,
2173
+ });
2179
2174
  }
2180
2175
  }
2181
2176
 
@@ -62,6 +62,7 @@ const {
62
62
  isGatewayBlocklet,
63
63
  hasStartEngine,
64
64
  getDisplayName,
65
+ isExternalBlocklet,
65
66
  } = require('@blocklet/meta/lib/util');
66
67
  const { getComponentsInternalInfo } = require('@blocklet/meta/lib/blocklet');
67
68
  const { getRequiredComponentsLayers } = require('@blocklet/meta/lib/get-required-components-layers');
@@ -891,7 +892,7 @@ class DiskBlockletManager extends BaseBlockletManager {
891
892
  (hookName) =>
892
893
  async (b, { env }) => {
893
894
  const hookArgs = getHookArgs(b);
894
- const needRunDocker = await checkNeedRunDocker(b.meta, env, nodeInfo);
895
+ const needRunDocker = await checkNeedRunDocker(b.meta, env, nodeInfo, isExternalBlocklet(blocklet));
895
896
  if (needRunDocker) {
896
897
  if (hookName === 'postStart' && b.meta.scripts?.postStart) {
897
898
  return dockerExec({
@@ -1005,7 +1006,7 @@ class DiskBlockletManager extends BaseBlockletManager {
1005
1006
  await stopBlockletProcess(blocklet, {
1006
1007
  preStop: async (b, { ancestors }) => {
1007
1008
  const nextEnv = getRuntimeEnvironments(b, nodeEnvironments, ancestors);
1008
- const needRunDocker = await checkNeedRunDocker(b.meta, nextEnv, nodeInfo);
1009
+ const needRunDocker = await checkNeedRunDocker(b.meta, nextEnv, nodeInfo, isExternalBlocklet(blocklet));
1009
1010
  const hookArgs = getHookArgs(b);
1010
1011
  if (needRunDocker) {
1011
1012
  const script = b.meta.scripts?.preStop;
@@ -1233,7 +1234,8 @@ class DiskBlockletManager extends BaseBlockletManager {
1233
1234
  const needRunDocker = await checkNeedRunDocker(
1234
1235
  b.meta,
1235
1236
  getRuntimeEnvironments(b, nodeEnvironments, ancestors),
1236
- nodeInfo
1237
+ nodeInfo,
1238
+ isExternalBlocklet(blocklet)
1237
1239
  );
1238
1240
  const hookArgs = getHookArgs(b);
1239
1241
  const nextEnv = getRuntimeEnvironments(b, nodeEnvironments, ancestors);
@@ -1722,7 +1724,7 @@ class DiskBlockletManager extends BaseBlockletManager {
1722
1724
  // FIXME: we should also call preConfig for child blocklets
1723
1725
  const nodeInfo = await states.node.read();
1724
1726
  const nextEnv = { ...getRuntimeEnvironments(blocklet, nodeEnvironments, ancestors), ...configObj };
1725
- const needRunDocker = await checkNeedRunDocker(blocklet.meta, nextEnv, nodeInfo);
1727
+ const needRunDocker = await checkNeedRunDocker(blocklet.meta, nextEnv, nodeInfo, isExternalBlocklet(blocklet));
1726
1728
  const hookArgs = getHookArgs(blocklet);
1727
1729
  if (needRunDocker) {
1728
1730
  if (blocklet.meta.scripts?.preConfig) {
@@ -2354,7 +2356,7 @@ class DiskBlockletManager extends BaseBlockletManager {
2354
2356
  }
2355
2357
 
2356
2358
  const cert = await this.certManager.manager.getByDomain(alias.value);
2357
- logger.info('cron check dns certificate', { cert });
2359
+ logger.info('cron check dns certificate', { status: cert?.status, domain: alias.value });
2358
2360
  if (cert?.status === 'error') {
2359
2361
  await issueCert(alias);
2360
2362
  }
@@ -4119,7 +4121,7 @@ class DiskBlockletManager extends BaseBlockletManager {
4119
4121
  return;
4120
4122
  }
4121
4123
  const nextEnv = getRuntimeEnvironments(b, nodeEnvironments, [blocklet]);
4122
- const subNeedRunDocker = await checkNeedRunDocker(b.meta, nextEnv, nodeInfo);
4124
+ const subNeedRunDocker = await checkNeedRunDocker(b.meta, nextEnv, nodeInfo, isExternalBlocklet(blocklet));
4123
4125
  const hookArgs = getHookArgs(b);
4124
4126
 
4125
4127
  const scriptsDir = path.join(b.env.appDir, 'migration');
@@ -4215,7 +4217,7 @@ class DiskBlockletManager extends BaseBlockletManager {
4215
4217
  const nodeEnvironments = await states.node.getEnvironments();
4216
4218
  const nodeInfo = await states.node.read();
4217
4219
  const env = getRuntimeEnvironments(blocklet, nodeEnvironments, {});
4218
- const needRunDocker = await checkNeedRunDocker(blocklet.meta, env, nodeInfo);
4220
+ const needRunDocker = await checkNeedRunDocker(blocklet.meta, env, nodeInfo, isExternalBlocklet(blocklet));
4219
4221
 
4220
4222
  if (!needRunDocker) {
4221
4223
  // pre install
@@ -4594,7 +4596,7 @@ class DiskBlockletManager extends BaseBlockletManager {
4594
4596
  const nodeInfo = await states.node.read();
4595
4597
  const hookFn = async (b, { ancestors }) => {
4596
4598
  const env = getRuntimeEnvironments(b, nodeEnvironments, ancestors);
4597
- const needRunDocker = await checkNeedRunDocker(b.meta, env, nodeInfo);
4599
+ const needRunDocker = await checkNeedRunDocker(b.meta, env, nodeInfo, isExternalBlocklet(blocklet));
4598
4600
  const hookArgs = getHookArgs(b);
4599
4601
  if (needRunDocker) {
4600
4602
  const script = b.meta.scripts?.[name];
@@ -5113,6 +5115,21 @@ class DiskBlockletManager extends BaseBlockletManager {
5113
5115
  const isExpired = await launcher.isBlockletExpired(blocklet.meta.did, blocklet.controller);
5114
5116
 
5115
5117
  if (isExpired) {
5118
+ if (blocklet.controller.status?.value !== BLOCKLET_CONTROLLER_STATUS.suspended) {
5119
+ await states.blockletExtras.updateByDid(blocklet.meta.did, {
5120
+ controller: {
5121
+ ...blocklet.controller,
5122
+ status: {
5123
+ value: BLOCKLET_CONTROLLER_STATUS.suspended,
5124
+ reason: SUSPENDED_REASON.expired,
5125
+ },
5126
+ },
5127
+ });
5128
+ logger.info('update blocklet controller status to suspended', {
5129
+ did: blocklet.meta.did,
5130
+ nftId: blocklet.controller?.nftId,
5131
+ });
5132
+ }
5116
5133
  logger.error(`try to ${action} an expired blocklet`, {
5117
5134
  did: blocklet.meta.did,
5118
5135
  nftId: blocklet.controller?.nftId,
@@ -6,7 +6,6 @@ const { getDisplayName } = require('@blocklet/meta/lib/util');
6
6
 
7
7
  const states = require('../../states');
8
8
  const { isBlockletPortHealthy, shouldCheckHealthy } = require('../../util/blocklet');
9
- const { shouldJobBackoff } = require('../../util/env');
10
9
 
11
10
  const inProgressStatuses = [BlockletStatus.stopping, BlockletStatus.restarting, BlockletStatus.waiting];
12
11
 
@@ -28,11 +27,11 @@ class EnsureBlockletRunning {
28
27
 
29
28
  fakeRunningToWaitingOnce = false;
30
29
 
31
- highLoadCpu = +process.env.ABT_NODE_ENSURE_RUNNING_HIGH_LOAD_CPU || 0.7;
30
+ highLoadCpu = +process.env.ABT_NODE_ENSURE_RUNNING_HIGH_LOAD_CPU || 0.85;
32
31
 
33
- highLoadMemory = +process.env.ABT_NODE_ENSURE_RUNNING_HIGH_LOAD_MEMORY || 0.8;
32
+ highLoadMemory = +process.env.ABT_NODE_ENSURE_RUNNING_HIGH_LOAD_MEMORY || 0.85;
34
33
 
35
- highLoadDisk = +process.env.ABT_NODE_ENSURE_RUNNING_HIGH_LOAD_DISK || 0.8;
34
+ highLoadDisk = +process.env.ABT_NODE_ENSURE_RUNNING_HIGH_LOAD_DISK || 0.95;
36
35
 
37
36
  runningBlocklets = {};
38
37
 
@@ -51,9 +50,6 @@ class EnsureBlockletRunning {
51
50
  // Ease to mock
52
51
  isBlockletPortHealthy = isBlockletPortHealthy;
53
52
 
54
- // Ease to mock
55
- shouldJobBackoff = shouldJobBackoff;
56
-
57
53
  isBlockletPortHealthyWithRetries = async (blocklet, isDoing = false) => {
58
54
  let error;
59
55
  for (let attempt = 0; attempt < 10; attempt++) {
@@ -88,15 +84,17 @@ class EnsureBlockletRunning {
88
84
  this.notification = notification;
89
85
  this.createAuditLog = createAuditLog;
90
86
  this.checkSystemHighLoad = checkSystemHighLoad;
87
+ logger.info('check and fix blocklet status interval', this.checkInterval);
91
88
  const task = async () => {
92
- if (this.stopped) {
93
- return;
94
- }
95
- await this.checkAndFix();
96
89
  await sleep(this.checkInterval);
90
+ try {
91
+ await this.checkAndFix();
92
+ } catch (e) {
93
+ logger.error('check and fix blocklet status failed', e);
94
+ }
97
95
  task();
98
96
  };
99
- setTimeout(task, this.deferredTime);
97
+ task();
100
98
  };
101
99
 
102
100
  getDisplayNameByRootDid = (rootDid) => {
@@ -112,20 +110,18 @@ class EnsureBlockletRunning {
112
110
  };
113
111
 
114
112
  checkAndFix = async () => {
113
+ logger.info('check and fix blocklet status');
115
114
  if (process.env.ABT_NODE_RESTART_RUNNING_COMPONENT === '1') {
115
+ logger.info('skip check and fix blocklet status because ABT_NODE_RESTART_RUNNING_COMPONENT is 1');
116
116
  return;
117
117
  }
118
118
 
119
- if (!this.shouldJobBackoff()) {
120
- return;
121
- }
122
119
  const systemHighLoad = this.checkSystemHighLoad({
123
120
  maxCpus: this.highLoadCpu,
124
121
  maxMem: this.highLoadMemory,
125
122
  maxDisk: this.highLoadDisk,
126
123
  });
127
124
 
128
- logger.info('Check ensure blocklet running', systemHighLoad);
129
125
  if (systemHighLoad.isHighLoad) {
130
126
  logger.warn('Skip once ensure blocklet running because system high load', systemHighLoad);
131
127
  return;
@@ -191,49 +187,58 @@ class EnsureBlockletRunning {
191
187
  }
192
188
  }
193
189
  }
190
+ logger.info('get running blocklets', Object.keys(this.runningBlocklets).length);
194
191
  };
195
192
 
196
193
  getFakeRunningBlocklets = async () => {
197
194
  this.fakeRunningBlocklets = {};
198
195
  const blockletDids = Object.keys(this.runningBlocklets);
199
- for (const did of blockletDids) {
200
- const blocklets = this.runningBlocklets[did];
201
-
202
- // eslint-disable-next-line
203
- await pAll(
204
- blocklets.map((blocklet) => {
205
- return async () => {
206
- if (!shouldCheckHealthy(blocklet)) {
207
- // 如果 blocklet 是不需要启动的,并且不是 running,则设置为 running 状态
208
- if (blocklet.status !== BlockletStatus.running) {
209
- await this.states.blocklet.setBlockletStatus(did, BlockletStatus.running, {
210
- componentDids: [blocklet.meta.did],
211
- });
212
- }
213
- return;
214
- }
196
+ await pAll(
197
+ blockletDids.map((did) => {
198
+ return async () => {
199
+ const blocklets = this.runningBlocklets[did];
200
+ // eslint-disable-next-line
201
+ await pAll(
202
+ blocklets.map((blocklet) => {
203
+ return async () => {
204
+ if (!shouldCheckHealthy(blocklet)) {
205
+ // 如果 blocklet 是不需要启动的,并且不是 running,则设置为 running 状态
206
+ if (blocklet.status !== BlockletStatus.running) {
207
+ await this.states.blocklet.setBlockletStatus(did, BlockletStatus.running, {
208
+ componentDids: [blocklet.meta.did],
209
+ });
210
+ }
211
+ return;
212
+ }
215
213
 
216
- const health = await this.isBlockletPortHealthyWithRetries(
217
- blocklet,
218
- inProgressStatuses.includes(blocklet.status)
219
- );
214
+ const health = await this.isBlockletPortHealthyWithRetries(
215
+ blocklet,
216
+ inProgressStatuses.includes(blocklet.status)
217
+ );
220
218
 
221
- if (health) {
222
- return;
223
- }
219
+ if (health) {
220
+ return;
221
+ }
224
222
 
225
- if (!this.fakeRunningBlocklets[did]) {
226
- this.fakeRunningBlocklets[did] = [];
227
- }
228
- if (this.fakeRunningBlocklets[did].find((b) => b.meta.did === blocklet.meta.did)) {
229
- return;
230
- }
231
- this.fakeRunningBlocklets[did].push(blocklet);
232
- };
233
- }),
234
- { concurrency: 10 }
235
- );
236
- }
223
+ logger.warn('check blocklet port healthy', did, blocklet.meta.did, 'no healthy');
224
+
225
+ if (!this.fakeRunningBlocklets[did]) {
226
+ this.fakeRunningBlocklets[did] = [];
227
+ }
228
+ if (this.fakeRunningBlocklets[did].find((b) => b.meta.did === blocklet.meta.did)) {
229
+ return;
230
+ }
231
+ this.fakeRunningBlocklets[did].push(blocklet);
232
+ };
233
+ }),
234
+ { concurrency: 10 }
235
+ );
236
+ };
237
+ }),
238
+ { concurrency: 3 }
239
+ );
240
+
241
+ logger.info('get fake running blocklets', Object.keys(this.fakeRunningBlocklets).length);
237
242
  };
238
243
 
239
244
  setFakeRunningToWaiting = async () => {
@@ -31210,6 +31210,9 @@ function configure (options) {
31210
31210
  /***/ 9379:
31211
31211
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
31212
31212
 
31213
+ "use strict";
31214
+
31215
+
31213
31216
  const ANY = Symbol('SemVer ANY')
31214
31217
  // hoisted class for cyclic dependency
31215
31218
  class Comparator {
@@ -31358,6 +31361,9 @@ const Range = __nccwpck_require__(6782)
31358
31361
  /***/ 6782:
31359
31362
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
31360
31363
 
31364
+ "use strict";
31365
+
31366
+
31361
31367
  const SPACE_CHARACTERS = /\s+/g
31362
31368
 
31363
31369
  // hoisted class for cyclic dependency
@@ -31919,9 +31925,12 @@ const testSet = (set, version, options) => {
31919
31925
  /***/ 7163:
31920
31926
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
31921
31927
 
31928
+ "use strict";
31929
+
31930
+
31922
31931
  const debug = __nccwpck_require__(1159)
31923
31932
  const { MAX_LENGTH, MAX_SAFE_INTEGER } = __nccwpck_require__(5101)
31924
- const { safeRe: re, safeSrc: src, t } = __nccwpck_require__(5471)
31933
+ const { safeRe: re, t } = __nccwpck_require__(5471)
31925
31934
 
31926
31935
  const parseOptions = __nccwpck_require__(356)
31927
31936
  const { compareIdentifiers } = __nccwpck_require__(3348)
@@ -32103,8 +32112,7 @@ class SemVer {
32103
32112
  }
32104
32113
  // Avoid an invalid semver results
32105
32114
  if (identifier) {
32106
- const r = new RegExp(`^${this.options.loose ? src[t.PRERELEASELOOSE] : src[t.PRERELEASE]}$`)
32107
- const match = `-${identifier}`.match(r)
32115
+ const match = `-${identifier}`.match(this.options.loose ? re[t.PRERELEASELOOSE] : re[t.PRERELEASE])
32108
32116
  if (!match || match[1] !== identifier) {
32109
32117
  throw new Error(`invalid identifier: ${identifier}`)
32110
32118
  }
@@ -32244,6 +32252,9 @@ module.exports = SemVer
32244
32252
  /***/ 1799:
32245
32253
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
32246
32254
 
32255
+ "use strict";
32256
+
32257
+
32247
32258
  const parse = __nccwpck_require__(6353)
32248
32259
  const clean = (version, options) => {
32249
32260
  const s = parse(version.trim().replace(/^[=v]+/, ''), options)
@@ -32257,6 +32268,9 @@ module.exports = clean
32257
32268
  /***/ 8646:
32258
32269
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
32259
32270
 
32271
+ "use strict";
32272
+
32273
+
32260
32274
  const eq = __nccwpck_require__(5082)
32261
32275
  const neq = __nccwpck_require__(4974)
32262
32276
  const gt = __nccwpck_require__(6599)
@@ -32316,6 +32330,9 @@ module.exports = cmp
32316
32330
  /***/ 5385:
32317
32331
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
32318
32332
 
32333
+ "use strict";
32334
+
32335
+
32319
32336
  const SemVer = __nccwpck_require__(7163)
32320
32337
  const parse = __nccwpck_require__(6353)
32321
32338
  const { safeRe: re, t } = __nccwpck_require__(5471)
@@ -32383,6 +32400,9 @@ module.exports = coerce
32383
32400
  /***/ 7648:
32384
32401
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
32385
32402
 
32403
+ "use strict";
32404
+
32405
+
32386
32406
  const SemVer = __nccwpck_require__(7163)
32387
32407
  const compareBuild = (a, b, loose) => {
32388
32408
  const versionA = new SemVer(a, loose)
@@ -32397,6 +32417,9 @@ module.exports = compareBuild
32397
32417
  /***/ 6874:
32398
32418
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
32399
32419
 
32420
+ "use strict";
32421
+
32422
+
32400
32423
  const compare = __nccwpck_require__(8469)
32401
32424
  const compareLoose = (a, b) => compare(a, b, true)
32402
32425
  module.exports = compareLoose
@@ -32407,6 +32430,9 @@ module.exports = compareLoose
32407
32430
  /***/ 8469:
32408
32431
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
32409
32432
 
32433
+ "use strict";
32434
+
32435
+
32410
32436
  const SemVer = __nccwpck_require__(7163)
32411
32437
  const compare = (a, b, loose) =>
32412
32438
  new SemVer(a, loose).compare(new SemVer(b, loose))
@@ -32419,6 +32445,9 @@ module.exports = compare
32419
32445
  /***/ 711:
32420
32446
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
32421
32447
 
32448
+ "use strict";
32449
+
32450
+
32422
32451
  const parse = __nccwpck_require__(6353)
32423
32452
 
32424
32453
  const diff = (version1, version2) => {
@@ -32484,6 +32513,9 @@ module.exports = diff
32484
32513
  /***/ 5082:
32485
32514
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
32486
32515
 
32516
+ "use strict";
32517
+
32518
+
32487
32519
  const compare = __nccwpck_require__(8469)
32488
32520
  const eq = (a, b, loose) => compare(a, b, loose) === 0
32489
32521
  module.exports = eq
@@ -32494,6 +32526,9 @@ module.exports = eq
32494
32526
  /***/ 6599:
32495
32527
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
32496
32528
 
32529
+ "use strict";
32530
+
32531
+
32497
32532
  const compare = __nccwpck_require__(8469)
32498
32533
  const gt = (a, b, loose) => compare(a, b, loose) > 0
32499
32534
  module.exports = gt
@@ -32504,6 +32539,9 @@ module.exports = gt
32504
32539
  /***/ 1236:
32505
32540
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
32506
32541
 
32542
+ "use strict";
32543
+
32544
+
32507
32545
  const compare = __nccwpck_require__(8469)
32508
32546
  const gte = (a, b, loose) => compare(a, b, loose) >= 0
32509
32547
  module.exports = gte
@@ -32514,6 +32552,9 @@ module.exports = gte
32514
32552
  /***/ 2338:
32515
32553
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
32516
32554
 
32555
+ "use strict";
32556
+
32557
+
32517
32558
  const SemVer = __nccwpck_require__(7163)
32518
32559
 
32519
32560
  const inc = (version, release, options, identifier, identifierBase) => {
@@ -32540,6 +32581,9 @@ module.exports = inc
32540
32581
  /***/ 3872:
32541
32582
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
32542
32583
 
32584
+ "use strict";
32585
+
32586
+
32543
32587
  const compare = __nccwpck_require__(8469)
32544
32588
  const lt = (a, b, loose) => compare(a, b, loose) < 0
32545
32589
  module.exports = lt
@@ -32550,6 +32594,9 @@ module.exports = lt
32550
32594
  /***/ 6717:
32551
32595
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
32552
32596
 
32597
+ "use strict";
32598
+
32599
+
32553
32600
  const compare = __nccwpck_require__(8469)
32554
32601
  const lte = (a, b, loose) => compare(a, b, loose) <= 0
32555
32602
  module.exports = lte
@@ -32560,6 +32607,9 @@ module.exports = lte
32560
32607
  /***/ 8511:
32561
32608
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
32562
32609
 
32610
+ "use strict";
32611
+
32612
+
32563
32613
  const SemVer = __nccwpck_require__(7163)
32564
32614
  const major = (a, loose) => new SemVer(a, loose).major
32565
32615
  module.exports = major
@@ -32570,6 +32620,9 @@ module.exports = major
32570
32620
  /***/ 2603:
32571
32621
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
32572
32622
 
32623
+ "use strict";
32624
+
32625
+
32573
32626
  const SemVer = __nccwpck_require__(7163)
32574
32627
  const minor = (a, loose) => new SemVer(a, loose).minor
32575
32628
  module.exports = minor
@@ -32580,6 +32633,9 @@ module.exports = minor
32580
32633
  /***/ 4974:
32581
32634
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
32582
32635
 
32636
+ "use strict";
32637
+
32638
+
32583
32639
  const compare = __nccwpck_require__(8469)
32584
32640
  const neq = (a, b, loose) => compare(a, b, loose) !== 0
32585
32641
  module.exports = neq
@@ -32590,6 +32646,9 @@ module.exports = neq
32590
32646
  /***/ 6353:
32591
32647
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
32592
32648
 
32649
+ "use strict";
32650
+
32651
+
32593
32652
  const SemVer = __nccwpck_require__(7163)
32594
32653
  const parse = (version, options, throwErrors = false) => {
32595
32654
  if (version instanceof SemVer) {
@@ -32613,6 +32672,9 @@ module.exports = parse
32613
32672
  /***/ 8756:
32614
32673
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
32615
32674
 
32675
+ "use strict";
32676
+
32677
+
32616
32678
  const SemVer = __nccwpck_require__(7163)
32617
32679
  const patch = (a, loose) => new SemVer(a, loose).patch
32618
32680
  module.exports = patch
@@ -32623,6 +32685,9 @@ module.exports = patch
32623
32685
  /***/ 5714:
32624
32686
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
32625
32687
 
32688
+ "use strict";
32689
+
32690
+
32626
32691
  const parse = __nccwpck_require__(6353)
32627
32692
  const prerelease = (version, options) => {
32628
32693
  const parsed = parse(version, options)
@@ -32636,6 +32701,9 @@ module.exports = prerelease
32636
32701
  /***/ 2173:
32637
32702
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
32638
32703
 
32704
+ "use strict";
32705
+
32706
+
32639
32707
  const compare = __nccwpck_require__(8469)
32640
32708
  const rcompare = (a, b, loose) => compare(b, a, loose)
32641
32709
  module.exports = rcompare
@@ -32646,6 +32714,9 @@ module.exports = rcompare
32646
32714
  /***/ 7192:
32647
32715
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
32648
32716
 
32717
+ "use strict";
32718
+
32719
+
32649
32720
  const compareBuild = __nccwpck_require__(7648)
32650
32721
  const rsort = (list, loose) => list.sort((a, b) => compareBuild(b, a, loose))
32651
32722
  module.exports = rsort
@@ -32656,6 +32727,9 @@ module.exports = rsort
32656
32727
  /***/ 8011:
32657
32728
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
32658
32729
 
32730
+ "use strict";
32731
+
32732
+
32659
32733
  const Range = __nccwpck_require__(6782)
32660
32734
  const satisfies = (version, range, options) => {
32661
32735
  try {
@@ -32673,6 +32747,9 @@ module.exports = satisfies
32673
32747
  /***/ 9872:
32674
32748
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
32675
32749
 
32750
+ "use strict";
32751
+
32752
+
32676
32753
  const compareBuild = __nccwpck_require__(7648)
32677
32754
  const sort = (list, loose) => list.sort((a, b) => compareBuild(a, b, loose))
32678
32755
  module.exports = sort
@@ -32683,6 +32760,9 @@ module.exports = sort
32683
32760
  /***/ 8780:
32684
32761
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
32685
32762
 
32763
+ "use strict";
32764
+
32765
+
32686
32766
  const parse = __nccwpck_require__(6353)
32687
32767
  const valid = (version, options) => {
32688
32768
  const v = parse(version, options)
@@ -32696,6 +32776,9 @@ module.exports = valid
32696
32776
  /***/ 2088:
32697
32777
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
32698
32778
 
32779
+ "use strict";
32780
+
32781
+
32699
32782
  // just pre-load all the stuff that index.js lazily exports
32700
32783
  const internalRe = __nccwpck_require__(5471)
32701
32784
  const constants = __nccwpck_require__(5101)
@@ -32792,6 +32875,9 @@ module.exports = {
32792
32875
  /***/ 5101:
32793
32876
  /***/ ((module) => {
32794
32877
 
32878
+ "use strict";
32879
+
32880
+
32795
32881
  // Note: this is the semver.org version of the spec that it implements
32796
32882
  // Not necessarily the package version of this code.
32797
32883
  const SEMVER_SPEC_VERSION = '2.0.0'
@@ -32834,6 +32920,9 @@ module.exports = {
32834
32920
  /***/ 1159:
32835
32921
  /***/ ((module) => {
32836
32922
 
32923
+ "use strict";
32924
+
32925
+
32837
32926
  const debug = (
32838
32927
  typeof process === 'object' &&
32839
32928
  process.env &&
@@ -32850,6 +32939,9 @@ module.exports = debug
32850
32939
  /***/ 3348:
32851
32940
  /***/ ((module) => {
32852
32941
 
32942
+ "use strict";
32943
+
32944
+
32853
32945
  const numeric = /^[0-9]+$/
32854
32946
  const compareIdentifiers = (a, b) => {
32855
32947
  const anum = numeric.test(a)
@@ -32880,6 +32972,9 @@ module.exports = {
32880
32972
  /***/ 1383:
32881
32973
  /***/ ((module) => {
32882
32974
 
32975
+ "use strict";
32976
+
32977
+
32883
32978
  class LRUCache {
32884
32979
  constructor () {
32885
32980
  this.max = 1000
@@ -32927,6 +33022,9 @@ module.exports = LRUCache
32927
33022
  /***/ 356:
32928
33023
  /***/ ((module) => {
32929
33024
 
33025
+ "use strict";
33026
+
33027
+
32930
33028
  // parse out just the options we care about
32931
33029
  const looseOption = Object.freeze({ loose: true })
32932
33030
  const emptyOpts = Object.freeze({ })
@@ -32949,6 +33047,9 @@ module.exports = parseOptions
32949
33047
  /***/ 5471:
32950
33048
  /***/ ((module, exports, __nccwpck_require__) => {
32951
33049
 
33050
+ "use strict";
33051
+
33052
+
32952
33053
  const {
32953
33054
  MAX_SAFE_COMPONENT_LENGTH,
32954
33055
  MAX_SAFE_BUILD_LENGTH,
@@ -33027,12 +33128,14 @@ createToken('MAINVERSIONLOOSE', `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` +
33027
33128
 
33028
33129
  // ## Pre-release Version Identifier
33029
33130
  // A numeric identifier, or a non-numeric identifier.
33131
+ // Non-numberic identifiers include numberic identifiers but can be longer.
33132
+ // Therefore non-numberic identifiers must go first.
33030
33133
 
33031
- createToken('PRERELEASEIDENTIFIER', `(?:${src[t.NUMERICIDENTIFIER]
33032
- }|${src[t.NONNUMERICIDENTIFIER]})`)
33134
+ createToken('PRERELEASEIDENTIFIER', `(?:${src[t.NONNUMERICIDENTIFIER]
33135
+ }|${src[t.NUMERICIDENTIFIER]})`)
33033
33136
 
33034
- createToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NUMERICIDENTIFIERLOOSE]
33035
- }|${src[t.NONNUMERICIDENTIFIER]})`)
33137
+ createToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NONNUMERICIDENTIFIER]
33138
+ }|${src[t.NUMERICIDENTIFIERLOOSE]})`)
33036
33139
 
33037
33140
  // ## Pre-release Version
33038
33141
  // Hyphen, followed by one or more dot-separated pre-release version
@@ -33175,6 +33278,9 @@ createToken('GTE0PRE', '^\\s*>=\\s*0\\.0\\.0-0\\s*$')
33175
33278
  /***/ 2276:
33176
33279
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
33177
33280
 
33281
+ "use strict";
33282
+
33283
+
33178
33284
  // Determine if version is greater than all the versions possible in the range.
33179
33285
  const outside = __nccwpck_require__(280)
33180
33286
  const gtr = (version, range, options) => outside(version, range, '>', options)
@@ -33186,6 +33292,9 @@ module.exports = gtr
33186
33292
  /***/ 3465:
33187
33293
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
33188
33294
 
33295
+ "use strict";
33296
+
33297
+
33189
33298
  const Range = __nccwpck_require__(6782)
33190
33299
  const intersects = (r1, r2, options) => {
33191
33300
  r1 = new Range(r1, options)
@@ -33200,6 +33309,9 @@ module.exports = intersects
33200
33309
  /***/ 5213:
33201
33310
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
33202
33311
 
33312
+ "use strict";
33313
+
33314
+
33203
33315
  const outside = __nccwpck_require__(280)
33204
33316
  // Determine if version is less than all the versions possible in the range
33205
33317
  const ltr = (version, range, options) => outside(version, range, '<', options)
@@ -33211,6 +33323,9 @@ module.exports = ltr
33211
33323
  /***/ 3193:
33212
33324
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
33213
33325
 
33326
+ "use strict";
33327
+
33328
+
33214
33329
  const SemVer = __nccwpck_require__(7163)
33215
33330
  const Range = __nccwpck_require__(6782)
33216
33331
 
@@ -33243,6 +33358,9 @@ module.exports = maxSatisfying
33243
33358
  /***/ 8595:
33244
33359
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
33245
33360
 
33361
+ "use strict";
33362
+
33363
+
33246
33364
  const SemVer = __nccwpck_require__(7163)
33247
33365
  const Range = __nccwpck_require__(6782)
33248
33366
  const minSatisfying = (versions, range, options) => {
@@ -33274,6 +33392,9 @@ module.exports = minSatisfying
33274
33392
  /***/ 1866:
33275
33393
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
33276
33394
 
33395
+ "use strict";
33396
+
33397
+
33277
33398
  const SemVer = __nccwpck_require__(7163)
33278
33399
  const Range = __nccwpck_require__(6782)
33279
33400
  const gt = __nccwpck_require__(6599)
@@ -33342,6 +33463,9 @@ module.exports = minVersion
33342
33463
  /***/ 280:
33343
33464
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
33344
33465
 
33466
+ "use strict";
33467
+
33468
+
33345
33469
  const SemVer = __nccwpck_require__(7163)
33346
33470
  const Comparator = __nccwpck_require__(9379)
33347
33471
  const { ANY } = Comparator
@@ -33429,6 +33553,9 @@ module.exports = outside
33429
33553
  /***/ 2028:
33430
33554
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
33431
33555
 
33556
+ "use strict";
33557
+
33558
+
33432
33559
  // given a set of versions and a range, create a "simplified" range
33433
33560
  // that includes the same versions that the original range does
33434
33561
  // If the original range is shorter than the simplified one, return that.
@@ -33483,6 +33610,9 @@ module.exports = (versions, range, options) => {
33483
33610
  /***/ 1489:
33484
33611
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
33485
33612
 
33613
+ "use strict";
33614
+
33615
+
33486
33616
  const Range = __nccwpck_require__(6782)
33487
33617
  const Comparator = __nccwpck_require__(9379)
33488
33618
  const { ANY } = Comparator
@@ -33737,6 +33867,9 @@ module.exports = subset
33737
33867
  /***/ 4750:
33738
33868
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
33739
33869
 
33870
+ "use strict";
33871
+
33872
+
33740
33873
  const Range = __nccwpck_require__(6782)
33741
33874
 
33742
33875
  // Mostly just for testing and legacy API reasons
@@ -33752,6 +33885,9 @@ module.exports = toComparators
33752
33885
  /***/ 4737:
33753
33886
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
33754
33887
 
33888
+ "use strict";
33889
+
33890
+
33755
33891
  const Range = __nccwpck_require__(6782)
33756
33892
  const validRange = (range, options) => {
33757
33893
  try {
@@ -38744,7 +38880,7 @@ module.exports = require("zlib");
38744
38880
  /***/ ((module) => {
38745
38881
 
38746
38882
  "use strict";
38747
- module.exports = /*#__PURE__*/JSON.parse('{"name":"@abtnode/core","publishConfig":{"access":"public"},"version":"1.16.43","description":"","main":"lib/index.js","files":["lib"],"scripts":{"lint":"eslint tests lib --ignore-pattern \'tests/assets/*\'","lint:fix":"eslint --fix tests lib","test":"node tools/jest.js","coverage":"npm run test -- --coverage"},"keywords":[],"author":"wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)","license":"Apache-2.0","dependencies":{"@abtnode/analytics":"1.16.43","@abtnode/auth":"1.16.43","@abtnode/certificate-manager":"1.16.43","@abtnode/client":"1.16.43","@abtnode/constant":"1.16.43","@abtnode/cron":"1.16.43","@abtnode/docker-utils":"1.16.43","@abtnode/logger":"1.16.43","@abtnode/models":"1.16.43","@abtnode/queue":"1.16.43","@abtnode/rbac":"1.16.43","@abtnode/router-provider":"1.16.43","@abtnode/static-server":"1.16.43","@abtnode/timemachine":"1.16.43","@abtnode/util":"1.16.43","@arcblock/did":"1.20.11","@arcblock/did-auth":"1.20.11","@arcblock/did-ext":"1.20.11","@arcblock/did-motif":"^1.1.13","@arcblock/did-util":"1.20.11","@arcblock/event-hub":"1.20.11","@arcblock/jwt":"1.20.11","@arcblock/pm2-events":"^0.0.5","@arcblock/validator":"1.20.11","@arcblock/vc":"1.20.11","@blocklet/constant":"1.16.43","@blocklet/did-space-js":"^1.0.53","@blocklet/env":"1.16.43","@blocklet/error":"^0.2.4","@blocklet/meta":"1.16.43","@blocklet/resolver":"1.16.43","@blocklet/sdk":"1.16.43","@blocklet/store":"1.16.43","@blocklet/theme":"^2.13.41","@fidm/x509":"^1.2.1","@ocap/mcrypto":"1.20.11","@ocap/util":"1.20.11","@ocap/wallet":"1.20.11","@slack/webhook":"^5.0.4","archiver":"^7.0.1","axios":"^1.7.9","axon":"^2.0.3","chalk":"^4.1.2","cross-spawn":"^7.0.3","dayjs":"^1.11.13","deep-diff":"^1.0.2","detect-port":"^1.5.1","envfile":"^7.1.0","escape-string-regexp":"^4.0.0","fast-glob":"^3.3.2","filesize":"^10.1.1","flat":"^5.0.2","fs-extra":"^11.2.0","get-port":"^5.1.1","hasha":"^5.2.2","is-base64":"^1.1.0","is-cidr":"4","is-ip":"3","is-url":"^1.2.4","joi":"17.12.2","joi-extension-semver":"^5.0.0","js-yaml":"^4.1.0","kill-port":"^2.0.1","lodash":"^4.17.21","lru-cache":"^11.0.2","node-stream-zip":"^1.15.0","p-all":"^3.0.0","p-limit":"^3.1.0","p-map":"^4.0.0","p-retry":"^4.6.2","p-wait-for":"^3.2.0","rate-limiter-flexible":"^5.0.5","read-last-lines":"^1.8.0","semver":"^7.6.3","sequelize":"^6.35.0","shelljs":"^0.8.5","slugify":"^1.6.6","ssri":"^8.0.1","stream-throttle":"^0.1.3","stream-to-promise":"^3.0.0","systeminformation":"^5.23.3","tail":"^2.2.4","tar":"^6.1.11","transliteration":"^2.3.5","ua-parser-js":"^1.0.2","ufo":"^1.5.3","uuid":"^9.0.1","valid-url":"^1.0.9","which":"^2.0.2","xbytes":"^1.8.0"},"devDependencies":{"expand-tilde":"^2.0.2","express":"^4.18.2","jest":"^29.7.0","unzipper":"^0.10.11"},"gitHead":"e5764f753181ed6a7c615cd4fc6682aacf0cb7cd"}');
38883
+ module.exports = /*#__PURE__*/JSON.parse('{"name":"@abtnode/core","publishConfig":{"access":"public"},"version":"1.16.43","description":"","main":"lib/index.js","files":["lib"],"scripts":{"lint":"eslint tests lib --ignore-pattern \'tests/assets/*\'","lint:fix":"eslint --fix tests lib","test":"node tools/jest.js","coverage":"npm run test -- --coverage"},"keywords":[],"author":"wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)","license":"Apache-2.0","dependencies":{"@abtnode/analytics":"1.16.43","@abtnode/auth":"1.16.43","@abtnode/certificate-manager":"1.16.43","@abtnode/client":"1.16.43","@abtnode/constant":"1.16.43","@abtnode/cron":"1.16.43","@abtnode/docker-utils":"1.16.43","@abtnode/logger":"1.16.43","@abtnode/models":"1.16.43","@abtnode/queue":"1.16.43","@abtnode/rbac":"1.16.43","@abtnode/router-provider":"1.16.43","@abtnode/static-server":"1.16.43","@abtnode/timemachine":"1.16.43","@abtnode/util":"1.16.43","@arcblock/did":"1.20.11","@arcblock/did-auth":"1.20.11","@arcblock/did-ext":"1.20.11","@arcblock/did-motif":"^1.1.13","@arcblock/did-util":"1.20.11","@arcblock/event-hub":"1.20.11","@arcblock/jwt":"1.20.11","@arcblock/pm2-events":"^0.0.5","@arcblock/validator":"1.20.11","@arcblock/vc":"1.20.11","@blocklet/constant":"1.16.43","@blocklet/did-space-js":"^1.0.56","@blocklet/env":"1.16.43","@blocklet/error":"^0.2.4","@blocklet/meta":"1.16.43","@blocklet/resolver":"1.16.43","@blocklet/sdk":"1.16.43","@blocklet/store":"1.16.43","@blocklet/theme":"^2.13.47","@fidm/x509":"^1.2.1","@ocap/mcrypto":"1.20.11","@ocap/util":"1.20.11","@ocap/wallet":"1.20.11","@slack/webhook":"^5.0.4","archiver":"^7.0.1","axios":"^1.7.9","axon":"^2.0.3","chalk":"^4.1.2","cross-spawn":"^7.0.3","dayjs":"^1.11.13","deep-diff":"^1.0.2","detect-port":"^1.5.1","envfile":"^7.1.0","escape-string-regexp":"^4.0.0","fast-glob":"^3.3.2","filesize":"^10.1.1","flat":"^5.0.2","fs-extra":"^11.2.0","get-port":"^5.1.1","hasha":"^5.2.2","is-base64":"^1.1.0","is-cidr":"4","is-ip":"3","is-url":"^1.2.4","joi":"17.12.2","joi-extension-semver":"^5.0.0","js-yaml":"^4.1.0","kill-port":"^2.0.1","lodash":"^4.17.21","lru-cache":"^11.0.2","node-stream-zip":"^1.15.0","p-all":"^3.0.0","p-limit":"^3.1.0","p-map":"^4.0.0","p-retry":"^4.6.2","p-wait-for":"^3.2.0","rate-limiter-flexible":"^5.0.5","read-last-lines":"^1.8.0","semver":"^7.6.3","sequelize":"^6.35.0","shelljs":"^0.8.5","slugify":"^1.6.6","ssri":"^8.0.1","stream-throttle":"^0.1.3","stream-to-promise":"^3.0.0","systeminformation":"^5.23.3","tail":"^2.2.4","tar":"^6.1.11","transliteration":"^2.3.5","ua-parser-js":"^1.0.2","ufo":"^1.5.3","uuid":"^9.0.1","valid-url":"^1.0.9","which":"^2.0.2","xbytes":"^1.8.0"},"devDependencies":{"expand-tilde":"^2.0.2","express":"^4.18.2","jest":"^29.7.0","unzipper":"^0.10.11"},"gitHead":"e5764f753181ed6a7c615cd4fc6682aacf0cb7cd"}');
38748
38884
 
38749
38885
  /***/ }),
38750
38886
 
@@ -630,9 +630,9 @@ module.exports = ({
630
630
 
631
631
  // 更新会话时,暂不做任何操作
632
632
  // listen(teamAPI, BlockletEvents.updateUserSession, noop);
633
- listen(teamAPI, BlockletEvents.addUserSession, (eventName, eventData) => {
633
+ listen(teamAPI, BlockletEvents.addUserSession, async (eventName, eventData) => {
634
634
  const { teamDid, userDid, userSession, locale = 'en', skipNotification = false, origin } = eventData;
635
- if (skipNotification) {
635
+ if (skipNotification || !userSession.ua) {
636
636
  return;
637
637
  }
638
638
  const translations = {
@@ -693,15 +693,26 @@ module.exports = ({
693
693
  ],
694
694
  };
695
695
  logger.info(`create notification on ${eventName}`, { teamDid, receiver: userDid, notification });
696
- teamManager.createNotification({
696
+ const { count: userSessionCount } = await teamAPI.getUserSessionsCount({
697
697
  teamDid,
698
- receiver: userDid,
699
- // NOTICE: createNotification 如果传递 notification 对象,就必须加上 pushOnly 选项,否则会调用失败
700
- // 目前先改为使用 payload 的形式传递通知内容
701
- // notification,
702
- ...notification,
703
- source: 'component',
698
+ query: {
699
+ userDid,
700
+ appPid: teamDid,
701
+ status: null, // 查询所有 userSession 的总数
702
+ },
704
703
  });
704
+ // 如果只有一个,代表是刚创建的账户,此时不发送新设备通知
705
+ if (userSessionCount > 1) {
706
+ teamManager.createNotification({
707
+ teamDid,
708
+ receiver: userDid,
709
+ // NOTICE: createNotification 如果传递 notification 对象,就必须加上 pushOnly 选项,否则会调用失败
710
+ // 目前先改为使用 payload 的形式传递通知内容
711
+ // notification,
712
+ ...notification,
713
+ source: 'component',
714
+ });
715
+ }
705
716
  });
706
717
 
707
718
  return events;
@@ -221,10 +221,6 @@ class BlockletRuntimeMonitor extends EventEmitter {
221
221
  }
222
222
 
223
223
  async getBlockletRuntimeInfo(blockletDid) {
224
- if (this.getRuntimeInfo(blockletDid)) {
225
- return this.getRuntimeInfo(blockletDid);
226
- }
227
-
228
224
  const blocklets = await this.states.blocklet.getBlocklets();
229
225
  const blocklet = blocklets.find((x) => x.meta.did === blockletDid);
230
226
 
@@ -231,11 +231,10 @@ class NodeRuntimeMonitor extends EventEmitter {
231
231
  checkSystemHighLoad({ maxCpus, maxMem, maxDisk }) {
232
232
  const { cpus, memory, disks } = this.calculateUtilization();
233
233
  let highType = '';
234
- if (cpus.some((v) => v > maxCpus)) {
235
- highType = 'cpu';
236
- } else if (memory > maxMem) {
237
- highType = 'memory';
238
- } else if (disks.some((v) => v > maxDisk)) {
234
+ if (cpus.some((v) => v > maxCpus) && memory > maxMem) {
235
+ highType = 'cpu and memory';
236
+ }
237
+ if (disks.some((v) => v > maxDisk)) {
239
238
  highType = 'disk';
240
239
  }
241
240
  if (highType) {
@@ -4,7 +4,6 @@ const { isValid } = require('@arcblock/did');
4
4
  const { fromRandom, fromPublicKey } = require('@ocap/wallet');
5
5
  const { toBase58, fromBase58 } = require('@ocap/util');
6
6
  const { CustomError } = require('@blocklet/error');
7
-
8
7
  const logger = require('@abtnode/logger')('@abtnode/core:states:access-key');
9
8
  const BaseState = require('./base');
10
9
  const { accessKeySchema, REMARK_MAX_LENGTH } = require('../validators/access-key');
@@ -33,7 +32,7 @@ const getOperator = (context) => get(context, 'user.did', '') || get(context, 'u
33
32
  * @extends BaseState<import('@abtnode/models').AccessKeyState>
34
33
  */
35
34
  class AccessKeyState extends BaseState {
36
- async create(input, context) {
35
+ async create(input, context, newWallet) {
37
36
  const {
38
37
  remark,
39
38
  passport,
@@ -50,7 +49,7 @@ class AccessKeyState extends BaseState {
50
49
  validatePassport(passport);
51
50
  validateExpireAt(expireAt);
52
51
 
53
- const wallet = fromRandom();
52
+ const wallet = newWallet || fromRandom();
54
53
  const data = {
55
54
  accessKeyId: wallet.address,
56
55
  accessKeyPublic: wallet.publicKey,
@@ -221,7 +221,8 @@ class NotificationState extends BaseState {
221
221
  const offset = (page - 1) * curPageSize;
222
222
 
223
223
  // 构建基础查询条件
224
- const conditions = [];
224
+ // FIXME: 这里需要对历史数据做出过滤,避免有非 notification 类型的数据
225
+ const conditions = ['n.type = "notification"'];
225
226
  const replacements = { receiver };
226
227
 
227
228
  if (typeof read === 'boolean') {
@@ -518,16 +519,12 @@ class NotificationState extends BaseState {
518
519
  /**
519
520
  * 获取当前用户未读消息数量
520
521
  */
521
- async getUnreadCount({ receiver }) {
522
+ getUnreadCount({ receiver }) {
522
523
  if (!receiver) {
523
524
  throw new Error('receiver is not allow empty');
524
525
  }
525
526
 
526
- const count = await this.notificationReceivers.count({
527
- receiver,
528
- read: false,
529
- });
530
- return count;
527
+ return this.getUnreadNotificationCount({ receiver });
531
528
  }
532
529
 
533
530
  /**
@@ -837,14 +834,18 @@ class NotificationState extends BaseState {
837
834
  * @param {Object} context 上下文
838
835
  * @returns {Promise<number>} 未读通知数量
839
836
  */
840
- async getUnreadCountByConditions({ receiver, severity, componentDid, entityId, source } = {}, context) {
837
+ getUnreadCountByConditions({ receiver, ...rest } = {}, context) {
841
838
  const errorMsg = receiverDidValidation(receiver, context);
842
839
  if (errorMsg) {
843
840
  throw new Error(errorMsg);
844
841
  }
845
842
 
843
+ return this.getUnreadNotificationCount({ receiver, ...rest });
844
+ }
845
+
846
+ async getUnreadNotificationCount({ receiver, severity, componentDid, entityId, source } = {}) {
846
847
  // 构建基础查询条件
847
- const conditions = [];
848
+ const conditions = ['n.type = "notification"'];
848
849
  const replacements = { receiver };
849
850
 
850
851
  // 强制将read设为false,只计算未读消息
@@ -884,12 +885,12 @@ class NotificationState extends BaseState {
884
885
  const whereClause = conditions.length ? `WHERE ${conditions.join(' AND ')}` : '';
885
886
 
886
887
  const countQuery = `
887
- SELECT COUNT(DISTINCT n.id) as total
888
- FROM notifications n
889
- INNER JOIN notification_receivers nr ON n.id = nr.notificationId
890
- ${whereClause}
891
- AND nr.receiver = :receiver
892
- `;
888
+ SELECT COUNT(DISTINCT n.id) as total
889
+ FROM notifications n
890
+ INNER JOIN notification_receivers nr ON n.id = nr.notificationId
891
+ ${whereClause}
892
+ AND nr.receiver = :receiver
893
+ `;
893
894
 
894
895
  const [countResult] = await this.model.sequelize.query(countQuery, {
895
896
  replacements,
@@ -102,6 +102,7 @@ const {
102
102
  isRunning,
103
103
  hasStartEngine,
104
104
  isEnvShareable,
105
+ isExternalBlocklet,
105
106
  } = require('@blocklet/meta/lib/util');
106
107
  const { getComponentsInternalInfo } = require('@blocklet/meta/lib/blocklet');
107
108
  const { titleSchema, descriptionSchema, logoSchema } = require('@blocklet/meta/lib/schema');
@@ -651,7 +652,7 @@ const startBlockletProcess = async (
651
652
  // get env
652
653
  const env = getRuntimeEnvironments(b, nodeEnvironments, ancestors);
653
654
  const startedAt = Date.now();
654
- const needRunDocker = await checkNeedRunDocker(b.meta, env, nodeInfo);
655
+ const needRunDocker = await checkNeedRunDocker(b.meta, env, nodeInfo, isExternalBlocklet(blocklet));
655
656
 
656
657
  if (!needRunDocker) {
657
658
  await installExternalDependencies({ appDir: env?.BLOCKLET_APP_DIR });
@@ -749,6 +750,7 @@ const startBlockletProcess = async (
749
750
  : await parseDockerOptionsFromPm2({
750
751
  options,
751
752
  nodeInfo,
753
+ isExternal: isExternalBlocklet(b),
752
754
  meta: b.meta,
753
755
  ports: b.ports,
754
756
  onlyStart,
@@ -1,7 +1,7 @@
1
1
  const path = require('path');
2
2
  const fs = require('fs');
3
3
  const md5 = require('@abtnode/util/lib/md5');
4
- const { dockerArgsToCamelCase } = require('@abtnode/docker-utils');
4
+ const { dockerArgsToCamelCase, isVolumePath } = require('@abtnode/docker-utils');
5
5
  const debianDockerfile = require('./debian-dockerfile');
6
6
  const debianChmodDockerfile = require('./debian-chmod-dockerfile');
7
7
 
@@ -50,6 +50,9 @@ function getBlockletCustomDockerfile({ appDir, dataDir, meta, ports, env, doChow
50
50
 
51
51
  const volumes = (dockerMeta.volume || [])
52
52
  .map((volume) => {
53
+ if (!isVolumePath(volume)) {
54
+ return ` -v ${dataDir}/${volume} `;
55
+ }
53
56
  const [a, b] = volume.split(':');
54
57
  const hostDir = a.replace('$BLOCKLET_DATA_DIR', dataDir).replace('$BLOCKLET_APP_DIR', appDir);
55
58
  return ` -v ${hostDir}:${b} `;
@@ -115,6 +118,7 @@ function getBlockletCustomDockerfile({ appDir, dataDir, meta, ports, env, doChow
115
118
  script: dockerMeta.script || dockerMeta.installNodeModules ? '' : 'tail -f /dev/null',
116
119
  installNodeModules: !!dockerMeta.installNodeModules,
117
120
  runParamString,
121
+ dockerMeta,
118
122
  };
119
123
  }
120
124
 
@@ -2,7 +2,7 @@ const { NODE_MODES } = require('@abtnode/constant');
2
2
  const { BLOCKLET_MODES } = require('@blocklet/constant');
3
3
  const { checkDockerInstalled } = require('./check-docker-installed');
4
4
 
5
- async function checkNeedRunDocker(meta = {}, env = {}, nodeInfo = {}) {
5
+ async function checkNeedRunDocker(meta = {}, env = {}, nodeInfo = {}, isExternal) {
6
6
  if (!process.env.ABT_NODE_DATA_DIR) {
7
7
  return false;
8
8
  }
@@ -15,7 +15,11 @@ async function checkNeedRunDocker(meta = {}, env = {}, nodeInfo = {}) {
15
15
  }
16
16
 
17
17
  // Serverless mode does not support skipping Docker
18
- if (env.SKIP_DOCKER && nodeInfo.mode !== NODE_MODES.SERVERLESS) {
18
+ let isSkipDocker = !!env.SKIP_DOCKER;
19
+ if (nodeInfo.mode === NODE_MODES.SERVERLESS && isExternal) {
20
+ isSkipDocker = false;
21
+ }
22
+ if (isSkipDocker) {
19
23
  return false;
20
24
  }
21
25
 
@@ -0,0 +1,66 @@
1
+ /* eslint-disable no-await-in-loop */
2
+ const { isVolumePath } = require('@abtnode/docker-utils');
3
+ const promiseSpawn = require('@abtnode/util/lib/promise-spawn');
4
+ const fs = require('fs/promises');
5
+ const path = require('path');
6
+
7
+ /**
8
+ * Generate and execute a docker workflow that:
9
+ * @param {string} appDataDir - Absolute path on host where container volumes should be mounted
10
+ * @param {object} dockerInfo - Metadata describing image, mounts, ports, and network
11
+ * @returns {Promise} resolves when all docker commands have executed
12
+ */
13
+ async function parseDockerCpVolume(dockerName, appDataDir, dockerInfo) {
14
+ const { image, volume = [] } = dockerInfo?.dockerMeta || {};
15
+
16
+ try {
17
+ await fs.access(appDataDir);
18
+ } catch (error) {
19
+ await fs.mkdir(appDataDir, { recursive: true });
20
+ }
21
+
22
+ const tmpContainer = `${dockerName}_cp`;
23
+
24
+ const needCopyVolumes = volume.filter((vol) => {
25
+ return !isVolumePath(vol);
26
+ });
27
+
28
+ if (needCopyVolumes.length === 0) {
29
+ return;
30
+ }
31
+
32
+ const copySteps = [];
33
+ for (const vol of needCopyVolumes) {
34
+ const [dir, dest] = vol.split(':');
35
+ const destPath = path.join(appDataDir, dir);
36
+ try {
37
+ await fs.access(destPath);
38
+ } catch (_) {
39
+ await fs.mkdir(destPath, { recursive: true });
40
+ }
41
+ // 判断路径下是否存在文件, 如果已经有文件了,就跳过
42
+ const files = await fs.readdir(destPath);
43
+ if (files.length > 0) {
44
+ continue;
45
+ }
46
+
47
+ copySteps.push(`docker cp ${tmpContainer}:${dest}/. ${destPath} || true`);
48
+ }
49
+
50
+ if (copySteps.length === 0) {
51
+ return;
52
+ }
53
+
54
+ const deleteContainerCmd = `docker rm -f ${tmpContainer} || true`;
55
+ const createContainerCmd = `docker create --name ${tmpContainer} ${image}`;
56
+
57
+ try {
58
+ await promiseSpawn([deleteContainerCmd, createContainerCmd, ...copySteps].join(' && '));
59
+ } catch (error) {
60
+ throw new Error(`Failed to create container ${tmpContainer}: ${error.message}`);
61
+ } finally {
62
+ await promiseSpawn(deleteContainerCmd);
63
+ }
64
+ }
65
+
66
+ module.exports = parseDockerCpVolume;
@@ -13,10 +13,12 @@ const promiseSpawn = require('@abtnode/util/lib/promise-spawn');
13
13
  const getLocalIPAddress = require('@abtnode/util/lib/get-local-ip-address');
14
14
  const { dockerCmdValidator } = require('@abtnode/docker-utils');
15
15
 
16
+ const { isExternalBlocklet } = require('@blocklet/meta/lib/util');
16
17
  const parseDockerName = require('./parse-docker-name');
17
18
  const { createDockerImage } = require('./create-docker-image');
18
19
  const checkNeedRunDocker = require('./check-need-run-docker');
19
20
  const replaceEnvValue = require('./replace-env-value');
21
+ const parseDockerCpVolume = require('./parse-docker-cp-volume');
20
22
 
21
23
  const getSystemResources = (() => {
22
24
  let cachedResources = null;
@@ -47,12 +49,23 @@ async function parseDockerOptionsFromPm2({
47
49
  eventName,
48
50
  dockerNetworkName,
49
51
  }) {
50
- if (!(await checkNeedRunDocker(meta, options.env, nodeInfo))) {
52
+ const isExternal = isExternalBlocklet(rootBlocklet);
53
+ if (!(await checkNeedRunDocker(meta, options.env, nodeInfo, isExternal))) {
51
54
  return options;
52
55
  }
56
+ const nextOptions = { ...options };
53
57
 
54
58
  const isServerless = nodeInfo.mode === NODE_MODES.SERVERLESS;
55
59
 
60
+ if (isServerless && isExternal) {
61
+ if (nextOptions.env.SKIP_DOCKER_NETWORK) {
62
+ throw new Error('Serverless mode does not support skipping Docker network');
63
+ }
64
+ if (nextOptions.env.ALLOW_DOCKER_HOST_ACCESS) {
65
+ throw new Error('Serverless mode does not support allowing Docker host access');
66
+ }
67
+ }
68
+
56
69
  const dockerInfo = {
57
70
  ...(await createDockerImage({
58
71
  appDir: options.env.BLOCKLET_APP_DIR,
@@ -63,7 +76,6 @@ async function parseDockerOptionsFromPm2({
63
76
  })),
64
77
  };
65
78
 
66
- const nextOptions = { ...options };
67
79
  nextOptions.env = { ...nextOptions.env };
68
80
  const name = parseDockerName(options.name, dockerNamePrefix);
69
81
 
@@ -141,15 +153,6 @@ async function parseDockerOptionsFromPm2({
141
153
  dockerEnv.USING_DOCKER = 'true';
142
154
  dockerEnv.LOCAL_USER_ID = process.getuid();
143
155
 
144
- if (nodeInfo.mode === NODE_MODES.SERVERLESS) {
145
- if (nextOptions.env.SKIP_DOCKER_NETWORK) {
146
- throw new Error('Serverless mode does not support skipping Docker network');
147
- }
148
- if (nextOptions.env.ALLOW_DOCKER_HOST_ACCESS) {
149
- throw new Error('Serverless mode does not support allowing Docker host access');
150
- }
151
- }
152
-
153
156
  if (meta.egress === undefined) {
154
157
  meta.egress = true;
155
158
  }
@@ -332,6 +335,8 @@ async function parseDockerOptionsFromPm2({
332
335
  .map(({ source, target, canEdit }) => `-v ${source}:${target}:${canEdit ? 'rw' : 'ro'}`)
333
336
  .join(' ');
334
337
 
338
+ await parseDockerCpVolume(name, nextOptions.env.BLOCKLET_DATA_DIR, dockerInfo);
339
+
335
340
  createScripts({
336
341
  rootCommands: [
337
342
  `echo "start ${meta.name} in docker: ${dockerInfo.network}, ${eventName || 'start'}"`,
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.16.44-beta-20250520-104453-912ed737",
6
+ "version": "1.16.44-beta-20250523-232943-369d21c5",
7
7
  "description": "",
8
8
  "main": "lib/index.js",
9
9
  "files": [
@@ -19,21 +19,21 @@
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.44-beta-20250520-104453-912ed737",
23
- "@abtnode/auth": "1.16.44-beta-20250520-104453-912ed737",
24
- "@abtnode/certificate-manager": "1.16.44-beta-20250520-104453-912ed737",
25
- "@abtnode/client": "1.16.44-beta-20250520-104453-912ed737",
26
- "@abtnode/constant": "1.16.44-beta-20250520-104453-912ed737",
27
- "@abtnode/cron": "1.16.44-beta-20250520-104453-912ed737",
28
- "@abtnode/docker-utils": "1.16.44-beta-20250520-104453-912ed737",
29
- "@abtnode/logger": "1.16.44-beta-20250520-104453-912ed737",
30
- "@abtnode/models": "1.16.44-beta-20250520-104453-912ed737",
31
- "@abtnode/queue": "1.16.44-beta-20250520-104453-912ed737",
32
- "@abtnode/rbac": "1.16.44-beta-20250520-104453-912ed737",
33
- "@abtnode/router-provider": "1.16.44-beta-20250520-104453-912ed737",
34
- "@abtnode/static-server": "1.16.44-beta-20250520-104453-912ed737",
35
- "@abtnode/timemachine": "1.16.44-beta-20250520-104453-912ed737",
36
- "@abtnode/util": "1.16.44-beta-20250520-104453-912ed737",
22
+ "@abtnode/analytics": "1.16.44-beta-20250523-232943-369d21c5",
23
+ "@abtnode/auth": "1.16.44-beta-20250523-232943-369d21c5",
24
+ "@abtnode/certificate-manager": "1.16.44-beta-20250523-232943-369d21c5",
25
+ "@abtnode/client": "1.16.44-beta-20250523-232943-369d21c5",
26
+ "@abtnode/constant": "1.16.44-beta-20250523-232943-369d21c5",
27
+ "@abtnode/cron": "1.16.44-beta-20250523-232943-369d21c5",
28
+ "@abtnode/docker-utils": "1.16.44-beta-20250523-232943-369d21c5",
29
+ "@abtnode/logger": "1.16.44-beta-20250523-232943-369d21c5",
30
+ "@abtnode/models": "1.16.44-beta-20250523-232943-369d21c5",
31
+ "@abtnode/queue": "1.16.44-beta-20250523-232943-369d21c5",
32
+ "@abtnode/rbac": "1.16.44-beta-20250523-232943-369d21c5",
33
+ "@abtnode/router-provider": "1.16.44-beta-20250523-232943-369d21c5",
34
+ "@abtnode/static-server": "1.16.44-beta-20250523-232943-369d21c5",
35
+ "@abtnode/timemachine": "1.16.44-beta-20250523-232943-369d21c5",
36
+ "@abtnode/util": "1.16.44-beta-20250523-232943-369d21c5",
37
37
  "@arcblock/did": "1.20.11",
38
38
  "@arcblock/did-auth": "1.20.11",
39
39
  "@arcblock/did-ext": "1.20.11",
@@ -44,15 +44,15 @@
44
44
  "@arcblock/pm2-events": "^0.0.5",
45
45
  "@arcblock/validator": "1.20.11",
46
46
  "@arcblock/vc": "1.20.11",
47
- "@blocklet/constant": "1.16.44-beta-20250520-104453-912ed737",
48
- "@blocklet/did-space-js": "^1.0.53",
49
- "@blocklet/env": "1.16.44-beta-20250520-104453-912ed737",
47
+ "@blocklet/constant": "1.16.44-beta-20250523-232943-369d21c5",
48
+ "@blocklet/did-space-js": "^1.0.56",
49
+ "@blocklet/env": "1.16.44-beta-20250523-232943-369d21c5",
50
50
  "@blocklet/error": "^0.2.4",
51
- "@blocklet/meta": "1.16.44-beta-20250520-104453-912ed737",
52
- "@blocklet/resolver": "1.16.44-beta-20250520-104453-912ed737",
53
- "@blocklet/sdk": "1.16.44-beta-20250520-104453-912ed737",
54
- "@blocklet/store": "1.16.44-beta-20250520-104453-912ed737",
55
- "@blocklet/theme": "^2.13.41",
51
+ "@blocklet/meta": "1.16.44-beta-20250523-232943-369d21c5",
52
+ "@blocklet/resolver": "1.16.44-beta-20250523-232943-369d21c5",
53
+ "@blocklet/sdk": "1.16.44-beta-20250523-232943-369d21c5",
54
+ "@blocklet/store": "1.16.44-beta-20250523-232943-369d21c5",
55
+ "@blocklet/theme": "^2.13.47",
56
56
  "@fidm/x509": "^1.2.1",
57
57
  "@ocap/mcrypto": "1.20.11",
58
58
  "@ocap/util": "1.20.11",
@@ -116,5 +116,5 @@
116
116
  "jest": "^29.7.0",
117
117
  "unzipper": "^0.10.11"
118
118
  },
119
- "gitHead": "b2f2e6a8fe20634cf4d034a26c4c388d687a7f55"
119
+ "gitHead": "979ad200c41b355039a856a356c3b2bdd573e5ba"
120
120
  }