@cloudbase/manager-node 4.2.3 → 4.2.4
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/CHANGELOG.md +4 -0
- package/package.json +4 -3
- package/lib/access/index.js +0 -141
- package/lib/access/types.js +0 -2
- package/lib/billing/index.js +0 -36
- package/lib/cam/index.js +0 -77
- package/lib/cloudBaseRun/index.js +0 -36
- package/lib/cloudBaseRun/types.js +0 -2
- package/lib/common/index.js +0 -39
- package/lib/constant.js +0 -51
- package/lib/context.js +0 -14
- package/lib/database/index.js +0 -244
- package/lib/debug.js +0 -34
- package/lib/env/index.js +0 -488
- package/lib/environment.js +0 -124
- package/lib/environmentManager.js +0 -44
- package/lib/error.js +0 -16
- package/lib/function/index.js +0 -1022
- package/lib/function/packer.js +0 -129
- package/lib/function/types.js +0 -2
- package/lib/hosting/index.js +0 -461
- package/lib/index.js +0 -83
- package/lib/interfaces/base.interface.js +0 -2
- package/lib/interfaces/billing.interface.js +0 -2
- package/lib/interfaces/cam.interface.js +0 -2
- package/lib/interfaces/flexdb.interface.js +0 -2
- package/lib/interfaces/function.interface.js +0 -2
- package/lib/interfaces/index.js +0 -19
- package/lib/interfaces/storage.interface.js +0 -2
- package/lib/interfaces/tcb.interface.js +0 -2
- package/lib/storage/index.js +0 -1037
- package/lib/third/index.js +0 -18
- package/lib/user/index.js +0 -136
- package/lib/user/types.js +0 -2
- package/lib/utils/auth.js +0 -97
- package/lib/utils/cloud-api-request.js +0 -205
- package/lib/utils/cloudbase-request.js +0 -69
- package/lib/utils/envLazy.js +0 -18
- package/lib/utils/fs.js +0 -64
- package/lib/utils/http-request.js +0 -44
- package/lib/utils/index.js +0 -103
- package/lib/utils/parallel.js +0 -69
- package/lib/utils/uuid.js +0 -18
- package/src/access/index.ts +0 -168
- package/src/access/types.ts +0 -55
- package/src/billing/index.ts +0 -43
- package/src/cam/index.ts +0 -106
- package/src/cloudBaseRun/index.ts +0 -40
- package/src/cloudBaseRun/types.ts +0 -24
- package/src/common/index.ts +0 -54
- package/src/constant.ts +0 -56
- package/src/context.ts +0 -18
- package/src/database/index.ts +0 -369
- package/src/debug.ts +0 -34
- package/src/env/index.ts +0 -614
- package/src/environment.ts +0 -156
- package/src/environmentManager.ts +0 -50
- package/src/error.ts +0 -27
- package/src/function/index.ts +0 -1378
- package/src/function/packer.ts +0 -164
- package/src/function/types.ts +0 -165
- package/src/hosting/index.ts +0 -698
- package/src/index.ts +0 -127
- package/src/interfaces/base.interface.ts +0 -8
- package/src/interfaces/billing.interface.ts +0 -21
- package/src/interfaces/cam.interface.ts +0 -28
- package/src/interfaces/flexdb.interface.ts +0 -104
- package/src/interfaces/function.interface.ts +0 -75
- package/src/interfaces/index.ts +0 -7
- package/src/interfaces/storage.interface.ts +0 -29
- package/src/interfaces/tcb.interface.ts +0 -642
- package/src/storage/index.ts +0 -1290
- package/src/third/index.ts +0 -24
- package/src/user/index.ts +0 -174
- package/src/user/types.ts +0 -21
- package/src/utils/auth.ts +0 -112
- package/src/utils/cloud-api-request.ts +0 -252
- package/src/utils/cloudbase-request.ts +0 -109
- package/src/utils/envLazy.ts +0 -15
- package/src/utils/fs.ts +0 -57
- package/src/utils/http-request.ts +0 -37
- package/src/utils/index.ts +0 -103
- package/src/utils/parallel.ts +0 -82
- package/src/utils/uuid.ts +0 -14
- package/types/access/index.d.ts +0 -38
- package/types/access/types.d.ts +0 -42
- package/types/billing/index.d.ts +0 -21
- package/types/cam/index.d.ts +0 -63
- package/types/cloudBaseRun/index.d.ts +0 -12
- package/types/cloudBaseRun/types.d.ts +0 -21
- package/types/common/index.d.ts +0 -18
- package/types/constant.d.ts +0 -37
- package/types/context.d.ts +0 -17
- package/types/database/index.d.ts +0 -66
- package/types/debug.d.ts +0 -1
- package/types/env/index.d.ts +0 -144
- package/types/environment.d.ts +0 -51
- package/types/environmentManager.d.ts +0 -13
- package/types/error.d.ts +0 -18
- package/types/function/index.d.ts +0 -379
- package/types/function/packer.d.ts +0 -37
- package/types/function/types.d.ts +0 -156
- package/types/hosting/index.d.ts +0 -253
- package/types/index.d.ts +0 -52
- package/types/interfaces/base.interface.d.ts +0 -7
- package/types/interfaces/billing.interface.d.ts +0 -18
- package/types/interfaces/cam.interface.d.ts +0 -24
- package/types/interfaces/flexdb.interface.d.ts +0 -67
- package/types/interfaces/function.interface.d.ts +0 -65
- package/types/interfaces/index.d.ts +0 -7
- package/types/interfaces/storage.interface.d.ts +0 -26
- package/types/interfaces/tcb.interface.d.ts +0 -305
- package/types/storage/index.d.ts +0 -324
- package/types/third/index.d.ts +0 -11
- package/types/user/index.d.ts +0 -52
- package/types/user/types.d.ts +0 -20
- package/types/utils/auth.d.ts +0 -8
- package/types/utils/cloud-api-request.d.ts +0 -21
- package/types/utils/cloudbase-request.d.ts +0 -14
- package/types/utils/envLazy.d.ts +0 -1
- package/types/utils/fs.d.ts +0 -7
- package/types/utils/http-request.d.ts +0 -2
- package/types/utils/index.d.ts +0 -20
- package/types/utils/parallel.d.ts +0 -17
- package/types/utils/uuid.d.ts +0 -2
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/manager-node",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.4",
|
|
4
4
|
"description": "The node manage service api for cloudbase.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
"test": "jest --runInBand --detectOpenHandles --coverage --testTimeout=50000",
|
|
9
9
|
"lint": "eslint \"./**/*.ts\"",
|
|
10
10
|
"lint:fix": "eslint --fix \"./**/*.ts\"",
|
|
11
|
-
"prepublishOnly": "npm run build"
|
|
11
|
+
"prepublishOnly": "npm run build",
|
|
12
|
+
"watch": "rimraf lib types && tsc -w"
|
|
12
13
|
},
|
|
13
14
|
"repository": {
|
|
14
15
|
"type": "git",
|
|
@@ -37,7 +38,7 @@
|
|
|
37
38
|
"archiver": "^3.1.1",
|
|
38
39
|
"cos-nodejs-sdk-v5": "2.9.0",
|
|
39
40
|
"del": "^5.1.0",
|
|
40
|
-
"https-proxy-agent": "^
|
|
41
|
+
"https-proxy-agent": "^5.0.1",
|
|
41
42
|
"make-dir": "^3.0.0",
|
|
42
43
|
"micromatch": "^4.0.2",
|
|
43
44
|
"node-fetch": "^2.6.0",
|
package/lib/access/index.js
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.AccessService = void 0;
|
|
10
|
-
const utils_1 = require("../utils");
|
|
11
|
-
class AccessService {
|
|
12
|
-
constructor(environment) {
|
|
13
|
-
this.environment = environment;
|
|
14
|
-
this.tcbService = new utils_1.CloudService(environment.cloudBaseContext, 'tcb', '2018-06-08');
|
|
15
|
-
}
|
|
16
|
-
// 创建云接入路径
|
|
17
|
-
async createAccess(options) {
|
|
18
|
-
const { path, name, type = 1, auth } = options;
|
|
19
|
-
const { envId } = this.getEnvInfo();
|
|
20
|
-
return this.tcbService.request('CreateCloudBaseGWAPI', {
|
|
21
|
-
ServiceId: envId,
|
|
22
|
-
Path: path,
|
|
23
|
-
Type: type,
|
|
24
|
-
Name: name,
|
|
25
|
-
AuthSwitch: auth ? 1 : 2
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
// 获取云接入自定义域名列表
|
|
29
|
-
async getDomainList() {
|
|
30
|
-
const { envId } = this.getEnvInfo();
|
|
31
|
-
return this.tcbService.request('DescribeCloudBaseGWService', {
|
|
32
|
-
ServiceId: envId
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
// 获取云接入服务列表
|
|
36
|
-
async getAccessList(options = {}) {
|
|
37
|
-
const { path, name, offset, limit } = options;
|
|
38
|
-
const { envId } = this.getEnvInfo();
|
|
39
|
-
return this.tcbService.request('DescribeCloudBaseGWAPI', {
|
|
40
|
-
ServiceId: envId,
|
|
41
|
-
Path: path,
|
|
42
|
-
Name: name,
|
|
43
|
-
Offset: offset,
|
|
44
|
-
limit: limit
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
// 切换云接入服务开关:开启/关闭
|
|
48
|
-
async switchAuth(auth) {
|
|
49
|
-
const { envId } = this.getEnvInfo();
|
|
50
|
-
return this.tcbService.request('ModifyCloudBaseGWPrivilege', {
|
|
51
|
-
ServiceId: envId,
|
|
52
|
-
EnableService: auth,
|
|
53
|
-
Options: [
|
|
54
|
-
{
|
|
55
|
-
Key: 'serviceswitch',
|
|
56
|
-
Value: auth ? 'true' : 'false'
|
|
57
|
-
}
|
|
58
|
-
]
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
// 更新云接入路径鉴权
|
|
62
|
-
async switchPathAuth(options) {
|
|
63
|
-
const { apiIds, auth } = options;
|
|
64
|
-
const { envId } = this.getEnvInfo();
|
|
65
|
-
return this.tcbService.request('ModifyCloudBaseGWAPIPrivilegeBatch', {
|
|
66
|
-
ServiceId: envId,
|
|
67
|
-
APIIdSet: apiIds,
|
|
68
|
-
Options: [
|
|
69
|
-
{
|
|
70
|
-
Key: 'authswitch',
|
|
71
|
-
Value: auth ? 'true' : 'false'
|
|
72
|
-
}
|
|
73
|
-
]
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
// 删除云接入服务
|
|
77
|
-
async deleteAccess(options) {
|
|
78
|
-
const { name, type = 1, apiId } = options;
|
|
79
|
-
const { envId } = this.getEnvInfo();
|
|
80
|
-
return this.tcbService.request('DeleteCloudBaseGWAPI', {
|
|
81
|
-
ServiceId: envId,
|
|
82
|
-
Name: name,
|
|
83
|
-
Type: type,
|
|
84
|
-
APIId: apiId
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
// 添加自定义域名
|
|
88
|
-
async addCustomDomain(options) {
|
|
89
|
-
const { domain, certId } = options;
|
|
90
|
-
const { envId } = this.getEnvInfo();
|
|
91
|
-
return this.tcbService.request('BindCloudBaseGWDomain', {
|
|
92
|
-
Domain: domain,
|
|
93
|
-
ServiceId: envId,
|
|
94
|
-
CertId: certId
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
// 删除自定义域名
|
|
98
|
-
async deleteCustomDomain(domain) {
|
|
99
|
-
const { envId } = this.getEnvInfo();
|
|
100
|
-
return this.tcbService.request('DeleteCloudBaseGWDomain', {
|
|
101
|
-
Domain: domain,
|
|
102
|
-
ServiceId: envId
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
getEnvInfo() {
|
|
106
|
-
var _a;
|
|
107
|
-
const envConfig = this.environment.lazyEnvironmentConfig;
|
|
108
|
-
const appId = (_a = envConfig.Storages[0]) === null || _a === void 0 ? void 0 : _a.AppId;
|
|
109
|
-
const { proxy } = this.environment.cloudBaseContext;
|
|
110
|
-
return {
|
|
111
|
-
appId,
|
|
112
|
-
proxy,
|
|
113
|
-
envId: envConfig.EnvId
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
__decorate([
|
|
118
|
-
utils_1.preLazy()
|
|
119
|
-
], AccessService.prototype, "createAccess", null);
|
|
120
|
-
__decorate([
|
|
121
|
-
utils_1.preLazy()
|
|
122
|
-
], AccessService.prototype, "getDomainList", null);
|
|
123
|
-
__decorate([
|
|
124
|
-
utils_1.preLazy()
|
|
125
|
-
], AccessService.prototype, "getAccessList", null);
|
|
126
|
-
__decorate([
|
|
127
|
-
utils_1.preLazy()
|
|
128
|
-
], AccessService.prototype, "switchAuth", null);
|
|
129
|
-
__decorate([
|
|
130
|
-
utils_1.preLazy()
|
|
131
|
-
], AccessService.prototype, "switchPathAuth", null);
|
|
132
|
-
__decorate([
|
|
133
|
-
utils_1.preLazy()
|
|
134
|
-
], AccessService.prototype, "deleteAccess", null);
|
|
135
|
-
__decorate([
|
|
136
|
-
utils_1.preLazy()
|
|
137
|
-
], AccessService.prototype, "addCustomDomain", null);
|
|
138
|
-
__decorate([
|
|
139
|
-
utils_1.preLazy()
|
|
140
|
-
], AccessService.prototype, "deleteCustomDomain", null);
|
|
141
|
-
exports.AccessService = AccessService;
|
package/lib/access/types.js
DELETED
package/lib/billing/index.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BillingService = void 0;
|
|
4
|
-
const utils_1 = require("../utils");
|
|
5
|
-
class BillingService {
|
|
6
|
-
constructor(context) {
|
|
7
|
-
this.billService = new utils_1.CloudService(context, BillingService.billServiceVersion.service, BillingService.billServiceVersion.version);
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* 创建订单
|
|
11
|
-
* @param {Array<IGoodItem>} goods
|
|
12
|
-
* @returns {Promise<IGenerateDealsRes>}
|
|
13
|
-
* @memberof BillingService
|
|
14
|
-
*/
|
|
15
|
-
async GenerateDeals(goods) {
|
|
16
|
-
return this.billService.request('GenerateDeals', {
|
|
17
|
-
Goods: goods
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* 支付订单
|
|
22
|
-
* @param {Array<string>} orderIds
|
|
23
|
-
* @returns {Promise<IPayDealsRes>}
|
|
24
|
-
* @memberof BillingService
|
|
25
|
-
*/
|
|
26
|
-
async PayDeals(orderIds) {
|
|
27
|
-
return this.billService.request('PayDeals', {
|
|
28
|
-
OrderIds: orderIds
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
exports.BillingService = BillingService;
|
|
33
|
-
BillingService.billServiceVersion = {
|
|
34
|
-
service: 'billing',
|
|
35
|
-
version: '2018-07-09'
|
|
36
|
-
};
|
package/lib/cam/index.js
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CamService = void 0;
|
|
4
|
-
const utils_1 = require("../utils");
|
|
5
|
-
class CamService {
|
|
6
|
-
constructor(context) {
|
|
7
|
-
this.camService = new utils_1.CloudService(context, CamService.camServiceVersion.service, CamService.camServiceVersion.version);
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* 查询账户角色列表
|
|
11
|
-
* @param {number} page
|
|
12
|
-
* @param {number} rp
|
|
13
|
-
* @returns {Promise<IRoleListRes>}
|
|
14
|
-
* @memberof CamService
|
|
15
|
-
*/
|
|
16
|
-
async describeRoleList(page, rp) {
|
|
17
|
-
return this.camService.request('DescribeRoleList', {
|
|
18
|
-
Page: page,
|
|
19
|
-
Rp: rp
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* 获取角色详情
|
|
24
|
-
* @param {string} roleName
|
|
25
|
-
* @returns {Promise<IGetRoleRes>}
|
|
26
|
-
* @memberof CamService
|
|
27
|
-
*/
|
|
28
|
-
async getRole(roleName) {
|
|
29
|
-
return this.camService.request('GetRole', {
|
|
30
|
-
RoleName: roleName
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* 创建角色
|
|
35
|
-
* @param {{
|
|
36
|
-
* RoleName: string
|
|
37
|
-
* PolicyDocument: string
|
|
38
|
-
* Description: string
|
|
39
|
-
* }} param
|
|
40
|
-
* @returns {Promise<ICreateRoleRes>}
|
|
41
|
-
* @memberof CamService
|
|
42
|
-
*/
|
|
43
|
-
async createRole(param) {
|
|
44
|
-
return this.camService.request('CreateRole', param);
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* 绑定角色策略
|
|
48
|
-
* @param {{
|
|
49
|
-
* PolicyId: number
|
|
50
|
-
* AttachRoleName: string
|
|
51
|
-
* }} param
|
|
52
|
-
* @returns {Promise<IResponseInfo>}
|
|
53
|
-
* @memberof CamService
|
|
54
|
-
*/
|
|
55
|
-
async attachRolePolicy(param) {
|
|
56
|
-
return this.camService.request('AttachRolePolicy', param);
|
|
57
|
-
}
|
|
58
|
-
async attachRolePolicies(param) {
|
|
59
|
-
return this.camService.request('AttachRolePolicies', param);
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* 删除角色
|
|
63
|
-
* @param {string} roleName
|
|
64
|
-
* @returns {Promise<IResponseInfo>}
|
|
65
|
-
* @memberof CamService
|
|
66
|
-
*/
|
|
67
|
-
async deleteRole(roleName) {
|
|
68
|
-
return this.camService.request('DeleteRole', {
|
|
69
|
-
RoleName: roleName
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
exports.CamService = CamService;
|
|
74
|
-
CamService.camServiceVersion = {
|
|
75
|
-
service: 'cam',
|
|
76
|
-
version: '2019-01-16'
|
|
77
|
-
};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.CloudBaseRunService = void 0;
|
|
10
|
-
const utils_1 = require("../utils");
|
|
11
|
-
class CloudBaseRunService {
|
|
12
|
-
constructor(environment) {
|
|
13
|
-
this.environment = environment;
|
|
14
|
-
this.tcbService = new utils_1.CloudService(environment.cloudBaseContext, 'tcb', '2018-06-08');
|
|
15
|
-
}
|
|
16
|
-
// 修改容器内版本流量配置
|
|
17
|
-
async modifyServerFlow(options) {
|
|
18
|
-
const { envId } = this.getEnvInfo();
|
|
19
|
-
return this.tcbService.request('ModifyCloudBaseRunServerFlowConf', {
|
|
20
|
-
EnvId: envId,
|
|
21
|
-
ServerName: options.serverName,
|
|
22
|
-
VersionFlowItems: utils_1.upperCaseObjKey(options.versionFlowItems)
|
|
23
|
-
// TrafficType: options.trafficType
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
getEnvInfo() {
|
|
27
|
-
const envConfig = this.environment.lazyEnvironmentConfig;
|
|
28
|
-
return {
|
|
29
|
-
envId: envConfig.EnvId
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
__decorate([
|
|
34
|
-
utils_1.preLazy()
|
|
35
|
-
], CloudBaseRunService.prototype, "modifyServerFlow", null);
|
|
36
|
-
exports.CloudBaseRunService = CloudBaseRunService;
|
package/lib/common/index.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CommonService = void 0;
|
|
4
|
-
const utils_1 = require("../utils");
|
|
5
|
-
const error_1 = require("../error");
|
|
6
|
-
/**
|
|
7
|
-
* 公共的云api调用方法 透传用户参数 无业务逻辑处理
|
|
8
|
-
* @export
|
|
9
|
-
* @class CommonService
|
|
10
|
-
*/
|
|
11
|
-
const ActionVersionMap = {
|
|
12
|
-
tcb: '2018-06-08',
|
|
13
|
-
flexdb: '2018-11-27',
|
|
14
|
-
scf: '2018-04-16',
|
|
15
|
-
sts: '2018-04-16',
|
|
16
|
-
cam: '2018-04-16',
|
|
17
|
-
lowcode: '2021-01-08'
|
|
18
|
-
};
|
|
19
|
-
class CommonService {
|
|
20
|
-
constructor(environment, serviceType, serviceVersion) {
|
|
21
|
-
this.environment = environment;
|
|
22
|
-
this.commonService = new utils_1.CloudService(environment.cloudBaseContext, serviceType, serviceVersion || ActionVersionMap[serviceType]);
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* 公共方法调用
|
|
26
|
-
* @param {ICommonApiServiceParam} param
|
|
27
|
-
* @returns {Promise<any>}
|
|
28
|
-
* @memberof CommonService
|
|
29
|
-
*/
|
|
30
|
-
async call(options) {
|
|
31
|
-
const { Action, Param = {} } = options;
|
|
32
|
-
if (!Action) {
|
|
33
|
-
throw new error_1.CloudBaseError('缺少必填参数 Action');
|
|
34
|
-
}
|
|
35
|
-
const res = await this.commonService.request(Action, Object.assign({}, Param));
|
|
36
|
-
return res;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
exports.CommonService = CommonService;
|
package/lib/constant.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// // cloudbase cli 配置的字段名
|
|
3
|
-
// export class ConfigItems {
|
|
4
|
-
// static credentail = 'credential'
|
|
5
|
-
// }
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.SCF_STATUS = exports.ROLE_NAME = exports.PUBLIC_RSA_KEY = exports.ERROR = exports.SERVICE_TYPE = exports.ENDPOINT = exports.RUN_ENV = exports.SDK_VERSION = exports.ENV_NAME = void 0;
|
|
8
|
-
exports.ENV_NAME = {
|
|
9
|
-
ENV_SECRETID: 'TENCENTCLOUD_SECRETID',
|
|
10
|
-
ENV_SECRETKEY: 'TENCENTCLOUD_SECRETKEY',
|
|
11
|
-
ENV_SESSIONTOKEN: 'TENCENTCLOUD_SESSIONTOKEN',
|
|
12
|
-
ENV_TCB_ENV_ID: 'TENCENTCLOUD_TCB_ENVID',
|
|
13
|
-
ENV_RUNENV: 'TENCENTCLOUD_RUNENV',
|
|
14
|
-
ENV_RUNENV_SCF: 'TENCENTCLOUD_RUNENV=SCF'
|
|
15
|
-
};
|
|
16
|
-
exports.SDK_VERSION = 'TCB-NODE-MANAGER/1.0.O';
|
|
17
|
-
exports.RUN_ENV = {
|
|
18
|
-
SCF: 'SCF'
|
|
19
|
-
};
|
|
20
|
-
exports.ENDPOINT = {
|
|
21
|
-
TCB: 'tcb.tencentcloudapi.com',
|
|
22
|
-
SCF: 'scf.tencentcloudapi.com',
|
|
23
|
-
COS: 'cos.tencentcloudapi.com',
|
|
24
|
-
FLEXDB: 'flexdb.tencentcloudapi.com'
|
|
25
|
-
};
|
|
26
|
-
exports.SERVICE_TYPE = {
|
|
27
|
-
TCB: 'tcb'
|
|
28
|
-
};
|
|
29
|
-
exports.ERROR = {
|
|
30
|
-
MISS_SECRET_INFO_IN_ENV: 'MISS_SECRET_INFO_IN_ENV',
|
|
31
|
-
MISS_SECRET_INFO_IN_ARGS: 'MISS_SECRET_INFO_IN_ARGS',
|
|
32
|
-
CURRENT_ENVIRONMENT_IS_NULL: 'CURRENT_ENVIRONMENT_IS_NULL',
|
|
33
|
-
ENV_ID_NOT_EXISTS: 'ENV_ID_NOT_EXISTS'
|
|
34
|
-
};
|
|
35
|
-
exports.PUBLIC_RSA_KEY = `
|
|
36
|
-
-----BEGIN PUBLIC KEY-----
|
|
37
|
-
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC0ZLB0ZpWWFsHPnDDw++Nc2wI3
|
|
38
|
-
nl2uyOrIJ5FUfxt4GAmt1Faf5pgMxAnL9exEUrrUDUX8Ri1R0KyfnHQQwCvKt8T8
|
|
39
|
-
bgILIJe9UB8e9dvFqgqH2oA8Vqwi0YqDcvFLFJk2BJbm/0QYtZ563FumW8LEXAgu
|
|
40
|
-
UeHi/0OZN9vQ33jWMQIDAQAB
|
|
41
|
-
-----END PUBLIC KEY-----
|
|
42
|
-
`;
|
|
43
|
-
exports.ROLE_NAME = {
|
|
44
|
-
TCB: 'TCB_QcsRole'
|
|
45
|
-
};
|
|
46
|
-
exports.SCF_STATUS = {
|
|
47
|
-
ACTIVE: 'Active',
|
|
48
|
-
CREATING: 'Creating',
|
|
49
|
-
UPDATING: 'Updating',
|
|
50
|
-
CREATE_FAILED: 'CreateFailed'
|
|
51
|
-
};
|
package/lib/context.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CloudBaseContext = void 0;
|
|
4
|
-
class CloudBaseContext {
|
|
5
|
-
constructor({ secretId = '', secretKey = '', token = '', proxy = '', region = '', envType = '' }) {
|
|
6
|
-
this.secretId = secretId;
|
|
7
|
-
this.secretKey = secretKey;
|
|
8
|
-
this.token = token;
|
|
9
|
-
this.proxy = proxy;
|
|
10
|
-
this.region = region;
|
|
11
|
-
this.envType = envType;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
exports.CloudBaseContext = CloudBaseContext;
|
package/lib/database/index.js
DELETED
|
@@ -1,244 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.DatabaseService = void 0;
|
|
13
|
-
const path_1 = __importDefault(require("path"));
|
|
14
|
-
const error_1 = require("../error");
|
|
15
|
-
const utils_1 = require("../utils");
|
|
16
|
-
function preLazy() {
|
|
17
|
-
return function (target, propertyKey, descriptor) {
|
|
18
|
-
let oldFunc = descriptor.value;
|
|
19
|
-
descriptor.value = async function () {
|
|
20
|
-
// 检查当前环境对象上是否已加载好环境信息
|
|
21
|
-
const currentEnvironment = this.environment;
|
|
22
|
-
if (!currentEnvironment.inited) {
|
|
23
|
-
await currentEnvironment.lazyInit();
|
|
24
|
-
}
|
|
25
|
-
let result = await oldFunc.apply(this, arguments);
|
|
26
|
-
return result;
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
class DatabaseService {
|
|
31
|
-
constructor(environment) {
|
|
32
|
-
this.DEFAULT_MGO_OFFSET = 0;
|
|
33
|
-
this.DEFAULT_MGO_LIMIT = 100;
|
|
34
|
-
this.environment = environment;
|
|
35
|
-
this.envId = environment.getEnvId();
|
|
36
|
-
this.dbOpService = new utils_1.CloudService(environment.cloudBaseContext, DatabaseService.tcbServiceVersion.service, DatabaseService.tcbServiceVersion.version);
|
|
37
|
-
this.collOpService = new utils_1.CloudService(environment.cloudBaseContext, DatabaseService.flexdbServiceVersion.service, DatabaseService.flexdbServiceVersion.version);
|
|
38
|
-
}
|
|
39
|
-
getCurrEnvironment() {
|
|
40
|
-
return this.environment;
|
|
41
|
-
}
|
|
42
|
-
getDatabaseConfig() {
|
|
43
|
-
const currEnv = this.environment;
|
|
44
|
-
const { Databases } = currEnv.lazyEnvironmentConfig;
|
|
45
|
-
return {
|
|
46
|
-
Tag: Databases[0].InstanceId
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
async checkCollectionExists(collectionName) {
|
|
50
|
-
try {
|
|
51
|
-
const result = await this.describeCollection(collectionName);
|
|
52
|
-
return {
|
|
53
|
-
RequestId: result.RequestId,
|
|
54
|
-
Exists: true
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
catch (e) {
|
|
58
|
-
return {
|
|
59
|
-
RequestId: e.requestId,
|
|
60
|
-
Msg: e.message,
|
|
61
|
-
Exists: false
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
async createCollection(collectionName) {
|
|
66
|
-
let { Tag } = this.getDatabaseConfig();
|
|
67
|
-
const res = await this.collOpService.request('CreateTable', {
|
|
68
|
-
Tag,
|
|
69
|
-
TableName: collectionName
|
|
70
|
-
});
|
|
71
|
-
return res;
|
|
72
|
-
}
|
|
73
|
-
async deleteCollection(collectionName) {
|
|
74
|
-
// 先检查当前集合是否存在
|
|
75
|
-
const existRes = await this.checkCollectionExists(collectionName);
|
|
76
|
-
if (existRes.Exists) {
|
|
77
|
-
let { Tag } = this.getDatabaseConfig();
|
|
78
|
-
const res = await this.collOpService.request('DeleteTable', {
|
|
79
|
-
Tag,
|
|
80
|
-
TableName: collectionName
|
|
81
|
-
});
|
|
82
|
-
return res;
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
return existRes;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
async updateCollection(collectionName, indexiesInfo) {
|
|
89
|
-
let { Tag } = this.getDatabaseConfig();
|
|
90
|
-
const res = await this.collOpService.request('UpdateTable', Object.assign({ Tag, TableName: collectionName }, indexiesInfo));
|
|
91
|
-
return res;
|
|
92
|
-
}
|
|
93
|
-
async describeCollection(collectionName) {
|
|
94
|
-
let { Tag } = this.getDatabaseConfig();
|
|
95
|
-
return this.collOpService.request('DescribeTable', {
|
|
96
|
-
Tag,
|
|
97
|
-
TableName: collectionName
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
// 获取
|
|
101
|
-
async listCollections(options = {
|
|
102
|
-
MgoLimit: this.DEFAULT_MGO_LIMIT,
|
|
103
|
-
MgoOffset: this.DEFAULT_MGO_OFFSET
|
|
104
|
-
}) {
|
|
105
|
-
let { Tag } = this.getDatabaseConfig();
|
|
106
|
-
if (options.MgoLimit === undefined) {
|
|
107
|
-
options.MgoLimit = this.DEFAULT_MGO_LIMIT;
|
|
108
|
-
}
|
|
109
|
-
if (options.MgoOffset === undefined) {
|
|
110
|
-
options.MgoOffset = this.DEFAULT_MGO_OFFSET;
|
|
111
|
-
}
|
|
112
|
-
const res = await this.collOpService.request('ListTables', Object.assign({ Tag }, options));
|
|
113
|
-
if (res.Tables === null) {
|
|
114
|
-
// 无集合
|
|
115
|
-
res.Collections = [];
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
// 云 API 返回转换为与TCB一致
|
|
119
|
-
res.Collections = res.Tables.map(item => {
|
|
120
|
-
item.CollectionName = item.TableName;
|
|
121
|
-
delete item.TableName;
|
|
122
|
-
return item;
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
delete res.Tables;
|
|
126
|
-
return res;
|
|
127
|
-
}
|
|
128
|
-
async createCollectionIfNotExists(collectionName) {
|
|
129
|
-
const existRes = await this.checkCollectionExists(collectionName);
|
|
130
|
-
let res;
|
|
131
|
-
if (!existRes.Exists) {
|
|
132
|
-
res = await this.createCollection(collectionName);
|
|
133
|
-
return {
|
|
134
|
-
RequestId: res.RequestId,
|
|
135
|
-
IsCreated: true,
|
|
136
|
-
ExistsResult: existRes
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
else {
|
|
140
|
-
return {
|
|
141
|
-
RequestId: '',
|
|
142
|
-
IsCreated: false,
|
|
143
|
-
ExistsResult: existRes
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
// 检查集合中是否存在某索引
|
|
148
|
-
async checkIndexExists(collectionName, indexName) {
|
|
149
|
-
const result = await this.describeCollection(collectionName);
|
|
150
|
-
let exists = result.Indexes.some(item => {
|
|
151
|
-
return item.Name === indexName;
|
|
152
|
-
});
|
|
153
|
-
return {
|
|
154
|
-
RequestId: result.RequestId,
|
|
155
|
-
Exists: exists
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
// 查询DB的数据存储分布
|
|
159
|
-
async distribution() {
|
|
160
|
-
const res = await this.dbOpService.request('DescribeDbDistribution', {
|
|
161
|
-
EnvId: this.envId
|
|
162
|
-
});
|
|
163
|
-
return res;
|
|
164
|
-
}
|
|
165
|
-
// 查询DB 迁移进度
|
|
166
|
-
async migrateStatus(jobId) {
|
|
167
|
-
const res = await this.dbOpService.request('DatabaseMigrateQueryInfo', {
|
|
168
|
-
EnvId: this.envId,
|
|
169
|
-
JobId: jobId
|
|
170
|
-
});
|
|
171
|
-
return res;
|
|
172
|
-
}
|
|
173
|
-
// 数据库导入数据
|
|
174
|
-
async import(collectionName, file, options) {
|
|
175
|
-
let filePath;
|
|
176
|
-
let fileType;
|
|
177
|
-
if (file['FilePath']) {
|
|
178
|
-
let temp = 'tmp/db-imports/';
|
|
179
|
-
if (options['ObjectKeyPrefix']) {
|
|
180
|
-
temp = options['ObjectKeyPrefix'];
|
|
181
|
-
delete options['ObjectKeyPrefix'];
|
|
182
|
-
}
|
|
183
|
-
filePath = path_1.default.join(temp, path_1.default.basename(file['FilePath']));
|
|
184
|
-
// 调用cos接口 上传文件 todo
|
|
185
|
-
await this.environment.getStorageService().uploadFile({
|
|
186
|
-
localPath: file['FilePath'],
|
|
187
|
-
cloudPath: filePath
|
|
188
|
-
});
|
|
189
|
-
fileType = path_1.default.extname(filePath).substring(1);
|
|
190
|
-
}
|
|
191
|
-
else if (file['ObjectKey']) {
|
|
192
|
-
delete options['ObjectKeyPrefix'];
|
|
193
|
-
filePath = file['ObjectKey'];
|
|
194
|
-
fileType = path_1.default.extname(filePath).substring(1);
|
|
195
|
-
}
|
|
196
|
-
else {
|
|
197
|
-
throw new error_1.CloudBaseError('Miss file.filePath or file.objectKey');
|
|
198
|
-
}
|
|
199
|
-
if (file['FileType']) {
|
|
200
|
-
fileType = file['FileType'];
|
|
201
|
-
}
|
|
202
|
-
return this.dbOpService.request('DatabaseMigrateImport', Object.assign({ CollectionName: collectionName, FilePath: filePath, FileType: fileType, EnvId: this.envId }, options));
|
|
203
|
-
}
|
|
204
|
-
// 数据库导出数据
|
|
205
|
-
async export(collectionName, file, options) {
|
|
206
|
-
let filePath;
|
|
207
|
-
let fileType;
|
|
208
|
-
if (file['ObjectKey']) {
|
|
209
|
-
filePath = file['ObjectKey'];
|
|
210
|
-
fileType = path_1.default.extname(filePath).substring(1);
|
|
211
|
-
}
|
|
212
|
-
else {
|
|
213
|
-
throw new error_1.CloudBaseError('Miss file.filePath or file.objectKey');
|
|
214
|
-
}
|
|
215
|
-
if (file['FileType']) {
|
|
216
|
-
fileType = file['FileType'];
|
|
217
|
-
}
|
|
218
|
-
return this.dbOpService.request('DatabaseMigrateExport', Object.assign({ CollectionName: collectionName, FilePath: filePath, FileType: fileType, EnvId: this.envId }, options));
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
DatabaseService.tcbServiceVersion = {
|
|
222
|
-
service: 'tcb',
|
|
223
|
-
version: '2018-06-08'
|
|
224
|
-
};
|
|
225
|
-
DatabaseService.flexdbServiceVersion = {
|
|
226
|
-
service: 'flexdb',
|
|
227
|
-
version: '2018-11-27'
|
|
228
|
-
};
|
|
229
|
-
__decorate([
|
|
230
|
-
preLazy()
|
|
231
|
-
], DatabaseService.prototype, "createCollection", null);
|
|
232
|
-
__decorate([
|
|
233
|
-
preLazy()
|
|
234
|
-
], DatabaseService.prototype, "deleteCollection", null);
|
|
235
|
-
__decorate([
|
|
236
|
-
preLazy()
|
|
237
|
-
], DatabaseService.prototype, "updateCollection", null);
|
|
238
|
-
__decorate([
|
|
239
|
-
preLazy()
|
|
240
|
-
], DatabaseService.prototype, "describeCollection", null);
|
|
241
|
-
__decorate([
|
|
242
|
-
preLazy()
|
|
243
|
-
], DatabaseService.prototype, "listCollections", null);
|
|
244
|
-
exports.DatabaseService = DatabaseService;
|