@abtnode/core 1.16.11-beta-0ae58a71 → 1.16.11-beta-f9719c31
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/node.js +1 -1
- package/lib/api/team.js +5 -5
- package/lib/blocklet/downloader/blocklet-downloader.js +34 -19
- package/lib/blocklet/downloader/bundle-downloader.js +2 -2
- package/lib/blocklet/hooks.js +1 -1
- package/lib/blocklet/manager/base.js +9 -9
- package/lib/blocklet/manager/disk.js +320 -199
- package/lib/blocklet/manager/helper/install-application-from-backup.js +1 -1
- package/lib/blocklet/manager/helper/install-application-from-general.js +18 -3
- package/lib/blocklet/manager/helper/install-component-from-dev.js +0 -1
- package/lib/blocklet/manager/helper/install-component-from-upload.js +8 -4
- package/lib/blocklet/manager/helper/install-component-from-url.js +4 -2
- package/lib/blocklet/manager/helper/upgrade-components.js +7 -7
- package/lib/blocklet/manager/pm2-events.js +3 -3
- package/lib/blocklet/migration.js +2 -2
- package/lib/blocklet/storage/backup/base.js +1 -0
- package/lib/blocklet/storage/backup/blocklet-extras.js +1 -1
- package/lib/blocklet/storage/backup/blocklet.js +1 -1
- package/lib/blocklet/storage/backup/disk.js +1 -0
- package/lib/blocklet/storage/restore/blocklet-extras.js +1 -1
- package/lib/blocklet/storage/restore/blocklet.js +1 -1
- package/lib/blocklet/storage/restore/disk.js +1 -1
- package/lib/blocklet/storage/restore/spaces.js +1 -1
- package/lib/cert.js +5 -5
- package/lib/crons/rotate-pm2-logs/index.js +1 -1
- package/lib/event.js +11 -1
- package/lib/index.js +8 -2
- package/lib/migrations/1.16.11-component-status.js +22 -0
- package/lib/migrations/index.js +3 -3
- package/lib/monitor/blocklet-runtime-monitor.js +7 -2
- package/lib/processes/updater.js +1 -1
- package/lib/router/helper.js +5 -5
- package/lib/states/audit-log.js +1 -1
- package/lib/states/backup.js +6 -4
- package/lib/states/blocklet-extras.js +11 -1
- package/lib/states/blocklet.js +46 -39
- package/lib/states/cache.js +1 -1
- package/lib/states/node.js +6 -2
- package/lib/states/notification.js +1 -1
- package/lib/states/routing-snapshot.js +1 -1
- package/lib/states/site.js +1 -1
- package/lib/states/user.js +12 -6
- package/lib/team/manager.js +6 -6
- package/lib/util/blocklet.js +130 -118
- package/lib/util/launcher.js +238 -0
- package/lib/util/reset-node.js +19 -16
- package/lib/util/rpc.js +1 -1
- package/lib/util/spaces.js +26 -0
- package/lib/util/store.js +1 -1
- package/lib/validators/backup.js +1 -0
- package/lib/validators/space-gateway.js +3 -0
- package/lib/validators/util.js +3 -0
- package/lib/webhook/sender/api/index.js +1 -1
- package/lib/webhook/sender/slack/index.js +1 -1
- package/package.json +29 -29
package/lib/api/node.js
CHANGED
package/lib/api/team.js
CHANGED
|
@@ -642,7 +642,7 @@ class TeamAPI extends EventEmitter {
|
|
|
642
642
|
/**
|
|
643
643
|
* this function is only used to create server owner transfer invitation
|
|
644
644
|
*/
|
|
645
|
-
|
|
645
|
+
createTransferInvitation({ teamDid, remark }, context = {}) {
|
|
646
646
|
return this.createMemberInvitation(
|
|
647
647
|
{ teamDid, expireTime: this.transferOwnerExpireTime, remark, role: 'owner' },
|
|
648
648
|
context
|
|
@@ -956,7 +956,7 @@ class TeamAPI extends EventEmitter {
|
|
|
956
956
|
|
|
957
957
|
// Access Control
|
|
958
958
|
|
|
959
|
-
|
|
959
|
+
getRoles({ teamDid }) {
|
|
960
960
|
return this.teamManager.getRoles(teamDid);
|
|
961
961
|
}
|
|
962
962
|
|
|
@@ -1171,15 +1171,15 @@ class TeamAPI extends EventEmitter {
|
|
|
1171
1171
|
// Private
|
|
1172
1172
|
// =======
|
|
1173
1173
|
|
|
1174
|
-
|
|
1174
|
+
getRBAC(did) {
|
|
1175
1175
|
return this.teamManager.getRBAC(did);
|
|
1176
1176
|
}
|
|
1177
1177
|
|
|
1178
|
-
|
|
1178
|
+
getUserState(did) {
|
|
1179
1179
|
return this.teamManager.getUserState(did);
|
|
1180
1180
|
}
|
|
1181
1181
|
|
|
1182
|
-
|
|
1182
|
+
getSessionState(did) {
|
|
1183
1183
|
return this.teamManager.getSessionState(did);
|
|
1184
1184
|
}
|
|
1185
1185
|
|
|
@@ -7,7 +7,7 @@ const { toBase58 } = require('@ocap/util');
|
|
|
7
7
|
|
|
8
8
|
const defaultLogger = require('@abtnode/logger')('@abtnode/core:blocklet-downloader');
|
|
9
9
|
|
|
10
|
-
const {
|
|
10
|
+
const { forEachComponentV2Sync, getComponentBundleId } = require('@blocklet/meta/lib/util');
|
|
11
11
|
const validateBlockletEntry = require('@blocklet/meta/lib/entry');
|
|
12
12
|
|
|
13
13
|
const { BlockletSource, BLOCKLET_META_FILE, BLOCKLET_META_FILE_ALT, BLOCKLET_MODES } = require('@blocklet/constant');
|
|
@@ -134,7 +134,7 @@ class BlockletDownloader extends EventEmitter {
|
|
|
134
134
|
|
|
135
135
|
const { preDownload = () => {}, postDownload = () => {}, skipCheckIntegrity, onProgress = () => {} } = options;
|
|
136
136
|
|
|
137
|
-
const { downloadComponentIds, downloadList } = await this.getDownloadList({
|
|
137
|
+
const { downloadComponentIds, downloadList, skipList } = await this.getDownloadList({
|
|
138
138
|
blocklet,
|
|
139
139
|
skipCheckIntegrity,
|
|
140
140
|
});
|
|
@@ -142,24 +142,35 @@ class BlockletDownloader extends EventEmitter {
|
|
|
142
142
|
await preDownload({ downloadList, downloadComponentIds });
|
|
143
143
|
|
|
144
144
|
try {
|
|
145
|
+
// Fake progress events for cached bundles
|
|
146
|
+
skipList.forEach((meta) => {
|
|
147
|
+
const info = pick(meta, ['title', 'name', 'did', 'version']);
|
|
148
|
+
onProgress({ status: 'downloading', component: info });
|
|
149
|
+
setTimeout(
|
|
150
|
+
() => {
|
|
151
|
+
onProgress({ status: 'completed', component: info });
|
|
152
|
+
},
|
|
153
|
+
process.env.NODE_ENV === 'test' ? 0 : Math.random() * 800
|
|
154
|
+
);
|
|
155
|
+
});
|
|
156
|
+
|
|
145
157
|
this.logger.info('Start Download Blocklet', {
|
|
146
158
|
name,
|
|
147
159
|
did,
|
|
148
160
|
bundles: downloadList.map((x) => get(x, 'dist.tarball')),
|
|
149
161
|
});
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
this.bundleDownloader.download(meta, did, url, {
|
|
162
|
+
|
|
163
|
+
const results = await Promise.all(
|
|
164
|
+
downloadList.map((meta) => {
|
|
165
|
+
const url = meta.dist.tarball;
|
|
166
|
+
return this.bundleDownloader.download(meta, did, url, {
|
|
155
167
|
...options,
|
|
156
168
|
onProgress: (data) => {
|
|
157
169
|
onProgress({ ...data, component: pick(meta, ['title', 'name', 'did', 'version']) });
|
|
158
170
|
},
|
|
159
|
-
})
|
|
160
|
-
)
|
|
161
|
-
|
|
162
|
-
const results = await Promise.all(tasks);
|
|
171
|
+
});
|
|
172
|
+
})
|
|
173
|
+
);
|
|
163
174
|
|
|
164
175
|
const isCancelled = results.some((x) => x.isCancelled);
|
|
165
176
|
|
|
@@ -177,7 +188,7 @@ class BlockletDownloader extends EventEmitter {
|
|
|
177
188
|
return { isCancelled: false };
|
|
178
189
|
}
|
|
179
190
|
|
|
180
|
-
|
|
191
|
+
cancelDownload(did) {
|
|
181
192
|
return this.bundleDownloader.cancelDownload(did);
|
|
182
193
|
}
|
|
183
194
|
|
|
@@ -187,19 +198,21 @@ class BlockletDownloader extends EventEmitter {
|
|
|
187
198
|
* }}
|
|
188
199
|
* @returns {{
|
|
189
200
|
* downloadList: Array<import('@abtnode/client').BlockletMeta>;
|
|
201
|
+
* skipList: Array<import('@abtnode/client').BlockletMeta>;
|
|
190
202
|
* downloadComponentIds: Array<string>; // like: "z8ia1i2yq67x39vruqQTbkVcwCnqRGx8zSPsJ/z8iZwubkNdA1BfEUwc5NJpY2Jnfm7yEbyvmKS"
|
|
191
203
|
* }}
|
|
192
204
|
*/
|
|
193
205
|
async getDownloadList({ blocklet, skipCheckIntegrity }) {
|
|
194
206
|
const downloadComponentIds = [];
|
|
195
|
-
const
|
|
207
|
+
const scheduled = {};
|
|
208
|
+
const skipped = {};
|
|
196
209
|
|
|
197
210
|
const cachedBundles = (await this.cache.get(CACHE_KEY)) || [];
|
|
198
211
|
|
|
199
|
-
|
|
212
|
+
forEachComponentV2Sync(blocklet, (component) => {
|
|
200
213
|
const bundleId = getComponentBundleId(component);
|
|
201
214
|
|
|
202
|
-
if (
|
|
215
|
+
if (scheduled[bundleId]) {
|
|
203
216
|
this.logger.info(`skip download duplicate bundle ${bundleId}`);
|
|
204
217
|
return;
|
|
205
218
|
}
|
|
@@ -210,6 +223,7 @@ class BlockletDownloader extends EventEmitter {
|
|
|
210
223
|
skipCheckIntegrity,
|
|
211
224
|
});
|
|
212
225
|
if (!needComponentDownload) {
|
|
226
|
+
skipped[bundleId] = component.meta;
|
|
213
227
|
this.logger.info(`skip download existed bundle ${bundleId}`, { source: component.source });
|
|
214
228
|
return;
|
|
215
229
|
}
|
|
@@ -222,13 +236,14 @@ class BlockletDownloader extends EventEmitter {
|
|
|
222
236
|
return;
|
|
223
237
|
}
|
|
224
238
|
|
|
225
|
-
|
|
226
|
-
downloadComponentIds.push(
|
|
239
|
+
scheduled[bundleId] = component.meta;
|
|
240
|
+
downloadComponentIds.push(component.meta.did);
|
|
227
241
|
});
|
|
228
242
|
|
|
229
|
-
const downloadList = Object.values(
|
|
243
|
+
const downloadList = Object.values(scheduled);
|
|
244
|
+
const skipList = Object.values(skipped);
|
|
230
245
|
|
|
231
|
-
return { downloadList, downloadComponentIds };
|
|
246
|
+
return { downloadList, skipList, downloadComponentIds };
|
|
232
247
|
}
|
|
233
248
|
}
|
|
234
249
|
|
|
@@ -121,7 +121,7 @@ class BundleDownloader extends EventEmitter {
|
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
// eslint-disable-next-line no-unused-vars
|
|
124
|
-
|
|
124
|
+
cancelDownload(rootDid) {
|
|
125
125
|
if (this.downloadCtrls[rootDid]) {
|
|
126
126
|
for (const cancelCtrl of this.downloadCtrls[rootDid].values()) {
|
|
127
127
|
cancelCtrl.cancel();
|
|
@@ -294,7 +294,7 @@ class BundleDownloader extends EventEmitter {
|
|
|
294
294
|
await this.cache.set(CACHE_KEY, cacheList);
|
|
295
295
|
}
|
|
296
296
|
|
|
297
|
-
|
|
297
|
+
_getCachedTarFile(integrity) {
|
|
298
298
|
// eslint-disable-next-line no-param-reassign
|
|
299
299
|
integrity = toBase58(integrity);
|
|
300
300
|
|
package/lib/blocklet/hooks.js
CHANGED
|
@@ -57,7 +57,7 @@ const runUserHook = async (label, hookName, args) => {
|
|
|
57
57
|
const preInstall = (label, ...args) => runUserHook(label, 'pre-install', ...args);
|
|
58
58
|
const postInstall = (label, ...args) => runUserHook(label, 'post-install', ...args);
|
|
59
59
|
const preConfig = (label, ...args) => runUserHook(label, 'pre-config', ...args);
|
|
60
|
-
const preStart =
|
|
60
|
+
const preStart = (blocklet, options) => {
|
|
61
61
|
// check required environments
|
|
62
62
|
let environments = get(blocklet, 'meta.environments', []);
|
|
63
63
|
if (!Array.isArray(environments)) {
|
|
@@ -16,39 +16,39 @@ class BaseBlockletManager extends EventEmitter {
|
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
install() {
|
|
20
20
|
throw new Error('Install must be implemented in sub class');
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
start() {
|
|
24
24
|
throw new Error('Install must be implemented in sub class');
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
stop() {
|
|
28
28
|
throw new Error('Stop must be implemented in sub class');
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
restart() {
|
|
32
32
|
throw new Error('Restart must be implemented in sub class');
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
reload() {
|
|
36
36
|
throw new Error('Reload must be implemented in sub class');
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
delete() {
|
|
40
40
|
throw new Error('Delete must be implemented in sub class');
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
detail() {
|
|
44
44
|
throw new Error('Detail must be implemented in sub class');
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
list() {
|
|
48
48
|
throw new Error('List must be implemented in sub class');
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
config() {
|
|
52
52
|
throw new Error('Config must be implemented in sub class');
|
|
53
53
|
}
|
|
54
54
|
}
|