@blocklet/launcher-util 2.0.46 → 2.1.0
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/constant.js +13 -0
- package/lib/format-error.js +18 -0
- package/package.json +8 -4
package/lib/constant.js
CHANGED
|
@@ -18,6 +18,18 @@ const PLAN_STATUS = Object.freeze({
|
|
|
18
18
|
dropped: 30, // 已下架
|
|
19
19
|
});
|
|
20
20
|
|
|
21
|
+
const LAUNCH_STATUS = {
|
|
22
|
+
created: 0,
|
|
23
|
+
selected: 10,
|
|
24
|
+
connected: 20,
|
|
25
|
+
paid: 30,
|
|
26
|
+
allocated: 40,
|
|
27
|
+
installed: 50,
|
|
28
|
+
started: 60,
|
|
29
|
+
expired: 70,
|
|
30
|
+
timeout: 80,
|
|
31
|
+
};
|
|
32
|
+
|
|
21
33
|
const SERVER_ACTIVITY_TYPE = Object.freeze({
|
|
22
34
|
purchase: 'purchase',
|
|
23
35
|
launch: 'launch',
|
|
@@ -108,4 +120,5 @@ module.exports = Object.freeze({
|
|
|
108
120
|
NFT_TYPE_SERVERLESS,
|
|
109
121
|
BLOCKLET_SERVER_OWNERSHIP_NFT,
|
|
110
122
|
SERVERLESS_INSTANCE_STATUS,
|
|
123
|
+
LAUNCH_STATUS,
|
|
111
124
|
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const get = require('lodash.get');
|
|
2
|
+
|
|
3
|
+
module.exports = function formatError(error) {
|
|
4
|
+
if (!error) {
|
|
5
|
+
return error;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
if (Array.isArray(error.errors)) {
|
|
9
|
+
return error.errors.map((x) => x.message).join('\n');
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const dataError = get(error, 'response.data.error');
|
|
13
|
+
if (dataError) {
|
|
14
|
+
return dataError;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return error.message || error;
|
|
18
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/launcher-util",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Common constants",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"constant"
|
|
@@ -23,7 +23,8 @@
|
|
|
23
23
|
"url": "git+https://github.com/blocklet/launcher.git"
|
|
24
24
|
},
|
|
25
25
|
"scripts": {
|
|
26
|
-
"lint": "eslint
|
|
26
|
+
"lint": "eslint lib",
|
|
27
|
+
"lint:fix": "npm run lint -- --fix",
|
|
27
28
|
"test": "node jest.js --runInBand",
|
|
28
29
|
"coverage": "npm run test -- --coverage"
|
|
29
30
|
},
|
|
@@ -33,7 +34,7 @@
|
|
|
33
34
|
"dependencies": {
|
|
34
35
|
"@blocklet/sdk": "^1.16.10",
|
|
35
36
|
"@ocap/util": "^1.18.80",
|
|
36
|
-
"axios": "^0.
|
|
37
|
+
"axios": "^0.27.2",
|
|
37
38
|
"flat": "^5.0.2",
|
|
38
39
|
"lodash.get": "^4.4.2",
|
|
39
40
|
"lodash.pick": "^4.4.0",
|
|
@@ -42,5 +43,8 @@
|
|
|
42
43
|
"nodemailer": "^6.9.3",
|
|
43
44
|
"url-join": "^4.0.1"
|
|
44
45
|
},
|
|
45
|
-
"
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"jest": "^27.5.1"
|
|
48
|
+
},
|
|
49
|
+
"gitHead": "97e5570a03831f25b8ea796c9e523e65a3e821dd"
|
|
46
50
|
}
|