@abtnode/core 1.16.29-beta-0070353c → 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 +30 -12
- package/lib/blocklet/manager/disk.js +9 -0
- package/lib/blocklet/project/disconnect-from-store.js +11 -0
- package/lib/blocklet/project/index.js +2 -0
- package/lib/blocklet/project/util.js +9 -2
- package/lib/index.js +1 -0
- package/lib/states/audit-log.js +1 -1
- package/package.json +22 -22
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,
|
|
@@ -661,7 +662,7 @@ class TeamAPI extends EventEmitter {
|
|
|
661
662
|
* }
|
|
662
663
|
* @returns
|
|
663
664
|
*/
|
|
664
|
-
async createMemberInvitation({ teamDid, role, expireTime, remark }, context) {
|
|
665
|
+
async createMemberInvitation({ teamDid, role, expireTime, remark, sourceAppPid }, context) {
|
|
665
666
|
await this.teamManager.checkEnablePassportIssuance(teamDid);
|
|
666
667
|
|
|
667
668
|
if (expireTime && expireTime <= 0) {
|
|
@@ -696,6 +697,7 @@ class TeamAPI extends EventEmitter {
|
|
|
696
697
|
expireDate,
|
|
697
698
|
inviter: user,
|
|
698
699
|
teamDid,
|
|
700
|
+
sourceAppPid,
|
|
699
701
|
});
|
|
700
702
|
|
|
701
703
|
logger.info('Create invite member', { role, user, inviteId });
|
|
@@ -707,6 +709,7 @@ class TeamAPI extends EventEmitter {
|
|
|
707
709
|
expireDate: new Date(expireDate).toString(),
|
|
708
710
|
inviter: user,
|
|
709
711
|
teamDid,
|
|
712
|
+
sourceAppPid,
|
|
710
713
|
};
|
|
711
714
|
}
|
|
712
715
|
|
|
@@ -731,6 +734,7 @@ class TeamAPI extends EventEmitter {
|
|
|
731
734
|
teamDid: invitation.teamDid,
|
|
732
735
|
status: invitation.status,
|
|
733
736
|
receiver: invitation.receiver,
|
|
737
|
+
sourceAppPid: invitation.sourceAppPid || null,
|
|
734
738
|
};
|
|
735
739
|
}
|
|
736
740
|
|
|
@@ -749,6 +753,7 @@ class TeamAPI extends EventEmitter {
|
|
|
749
753
|
teamDid: d.teamDid,
|
|
750
754
|
status: d.status,
|
|
751
755
|
receiver: d.receiver,
|
|
756
|
+
sourceAppPid: d.sourceAppPid || null,
|
|
752
757
|
}));
|
|
753
758
|
}
|
|
754
759
|
|
|
@@ -1327,14 +1332,27 @@ class TeamAPI extends EventEmitter {
|
|
|
1327
1332
|
logger.info('add store', { teamDid, url, scope });
|
|
1328
1333
|
|
|
1329
1334
|
const urlObj = new URL(url);
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
const
|
|
1336
|
-
|
|
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}`);
|
|
1337
1354
|
}
|
|
1355
|
+
const newUrl = withoutTrailingSlash(joinURL(urlObj.origin, blockletJson?.prefix || '/'));
|
|
1338
1356
|
|
|
1339
1357
|
const sanitized = sanitizeUrl(newUrl);
|
|
1340
1358
|
|
|
@@ -1342,14 +1360,14 @@ class TeamAPI extends EventEmitter {
|
|
|
1342
1360
|
|
|
1343
1361
|
const exist = storeList.find((x) => x.url === sanitized);
|
|
1344
1362
|
if (exist) {
|
|
1345
|
-
throw new Error(`Blocklet
|
|
1363
|
+
throw new Error(`Blocklet Store already exist: ${sanitized}`);
|
|
1346
1364
|
}
|
|
1347
1365
|
|
|
1348
1366
|
const store = await StoreUtil.getStoreMeta(sanitized);
|
|
1349
1367
|
|
|
1350
1368
|
const existById = storeList.find((x) => x.id === store.id);
|
|
1351
1369
|
if (existById) {
|
|
1352
|
-
throw new Error(`Blocklet
|
|
1370
|
+
throw new Error(`Blocklet Store already exist: ${sanitized}`);
|
|
1353
1371
|
}
|
|
1354
1372
|
|
|
1355
1373
|
storeList.push({ ...store, scope, url: sanitized, protected: false });
|
|
@@ -204,6 +204,7 @@ const {
|
|
|
204
204
|
connectToStore,
|
|
205
205
|
publishToStore,
|
|
206
206
|
connectByStudio,
|
|
207
|
+
disconnectFromStore,
|
|
207
208
|
} = require('../project');
|
|
208
209
|
|
|
209
210
|
const { formatEnvironments, getBlockletMeta, validateOwner, isCLI } = util;
|
|
@@ -1983,6 +1984,10 @@ class DiskBlockletManager extends BaseBlockletManager {
|
|
|
1983
1984
|
return;
|
|
1984
1985
|
}
|
|
1985
1986
|
|
|
1987
|
+
if (getBlockletEngine(component.meta)?.interpreter === 'blocklet') {
|
|
1988
|
+
return;
|
|
1989
|
+
}
|
|
1990
|
+
|
|
1986
1991
|
try {
|
|
1987
1992
|
const status = await getProcessState(component.env.processId);
|
|
1988
1993
|
const oldStatus = component.status;
|
|
@@ -2399,6 +2404,10 @@ class DiskBlockletManager extends BaseBlockletManager {
|
|
|
2399
2404
|
return connectToStore({ ...params, manager: this });
|
|
2400
2405
|
}
|
|
2401
2406
|
|
|
2407
|
+
disconnectFromStore(params) {
|
|
2408
|
+
return disconnectFromStore({ ...params, manager: this });
|
|
2409
|
+
}
|
|
2410
|
+
|
|
2402
2411
|
connectByStudio(params, context) {
|
|
2403
2412
|
return connectByStudio({ ...params, context, manager: this });
|
|
2404
2413
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const disconnectFromStore = async ({ did, storeId, projectId, manager }) => {
|
|
2
|
+
if (!did) {
|
|
3
|
+
throw new Error('Invalid did');
|
|
4
|
+
}
|
|
5
|
+
const { projectState } = await manager._getProjectState(did);
|
|
6
|
+
const project = await projectState.findOne({ id: projectId });
|
|
7
|
+
project.connectedStores = (project.connectedStores || []).filter((x) => x.storeId !== storeId);
|
|
8
|
+
await projectState.updateProject(projectId, project);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
module.exports = disconnectFromStore;
|
|
@@ -28,6 +28,7 @@ const createPackRelease = require('./create-pack-release');
|
|
|
28
28
|
const connectToStore = require('./connect-to-store');
|
|
29
29
|
const publishToStore = require('./publish-to-store');
|
|
30
30
|
const connectByStudio = require('./connect-by-studio');
|
|
31
|
+
const disconnectFromStore = require('./disconnect-from-store');
|
|
31
32
|
|
|
32
33
|
const COMPONENT_CONFIG_MAP_DIR = '.component_config';
|
|
33
34
|
|
|
@@ -528,6 +529,7 @@ module.exports = {
|
|
|
528
529
|
updateSelectedResources: ensureProjectCreateBy(updateSelectedResources),
|
|
529
530
|
deleteProject,
|
|
530
531
|
connectToStore,
|
|
532
|
+
disconnectFromStore,
|
|
531
533
|
connectByStudio,
|
|
532
534
|
publishToStore,
|
|
533
535
|
};
|
|
@@ -161,10 +161,17 @@ const checkUploadExists = async (projectDir, action, releaseId, uploadedResource
|
|
|
161
161
|
}
|
|
162
162
|
fs.ensureDirSync(resourceDir);
|
|
163
163
|
|
|
164
|
-
|
|
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(
|
|
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/lib/index.js
CHANGED
|
@@ -346,6 +346,7 @@ function ABTNode(options) {
|
|
|
346
346
|
updateProject: blockletManager.updateProject.bind(blockletManager),
|
|
347
347
|
createRelease: blockletManager.createRelease.bind(blockletManager),
|
|
348
348
|
connectToStore: blockletManager.connectToStore.bind(blockletManager),
|
|
349
|
+
disconnectFromStore: blockletManager.disconnectFromStore.bind(blockletManager),
|
|
349
350
|
connectByStudio: blockletManager.connectByStudio.bind(blockletManager),
|
|
350
351
|
publishToStore: blockletManager.publishToStore.bind(blockletManager),
|
|
351
352
|
getReleases: blockletManager.getReleases.bind(blockletManager),
|
package/lib/states/audit-log.js
CHANGED
|
@@ -273,7 +273,7 @@ ${JSON.stringify(syncData, null, 2)}
|
|
|
273
273
|
case 'deletePassportIssuance':
|
|
274
274
|
return `removed passport issuance ${args.sessionId}`;
|
|
275
275
|
case 'createMemberInvitation':
|
|
276
|
-
return `created member invitation(${result.inviteId}: ${args.remark}) with **${args.role}** passport`; // prettier-ignore
|
|
276
|
+
return `created member invitation(${result.inviteId}: ${args.remark}) with **${args.role}** passport(within app: ${args.sourceAppPid})`; // prettier-ignore
|
|
277
277
|
case 'deleteInvitation':
|
|
278
278
|
return `removed unused member invitation(${args.inviteId})`;
|
|
279
279
|
case 'createRole':
|
package/package.json
CHANGED
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.16.29-beta-
|
|
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-
|
|
23
|
-
"@abtnode/auth": "1.16.29-beta-
|
|
24
|
-
"@abtnode/certificate-manager": "1.16.29-beta-
|
|
25
|
-
"@abtnode/constant": "1.16.29-beta-
|
|
26
|
-
"@abtnode/cron": "1.16.29-beta-
|
|
27
|
-
"@abtnode/logger": "1.16.29-beta-
|
|
28
|
-
"@abtnode/models": "1.16.29-beta-
|
|
29
|
-
"@abtnode/queue": "1.16.29-beta-
|
|
30
|
-
"@abtnode/rbac": "1.16.29-beta-
|
|
31
|
-
"@abtnode/router-provider": "1.16.29-beta-
|
|
32
|
-
"@abtnode/static-server": "1.16.29-beta-
|
|
33
|
-
"@abtnode/timemachine": "1.16.29-beta-
|
|
34
|
-
"@abtnode/util": "1.16.29-beta-
|
|
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-
|
|
46
|
-
"@blocklet/env": "1.16.29-beta-
|
|
47
|
-
"@blocklet/meta": "1.16.29-beta-
|
|
48
|
-
"@blocklet/resolver": "1.16.29-beta-
|
|
49
|
-
"@blocklet/sdk": "1.16.29-beta-
|
|
50
|
-
"@blocklet/store": "1.16.29-beta-
|
|
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": "
|
|
106
|
+
"gitHead": "2a91288d21c8defe019e1debfc242b6ef708573e"
|
|
107
107
|
}
|