@abtnode/core 1.8.12 → 1.8.13

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.
@@ -533,7 +533,7 @@ class BlockletManager extends BaseBlockletManager {
533
533
  logger.info('blocklet reload successfully', { did });
534
534
 
535
535
  const res = await this.status(did);
536
- this.emit(BlockletEvents.statusUpdated, res);
536
+ this.emit(BlockletEvents.statusChange, res);
537
537
  return res;
538
538
  }
539
539
 
@@ -1370,7 +1370,9 @@ class BlockletManager extends BaseBlockletManager {
1370
1370
  return blocklet;
1371
1371
  }
1372
1372
 
1373
- return states.blocklet.setBlockletStatus(did, BlockletStatus.stopped);
1373
+ const res = await states.blocklet.setBlockletStatus(did, BlockletStatus.stopped);
1374
+ this.emit(BlockletEvents.statusChange, res);
1375
+ return res;
1374
1376
  };
1375
1377
 
1376
1378
  const blocklet = await this.ensureBlocklet(did);
@@ -1384,22 +1386,22 @@ class BlockletManager extends BaseBlockletManager {
1384
1386
  }
1385
1387
  }
1386
1388
 
1389
+ if (!shouldUpdateStatus) {
1390
+ return blocklet;
1391
+ }
1392
+
1387
1393
  try {
1388
1394
  const status = await getBlockletStatusFromProcess(blocklet);
1389
- if (shouldUpdateStatus) {
1390
- if (status === BlockletStatus.stopped) {
1391
- await states.blocklet.stopBlocklet(did);
1392
- }
1393
- return states.blocklet.setBlockletStatus(did, status);
1395
+ if (blocklet.status !== status) {
1396
+ const res = await states.blocklet.setBlockletStatus(did, status);
1397
+ this.emit(BlockletEvents.statusChange, res);
1398
+ return res;
1394
1399
  }
1400
+
1401
+ return blocklet;
1395
1402
  } catch (err) {
1396
- if (shouldUpdateStatus) {
1397
- return fastReturnOnForceSync(blocklet);
1398
- }
1399
- throw err;
1403
+ return fastReturnOnForceSync(blocklet);
1400
1404
  }
1401
-
1402
- return blocklet;
1403
1405
  }
1404
1406
 
1405
1407
  async getBlockletInterfaces({ blocklet, nodeInfo, context }) {
@@ -2301,7 +2303,7 @@ class BlockletManager extends BaseBlockletManager {
2301
2303
  async _syncBlockletStatus() {
2302
2304
  const run = async (blocklet) => {
2303
2305
  try {
2304
- await this.status(blocklet.meta.did, { forceSync: true });
2306
+ await this.status(blocklet.meta.did);
2305
2307
  } catch (err) {
2306
2308
  logger.error('sync blocklet status failed', { error: err });
2307
2309
  }
@@ -8,7 +8,7 @@ class WebhookState extends BaseState {
8
8
  super(baseDir, { filename: 'webhook.db', ...options });
9
9
  }
10
10
 
11
- async create(info) {
11
+ async create(info, { mock } = {}) {
12
12
  const { type, params } = info;
13
13
  const filterParams = params.map((item) => {
14
14
  const data = {
@@ -26,6 +26,10 @@ class WebhookState extends BaseState {
26
26
 
27
27
  await validateWebhook(data);
28
28
 
29
+ if (mock) {
30
+ return data;
31
+ }
32
+
29
33
  const webhook = await this.asyncDB.insert(data);
30
34
  return webhook;
31
35
  }
@@ -353,8 +353,8 @@ const getRuntimeEnvironments = (blocklet, nodeEnvironments, ancestors) => {
353
353
  for (const x of root.children || []) {
354
354
  mountPoints.push({
355
355
  title: x.meta.title,
356
- did: x.meta.did,
357
- name: x.meta.name,
356
+ did: x.meta.bundleDid,
357
+ name: x.meta.bundleName,
358
358
  mountPoint: x.mountPoint || '',
359
359
  });
360
360
  }
@@ -366,6 +366,7 @@ const getRuntimeEnvironments = (blocklet, nodeEnvironments, ancestors) => {
366
366
  ...devEnvironments,
367
367
  BLOCKLET_WEB_PORTS: JSON.stringify(ports),
368
368
  BLOCKLET_MOUNT_POINTS: JSON.stringify(mountPoints),
369
+ BLOCKLET_MODE: blocklet.mode || BLOCKLET_MODES.PRODUCTION,
369
370
  ...nodeEnvironments,
370
371
  ...safeNodeEnvironments,
371
372
  };
@@ -134,13 +134,14 @@ module.exports = ({ events, dataDirs, instance }) => {
134
134
 
135
135
  const createWebhook = async (webhook) => {
136
136
  try {
137
- const createRes = await webhookState.create(webhook);
138
- await sentTextMessage(createRes, `A ${createRes.type} integration is now *successfully added*`);
137
+ const mockCreateRes = await webhookState.create(webhook, { mock: true });
138
+ await sentTextMessage(mockCreateRes, `A ${mockCreateRes.type} integration is now *successfully added*`);
139
139
 
140
+ const createRes = await webhookState.create(webhook);
140
141
  return createRes;
141
142
  } catch (err) {
142
- logger.error('create webhook error', { err });
143
- throw new Error(err.message);
143
+ logger.error('Failed to create webhook', { err });
144
+ throw new Error(`Failed to create webhook: ${err.message}`);
144
145
  }
145
146
  };
146
147
 
@@ -29,7 +29,7 @@ class SlackSender extends BaseSender {
29
29
  type: 'section',
30
30
  text: {
31
31
  type: 'mrkdwn',
32
- text: `*${nodeInfo.name}*`,
32
+ text: `*${nodeInfo?.name}*`,
33
33
  },
34
34
  },
35
35
  {
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.8.12",
6
+ "version": "1.8.13",
7
7
  "description": "",
8
8
  "main": "lib/index.js",
9
9
  "files": [
@@ -19,32 +19,32 @@
19
19
  "author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
20
20
  "license": "MIT",
21
21
  "dependencies": {
22
- "@abtnode/certificate-manager": "1.8.12",
23
- "@abtnode/constant": "1.8.12",
24
- "@abtnode/cron": "1.8.12",
25
- "@abtnode/db": "1.8.12",
26
- "@abtnode/logger": "1.8.12",
27
- "@abtnode/queue": "1.8.12",
28
- "@abtnode/rbac": "1.8.12",
29
- "@abtnode/router-provider": "1.8.12",
30
- "@abtnode/static-server": "1.8.12",
31
- "@abtnode/timemachine": "1.8.12",
32
- "@abtnode/util": "1.8.12",
33
- "@arcblock/did": "1.17.12",
22
+ "@abtnode/certificate-manager": "1.8.13",
23
+ "@abtnode/constant": "1.8.13",
24
+ "@abtnode/cron": "1.8.13",
25
+ "@abtnode/db": "1.8.13",
26
+ "@abtnode/logger": "1.8.13",
27
+ "@abtnode/queue": "1.8.13",
28
+ "@abtnode/rbac": "1.8.13",
29
+ "@abtnode/router-provider": "1.8.13",
30
+ "@abtnode/static-server": "1.8.13",
31
+ "@abtnode/timemachine": "1.8.13",
32
+ "@abtnode/util": "1.8.13",
33
+ "@arcblock/did": "1.17.15",
34
34
  "@arcblock/did-motif": "^1.1.10",
35
- "@arcblock/did-util": "1.17.12",
36
- "@arcblock/event-hub": "1.17.12",
37
- "@arcblock/jwt": "^1.17.12",
35
+ "@arcblock/did-util": "1.17.15",
36
+ "@arcblock/event-hub": "1.17.15",
37
+ "@arcblock/jwt": "^1.17.15",
38
38
  "@arcblock/pm2-events": "^0.0.5",
39
- "@arcblock/vc": "1.17.12",
40
- "@blocklet/meta": "1.8.12",
41
- "@blocklet/sdk": "1.8.12",
39
+ "@arcblock/vc": "1.17.15",
40
+ "@blocklet/meta": "1.8.13",
41
+ "@blocklet/sdk": "1.8.13",
42
42
  "@fidm/x509": "^1.2.1",
43
43
  "@nedb/core": "^1.3.4",
44
44
  "@nedb/multi": "^1.3.4",
45
- "@ocap/mcrypto": "1.17.12",
46
- "@ocap/util": "1.17.12",
47
- "@ocap/wallet": "1.17.12",
45
+ "@ocap/mcrypto": "1.17.15",
46
+ "@ocap/util": "1.17.15",
47
+ "@ocap/wallet": "1.17.15",
48
48
  "@slack/webhook": "^5.0.4",
49
49
  "axios": "^0.27.2",
50
50
  "axon": "^2.0.3",
@@ -82,5 +82,5 @@
82
82
  "express": "^4.18.1",
83
83
  "jest": "^27.5.1"
84
84
  },
85
- "gitHead": "f4cb25a77f7ee48333b3243918a0a9c81b94ab8c"
85
+ "gitHead": "028f33d8a3a4f999456bfe8e7bd2e1a53b664b47"
86
86
  }