@abtnode/core 1.8.1 → 1.8.2
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 +7 -1
- package/lib/event.js +6 -2
- package/lib/index.js +1 -0
- package/lib/states/blocklet.js +16 -0
- package/lib/util/blocklet.js +10 -0
- package/package.json +22 -22
|
@@ -870,7 +870,9 @@ class BlockletManager extends BaseBlockletManager {
|
|
|
870
870
|
|
|
871
871
|
async configPublicToStore({ did, publicToStore = false }) {
|
|
872
872
|
const blocklet = await this.ensureBlocklet(did);
|
|
873
|
-
|
|
873
|
+
// publicToStore 由用户传入
|
|
874
|
+
// handleInstanceInStore 方法写在前面,保证向 store 操作成功后才会更改 blocklet 中的 publicToStore值
|
|
875
|
+
// handleInstanceInStore 中会校验修改 publicToStore字段 的条件,不符合则会抛错,就不会执行下面更新 publicToStore 的逻辑
|
|
874
876
|
await handleInstanceInStore(blocklet, { publicToStore });
|
|
875
877
|
await states.blockletExtras.setSettings(did, { publicToStore });
|
|
876
878
|
|
|
@@ -1302,6 +1304,10 @@ class BlockletManager extends BaseBlockletManager {
|
|
|
1302
1304
|
return blocklet;
|
|
1303
1305
|
}
|
|
1304
1306
|
|
|
1307
|
+
async hasBlocklet({ did }) {
|
|
1308
|
+
return states.blocklet.hasBlocklet(did);
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1305
1311
|
async setInitialized({ did, owner }) {
|
|
1306
1312
|
if (!validateOwner(owner)) {
|
|
1307
1313
|
throw new Error('Blocklet owner is invalid');
|
package/lib/event.js
CHANGED
|
@@ -164,9 +164,13 @@ module.exports = ({
|
|
|
164
164
|
} else if ([BlockletEvents.started].includes(eventName)) {
|
|
165
165
|
try {
|
|
166
166
|
const blocklet = await blockletManager.ensureBlocklet(payload.meta.did);
|
|
167
|
-
|
|
167
|
+
const { publicToStore } = blocklet.settings;
|
|
168
|
+
// 如果一个 blocklet 没有设置 publicToStore,启动成功后不应给 store 发请求
|
|
169
|
+
if (publicToStore) {
|
|
170
|
+
await handleInstanceInStore(blocklet, { publicToStore });
|
|
171
|
+
}
|
|
168
172
|
} catch (error) {
|
|
169
|
-
logger.error('
|
|
173
|
+
logger.error('BlockletEvents started failed', { error });
|
|
170
174
|
}
|
|
171
175
|
}
|
|
172
176
|
|
package/lib/index.js
CHANGED
|
@@ -238,6 +238,7 @@ function ABTNode(options) {
|
|
|
238
238
|
getBlocklets: blockletManager.list.bind(blockletManager),
|
|
239
239
|
getBlocklet: blockletManager.detail.bind(blockletManager),
|
|
240
240
|
getBlockletDiff: blockletManager.diff.bind(blockletManager),
|
|
241
|
+
hasBlocklet: blockletManager.hasBlocklet.bind(blockletManager),
|
|
241
242
|
updateAllBlockletEnvironment: blockletManager.updateAllBlockletEnvironment.bind(blockletManager),
|
|
242
243
|
setBlockletInitialized: blockletManager.setInitialized.bind(blockletManager),
|
|
243
244
|
|
package/lib/states/blocklet.js
CHANGED
|
@@ -102,6 +102,22 @@ class BlockletState extends BaseState {
|
|
|
102
102
|
});
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
+
hasBlocklet(did) {
|
|
106
|
+
return new Promise((resolve, reject) => {
|
|
107
|
+
if (!did) {
|
|
108
|
+
resolve(false);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
this.db.count({ $or: [{ 'meta.did': did }, { appDid: did }] }, (err, count) => {
|
|
112
|
+
if (err) {
|
|
113
|
+
return reject(err);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return resolve(!!count);
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
|
|
105
121
|
getBlocklets(query = {}, projection) {
|
|
106
122
|
return new Promise((resolve, reject) => {
|
|
107
123
|
this.db
|
package/lib/util/blocklet.js
CHANGED
|
@@ -309,6 +309,7 @@ const getComponentSystemEnvironments = (blocklet) => {
|
|
|
309
309
|
if (ports) {
|
|
310
310
|
Object.assign(portEnvironments, ports);
|
|
311
311
|
}
|
|
312
|
+
|
|
312
313
|
return {
|
|
313
314
|
BLOCKLET_REAL_DID: blocklet.env.id,
|
|
314
315
|
BLOCKLET_DATA_DIR: blocklet.env.dataDir,
|
|
@@ -328,10 +329,19 @@ const getRuntimeEnvironments = (blocklet, nodeEnvironments, ancestors) => {
|
|
|
328
329
|
return o;
|
|
329
330
|
}, {});
|
|
330
331
|
|
|
332
|
+
// get devEnvironments, when blocklet is in dev mode
|
|
333
|
+
const devEnvironments =
|
|
334
|
+
blocklet.mode === BLOCKLET_MODES.DEVELOPMENT
|
|
335
|
+
? {
|
|
336
|
+
BLOCKLET_DEV_MOUNT_POINT: blocklet?.mountPoint || '',
|
|
337
|
+
}
|
|
338
|
+
: {};
|
|
339
|
+
|
|
331
340
|
return {
|
|
332
341
|
...blocklet.configObj,
|
|
333
342
|
...getSharedConfigObj(blocklet, ancestors),
|
|
334
343
|
...blocklet.environmentObj,
|
|
344
|
+
...devEnvironments,
|
|
335
345
|
...nodeEnvironments,
|
|
336
346
|
...safeNodeEnvironments,
|
|
337
347
|
};
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.8.
|
|
6
|
+
"version": "1.8.2",
|
|
7
7
|
"description": "",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -19,31 +19,31 @@
|
|
|
19
19
|
"author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@abtnode/certificate-manager": "1.8.
|
|
23
|
-
"@abtnode/constant": "1.8.
|
|
24
|
-
"@abtnode/cron": "1.8.
|
|
25
|
-
"@abtnode/db": "1.8.
|
|
26
|
-
"@abtnode/logger": "1.8.
|
|
27
|
-
"@abtnode/queue": "1.8.
|
|
28
|
-
"@abtnode/rbac": "1.8.
|
|
29
|
-
"@abtnode/router-provider": "1.8.
|
|
30
|
-
"@abtnode/static-server": "1.8.
|
|
31
|
-
"@abtnode/timemachine": "1.8.
|
|
32
|
-
"@abtnode/util": "1.8.
|
|
33
|
-
"@arcblock/did": "1.17.
|
|
22
|
+
"@abtnode/certificate-manager": "1.8.2",
|
|
23
|
+
"@abtnode/constant": "1.8.2",
|
|
24
|
+
"@abtnode/cron": "1.8.2",
|
|
25
|
+
"@abtnode/db": "1.8.2",
|
|
26
|
+
"@abtnode/logger": "1.8.2",
|
|
27
|
+
"@abtnode/queue": "1.8.2",
|
|
28
|
+
"@abtnode/rbac": "1.8.2",
|
|
29
|
+
"@abtnode/router-provider": "1.8.2",
|
|
30
|
+
"@abtnode/static-server": "1.8.2",
|
|
31
|
+
"@abtnode/timemachine": "1.8.2",
|
|
32
|
+
"@abtnode/util": "1.8.2",
|
|
33
|
+
"@arcblock/did": "1.17.2",
|
|
34
34
|
"@arcblock/did-motif": "^1.1.10",
|
|
35
|
-
"@arcblock/did-util": "1.17.
|
|
36
|
-
"@arcblock/event-hub": "1.17.
|
|
37
|
-
"@arcblock/jwt": "^1.17.
|
|
35
|
+
"@arcblock/did-util": "1.17.2",
|
|
36
|
+
"@arcblock/event-hub": "1.17.2",
|
|
37
|
+
"@arcblock/jwt": "^1.17.2",
|
|
38
38
|
"@arcblock/pm2-events": "^0.0.5",
|
|
39
|
-
"@arcblock/vc": "1.17.
|
|
40
|
-
"@blocklet/meta": "1.8.
|
|
39
|
+
"@arcblock/vc": "1.17.2",
|
|
40
|
+
"@blocklet/meta": "1.8.2",
|
|
41
41
|
"@fidm/x509": "^1.2.1",
|
|
42
42
|
"@nedb/core": "^1.3.1",
|
|
43
43
|
"@nedb/multi": "^1.3.1",
|
|
44
|
-
"@ocap/mcrypto": "1.17.
|
|
45
|
-
"@ocap/util": "1.17.
|
|
46
|
-
"@ocap/wallet": "1.17.
|
|
44
|
+
"@ocap/mcrypto": "1.17.2",
|
|
45
|
+
"@ocap/util": "1.17.2",
|
|
46
|
+
"@ocap/wallet": "1.17.2",
|
|
47
47
|
"@slack/webhook": "^5.0.3",
|
|
48
48
|
"axios": "^0.27.2",
|
|
49
49
|
"axon": "^2.0.3",
|
|
@@ -81,5 +81,5 @@
|
|
|
81
81
|
"express": "^4.17.1",
|
|
82
82
|
"jest": "^27.4.5"
|
|
83
83
|
},
|
|
84
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "fcbe3c97f3825c507ee16714f49bbf8f58c5b59f"
|
|
85
85
|
}
|