@blocklet/sdk 1.8.69-beta-54faead3 → 1.8.69-beta-76f8a46f
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/component/index.d.ts +1 -1
- package/lib/component/index.js +24 -15
- package/lib/database/index.js +5 -6
- package/package.json +13 -13
package/lib/component/index.d.ts
CHANGED
|
@@ -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 };
|
package/lib/component/index.js
CHANGED
|
@@ -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
|
|
54
|
-
const mountPoints =
|
|
55
|
-
mountPoints.
|
|
56
|
-
|
|
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
|
-
|
|
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/lib/database/index.js
CHANGED
|
@@ -5,12 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
6
6
|
const path_1 = __importDefault(require("path"));
|
|
7
7
|
const core_1 = require("@nedb/core");
|
|
8
|
-
// FIXME: 实例创建时才去校验 process.env.BLOCKLET_DATA_DIR
|
|
9
|
-
// if (!process.env.BLOCKLET_DATA_DIR) {
|
|
10
|
-
// throw new Error('Blocklet SDK must be used in blocklet runtime');
|
|
11
|
-
// }
|
|
12
|
-
// const DB_DIR = path.join(process.env.BLOCKLET_DATA_DIR, 'db');
|
|
13
|
-
// fs.ensureDirSync(DB_DIR);
|
|
14
8
|
class DataBase extends core_1.DataStore {
|
|
15
9
|
constructor(name, options = {}) {
|
|
16
10
|
if (!process.env.BLOCKLET_DATA_DIR) {
|
|
@@ -30,6 +24,11 @@ class DataBase extends core_1.DataStore {
|
|
|
30
24
|
},
|
|
31
25
|
...options,
|
|
32
26
|
});
|
|
27
|
+
// @ts-ignore
|
|
28
|
+
const compactInterval = typeof options.compactInterval === 'undefined' ? 60 * 60 * 1000 : +options.compactInterval;
|
|
29
|
+
if (compactInterval > 0) {
|
|
30
|
+
this.persistence.setAutoCompactionInterval(compactInterval, console.warn);
|
|
31
|
+
}
|
|
33
32
|
}
|
|
34
33
|
async exists(...args) {
|
|
35
34
|
const doc = await this.findOne(...args);
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.8.69-beta-
|
|
6
|
+
"version": "1.8.69-beta-76f8a46f",
|
|
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,18 +26,18 @@
|
|
|
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-
|
|
30
|
-
"@abtnode/constant": "1.8.69-beta-
|
|
31
|
-
"@arcblock/did-auth": "1.18.
|
|
32
|
-
"@arcblock/jwt": "1.18.
|
|
33
|
-
"@arcblock/ws": "1.18.
|
|
34
|
-
"@blocklet/constant": "1.8.69-beta-
|
|
35
|
-
"@blocklet/meta": "1.8.69-beta-
|
|
36
|
-
"@did-connect/authenticator": "^2.1.
|
|
37
|
-
"@did-connect/handler": "^2.1.
|
|
29
|
+
"@abtnode/client": "1.8.69-beta-76f8a46f",
|
|
30
|
+
"@abtnode/constant": "1.8.69-beta-76f8a46f",
|
|
31
|
+
"@arcblock/did-auth": "1.18.58",
|
|
32
|
+
"@arcblock/jwt": "1.18.58",
|
|
33
|
+
"@arcblock/ws": "1.18.58",
|
|
34
|
+
"@blocklet/constant": "1.8.69-beta-76f8a46f",
|
|
35
|
+
"@blocklet/meta": "1.8.69-beta-76f8a46f",
|
|
36
|
+
"@did-connect/authenticator": "^2.1.42",
|
|
37
|
+
"@did-connect/handler": "^2.1.42",
|
|
38
38
|
"@nedb/core": "^2.1.5",
|
|
39
|
-
"@ocap/mcrypto": "1.18.
|
|
40
|
-
"@ocap/wallet": "1.18.
|
|
39
|
+
"@ocap/mcrypto": "1.18.58",
|
|
40
|
+
"@ocap/wallet": "1.18.58",
|
|
41
41
|
"axios": "^0.27.2",
|
|
42
42
|
"cheerio": "^1.0.0-rc.12",
|
|
43
43
|
"fs-extra": "^10.1.0",
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
"ts-node": "^10.9.1",
|
|
71
71
|
"typescript": "^4.8.4"
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "07415e674443b85648ea80b734f7a3690abfc15e"
|
|
74
74
|
}
|