@cloudbase/manager-node 4.2.4 → 4.2.6
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/access/index.js +141 -0
- package/lib/access/types.js +2 -0
- package/lib/billing/index.js +36 -0
- package/lib/cam/index.js +77 -0
- package/lib/cloudBaseRun/index.js +36 -0
- package/lib/cloudBaseRun/types.js +2 -0
- package/lib/common/index.js +39 -0
- package/lib/constant.js +55 -0
- package/lib/context.js +14 -0
- package/lib/database/index.js +244 -0
- package/lib/debug.js +34 -0
- package/lib/env/index.js +288 -0
- package/lib/environment.js +124 -0
- package/lib/environmentManager.js +44 -0
- package/lib/error.js +16 -0
- package/lib/function/index.js +1019 -0
- package/lib/function/packer.js +129 -0
- package/lib/function/types.js +2 -0
- package/lib/hosting/index.js +461 -0
- package/lib/index.js +83 -0
- package/lib/interfaces/base.interface.js +2 -0
- package/lib/interfaces/billing.interface.js +2 -0
- package/lib/interfaces/cam.interface.js +2 -0
- package/lib/interfaces/flexdb.interface.js +2 -0
- package/lib/interfaces/function.interface.js +2 -0
- package/lib/interfaces/index.js +19 -0
- package/lib/interfaces/storage.interface.js +2 -0
- package/lib/interfaces/tcb.interface.js +2 -0
- package/lib/storage/index.js +1051 -0
- package/lib/third/index.js +18 -0
- package/lib/user/index.js +136 -0
- package/lib/user/types.js +2 -0
- package/lib/utils/auth.js +97 -0
- package/lib/utils/cloud-api-request.js +212 -0
- package/lib/utils/cloudbase-request.js +69 -0
- package/lib/utils/envLazy.js +18 -0
- package/lib/utils/fs.js +64 -0
- package/lib/utils/http-request.js +44 -0
- package/lib/utils/index.js +103 -0
- package/lib/utils/parallel.js +69 -0
- package/lib/utils/runenv.js +8 -0
- package/lib/utils/uuid.js +18 -0
- package/package.json +1 -1
- package/types/access/index.d.ts +38 -0
- package/types/access/types.d.ts +42 -0
- package/types/billing/index.d.ts +21 -0
- package/types/cam/index.d.ts +63 -0
- package/types/cloudBaseRun/index.d.ts +12 -0
- package/types/cloudBaseRun/types.d.ts +21 -0
- package/types/common/index.d.ts +18 -0
- package/types/constant.d.ts +44 -0
- package/types/context.d.ts +17 -0
- package/types/database/index.d.ts +66 -0
- package/types/debug.d.ts +1 -0
- package/types/env/index.d.ts +127 -0
- package/types/environment.d.ts +51 -0
- package/types/environmentManager.d.ts +13 -0
- package/types/error.d.ts +18 -0
- package/types/function/index.d.ts +379 -0
- package/types/function/packer.d.ts +37 -0
- package/types/function/types.d.ts +154 -0
- package/types/hosting/index.d.ts +253 -0
- package/types/index.d.ts +52 -0
- package/types/interfaces/base.interface.d.ts +7 -0
- package/types/interfaces/billing.interface.d.ts +18 -0
- package/types/interfaces/cam.interface.d.ts +24 -0
- package/types/interfaces/flexdb.interface.d.ts +67 -0
- package/types/interfaces/function.interface.d.ts +65 -0
- package/types/interfaces/index.d.ts +7 -0
- package/types/interfaces/storage.interface.d.ts +26 -0
- package/types/interfaces/tcb.interface.d.ts +305 -0
- package/types/storage/index.d.ts +324 -0
- package/types/third/index.d.ts +11 -0
- package/types/user/index.d.ts +52 -0
- package/types/user/types.d.ts +20 -0
- package/types/utils/auth.d.ts +8 -0
- package/types/utils/cloud-api-request.d.ts +21 -0
- package/types/utils/cloudbase-request.d.ts +14 -0
- package/types/utils/envLazy.d.ts +1 -0
- package/types/utils/fs.d.ts +7 -0
- package/types/utils/http-request.d.ts +2 -0
- package/types/utils/index.d.ts +20 -0
- package/types/utils/parallel.d.ts +17 -0
- package/types/utils/runenv.d.ts +1 -0
- package/types/utils/uuid.d.ts +2 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
13
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
14
|
+
};
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.upperCaseObjKey = exports.upperCaseStringFisrt = exports.sleep = exports.rsaEncrypt = exports.getEnvVar = exports.getRuntime = exports.compressToZip = void 0;
|
|
17
|
+
const fs_1 = __importDefault(require("fs"));
|
|
18
|
+
const archiver_1 = __importDefault(require("archiver"));
|
|
19
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
20
|
+
const constant_1 = require("../constant");
|
|
21
|
+
var uuid_1 = require("./uuid");
|
|
22
|
+
Object.defineProperty(exports, "guid6", { enumerable: true, get: function () { return uuid_1.guid6; } });
|
|
23
|
+
__exportStar(require("./cloud-api-request"), exports);
|
|
24
|
+
__exportStar(require("./auth"), exports);
|
|
25
|
+
__exportStar(require("./cloudbase-request"), exports);
|
|
26
|
+
__exportStar(require("./http-request"), exports);
|
|
27
|
+
__exportStar(require("./envLazy"), exports);
|
|
28
|
+
__exportStar(require("./fs"), exports);
|
|
29
|
+
async function compressToZip(option) {
|
|
30
|
+
const { dirPath, outputPath, ignore, pattern = '**/*' } = option;
|
|
31
|
+
return new Promise((resolve, reject) => {
|
|
32
|
+
const output = fs_1.default.createWriteStream(outputPath);
|
|
33
|
+
const archive = archiver_1.default('zip');
|
|
34
|
+
output.on('close', function () {
|
|
35
|
+
resolve({
|
|
36
|
+
zipPath: outputPath,
|
|
37
|
+
size: Math.ceil(archive.pointer() / 1024)
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
archive.on('error', function (err) {
|
|
41
|
+
reject(err);
|
|
42
|
+
});
|
|
43
|
+
archive.pipe(output);
|
|
44
|
+
// append files from a glob pattern
|
|
45
|
+
archive.glob(pattern, {
|
|
46
|
+
// 目标路径
|
|
47
|
+
cwd: dirPath,
|
|
48
|
+
ignore: ignore,
|
|
49
|
+
dot: true
|
|
50
|
+
});
|
|
51
|
+
archive.finalize();
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
exports.compressToZip = compressToZip;
|
|
55
|
+
function getRuntime() {
|
|
56
|
+
return process.env[constant_1.ENV_NAME.ENV_RUNENV];
|
|
57
|
+
}
|
|
58
|
+
exports.getRuntime = getRuntime;
|
|
59
|
+
function getEnvVar(envName) {
|
|
60
|
+
return process.env[envName];
|
|
61
|
+
}
|
|
62
|
+
exports.getEnvVar = getEnvVar;
|
|
63
|
+
function rsaEncrypt(data) {
|
|
64
|
+
const buffer = Buffer.from(data);
|
|
65
|
+
const encrypted = crypto_1.default.publicEncrypt({
|
|
66
|
+
key: constant_1.PUBLIC_RSA_KEY,
|
|
67
|
+
padding: crypto_1.default.constants.RSA_PKCS1_PADDING
|
|
68
|
+
}, buffer);
|
|
69
|
+
return encrypted.toString('base64');
|
|
70
|
+
}
|
|
71
|
+
exports.rsaEncrypt = rsaEncrypt;
|
|
72
|
+
function sleep(time) {
|
|
73
|
+
return new Promise(resolve => {
|
|
74
|
+
setTimeout(() => {
|
|
75
|
+
resolve();
|
|
76
|
+
}, time);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
exports.sleep = sleep;
|
|
80
|
+
function upperCaseStringFisrt(str) {
|
|
81
|
+
return str.slice(0, 1).toUpperCase().concat(str.slice(1));
|
|
82
|
+
}
|
|
83
|
+
exports.upperCaseStringFisrt = upperCaseStringFisrt;
|
|
84
|
+
function upperCaseObjKey(object) {
|
|
85
|
+
const type = Object.prototype.toString.call(object).slice(8, -1);
|
|
86
|
+
if (type === 'Object') {
|
|
87
|
+
let newObj = {};
|
|
88
|
+
// eslint-disable-next-line guard-for-in
|
|
89
|
+
for (let key in object) {
|
|
90
|
+
newObj[upperCaseStringFisrt(key)] = upperCaseObjKey(object[key]);
|
|
91
|
+
}
|
|
92
|
+
return newObj;
|
|
93
|
+
}
|
|
94
|
+
if (type === 'Array') {
|
|
95
|
+
let newArr = [];
|
|
96
|
+
for (let item of object) {
|
|
97
|
+
newArr.push(upperCaseObjKey(item));
|
|
98
|
+
}
|
|
99
|
+
return newArr;
|
|
100
|
+
}
|
|
101
|
+
return object;
|
|
102
|
+
}
|
|
103
|
+
exports.upperCaseObjKey = upperCaseObjKey;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AsyncTaskParallelController = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* 异步任务并发控制器,以一定的并发数执行所有任务
|
|
6
|
+
* 不具备队列性质,异步任务随机执行
|
|
7
|
+
* 单个任务异常,错误会返回,单不会退出执行
|
|
8
|
+
* 所有任务执行
|
|
9
|
+
*/
|
|
10
|
+
class AsyncTaskParallelController {
|
|
11
|
+
constructor(maxParallel, checkInterval = 20) {
|
|
12
|
+
this.tasks = [];
|
|
13
|
+
this.maxParallel = Number(maxParallel) || 20;
|
|
14
|
+
this.checkInterval = checkInterval;
|
|
15
|
+
}
|
|
16
|
+
loadTasks(tasks) {
|
|
17
|
+
this.tasks.push(...tasks);
|
|
18
|
+
this.totalTasks = this.tasks.length;
|
|
19
|
+
}
|
|
20
|
+
push(task) {
|
|
21
|
+
this.tasks.push(task);
|
|
22
|
+
this.totalTasks = this.tasks.length;
|
|
23
|
+
}
|
|
24
|
+
// 开始执行任务
|
|
25
|
+
async run() {
|
|
26
|
+
// 存储任务执行结果
|
|
27
|
+
const results = [];
|
|
28
|
+
// 记录已经运行的任务
|
|
29
|
+
const taskHasRun = [];
|
|
30
|
+
// 记录任务是否执行完成
|
|
31
|
+
const taskDone = [];
|
|
32
|
+
// 当前正在运行的任务数量
|
|
33
|
+
let runningTask = 0;
|
|
34
|
+
return new Promise(resolve => {
|
|
35
|
+
// 使用定时器,不阻塞线程
|
|
36
|
+
const timer = setInterval(() => {
|
|
37
|
+
// 全部任务运行完成
|
|
38
|
+
const taskDoneLength = taskDone.filter(item => item).length;
|
|
39
|
+
if (runningTask === 0 && taskDoneLength === this.totalTasks) {
|
|
40
|
+
clearInterval(timer);
|
|
41
|
+
resolve(results);
|
|
42
|
+
}
|
|
43
|
+
// 当前运行任务数超过最大并发,不再执行新的任务
|
|
44
|
+
if (runningTask >= this.maxParallel) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
// 遍历任务列表,开始执行还没有执行的任务
|
|
48
|
+
this.tasks.forEach((task, index) => {
|
|
49
|
+
if (!taskHasRun[index] && runningTask < this.maxParallel) {
|
|
50
|
+
runningTask++;
|
|
51
|
+
taskHasRun[index] = 1;
|
|
52
|
+
task()
|
|
53
|
+
.then(res => {
|
|
54
|
+
results[index] = res;
|
|
55
|
+
})
|
|
56
|
+
.catch(err => {
|
|
57
|
+
results[index] = err;
|
|
58
|
+
})
|
|
59
|
+
.then(() => {
|
|
60
|
+
runningTask--;
|
|
61
|
+
taskDone[index] = 1;
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}, this.checkInterval);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.AsyncTaskParallelController = AsyncTaskParallelController;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.uuidv4 = exports.guid6 = void 0;
|
|
4
|
+
// 环境 uuid
|
|
5
|
+
function guid6() {
|
|
6
|
+
return Math.floor((1 + Math.random()) * 0x1000000)
|
|
7
|
+
.toString(16)
|
|
8
|
+
.substring(1);
|
|
9
|
+
}
|
|
10
|
+
exports.guid6 = guid6;
|
|
11
|
+
function uuidv4() {
|
|
12
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
13
|
+
const r = (Math.random() * 16) | 0;
|
|
14
|
+
const v = c === 'x' ? r : (r & 0x3) | 0x8;
|
|
15
|
+
return v.toString(16);
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
exports.uuidv4 = uuidv4;
|
package/package.json
CHANGED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Environment } from '../environment';
|
|
2
|
+
import { ICreateAccessOptions, IApi, IUpdateOptions, IService, IDeleteOptions, IGetOptions, IDomainOptions } from './types';
|
|
3
|
+
import { IResponseInfo } from '../interfaces';
|
|
4
|
+
export declare class AccessService {
|
|
5
|
+
private tcbService;
|
|
6
|
+
private environment;
|
|
7
|
+
constructor(environment: Environment);
|
|
8
|
+
createAccess(options: ICreateAccessOptions): Promise<{
|
|
9
|
+
APIId: string;
|
|
10
|
+
RequestId: string;
|
|
11
|
+
}>;
|
|
12
|
+
getDomainList(): Promise<{
|
|
13
|
+
RequestId: string;
|
|
14
|
+
DefaultDomain: string;
|
|
15
|
+
EnableService: boolean;
|
|
16
|
+
ServiceSet: IService[];
|
|
17
|
+
}>;
|
|
18
|
+
getAccessList(options?: IGetOptions): Promise<{
|
|
19
|
+
RequestId: string;
|
|
20
|
+
APISet: IApi[];
|
|
21
|
+
Total: number;
|
|
22
|
+
Limit: number;
|
|
23
|
+
Offset: number;
|
|
24
|
+
EnableService: boolean;
|
|
25
|
+
}>;
|
|
26
|
+
switchAuth(auth: boolean): Promise<{
|
|
27
|
+
Count: number;
|
|
28
|
+
RequestId: string;
|
|
29
|
+
}>;
|
|
30
|
+
switchPathAuth(options: IUpdateOptions): Promise<{
|
|
31
|
+
Count: number;
|
|
32
|
+
RequestId: string;
|
|
33
|
+
}>;
|
|
34
|
+
deleteAccess(options: IDeleteOptions): Promise<IResponseInfo>;
|
|
35
|
+
addCustomDomain(options: IDomainOptions): Promise<IResponseInfo>;
|
|
36
|
+
deleteCustomDomain(domain: string): Promise<IResponseInfo>;
|
|
37
|
+
private getEnvInfo;
|
|
38
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export interface ICreateAccessOptions {
|
|
2
|
+
path: string;
|
|
3
|
+
name: string;
|
|
4
|
+
type?: 1 | 2;
|
|
5
|
+
auth?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface IApi {
|
|
8
|
+
ServiceId: string;
|
|
9
|
+
APIId: string;
|
|
10
|
+
Path: string;
|
|
11
|
+
Type: number;
|
|
12
|
+
Name: string;
|
|
13
|
+
CreateTime: number;
|
|
14
|
+
EnvId: string;
|
|
15
|
+
EnableAuth: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface IUpdateOptions {
|
|
18
|
+
apiIds: string[];
|
|
19
|
+
auth: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface IService {
|
|
22
|
+
ServiceId: string;
|
|
23
|
+
Domain: string;
|
|
24
|
+
OpenTime: number;
|
|
25
|
+
Status?: number;
|
|
26
|
+
}
|
|
27
|
+
export interface IDeleteOptions {
|
|
28
|
+
name?: string;
|
|
29
|
+
type?: number;
|
|
30
|
+
apiId?: string;
|
|
31
|
+
path?: string;
|
|
32
|
+
}
|
|
33
|
+
export interface IGetOptions {
|
|
34
|
+
path?: string;
|
|
35
|
+
name?: string;
|
|
36
|
+
limit?: number;
|
|
37
|
+
offset?: number;
|
|
38
|
+
}
|
|
39
|
+
export interface IDomainOptions {
|
|
40
|
+
domain: string;
|
|
41
|
+
certId?: string;
|
|
42
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { CloudBaseContext } from '../context';
|
|
2
|
+
import { IServiceVersion, IGoodItem, IGenerateDealsRes, IPayDealsRes } from '../interfaces';
|
|
3
|
+
export declare class BillingService {
|
|
4
|
+
static billServiceVersion: IServiceVersion;
|
|
5
|
+
private billService;
|
|
6
|
+
constructor(context: CloudBaseContext);
|
|
7
|
+
/**
|
|
8
|
+
* 创建订单
|
|
9
|
+
* @param {Array<IGoodItem>} goods
|
|
10
|
+
* @returns {Promise<IGenerateDealsRes>}
|
|
11
|
+
* @memberof BillingService
|
|
12
|
+
*/
|
|
13
|
+
GenerateDeals(goods: Array<IGoodItem>): Promise<IGenerateDealsRes>;
|
|
14
|
+
/**
|
|
15
|
+
* 支付订单
|
|
16
|
+
* @param {Array<string>} orderIds
|
|
17
|
+
* @returns {Promise<IPayDealsRes>}
|
|
18
|
+
* @memberof BillingService
|
|
19
|
+
*/
|
|
20
|
+
PayDeals(orderIds: Array<string>): Promise<IPayDealsRes>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { CloudBaseContext } from '../context';
|
|
2
|
+
import { IServiceVersion, IRoleListRes, ICreateRoleRes, IResponseInfo, IGetRoleRes } from '../interfaces';
|
|
3
|
+
export declare class CamService {
|
|
4
|
+
static camServiceVersion: IServiceVersion;
|
|
5
|
+
private camService;
|
|
6
|
+
constructor(context: CloudBaseContext);
|
|
7
|
+
/**
|
|
8
|
+
* 查询账户角色列表
|
|
9
|
+
* @param {number} page
|
|
10
|
+
* @param {number} rp
|
|
11
|
+
* @returns {Promise<IRoleListRes>}
|
|
12
|
+
* @memberof CamService
|
|
13
|
+
*/
|
|
14
|
+
describeRoleList(page: number, rp: number): Promise<IRoleListRes>;
|
|
15
|
+
/**
|
|
16
|
+
* 获取角色详情
|
|
17
|
+
* @param {string} roleName
|
|
18
|
+
* @returns {Promise<IGetRoleRes>}
|
|
19
|
+
* @memberof CamService
|
|
20
|
+
*/
|
|
21
|
+
getRole(roleName: string): Promise<IGetRoleRes>;
|
|
22
|
+
/**
|
|
23
|
+
* 创建角色
|
|
24
|
+
* @param {{
|
|
25
|
+
* RoleName: string
|
|
26
|
+
* PolicyDocument: string
|
|
27
|
+
* Description: string
|
|
28
|
+
* }} param
|
|
29
|
+
* @returns {Promise<ICreateRoleRes>}
|
|
30
|
+
* @memberof CamService
|
|
31
|
+
*/
|
|
32
|
+
createRole(param: {
|
|
33
|
+
RoleName: string;
|
|
34
|
+
PolicyDocument: string;
|
|
35
|
+
Description: string;
|
|
36
|
+
}): Promise<ICreateRoleRes>;
|
|
37
|
+
/**
|
|
38
|
+
* 绑定角色策略
|
|
39
|
+
* @param {{
|
|
40
|
+
* PolicyId: number
|
|
41
|
+
* AttachRoleName: string
|
|
42
|
+
* }} param
|
|
43
|
+
* @returns {Promise<IResponseInfo>}
|
|
44
|
+
* @memberof CamService
|
|
45
|
+
*/
|
|
46
|
+
attachRolePolicy(param: {
|
|
47
|
+
PolicyId: number;
|
|
48
|
+
AttachRoleName: string;
|
|
49
|
+
}): Promise<IResponseInfo>;
|
|
50
|
+
attachRolePolicies(param: {
|
|
51
|
+
RoleId?: number;
|
|
52
|
+
RoleName?: string;
|
|
53
|
+
PolicyId?: number[];
|
|
54
|
+
PolicyName?: string[];
|
|
55
|
+
}): Promise<IResponseInfo>;
|
|
56
|
+
/**
|
|
57
|
+
* 删除角色
|
|
58
|
+
* @param {string} roleName
|
|
59
|
+
* @returns {Promise<IResponseInfo>}
|
|
60
|
+
* @memberof CamService
|
|
61
|
+
*/
|
|
62
|
+
deleteRole(roleName: string): Promise<IResponseInfo>;
|
|
63
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Environment } from '../environment';
|
|
2
|
+
import { IModifyServerFlowOption } from './types';
|
|
3
|
+
export declare class CloudBaseRunService {
|
|
4
|
+
private tcbService;
|
|
5
|
+
private environment;
|
|
6
|
+
constructor(environment: Environment);
|
|
7
|
+
modifyServerFlow(options: IModifyServerFlowOption): Promise<{
|
|
8
|
+
Result: string;
|
|
9
|
+
RequestId: string;
|
|
10
|
+
}>;
|
|
11
|
+
private getEnvInfo;
|
|
12
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface IModifyServerFlowOption {
|
|
2
|
+
serverName: string;
|
|
3
|
+
versionFlowItems?: ICloudBaseRunVersionFlowItem[];
|
|
4
|
+
trafficType?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface ICloudBaseRunVersionFlowItem {
|
|
7
|
+
versionName: string;
|
|
8
|
+
flowRatio: number;
|
|
9
|
+
urlParam?: IObjectKV;
|
|
10
|
+
priority?: number;
|
|
11
|
+
isDefaultPriority?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface IObjectKV {
|
|
14
|
+
key: string;
|
|
15
|
+
value: string;
|
|
16
|
+
}
|
|
17
|
+
export interface IClouBaseRunKVPriority {
|
|
18
|
+
key: string;
|
|
19
|
+
value: string;
|
|
20
|
+
priority: number;
|
|
21
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Environment } from '../environment';
|
|
2
|
+
interface ICommonApiServiceOption {
|
|
3
|
+
Action: string;
|
|
4
|
+
Param: Record<string, any>;
|
|
5
|
+
}
|
|
6
|
+
export declare class CommonService {
|
|
7
|
+
private commonService;
|
|
8
|
+
private environment;
|
|
9
|
+
constructor(environment: Environment, serviceType: string, serviceVersion: string);
|
|
10
|
+
/**
|
|
11
|
+
* 公共方法调用
|
|
12
|
+
* @param {ICommonApiServiceParam} param
|
|
13
|
+
* @returns {Promise<any>}
|
|
14
|
+
* @memberof CommonService
|
|
15
|
+
*/
|
|
16
|
+
call(options: ICommonApiServiceOption): Promise<any>;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export declare const ENV_NAME: {
|
|
2
|
+
ENV_SECRETID: string;
|
|
3
|
+
ENV_SECRETKEY: string;
|
|
4
|
+
ENV_SESSIONTOKEN: string;
|
|
5
|
+
ENV_TCB_ENV_ID: string;
|
|
6
|
+
ENV_RUNENV: string;
|
|
7
|
+
ENV_RUNENV_SCF: string;
|
|
8
|
+
};
|
|
9
|
+
export declare const SDK_VERSION = "TCB-NODE-MANAGER/1.0.O";
|
|
10
|
+
export declare const RUN_ENV: {
|
|
11
|
+
SCF: string;
|
|
12
|
+
};
|
|
13
|
+
export declare const ENDPOINT: {
|
|
14
|
+
TCB: string;
|
|
15
|
+
SCF: string;
|
|
16
|
+
COS: string;
|
|
17
|
+
FLEXDB: string;
|
|
18
|
+
};
|
|
19
|
+
export declare const SERVICE_TYPE: {
|
|
20
|
+
TCB: string;
|
|
21
|
+
};
|
|
22
|
+
export declare const ERROR: {
|
|
23
|
+
MISS_SECRET_INFO_IN_ENV: string;
|
|
24
|
+
MISS_SECRET_INFO_IN_ARGS: string;
|
|
25
|
+
CURRENT_ENVIRONMENT_IS_NULL: string;
|
|
26
|
+
ENV_ID_NOT_EXISTS: string;
|
|
27
|
+
};
|
|
28
|
+
export declare const PUBLIC_RSA_KEY = "\n-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC0ZLB0ZpWWFsHPnDDw++Nc2wI3\nnl2uyOrIJ5FUfxt4GAmt1Faf5pgMxAnL9exEUrrUDUX8Ri1R0KyfnHQQwCvKt8T8\nbgILIJe9UB8e9dvFqgqH2oA8Vqwi0YqDcvFLFJk2BJbm/0QYtZ563FumW8LEXAgu\nUeHi/0OZN9vQ33jWMQIDAQAB\n-----END PUBLIC KEY-----\n";
|
|
29
|
+
export declare const ROLE_NAME: {
|
|
30
|
+
TCB: string;
|
|
31
|
+
};
|
|
32
|
+
export declare const SCF_STATUS: {
|
|
33
|
+
ACTIVE: string;
|
|
34
|
+
CREATING: string;
|
|
35
|
+
UPDATING: string;
|
|
36
|
+
CREATE_FAILED: string;
|
|
37
|
+
};
|
|
38
|
+
export declare const USE_INTERNAL_ENDPOINT: boolean;
|
|
39
|
+
export declare const enum COS_ENDPOINT {
|
|
40
|
+
INTERNAL = "{Bucket}.cos-internal.{Region}.tencentcos.cn",
|
|
41
|
+
PUBLIC = "{Bucket}.cos.{Region}.tencentcos.cn"
|
|
42
|
+
}
|
|
43
|
+
export declare const COS_SDK_PROTOCOL: string;
|
|
44
|
+
export declare const COS_SDK_KEEPALIVE: string;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare class CloudBaseContext {
|
|
2
|
+
readonly secretId: string;
|
|
3
|
+
readonly secretKey: string;
|
|
4
|
+
readonly token: string;
|
|
5
|
+
readonly proxy: string;
|
|
6
|
+
readonly envId: string;
|
|
7
|
+
readonly region: string;
|
|
8
|
+
readonly envType: string;
|
|
9
|
+
constructor({ secretId, secretKey, token, proxy, region, envType }: {
|
|
10
|
+
secretId?: string;
|
|
11
|
+
secretKey?: string;
|
|
12
|
+
token?: string;
|
|
13
|
+
proxy?: string;
|
|
14
|
+
region?: string;
|
|
15
|
+
envType?: string;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { IServiceVersion, IExistsRes, CreateIndex, DropIndex, IndexInfo, TableInfo, Pager, IResponseInfo, CollectionDispension } from '../interfaces/';
|
|
2
|
+
import { Environment } from '../environment';
|
|
3
|
+
interface IDatabaseConfig {
|
|
4
|
+
Tag: string;
|
|
5
|
+
}
|
|
6
|
+
interface IIndexiesInfo {
|
|
7
|
+
CreateIndexes?: Array<CreateIndex>;
|
|
8
|
+
DropIndexes?: Array<DropIndex>;
|
|
9
|
+
}
|
|
10
|
+
interface ITableInfo extends IResponseInfo {
|
|
11
|
+
Indexes?: Array<IndexInfo>;
|
|
12
|
+
IndexNum?: number;
|
|
13
|
+
}
|
|
14
|
+
interface IMgoQueryInfo {
|
|
15
|
+
MgoLimit?: number;
|
|
16
|
+
MgoOffset?: number;
|
|
17
|
+
}
|
|
18
|
+
interface ICollectionInfo extends IResponseInfo {
|
|
19
|
+
Collections: Array<TableInfo>;
|
|
20
|
+
Pager: Pager;
|
|
21
|
+
}
|
|
22
|
+
interface ICollectionExistInfo extends IResponseInfo {
|
|
23
|
+
IsCreated: boolean;
|
|
24
|
+
ExistsResult: IExistsRes;
|
|
25
|
+
}
|
|
26
|
+
interface IDistributionInfo extends IResponseInfo {
|
|
27
|
+
Collections: CollectionDispension;
|
|
28
|
+
Count: number;
|
|
29
|
+
Total: number;
|
|
30
|
+
}
|
|
31
|
+
interface IDatabaseMigrateQueryInfo extends IResponseInfo {
|
|
32
|
+
Status: string;
|
|
33
|
+
RecordSuccess: number;
|
|
34
|
+
RecordFail: number;
|
|
35
|
+
ErrorMsg: string;
|
|
36
|
+
FileUrl: string;
|
|
37
|
+
}
|
|
38
|
+
interface IDatabaseImportAndExportInfo extends IResponseInfo {
|
|
39
|
+
JobId: number;
|
|
40
|
+
}
|
|
41
|
+
export declare class DatabaseService {
|
|
42
|
+
static tcbServiceVersion: IServiceVersion;
|
|
43
|
+
static flexdbServiceVersion: IServiceVersion;
|
|
44
|
+
private environment;
|
|
45
|
+
private envId;
|
|
46
|
+
private dbOpService;
|
|
47
|
+
private collOpService;
|
|
48
|
+
private DEFAULT_MGO_OFFSET;
|
|
49
|
+
private DEFAULT_MGO_LIMIT;
|
|
50
|
+
constructor(environment: Environment);
|
|
51
|
+
getCurrEnvironment(): Environment;
|
|
52
|
+
getDatabaseConfig(): IDatabaseConfig;
|
|
53
|
+
checkCollectionExists(collectionName: string): Promise<IExistsRes>;
|
|
54
|
+
createCollection(collectionName: string): Promise<any>;
|
|
55
|
+
deleteCollection(collectionName: string): Promise<any>;
|
|
56
|
+
updateCollection(collectionName: string, indexiesInfo: IIndexiesInfo): Promise<any>;
|
|
57
|
+
describeCollection(collectionName: string): Promise<ITableInfo>;
|
|
58
|
+
listCollections(options?: IMgoQueryInfo): Promise<ICollectionInfo>;
|
|
59
|
+
createCollectionIfNotExists(collectionName: string): Promise<ICollectionExistInfo>;
|
|
60
|
+
checkIndexExists(collectionName: string, indexName: string): Promise<IExistsRes>;
|
|
61
|
+
distribution(): Promise<IDistributionInfo>;
|
|
62
|
+
migrateStatus(jobId: number): Promise<IDatabaseMigrateQueryInfo>;
|
|
63
|
+
import(collectionName: string, file: any, options: any): Promise<IDatabaseImportAndExportInfo>;
|
|
64
|
+
export(collectionName: string, file: any, options: any): Promise<IDatabaseImportAndExportInfo>;
|
|
65
|
+
}
|
|
66
|
+
export {};
|
package/types/debug.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|