@cloudbase/cli 1.12.7-alpha.4 → 2.0.2
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/bin/tcb.js +6 -4
- package/lib/commands/run/create.js +6 -1
- package/lib/commands/run/delete.js +6 -1
- package/lib/commands/run/image/common.js +1 -1
- package/lib/commands/run/image/delete.js +5 -0
- package/lib/commands/run/image/download.js +5 -0
- package/lib/commands/run/image/list.js +5 -0
- package/lib/commands/run/image/upload.js +5 -0
- package/lib/commands/run/index.js +1 -0
- package/lib/commands/run/list.js +7 -1
- package/lib/commands/run/service/config.js +112 -0
- package/lib/commands/run/service/create.js +140 -0
- package/lib/commands/run/service/deploy.js +145 -0
- package/lib/commands/run/service/index.js +21 -0
- package/lib/commands/run/service/list.js +115 -0
- package/lib/commands/run/service/update.js +132 -0
- package/lib/commands/run/version/common.js +1 -1
- package/lib/commands/run/version/create.js +5 -0
- package/lib/commands/run/version/delete.js +5 -0
- package/lib/commands/run/version/list.js +5 -0
- package/lib/commands/run/version/modify.js +5 -0
- package/lib/commands/run/version/update.js +5 -0
- package/lib/constant.js +20 -1
- package/lib/help.js +40 -38
- package/lib/run/index.js +1 -0
- package/lib/run/service/common.js +163 -0
- package/lib/run/service/config.js +70 -0
- package/lib/run/service/create.js +67 -0
- package/lib/run/service/deployPackage.js +89 -0
- package/lib/run/service/index.js +23 -0
- package/lib/run/service/list.js +31 -0
- package/lib/run/service/showLogs.js +116 -0
- package/lib/run/service/update.js +83 -0
- package/lib/utils/checkTcbrEnv.js +74 -0
- package/lib/utils/commonParamsCheck.js +48 -0
- package/lib/utils/index.js +3 -0
- package/lib/utils/net/http-request.js +4 -4
- package/lib/utils/tcbrApi/callTcbrApi.js +38 -0
- package/lib/utils/tcbrApi/index.js +17 -0
- package/lib/utils/tcbrApi/tcbr-cloud-api/cloud-api-service.js +268 -0
- package/lib/utils/tcbrApi/tcbr-cloud-api/error.js +17 -0
- package/lib/utils/tcbrApi/tcbr-cloud-api/index.js +17 -0
- package/lib/utils/tcbrApi/tcbr-cloud-api/request.js +40 -0
- package/lib/utils/tcbrApi/tcbr-cloud-api-request.js +61 -0
- package/lib/utils/validator.js +32 -1
- package/package.json +88 -88
- package/src/commands/run/create.ts +9 -2
- package/src/commands/run/delete.ts +8 -2
- package/src/commands/run/image/common.ts +1 -1
- package/src/commands/run/image/delete.ts +8 -1
- package/src/commands/run/image/download.ts +7 -1
- package/src/commands/run/image/list.ts +7 -2
- package/src/commands/run/image/upload.ts +8 -1
- package/src/commands/run/index.ts +2 -1
- package/src/commands/run/list.ts +11 -3
- package/src/commands/run/service/config.ts +81 -0
- package/src/commands/run/service/create.ts +118 -0
- package/src/commands/run/service/deploy.ts +121 -0
- package/src/commands/run/service/index.ts +5 -0
- package/src/commands/run/service/list.ts +94 -0
- package/src/commands/run/service/update.ts +104 -0
- package/src/commands/run/version/common.ts +1 -1
- package/src/commands/run/version/create.ts +8 -1
- package/src/commands/run/version/delete.ts +8 -2
- package/src/commands/run/version/list.ts +7 -1
- package/src/commands/run/version/modify.ts +8 -1
- package/src/commands/run/version/update.ts +8 -1
- package/src/constant.ts +35 -1
- package/src/help.ts +50 -48
- package/src/run/index.ts +2 -1
- package/src/run/service/common.ts +206 -0
- package/src/run/service/config.ts +77 -0
- package/src/run/service/create.ts +52 -0
- package/src/run/service/deployPackage.ts +65 -0
- package/src/run/service/index.ts +7 -0
- package/src/run/service/list.ts +29 -0
- package/src/run/service/showLogs.ts +98 -0
- package/src/run/service/update.ts +81 -0
- package/src/types.ts +128 -2
- package/src/utils/checkTcbrEnv.ts +67 -0
- package/src/utils/commonParamsCheck.ts +65 -0
- package/src/utils/index.ts +5 -1
- package/src/utils/net/http-request.ts +1 -1
- package/src/utils/tcbrApi/callTcbrApi.ts +28 -0
- package/src/utils/tcbrApi/index.ts +1 -0
- package/src/utils/tcbrApi/tcbr-cloud-api/cloud-api-service.ts +363 -0
- package/src/utils/tcbrApi/tcbr-cloud-api/error.ts +30 -0
- package/src/utils/tcbrApi/tcbr-cloud-api/index.ts +1 -0
- package/src/utils/tcbrApi/tcbr-cloud-api/request.ts +28 -0
- package/src/utils/tcbrApi/tcbr-cloud-api-request.ts +66 -0
- package/src/utils/validator.ts +64 -32
- package/types/commands/run/index.d.ts +1 -0
- package/types/commands/run/service/config.d.ts +14 -0
- package/types/commands/run/service/create.d.ts +13 -0
- package/types/commands/run/service/deploy.d.ts +13 -0
- package/types/commands/run/service/index.d.ts +5 -0
- package/types/commands/run/service/list.d.ts +13 -0
- package/types/commands/run/service/update.d.ts +13 -0
- package/types/constant.d.ts +18 -0
- package/types/run/index.d.ts +1 -0
- package/types/run/service/common.d.ts +32 -0
- package/types/run/service/config.d.ts +23 -0
- package/types/run/service/create.d.ts +7 -0
- package/types/run/service/deployPackage.d.ts +11 -0
- package/types/run/service/index.d.ts +7 -0
- package/types/run/service/list.d.ts +2 -0
- package/types/run/service/showLogs.d.ts +2 -0
- package/types/run/service/update.d.ts +2 -0
- package/types/types.d.ts +116 -2
- package/types/utils/checkTcbrEnv.d.ts +3 -0
- package/types/utils/commonParamsCheck.d.ts +3 -0
- package/types/utils/index.d.ts +3 -0
- package/types/utils/tcbrApi/callTcbrApi.d.ts +1 -0
- package/types/utils/tcbrApi/index.d.ts +1 -0
- package/types/utils/tcbrApi/tcbr-cloud-api/cloud-api-service.d.ts +51 -0
- package/types/utils/tcbrApi/tcbr-cloud-api/error.d.ts +20 -0
- package/types/utils/tcbrApi/tcbr-cloud-api/index.d.ts +1 -0
- package/types/utils/tcbrApi/tcbr-cloud-api/request.d.ts +4 -0
- package/types/utils/tcbrApi/tcbr-cloud-api-request.d.ts +9 -0
- package/types/utils/validator.d.ts +4 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
interface Options {
|
|
2
|
+
exit?: number;
|
|
3
|
+
original?: Error | undefined;
|
|
4
|
+
code?: string | number;
|
|
5
|
+
requestId?: string;
|
|
6
|
+
action?: string;
|
|
7
|
+
type?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export class CloudBaseError extends Error {
|
|
11
|
+
readonly exit: number;
|
|
12
|
+
readonly message: string;
|
|
13
|
+
readonly name = 'CloudBaseError';
|
|
14
|
+
readonly original: Error | undefined;
|
|
15
|
+
readonly code: string | number;
|
|
16
|
+
readonly requestId: string;
|
|
17
|
+
readonly action: string;
|
|
18
|
+
readonly type: string;
|
|
19
|
+
|
|
20
|
+
constructor(message: string, options: Options = {}) {
|
|
21
|
+
super()
|
|
22
|
+
const { code = '', action = '', original = null, requestId = '', type } = options
|
|
23
|
+
this.message = `[${action}]\nRequestId:${requestId}\n${message}`
|
|
24
|
+
this.original = original
|
|
25
|
+
this.code = code
|
|
26
|
+
this.requestId = requestId
|
|
27
|
+
this.action = action
|
|
28
|
+
this.type = type
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './cloud-api-service'
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { URL } from 'url'
|
|
2
|
+
import _fetch, { RequestInit } from 'node-fetch'
|
|
3
|
+
import { HttpsProxyAgent } from 'https-proxy-agent'
|
|
4
|
+
|
|
5
|
+
export const nodeFetch = _fetch
|
|
6
|
+
|
|
7
|
+
// 使用 fetch + 代理
|
|
8
|
+
export async function fetch(url: string, config: RequestInit = {}, proxy = '') {
|
|
9
|
+
if (proxy) {
|
|
10
|
+
config.agent = new HttpsProxyAgent(proxy)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// 解决中文编码问题
|
|
14
|
+
const escapeUrl = new URL(url).toString()
|
|
15
|
+
|
|
16
|
+
const res = await _fetch(escapeUrl, config)
|
|
17
|
+
return res.json()
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export async function fetchStream(url: string, config: RequestInit = {}, proxy = '') {
|
|
21
|
+
if (proxy) {
|
|
22
|
+
config.agent = new HttpsProxyAgent(proxy)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const escapeUrl = new URL(url).toString()
|
|
26
|
+
|
|
27
|
+
return _fetch(escapeUrl, config)
|
|
28
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { getCredentialWithoutCheck, getRegion, Credential, getProxy } from '@cloudbase/toolbox'
|
|
2
|
+
import { CloudApiService as _CloudApiService } from './tcbr-cloud-api/index'
|
|
3
|
+
import { CloudBaseError } from '../../error'
|
|
4
|
+
import { REQUEST_TIMEOUT } from '../../constant'
|
|
5
|
+
|
|
6
|
+
let commonCredential: Credential
|
|
7
|
+
|
|
8
|
+
// token 将在 n 分钟内过期
|
|
9
|
+
const isTokenExpired = (credential: Credential, gap = 120) =>
|
|
10
|
+
credential.accessTokenExpired && Number(credential.accessTokenExpired) < Date.now() + gap * 1000
|
|
11
|
+
|
|
12
|
+
export class CloudApiService {
|
|
13
|
+
// 缓存请求实例
|
|
14
|
+
static serviceCacheMap: Record<string, CloudApiService> = {}
|
|
15
|
+
|
|
16
|
+
// 单例模式
|
|
17
|
+
static getInstance(service: string) {
|
|
18
|
+
if (CloudApiService.serviceCacheMap?.[service]) {
|
|
19
|
+
return CloudApiService.serviceCacheMap[service]
|
|
20
|
+
}
|
|
21
|
+
const apiService = new CloudApiService(service)
|
|
22
|
+
CloudApiService.serviceCacheMap[service] = apiService
|
|
23
|
+
return apiService
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
region: string
|
|
27
|
+
apiService: _CloudApiService
|
|
28
|
+
|
|
29
|
+
constructor(service: string, baseParams?: Record<string, any>, version = '') {
|
|
30
|
+
// 初始化 API 实例
|
|
31
|
+
this.apiService = new _CloudApiService({
|
|
32
|
+
service,
|
|
33
|
+
version: service === 'tcr'
|
|
34
|
+
? version
|
|
35
|
+
: service === 'tcbr'
|
|
36
|
+
? '2022-02-17'
|
|
37
|
+
:'2019-09-24',
|
|
38
|
+
baseParams,
|
|
39
|
+
proxy: getProxy(),
|
|
40
|
+
timeout: REQUEST_TIMEOUT,
|
|
41
|
+
getCredential: async () => {
|
|
42
|
+
// 存在未过期的 token
|
|
43
|
+
if (commonCredential?.secretId && !isTokenExpired(commonCredential)) {
|
|
44
|
+
return commonCredential
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const credential = await getCredentialWithoutCheck()
|
|
48
|
+
if (!credential) {
|
|
49
|
+
throw new CloudBaseError('无有效身份信息,请使用 cloudbase login 登录')
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
commonCredential = credential
|
|
53
|
+
|
|
54
|
+
return {
|
|
55
|
+
...credential,
|
|
56
|
+
tokenExpired: Number(credential.accessTokenExpired)
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
})
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
async request(action: string, data: Record<string, any> = {}, method: 'POST' | 'GET' = 'POST') {
|
|
63
|
+
const region = this.region || (await getRegion())
|
|
64
|
+
return this.apiService.request({ action, data, method, region })
|
|
65
|
+
}
|
|
66
|
+
}
|
package/src/utils/validator.ts
CHANGED
|
@@ -1,33 +1,65 @@
|
|
|
1
|
-
import { CloudBaseError } from '../error'
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
ok = Boolean(val)
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
1
|
+
import { CloudBaseError } from '../error'
|
|
2
|
+
import { CPU_MEM_OPTS } from '../constant'
|
|
3
|
+
import { convertNumber } from '../run'
|
|
4
|
+
|
|
5
|
+
type SimpleValue = number | string | boolean
|
|
6
|
+
|
|
7
|
+
export function assertTruthy(val: SimpleValue | SimpleValue[], errMsg: string) {
|
|
8
|
+
let ok
|
|
9
|
+
if (Array.isArray(val)) {
|
|
10
|
+
ok = val.every(item => Boolean(val))
|
|
11
|
+
} else {
|
|
12
|
+
ok = Boolean(val)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (!ok) {
|
|
16
|
+
throw new CloudBaseError(errMsg)
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function assertHas(obj: any, prop: string, errMsg): void {
|
|
21
|
+
if (!obj[prop]) {
|
|
22
|
+
throw new CloudBaseError(errMsg)
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
export const validateIp = (ip: string): boolean => {
|
|
28
|
+
if (Object.prototype.toString.call(ip) !== '[object String]') return false
|
|
29
|
+
const fields = ip.split('.')
|
|
30
|
+
if (
|
|
31
|
+
fields.length !== 4 ||
|
|
32
|
+
fields.find(item => isNaN(Number(item)) || Number(item) < 0 || Number(item) > 255)
|
|
33
|
+
) return false
|
|
34
|
+
return true
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// 检查 cpu 和 mem 是否符合约束条件
|
|
38
|
+
export const validateCpuMem = (cpuInput: number | string | undefined, memInput: number | string | undefined): { cpuOutput: number, memOutput: number } => {
|
|
39
|
+
if (cpuInput !== undefined && memInput !== undefined) {
|
|
40
|
+
let cpuSet = convertNumber(cpuInput)
|
|
41
|
+
let memSet = convertNumber(memInput)
|
|
42
|
+
let validMemSet = CPU_MEM_OPTS.find(({ cpu }) => cpu === cpuSet)
|
|
43
|
+
if (!validMemSet || !validMemSet.mems.length || !validMemSet.mems.includes(memSet)) {
|
|
44
|
+
throw new CloudBaseError(`cpu 与 mem 规格不匹配,当前规格:cpu: ${cpuInput}, mem: ${memInput}
|
|
45
|
+
请使用下列规格组合之一:${CPU_MEM_OPTS.map(({ cpu, mems }) => `${cpu}-${mems.join('/')}`).join(',')}`)
|
|
46
|
+
}
|
|
47
|
+
return { cpuOutput: cpuSet, memOutput: memSet }
|
|
48
|
+
}
|
|
49
|
+
if (cpuInput) {
|
|
50
|
+
let cpuSet = convertNumber(cpuInput)
|
|
51
|
+
let validSet = CPU_MEM_OPTS.find(({ cpu }) => cpu === cpuSet)
|
|
52
|
+
if (!validSet) {
|
|
53
|
+
throw new CloudBaseError(`不支持当前 cpu 规格,请使用下列 cpu 规格之一:${CPU_MEM_OPTS.map(({ cpu }) => cpu).join(',')}`)
|
|
54
|
+
}
|
|
55
|
+
return { cpuOutput: cpuSet, memOutput: CPU_MEM_OPTS.find(({ cpu }) => cpu === cpuSet).mems[0] }
|
|
56
|
+
}
|
|
57
|
+
if (memInput) {
|
|
58
|
+
let memSet = convertNumber(memInput)
|
|
59
|
+
let validSet = CPU_MEM_OPTS.find(({ mems }) => mems.includes(memSet))
|
|
60
|
+
if (!validSet) {
|
|
61
|
+
throw new CloudBaseError(`不支持当前 mem 规格,请使用下列 mem 规格之一:${CPU_MEM_OPTS.map(({ mems }) => mems.join('/')).join(',')}`)
|
|
62
|
+
}
|
|
63
|
+
return { cpuOutput: validSet.cpu, memOutput: memSet }
|
|
64
|
+
}
|
|
33
65
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Command } from '../../common';
|
|
2
|
+
import { Logger } from '../../../decorators';
|
|
3
|
+
export declare class ConfigServiceTcbr extends Command {
|
|
4
|
+
get options(): {
|
|
5
|
+
cmd: string;
|
|
6
|
+
childCmd: string;
|
|
7
|
+
options: {
|
|
8
|
+
flags: string;
|
|
9
|
+
desc: string;
|
|
10
|
+
}[];
|
|
11
|
+
desc: string;
|
|
12
|
+
};
|
|
13
|
+
execute(options: any, log: Logger): Promise<void>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Command } from '../../common';
|
|
2
|
+
export declare class CreateServiceTcbr extends Command {
|
|
3
|
+
get options(): {
|
|
4
|
+
cmd: string;
|
|
5
|
+
childCmd: string;
|
|
6
|
+
options: {
|
|
7
|
+
flags: string;
|
|
8
|
+
desc: string;
|
|
9
|
+
}[];
|
|
10
|
+
desc: string;
|
|
11
|
+
};
|
|
12
|
+
execute(options: any): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Command } from '../../common';
|
|
2
|
+
export declare class DeployServiceTcbr extends Command {
|
|
3
|
+
get options(): {
|
|
4
|
+
cmd: string;
|
|
5
|
+
childCmd: string;
|
|
6
|
+
options: {
|
|
7
|
+
flags: string;
|
|
8
|
+
desc: string;
|
|
9
|
+
}[];
|
|
10
|
+
desc: string;
|
|
11
|
+
};
|
|
12
|
+
execute(options: any): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Command } from '../../common';
|
|
2
|
+
export declare class ListServiceTcbr extends Command {
|
|
3
|
+
get options(): {
|
|
4
|
+
cmd: string;
|
|
5
|
+
childCmd: string;
|
|
6
|
+
options: {
|
|
7
|
+
flags: string;
|
|
8
|
+
desc: string;
|
|
9
|
+
}[];
|
|
10
|
+
desc: string;
|
|
11
|
+
};
|
|
12
|
+
execute(options: any): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Command } from '../../common';
|
|
2
|
+
export declare class UpdateServiceTcbr extends Command {
|
|
3
|
+
get options(): {
|
|
4
|
+
cmd: string;
|
|
5
|
+
childCmd: string;
|
|
6
|
+
options: {
|
|
7
|
+
flags: string;
|
|
8
|
+
desc: string;
|
|
9
|
+
}[];
|
|
10
|
+
desc: string;
|
|
11
|
+
};
|
|
12
|
+
execute(options: any): Promise<void>;
|
|
13
|
+
}
|
package/types/constant.d.ts
CHANGED
|
@@ -45,3 +45,21 @@ export declare const ConcurrencyTaskStatus: {
|
|
|
45
45
|
InProgress: string;
|
|
46
46
|
Failed: string;
|
|
47
47
|
};
|
|
48
|
+
export declare const enum EnumEnvCheck {
|
|
49
|
+
EnvFit = 0,
|
|
50
|
+
EnvNewCmdOld = 1,
|
|
51
|
+
EnvOldCmdNew = 2
|
|
52
|
+
}
|
|
53
|
+
export declare const enum EnumDeployStatus {
|
|
54
|
+
Deploying = "deploying",
|
|
55
|
+
DeploySuccess = "running",
|
|
56
|
+
DeployFailed = "deploy_failed"
|
|
57
|
+
}
|
|
58
|
+
export declare const CPU_MEM_OPTS: {
|
|
59
|
+
cpu: number;
|
|
60
|
+
mems: number[];
|
|
61
|
+
}[];
|
|
62
|
+
export declare const DEFAULT_CPU_MEM_SET: {
|
|
63
|
+
PolicyType: 'mem' | 'cpu';
|
|
64
|
+
PolicyThreshold: number;
|
|
65
|
+
}[];
|
package/types/run/index.d.ts
CHANGED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ITcbrServiceOptions, IDescribeWxCloudBaseRunReleaseOrder } from '../../types';
|
|
2
|
+
export declare function describeWxCloudBaseRunReleaseOrder(options: IDescribeWxCloudBaseRunReleaseOrder): Promise<any>;
|
|
3
|
+
export declare const convertNumber: (item: any) => number;
|
|
4
|
+
export declare const extractPolicyDetails: (policyDetails: string) => {
|
|
5
|
+
PolicyType: string;
|
|
6
|
+
PolicyThreshold: number;
|
|
7
|
+
}[];
|
|
8
|
+
export declare const parseEnvParams: (envParams: string) => {};
|
|
9
|
+
export declare const mergeEnvParams: (curEnvParams: string, preEnvParams: string) => string;
|
|
10
|
+
export declare function tcbrServiceOptions(options: ITcbrServiceOptions, isCreated: boolean, defaultOverride?: boolean, previousServerConfig?: any): Promise<{
|
|
11
|
+
ServerName: string;
|
|
12
|
+
EnvId: string;
|
|
13
|
+
ServerConfig: {
|
|
14
|
+
EnvId: string;
|
|
15
|
+
MaxNum: any;
|
|
16
|
+
MinNum: any;
|
|
17
|
+
BuildDir: any;
|
|
18
|
+
Cpu: any;
|
|
19
|
+
Mem: any;
|
|
20
|
+
OpenAccessTypes: string[];
|
|
21
|
+
ServerName: string;
|
|
22
|
+
InitialDelaySeconds: number;
|
|
23
|
+
CustomLogs: any;
|
|
24
|
+
CreateTime: any;
|
|
25
|
+
PolicyDetails: any;
|
|
26
|
+
EnvParams: any;
|
|
27
|
+
Port: number;
|
|
28
|
+
HasDockerfile: boolean;
|
|
29
|
+
Dockerfile: string;
|
|
30
|
+
};
|
|
31
|
+
DeployInfo: any;
|
|
32
|
+
}>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ITcbrServiceConfigOptions } from '../../types';
|
|
2
|
+
export declare function tcbrServiceConfigOptions(options: ITcbrServiceConfigOptions): Promise<{
|
|
3
|
+
EnvId: string;
|
|
4
|
+
ServerName: string;
|
|
5
|
+
OpenAccessTypes: string[];
|
|
6
|
+
Cpu: number;
|
|
7
|
+
Mem: number;
|
|
8
|
+
MinNum: number;
|
|
9
|
+
MaxNum: number;
|
|
10
|
+
PolicyDetails: {
|
|
11
|
+
PolicyType: string;
|
|
12
|
+
PolicyThreshold: number;
|
|
13
|
+
}[];
|
|
14
|
+
CustomLogs: string;
|
|
15
|
+
EnvParams: string;
|
|
16
|
+
InitialDelaySeconds: number;
|
|
17
|
+
CreateTime: string;
|
|
18
|
+
Port: number;
|
|
19
|
+
HasDockerfile: boolean;
|
|
20
|
+
Dockerfile: string;
|
|
21
|
+
BuildDir: string;
|
|
22
|
+
}>;
|
|
23
|
+
export declare function updateCloudRunServerConfig(options: any): Promise<any>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ITcbrServiceOptions } from '../../types';
|
|
2
|
+
export declare const describeCloudRunServerDetail: (options: {
|
|
3
|
+
envId: string;
|
|
4
|
+
serviceName: string;
|
|
5
|
+
}) => Promise<any>;
|
|
6
|
+
export declare function createCloudRunServer(serviceConfigOptions: any): Promise<any>;
|
|
7
|
+
export declare function createTcbrService(options: ITcbrServiceOptions): Promise<void>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface IPackageDeploy {
|
|
2
|
+
envId: string;
|
|
3
|
+
serviceName: string;
|
|
4
|
+
filePath: string;
|
|
5
|
+
fileToIgnore?: string | string[];
|
|
6
|
+
}
|
|
7
|
+
export declare function packageDeploy(options: IPackageDeploy): Promise<{
|
|
8
|
+
PackageName: any;
|
|
9
|
+
PackageVersion: any;
|
|
10
|
+
}>;
|
|
11
|
+
export {};
|
package/types/types.d.ts
CHANGED
|
@@ -325,8 +325,8 @@ export interface IListBranch {
|
|
|
325
325
|
export interface IListImage {
|
|
326
326
|
envId: string;
|
|
327
327
|
serviceName: string;
|
|
328
|
-
limit
|
|
329
|
-
offset
|
|
328
|
+
limit?: number;
|
|
329
|
+
offset?: number;
|
|
330
330
|
}
|
|
331
331
|
export interface IDeleteImage {
|
|
332
332
|
envId: string;
|
|
@@ -458,3 +458,117 @@ export interface IGetFunctionAliasRes {
|
|
|
458
458
|
AddTime: string;
|
|
459
459
|
ModTime: string;
|
|
460
460
|
}
|
|
461
|
+
export interface ITcbrServerBaseConfig {
|
|
462
|
+
EnvId: string;
|
|
463
|
+
ServerName: string;
|
|
464
|
+
OpenAccessTypes: string[];
|
|
465
|
+
Cpu: number;
|
|
466
|
+
Mem: number;
|
|
467
|
+
MinNum: number;
|
|
468
|
+
MaxNum: number;
|
|
469
|
+
PolicyDetails: {
|
|
470
|
+
PolicyType: string;
|
|
471
|
+
PolicyThreshold: number;
|
|
472
|
+
}[];
|
|
473
|
+
CustomLogs: string;
|
|
474
|
+
EnvParams: string;
|
|
475
|
+
InitialDelaySeconds: number;
|
|
476
|
+
CreateTime: string;
|
|
477
|
+
Port: number;
|
|
478
|
+
HasDockerfile: boolean;
|
|
479
|
+
Dockerfile: string;
|
|
480
|
+
BuildDir: string;
|
|
481
|
+
}
|
|
482
|
+
export interface IDescribeCloudRunServerDetail {
|
|
483
|
+
BaseInfo: {
|
|
484
|
+
ServerName: string;
|
|
485
|
+
DefaultDomainName: string;
|
|
486
|
+
CustomDomainName: string;
|
|
487
|
+
Status: 'running' | 'deploying' | 'deploy_failed';
|
|
488
|
+
UpdateTime: string;
|
|
489
|
+
};
|
|
490
|
+
ServerConfig: ITcbrServerBaseConfig;
|
|
491
|
+
RequestId: string;
|
|
492
|
+
}
|
|
493
|
+
export interface ITcbrServiceOptions {
|
|
494
|
+
noConfirm: boolean;
|
|
495
|
+
override: boolean;
|
|
496
|
+
defaultOverride: boolean;
|
|
497
|
+
envId: string;
|
|
498
|
+
serviceName: string;
|
|
499
|
+
path: string;
|
|
500
|
+
cpu: number;
|
|
501
|
+
mem: number;
|
|
502
|
+
minNum: number;
|
|
503
|
+
maxNum: number;
|
|
504
|
+
policyDetails: string;
|
|
505
|
+
customLogs: string;
|
|
506
|
+
envParams: string;
|
|
507
|
+
containerPort: number;
|
|
508
|
+
remark: string;
|
|
509
|
+
targetDir: string;
|
|
510
|
+
dockerfile: string;
|
|
511
|
+
image: string;
|
|
512
|
+
library_image: string;
|
|
513
|
+
json: boolean;
|
|
514
|
+
}
|
|
515
|
+
export interface ICloudRunProcessLog {
|
|
516
|
+
EnvId: string;
|
|
517
|
+
RunId: string;
|
|
518
|
+
}
|
|
519
|
+
export interface ICloudRunBuildLog {
|
|
520
|
+
EnvId: string;
|
|
521
|
+
ServerName: string;
|
|
522
|
+
ServerVersion: string;
|
|
523
|
+
BuildId: number;
|
|
524
|
+
Offset: number;
|
|
525
|
+
}
|
|
526
|
+
export interface IDescribeWxCloudBaseRunReleaseOrder {
|
|
527
|
+
envId: string;
|
|
528
|
+
serviceName: string;
|
|
529
|
+
}
|
|
530
|
+
export interface IGetLogs {
|
|
531
|
+
envId: string;
|
|
532
|
+
taskId: number;
|
|
533
|
+
serviceName: string;
|
|
534
|
+
}
|
|
535
|
+
export interface ITcbrServiceConfigOptions {
|
|
536
|
+
serviceName: string;
|
|
537
|
+
envId: string;
|
|
538
|
+
cpu: number;
|
|
539
|
+
mem: number;
|
|
540
|
+
minNum: number;
|
|
541
|
+
maxNum: number;
|
|
542
|
+
policyDetails: string;
|
|
543
|
+
customLogs: string;
|
|
544
|
+
envParams: string;
|
|
545
|
+
}
|
|
546
|
+
export interface IServerInfo {
|
|
547
|
+
ServerName: string;
|
|
548
|
+
DefaultDomainName: string;
|
|
549
|
+
CustomDomainName: string;
|
|
550
|
+
Status: string;
|
|
551
|
+
UpdateTime: string;
|
|
552
|
+
CreatedTime: string;
|
|
553
|
+
}
|
|
554
|
+
export interface ITcbrServiceRequiredOptions {
|
|
555
|
+
envId: string;
|
|
556
|
+
serviceName: string;
|
|
557
|
+
containerPort: number;
|
|
558
|
+
isCreated: boolean;
|
|
559
|
+
path: string;
|
|
560
|
+
library_image: string;
|
|
561
|
+
image: string;
|
|
562
|
+
}
|
|
563
|
+
export interface ITcbrServiceOptionalOptions {
|
|
564
|
+
cpu: number | string;
|
|
565
|
+
mem: number | string;
|
|
566
|
+
maxNum: number | string;
|
|
567
|
+
minNum: number | string;
|
|
568
|
+
}
|
|
569
|
+
export interface ITcbrServiceConvertedOptionalOptions {
|
|
570
|
+
cpuConverted: number;
|
|
571
|
+
memConverted: number;
|
|
572
|
+
maxNumConverted: number;
|
|
573
|
+
minNumConverted: number;
|
|
574
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ITcbrServiceOptionalOptions, ITcbrServiceConvertedOptionalOptions } from '../types';
|
|
2
|
+
export declare function parseOptionalParams(options: ITcbrServiceOptionalOptions): ITcbrServiceConvertedOptionalOptions;
|
|
3
|
+
export declare function parseInputParam(originalParam: any, override: boolean, handler: Function | null, overrideVal: any, defaultVal: any, ...args: any[]): any;
|
package/types/utils/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function callTcbrApi(action: string, data: Record<string, any>): Promise<any>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './callTcbrApi';
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { fetch as _fetch, fetchStream as _fetchStream } from './request';
|
|
2
|
+
export interface ServiceOptions {
|
|
3
|
+
service: string;
|
|
4
|
+
version?: string;
|
|
5
|
+
proxy?: string;
|
|
6
|
+
timeout?: number;
|
|
7
|
+
region?: string;
|
|
8
|
+
baseParams?: Record<string, any>;
|
|
9
|
+
credential?: Credential;
|
|
10
|
+
getCredential?: () => Promise<Credential> | Credential;
|
|
11
|
+
}
|
|
12
|
+
export interface Credential {
|
|
13
|
+
secretId: string;
|
|
14
|
+
secretKey: string;
|
|
15
|
+
token?: string;
|
|
16
|
+
tokenExpired?: number;
|
|
17
|
+
}
|
|
18
|
+
export interface RequestOptions {
|
|
19
|
+
action: string;
|
|
20
|
+
data?: Record<string, any>;
|
|
21
|
+
method?: 'POST' | 'GET';
|
|
22
|
+
region?: string;
|
|
23
|
+
}
|
|
24
|
+
export declare const fetch: typeof _fetch;
|
|
25
|
+
export declare const fetchStream: typeof _fetchStream;
|
|
26
|
+
export declare const nodeFetch: typeof import("node-fetch").default;
|
|
27
|
+
export declare class CloudApiService {
|
|
28
|
+
static serviceCacheMap: Record<string, CloudApiService>;
|
|
29
|
+
static getInstance(options: ServiceOptions): CloudApiService;
|
|
30
|
+
service: string;
|
|
31
|
+
version: string;
|
|
32
|
+
proxy: string;
|
|
33
|
+
timeout: number;
|
|
34
|
+
region: string;
|
|
35
|
+
credential: Credential;
|
|
36
|
+
baseParams: Record<string, any>;
|
|
37
|
+
getCredential: () => Promise<Credential> | Credential;
|
|
38
|
+
url: string;
|
|
39
|
+
host: string;
|
|
40
|
+
action: string;
|
|
41
|
+
method: 'POST' | 'GET';
|
|
42
|
+
data: Record<string, any>;
|
|
43
|
+
payload: Record<string, any>;
|
|
44
|
+
constructor(options: ServiceOptions);
|
|
45
|
+
get baseUrl(): any;
|
|
46
|
+
request(options: RequestOptions): any;
|
|
47
|
+
request(action: string, data?: Record<string, any>, method?: 'POST' | 'GET'): any;
|
|
48
|
+
requestWithSign(region: any): Promise<any>;
|
|
49
|
+
getRequestSign(timestamp: number): string;
|
|
50
|
+
clearCredentialCache(): void;
|
|
51
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
interface Options {
|
|
2
|
+
exit?: number;
|
|
3
|
+
original?: Error | undefined;
|
|
4
|
+
code?: string | number;
|
|
5
|
+
requestId?: string;
|
|
6
|
+
action?: string;
|
|
7
|
+
type?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare class CloudBaseError extends Error {
|
|
10
|
+
readonly exit: number;
|
|
11
|
+
readonly message: string;
|
|
12
|
+
readonly name = "CloudBaseError";
|
|
13
|
+
readonly original: Error | undefined;
|
|
14
|
+
readonly code: string | number;
|
|
15
|
+
readonly requestId: string;
|
|
16
|
+
readonly action: string;
|
|
17
|
+
readonly type: string;
|
|
18
|
+
constructor(message: string, options?: Options);
|
|
19
|
+
}
|
|
20
|
+
export {};
|