@abtnode/core 1.16.17-beta-4f13d99d → 1.16.17-beta-1cab4b42

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.
@@ -177,6 +177,8 @@ const {
177
177
  getReleases,
178
178
  getRelease,
179
179
  deleteRelease,
180
+ getSelectedResources,
181
+ updateSelectedResources,
180
182
  } = require('../project');
181
183
 
182
184
  const { formatEnvironments, getBlockletMeta, validateOwner, isCLI } = util;
@@ -1923,6 +1925,14 @@ class DiskBlockletManager extends BaseBlockletManager {
1923
1925
  return deleteRelease({ did, projectId, releaseId, manager: this });
1924
1926
  }
1925
1927
 
1928
+ getSelectedResources({ did, projectId, releaseId, componentDid } = {}) {
1929
+ return getSelectedResources({ did, projectId, releaseId, componentDid, manager: this });
1930
+ }
1931
+
1932
+ updateSelectedResources({ did, projectId, releaseId, componentDid, resources } = {}) {
1933
+ return updateSelectedResources({ did, projectId, releaseId, componentDid, resources, manager: this });
1934
+ }
1935
+
1926
1936
  // ============================================================================================
1927
1937
  // Private API that are used by self of helper function
1928
1938
  // ============================================================================================
@@ -312,6 +312,58 @@ const createRelease = async ({
312
312
  }
313
313
  };
314
314
 
315
+ const getSelectedResourcesFile = ({ app, projectId, releaseId, componentDid }) => {
316
+ const { dataDir } = app.env;
317
+ const dirArr = [dataDir, PROJECT.DIR, projectId || '/'];
318
+ if (releaseId) {
319
+ dirArr.push(PROJECT.RELEASE_DIR, releaseId || '/');
320
+ }
321
+ dirArr.push(PROJECT.RESOURCE_DIR);
322
+ dirArr.push('.component_config');
323
+ dirArr.push(`${componentDid}.json`);
324
+ return path.join(...dirArr);
325
+ };
326
+
327
+ const getSelectedResources = async ({ did, projectId, releaseId, componentDid, manager }) => {
328
+ if (!projectId) {
329
+ throw new Error('projectId is required');
330
+ }
331
+
332
+ if (!componentDid) {
333
+ throw new Error('componentDid is required');
334
+ }
335
+
336
+ const app = await manager.getBlocklet(did, { useCache: true });
337
+ const file = getSelectedResourcesFile({ app, projectId, releaseId, componentDid });
338
+
339
+ if (!fs.existsSync(file)) {
340
+ return [];
341
+ }
342
+
343
+ const content = await fs.readJSON(file);
344
+ return content;
345
+ };
346
+
347
+ const updateSelectedResources = async ({ did, projectId, releaseId, componentDid, resources, manager }) => {
348
+ if (!projectId) {
349
+ throw new Error('projectId is required');
350
+ }
351
+
352
+ if (!componentDid) {
353
+ throw new Error('componentDid is required');
354
+ }
355
+
356
+ const app = await manager.getBlocklet(did, { useCache: true });
357
+ const file = getSelectedResourcesFile({ app, projectId, releaseId, componentDid });
358
+
359
+ if (fs.existsSync(file)) {
360
+ await fs.remove(file);
361
+ }
362
+
363
+ await fs.ensureDir(path.dirname(file));
364
+ await fs.outputJSON(file, resources);
365
+ };
366
+
315
367
  module.exports = {
316
368
  createProject,
317
369
  getProjects,
@@ -322,4 +374,6 @@ module.exports = {
322
374
  getReleases,
323
375
  getRelease,
324
376
  deleteRelease,
377
+ getSelectedResources,
378
+ updateSelectedResources,
325
379
  };
package/lib/index.js CHANGED
@@ -288,6 +288,8 @@ function ABTNode(options) {
288
288
  getReleases: blockletManager.getReleases.bind(blockletManager),
289
289
  getRelease: blockletManager.getRelease.bind(blockletManager),
290
290
  deleteRelease: blockletManager.deleteRelease.bind(blockletManager),
291
+ getSelectedResources: blockletManager.getSelectedResources.bind(blockletManager),
292
+ updateSelectedResources: blockletManager.updateSelectedResources.bind(blockletManager),
291
293
 
292
294
  // For diagnose purpose
293
295
  syncBlockletStatus: blockletManager.status.bind(blockletManager),
@@ -17,6 +17,7 @@ const {
17
17
  forEachComponentV2,
18
18
  forEachComponentV2Sync,
19
19
  getBlockletServices,
20
+ hasStartEngine,
20
21
  } = require('@blocklet/meta/lib/util');
21
22
  const {
22
23
  BlockletStatus,
@@ -634,7 +635,7 @@ class BlockletState extends BaseState {
634
635
  for (const child of children) {
635
636
  const { meta, mountPoint, bundleSource = null, source = '', deployedFrom = '', mode } = child;
636
637
 
637
- if (!mountPoint) {
638
+ if (hasStartEngine(meta) && !mountPoint) {
638
639
  throw new Error(`mountPoint is required when adding component ${getDisplayName(child, true)}`);
639
640
  }
640
641
 
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.16.17-beta-4f13d99d",
6
+ "version": "1.16.17-beta-1cab4b42",
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-beta-4f13d99d",
23
- "@abtnode/auth": "1.16.17-beta-4f13d99d",
24
- "@abtnode/certificate-manager": "1.16.17-beta-4f13d99d",
25
- "@abtnode/constant": "1.16.17-beta-4f13d99d",
26
- "@abtnode/cron": "1.16.17-beta-4f13d99d",
27
- "@abtnode/logger": "1.16.17-beta-4f13d99d",
28
- "@abtnode/models": "1.16.17-beta-4f13d99d",
29
- "@abtnode/queue": "1.16.17-beta-4f13d99d",
30
- "@abtnode/rbac": "1.16.17-beta-4f13d99d",
31
- "@abtnode/router-provider": "1.16.17-beta-4f13d99d",
32
- "@abtnode/static-server": "1.16.17-beta-4f13d99d",
33
- "@abtnode/timemachine": "1.16.17-beta-4f13d99d",
34
- "@abtnode/util": "1.16.17-beta-4f13d99d",
22
+ "@abtnode/analytics": "1.16.17-beta-1cab4b42",
23
+ "@abtnode/auth": "1.16.17-beta-1cab4b42",
24
+ "@abtnode/certificate-manager": "1.16.17-beta-1cab4b42",
25
+ "@abtnode/constant": "1.16.17-beta-1cab4b42",
26
+ "@abtnode/cron": "1.16.17-beta-1cab4b42",
27
+ "@abtnode/logger": "1.16.17-beta-1cab4b42",
28
+ "@abtnode/models": "1.16.17-beta-1cab4b42",
29
+ "@abtnode/queue": "1.16.17-beta-1cab4b42",
30
+ "@abtnode/rbac": "1.16.17-beta-1cab4b42",
31
+ "@abtnode/router-provider": "1.16.17-beta-1cab4b42",
32
+ "@abtnode/static-server": "1.16.17-beta-1cab4b42",
33
+ "@abtnode/timemachine": "1.16.17-beta-1cab4b42",
34
+ "@abtnode/util": "1.16.17-beta-1cab4b42",
35
35
  "@arcblock/did": "1.18.92",
36
36
  "@arcblock/did-auth": "1.18.92",
37
37
  "@arcblock/did-ext": "^1.18.92",
@@ -42,11 +42,11 @@
42
42
  "@arcblock/pm2-events": "^0.0.5",
43
43
  "@arcblock/validator": "^1.18.92",
44
44
  "@arcblock/vc": "1.18.92",
45
- "@blocklet/constant": "1.16.17-beta-4f13d99d",
46
- "@blocklet/env": "1.16.17-beta-4f13d99d",
47
- "@blocklet/meta": "1.16.17-beta-4f13d99d",
48
- "@blocklet/resolver": "1.16.17-beta-4f13d99d",
49
- "@blocklet/sdk": "1.16.17-beta-4f13d99d",
45
+ "@blocklet/constant": "1.16.17-beta-1cab4b42",
46
+ "@blocklet/env": "1.16.17-beta-1cab4b42",
47
+ "@blocklet/meta": "1.16.17-beta-1cab4b42",
48
+ "@blocklet/resolver": "1.16.17-beta-1cab4b42",
49
+ "@blocklet/sdk": "1.16.17-beta-1cab4b42",
50
50
  "@did-space/client": "^0.3.11",
51
51
  "@fidm/x509": "^1.2.1",
52
52
  "@ocap/mcrypto": "1.18.92",
@@ -101,5 +101,5 @@
101
101
  "jest": "^27.5.1",
102
102
  "unzipper": "^0.10.11"
103
103
  },
104
- "gitHead": "005478c4b14448f2ae896ae363972afbde1d7e7b"
104
+ "gitHead": "114d4fedc6b4a8034a3d2ea9e166544fb6c2588e"
105
105
  }