@blocklet/sdk 1.8.69-beta-e0666d0d → 1.8.69-beta-b0bb2d67

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.
@@ -9,13 +9,13 @@ export type MountPoint = {
9
9
  };
10
10
  declare const getChildWebEndpoint: (name: string) => string;
11
11
  declare const getParentWebEndpoint: () => string;
12
+ declare const getComponentWebEndpoint: (keyword: string) => string;
12
13
  declare const call: ({ name, path: _path, data }: {
13
14
  name?: string;
14
15
  path: string;
15
16
  data: any;
16
17
  }) => Promise<AxiosResponse<any, any>>;
17
18
  declare const getComponentMountPoint: (keyword: string) => string;
18
- declare const getComponentWebEndpoint: (keyword: string) => string;
19
19
  export { call };
20
20
  export { getComponentMountPoint };
21
21
  export { getComponentWebEndpoint };
@@ -11,6 +11,15 @@ const json_stable_stringify_1 = __importDefault(require("json-stable-stringify")
11
11
  const util_1 = require("@blocklet/meta/lib/util");
12
12
  const wallet_1 = __importDefault(require("../wallet"));
13
13
  const config_1 = require("../config");
14
+ const parseMountPoints = () => {
15
+ const mountPoints = JSON.parse(process.env.BLOCKLET_MOUNT_POINTS) || [];
16
+ mountPoints.forEach((x) => {
17
+ if (x.port) {
18
+ x.webEndpoint = `http://127.0.0.1:${x.port}`;
19
+ }
20
+ });
21
+ return mountPoints;
22
+ };
14
23
  const sign = (data) => {
15
24
  const wallet = (0, wallet_1.default)();
16
25
  const signData = typeof data === 'undefined' ? {} : data;
@@ -50,17 +59,23 @@ const getParentWebEndpoint = () => {
50
59
  return getWebEndpoint(parentName);
51
60
  };
52
61
  exports.getParentWebEndpoint = getParentWebEndpoint;
53
- const parseMountPoints = () => {
54
- const mountPoints = JSON.parse(process.env.BLOCKLET_MOUNT_POINTS) || [];
55
- mountPoints.forEach((x) => {
56
- if (x.port) {
57
- x.webEndpoint = `http://127.0.0.1:${x.port}`;
58
- }
59
- });
60
- return mountPoints;
62
+ const getComponentWebEndpoint = (keyword) => {
63
+ const mountPoints = parseMountPoints();
64
+ const item = mountPoints.find((x) => [x.title, x.name, x.did].includes(keyword));
65
+ return item ? item.webEndpoint : '';
61
66
  };
67
+ exports.getComponentWebEndpoint = getComponentWebEndpoint;
62
68
  const call = async ({ name, path: _path, data }) => {
63
- const baseURL = name ? getChildWebEndpoint(name) : getParentWebEndpoint();
69
+ let baseURL;
70
+ if (name) {
71
+ baseURL = getComponentWebEndpoint(name) || getChildWebEndpoint(name);
72
+ }
73
+ else {
74
+ baseURL = getParentWebEndpoint();
75
+ }
76
+ if (!baseURL) {
77
+ throw new Error(`can not find web endpoint for ${name}`);
78
+ }
64
79
  const url = (0, url_join_1.default)(baseURL, _path);
65
80
  return doCall({ url, data });
66
81
  };
@@ -71,12 +86,6 @@ const getComponentMountPoint = (keyword) => {
71
86
  return item ? item.mountPoint : '';
72
87
  };
73
88
  exports.getComponentMountPoint = getComponentMountPoint;
74
- const getComponentWebEndpoint = (keyword) => {
75
- const mountPoints = parseMountPoints();
76
- const item = mountPoints.find((x) => [x.title, x.name, x.did].includes(keyword));
77
- return item ? item.webEndpoint : '';
78
- };
79
- exports.getComponentWebEndpoint = getComponentWebEndpoint;
80
89
  exports.default = {
81
90
  call,
82
91
  getComponentMountPoint,
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.8.69-beta-e0666d0d",
6
+ "version": "1.8.69-beta-b0bb2d67",
7
7
  "description": "graphql client to read/write data on abt node",
8
8
  "main": "lib/index.js",
9
9
  "typings": "lib/index.d.ts",
@@ -26,13 +26,13 @@
26
26
  "author": "linchen1987 <linchen.1987@foxmail.com> (http://github.com/linchen1987)",
27
27
  "license": "MIT",
28
28
  "dependencies": {
29
- "@abtnode/client": "1.8.69-beta-e0666d0d",
30
- "@abtnode/constant": "1.8.69-beta-e0666d0d",
29
+ "@abtnode/client": "1.8.69-beta-b0bb2d67",
30
+ "@abtnode/constant": "1.8.69-beta-b0bb2d67",
31
31
  "@arcblock/did-auth": "1.18.57",
32
32
  "@arcblock/jwt": "1.18.57",
33
33
  "@arcblock/ws": "1.18.57",
34
- "@blocklet/constant": "1.8.69-beta-e0666d0d",
35
- "@blocklet/meta": "1.8.69-beta-e0666d0d",
34
+ "@blocklet/constant": "1.8.69-beta-b0bb2d67",
35
+ "@blocklet/meta": "1.8.69-beta-b0bb2d67",
36
36
  "@did-connect/authenticator": "^2.1.41",
37
37
  "@did-connect/handler": "^2.1.41",
38
38
  "@nedb/core": "^2.1.5",
@@ -70,5 +70,5 @@
70
70
  "ts-node": "^10.9.1",
71
71
  "typescript": "^4.8.4"
72
72
  },
73
- "gitHead": "acf0373591eaa3aff76483edc4e648afc543f1f7"
73
+ "gitHead": "d6853c4b55a67526748017268257b869a5092cb1"
74
74
  }