@abtnode/core 1.16.17 → 1.16.18-beta-7aa6be5a

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.
@@ -230,13 +230,13 @@ class DiskBlockletManager extends BaseBlockletManager {
230
230
  *
231
231
  * @param {{
232
232
  * id: string,
233
- * job: { blocklet: import('@abtnode/client').BlockletState }
233
+ * job: { did: string }
234
234
  * }} param0
235
235
  */
236
236
  const handleBackupComplete = async ({ id: jobId, job }) => {
237
237
  await this.backupQueue.delete(jobId);
238
238
 
239
- const autoBackup = await this.getAutoBackup({ did: job.blocklet.meta.did });
239
+ const autoBackup = await this.getAutoBackup({ did: job.did });
240
240
  if (autoBackup?.enabled) {
241
241
  this.backupQueue.push(job, jobId, true, BACKUPS.JOB.INTERVAL);
242
242
  }
@@ -1916,13 +1916,11 @@ class DiskBlockletManager extends BaseBlockletManager {
1916
1916
  logger.info('updateAutoBackup.$value', value);
1917
1917
 
1918
1918
  if (value.enabled) {
1919
- const blocklet = await states.blocklet.getBlocklet(did);
1920
-
1921
1919
  this.backupQueue.push(
1922
1920
  {
1923
1921
  entity: 'blocklet',
1924
1922
  action: 'backupToSpaces',
1925
- blocklet,
1923
+ did,
1926
1924
  context,
1927
1925
  },
1928
1926
  jobId,
@@ -2331,6 +2329,7 @@ class DiskBlockletManager extends BaseBlockletManager {
2331
2329
 
2332
2330
  /**
2333
2331
  * @param {{
2332
+ * did: string,
2334
2333
  * blocklet: import('@abtnode/client').BlockletState,
2335
2334
  * context: {
2336
2335
  * referrer: string;
@@ -2342,11 +2341,13 @@ class DiskBlockletManager extends BaseBlockletManager {
2342
2341
  * }} { blocklet, context }
2343
2342
  * @memberof BlockletManager
2344
2343
  */
2345
- async _onBackupToSpaces({ blocklet, context, backupState }) {
2344
+ async _onBackupToSpaces({ did, context, backupState }) {
2346
2345
  const {
2347
2346
  referrer,
2348
2347
  user: { did: userDid, locale },
2349
2348
  } = context;
2349
+
2350
+ const blocklet = await states.blocklet.getBlocklet(did);
2350
2351
  const {
2351
2352
  appDid,
2352
2353
  meta: { did: appPid },
@@ -3589,7 +3590,7 @@ class DiskBlockletManager extends BaseBlockletManager {
3589
3590
  {
3590
3591
  entity: 'blocklet',
3591
3592
  action: 'backupToSpaces',
3592
- blocklet,
3593
+ did,
3593
3594
  context,
3594
3595
  backupState: {
3595
3596
  strategy: BACKUPS.STRATEGY.MANUAL,
@@ -23,7 +23,7 @@ async function autoBackupHandler(eventName, payload, blockletManager) {
23
23
  {
24
24
  entity: 'blocklet',
25
25
  action: 'backupToSpaces',
26
- blocklet: payload,
26
+ did,
27
27
  context: payload.context,
28
28
  },
29
29
  jobId
@@ -1026,7 +1026,10 @@ module.exports = function getRouterHelpers({ dataDirs, routingSnapshot, routerMa
1026
1026
  }
1027
1027
 
1028
1028
  const existRule = (existSite.rules || []).find((y) => get(y, 'from.pathPrefix') === pathPrefix);
1029
- if (existRule) {
1029
+ if (
1030
+ existRule &&
1031
+ (rule.to?.type !== ROUTING_RULE_TYPES.BLOCKLET || existRule.to?.type === ROUTING_RULE_TYPES.BLOCKLET)
1032
+ ) {
1030
1033
  await routerManager.updateRoutingRule({
1031
1034
  id: existSite.id,
1032
1035
  rule: {
@@ -307,7 +307,16 @@ class RouterManager extends EventEmitter {
307
307
  const existedRule = dbSite.rules.find((x) => x.from.pathPrefix === rule.from.pathPrefix);
308
308
 
309
309
  if (existedRule) {
310
- throw new Error(`addRoutingRule: path prefix '${originalPathPrefix}' already exists`);
310
+ if (
311
+ rule.from.pathPrefix === '/' &&
312
+ rule.to.type === ROUTING_RULE_TYPES.BLOCKLET &&
313
+ existedRule.to.type !== ROUTING_RULE_TYPES.BLOCKLET
314
+ ) {
315
+ // Do nothing
316
+ // This is a special case that we allow a non-blocklet rule already exists in '/'
317
+ } else {
318
+ throw new Error(`addRoutingRule: path prefix '${originalPathPrefix}' already exists`);
319
+ }
311
320
  }
312
321
  }
313
322
 
@@ -159,6 +159,13 @@ class BlockletState extends BaseState {
159
159
  this.statusLocks = new Map();
160
160
  }
161
161
 
162
+ /**
163
+ * @description
164
+ * @param {string} did
165
+ * @param {*} [{ decryptSk = true }={}]
166
+ * @return {Promise<import('@abtnode/client').BlockletState>}
167
+ * @memberof BlockletState
168
+ */
162
169
  async getBlocklet(did, { decryptSk = true } = {}) {
163
170
  if (!did) {
164
171
  return null;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.16.17",
6
+ "version": "1.16.18-beta-7aa6be5a",
7
7
  "description": "",
8
8
  "main": "lib/index.js",
9
9
  "files": [
@@ -19,19 +19,19 @@
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.17",
23
- "@abtnode/auth": "1.16.17",
24
- "@abtnode/certificate-manager": "1.16.17",
25
- "@abtnode/constant": "1.16.17",
26
- "@abtnode/cron": "1.16.17",
27
- "@abtnode/logger": "1.16.17",
28
- "@abtnode/models": "1.16.17",
29
- "@abtnode/queue": "1.16.17",
30
- "@abtnode/rbac": "1.16.17",
31
- "@abtnode/router-provider": "1.16.17",
32
- "@abtnode/static-server": "1.16.17",
33
- "@abtnode/timemachine": "1.16.17",
34
- "@abtnode/util": "1.16.17",
22
+ "@abtnode/analytics": "1.16.18-beta-7aa6be5a",
23
+ "@abtnode/auth": "1.16.18-beta-7aa6be5a",
24
+ "@abtnode/certificate-manager": "1.16.18-beta-7aa6be5a",
25
+ "@abtnode/constant": "1.16.18-beta-7aa6be5a",
26
+ "@abtnode/cron": "1.16.18-beta-7aa6be5a",
27
+ "@abtnode/logger": "1.16.18-beta-7aa6be5a",
28
+ "@abtnode/models": "1.16.18-beta-7aa6be5a",
29
+ "@abtnode/queue": "1.16.18-beta-7aa6be5a",
30
+ "@abtnode/rbac": "1.16.18-beta-7aa6be5a",
31
+ "@abtnode/router-provider": "1.16.18-beta-7aa6be5a",
32
+ "@abtnode/static-server": "1.16.18-beta-7aa6be5a",
33
+ "@abtnode/timemachine": "1.16.18-beta-7aa6be5a",
34
+ "@abtnode/util": "1.16.18-beta-7aa6be5a",
35
35
  "@arcblock/did": "1.18.93",
36
36
  "@arcblock/did-auth": "1.18.93",
37
37
  "@arcblock/did-ext": "^1.18.93",
@@ -42,11 +42,11 @@
42
42
  "@arcblock/pm2-events": "^0.0.5",
43
43
  "@arcblock/validator": "^1.18.93",
44
44
  "@arcblock/vc": "1.18.93",
45
- "@blocklet/constant": "1.16.17",
46
- "@blocklet/env": "1.16.17",
47
- "@blocklet/meta": "1.16.17",
48
- "@blocklet/resolver": "1.16.17",
49
- "@blocklet/sdk": "1.16.17",
45
+ "@blocklet/constant": "1.16.18-beta-7aa6be5a",
46
+ "@blocklet/env": "1.16.18-beta-7aa6be5a",
47
+ "@blocklet/meta": "1.16.18-beta-7aa6be5a",
48
+ "@blocklet/resolver": "1.16.18-beta-7aa6be5a",
49
+ "@blocklet/sdk": "1.16.18-beta-7aa6be5a",
50
50
  "@did-space/client": "^0.3.12",
51
51
  "@fidm/x509": "^1.2.1",
52
52
  "@ocap/mcrypto": "1.18.93",
@@ -101,5 +101,5 @@
101
101
  "jest": "^27.5.1",
102
102
  "unzipper": "^0.10.11"
103
103
  },
104
- "gitHead": "628ba2f5dac74749900bc1e9fd81bab8d320412a"
104
+ "gitHead": "b2da6c7e30adf84d7eca941ada27427344c49044"
105
105
  }