@abtnode/core 1.16.29-beta-e04c6f40 → 1.16.29-beta-88bdefe8

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
@@ -2,7 +2,9 @@ const { EventEmitter } = require('events');
2
2
  const pick = require('lodash/pick');
3
3
  const defaults = require('lodash/defaults');
4
4
  const cloneDeep = require('lodash/cloneDeep');
5
- const { joinURL } = require('ufo');
5
+ const { joinURL, withQuery, resolveURL, withoutTrailingSlash } = require('ufo');
6
+ const axios = require('@abtnode/util/lib/axios');
7
+ const pRetry = require('p-retry');
6
8
 
7
9
  const logger = require('@abtnode/logger')('@abtnode/core:api:team');
8
10
  const {
@@ -12,7 +14,6 @@ const {
12
14
  PASSPORT_STATUS,
13
15
  WELLKNOWN_SERVICE_PATH_PREFIX,
14
16
  MAX_USER_PAGE_SIZE,
15
- STORE_DETAIL_PAGE_PATH_PREFIX,
16
17
  MAIN_CHAIN_ENDPOINT,
17
18
  USER_AVATAR_URL_PREFIX,
18
19
  SESSION_TTL,
@@ -1331,14 +1332,27 @@ class TeamAPI extends EventEmitter {
1331
1332
  logger.info('add store', { teamDid, url, scope });
1332
1333
 
1333
1334
  const urlObj = new URL(url);
1334
- let newUrl = urlObj.origin;
1335
-
1336
- // if the pathname is store blocklet list or blocklet detail
1337
- if (urlObj.pathname?.includes(STORE_DETAIL_PAGE_PATH_PREFIX)) {
1338
- const lastIndex = urlObj.pathname.lastIndexOf(STORE_DETAIL_PAGE_PATH_PREFIX);
1339
- const pathnamePrefix = urlObj.pathname.substring(0, lastIndex);
1340
- newUrl = `${newUrl}${pathnamePrefix || ''}`;
1335
+ const jsonUrl = withQuery(resolveURL(url, '__blocklet__.js'), {
1336
+ type: 'json',
1337
+ });
1338
+ let blockletJson;
1339
+ try {
1340
+ const blockletFetchResult = await pRetry(
1341
+ () =>
1342
+ axios.get(jsonUrl, {
1343
+ headers: {
1344
+ 'Content-Type': 'json',
1345
+ },
1346
+ }),
1347
+ { retries: 3 }
1348
+ );
1349
+ blockletJson = blockletFetchResult?.data;
1350
+ } catch (error) {
1351
+ logger.error(`Failed to get Blockelt Store blockletMeta: ${url}`, { error });
1352
+ console.error(error);
1353
+ throw new Error(`Failed to get Blocklet Store blockletMeta, please check the url's validity: ${url}`);
1341
1354
  }
1355
+ const newUrl = withoutTrailingSlash(joinURL(urlObj.origin, blockletJson?.prefix || '/'));
1342
1356
 
1343
1357
  const sanitized = sanitizeUrl(newUrl);
1344
1358
 
@@ -1346,14 +1360,14 @@ class TeamAPI extends EventEmitter {
1346
1360
 
1347
1361
  const exist = storeList.find((x) => x.url === sanitized);
1348
1362
  if (exist) {
1349
- throw new Error(`Blocklet registry already exist: ${sanitized}`);
1363
+ throw new Error(`Blocklet Store already exist: ${sanitized}`);
1350
1364
  }
1351
1365
 
1352
1366
  const store = await StoreUtil.getStoreMeta(sanitized);
1353
1367
 
1354
1368
  const existById = storeList.find((x) => x.id === store.id);
1355
1369
  if (existById) {
1356
- throw new Error(`Blocklet registry already exist: ${sanitized}`);
1370
+ throw new Error(`Blocklet Store already exist: ${sanitized}`);
1357
1371
  }
1358
1372
 
1359
1373
  storeList.push({ ...store, scope, url: sanitized, protected: false });
@@ -161,10 +161,17 @@ const checkUploadExists = async (projectDir, action, releaseId, uploadedResource
161
161
  }
162
162
  fs.ensureDirSync(resourceDir);
163
163
 
164
- await expandBundle(uploadedFile, resourceDir);
164
+ try {
165
+ await expandBundle(uploadedFile, resourceDir);
166
+ } catch (err) {
167
+ throw new Error('When uploading resources from your disk, only zip archives are supported.');
168
+ }
169
+
165
170
  const files = ['index.html', 'index.htm'];
166
171
  if (files.every((file) => fs.existsSync(path.join(resourceDir, file)) === false)) {
167
- throw new Error(`Uploaded resource does not contain index.html or index.htm: ${uploadedResource}`);
172
+ throw new Error(
173
+ `The uploaded resource does not contain an index.html file in the root directory of the archive: ${uploadedResource}`
174
+ );
168
175
  }
169
176
  };
170
177
 
package/package.json CHANGED
@@ -3,14 +3,14 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.16.29-beta-e04c6f40",
6
+ "version": "1.16.29-beta-88bdefe8",
7
7
  "description": "",
8
8
  "main": "lib/index.js",
9
9
  "files": [
10
10
  "lib"
11
11
  ],
12
12
  "scripts": {
13
- "lint": "eslint tests lib",
13
+ "lint": "eslint tests lib --ignore-pattern 'tests/assets/*'",
14
14
  "lint:fix": "eslint --fix tests lib",
15
15
  "test": "node tools/jest.js",
16
16
  "coverage": "npm run test -- --coverage"
@@ -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.29-beta-e04c6f40",
23
- "@abtnode/auth": "1.16.29-beta-e04c6f40",
24
- "@abtnode/certificate-manager": "1.16.29-beta-e04c6f40",
25
- "@abtnode/constant": "1.16.29-beta-e04c6f40",
26
- "@abtnode/cron": "1.16.29-beta-e04c6f40",
27
- "@abtnode/logger": "1.16.29-beta-e04c6f40",
28
- "@abtnode/models": "1.16.29-beta-e04c6f40",
29
- "@abtnode/queue": "1.16.29-beta-e04c6f40",
30
- "@abtnode/rbac": "1.16.29-beta-e04c6f40",
31
- "@abtnode/router-provider": "1.16.29-beta-e04c6f40",
32
- "@abtnode/static-server": "1.16.29-beta-e04c6f40",
33
- "@abtnode/timemachine": "1.16.29-beta-e04c6f40",
34
- "@abtnode/util": "1.16.29-beta-e04c6f40",
22
+ "@abtnode/analytics": "1.16.29-beta-88bdefe8",
23
+ "@abtnode/auth": "1.16.29-beta-88bdefe8",
24
+ "@abtnode/certificate-manager": "1.16.29-beta-88bdefe8",
25
+ "@abtnode/constant": "1.16.29-beta-88bdefe8",
26
+ "@abtnode/cron": "1.16.29-beta-88bdefe8",
27
+ "@abtnode/logger": "1.16.29-beta-88bdefe8",
28
+ "@abtnode/models": "1.16.29-beta-88bdefe8",
29
+ "@abtnode/queue": "1.16.29-beta-88bdefe8",
30
+ "@abtnode/rbac": "1.16.29-beta-88bdefe8",
31
+ "@abtnode/router-provider": "1.16.29-beta-88bdefe8",
32
+ "@abtnode/static-server": "1.16.29-beta-88bdefe8",
33
+ "@abtnode/timemachine": "1.16.29-beta-88bdefe8",
34
+ "@abtnode/util": "1.16.29-beta-88bdefe8",
35
35
  "@arcblock/did": "1.18.123",
36
36
  "@arcblock/did-auth": "1.18.123",
37
37
  "@arcblock/did-ext": "^1.18.123",
@@ -42,12 +42,12 @@
42
42
  "@arcblock/pm2-events": "^0.0.5",
43
43
  "@arcblock/validator": "^1.18.123",
44
44
  "@arcblock/vc": "1.18.123",
45
- "@blocklet/constant": "1.16.29-beta-e04c6f40",
46
- "@blocklet/env": "1.16.29-beta-e04c6f40",
47
- "@blocklet/meta": "1.16.29-beta-e04c6f40",
48
- "@blocklet/resolver": "1.16.29-beta-e04c6f40",
49
- "@blocklet/sdk": "1.16.29-beta-e04c6f40",
50
- "@blocklet/store": "1.16.29-beta-e04c6f40",
45
+ "@blocklet/constant": "1.16.29-beta-88bdefe8",
46
+ "@blocklet/env": "1.16.29-beta-88bdefe8",
47
+ "@blocklet/meta": "1.16.29-beta-88bdefe8",
48
+ "@blocklet/resolver": "1.16.29-beta-88bdefe8",
49
+ "@blocklet/sdk": "1.16.29-beta-88bdefe8",
50
+ "@blocklet/store": "1.16.29-beta-88bdefe8",
51
51
  "@did-space/client": "^0.5.1",
52
52
  "@fidm/x509": "^1.2.1",
53
53
  "@ocap/mcrypto": "1.18.123",
@@ -103,5 +103,5 @@
103
103
  "jest": "^29.7.0",
104
104
  "unzipper": "^0.10.11"
105
105
  },
106
- "gitHead": "f3e8f2ce931215b95ada33e87aee997d8ae52a69"
106
+ "gitHead": "2a91288d21c8defe019e1debfc242b6ef708573e"
107
107
  }