@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.
Files changed (120) hide show
  1. package/bin/tcb.js +6 -4
  2. package/lib/commands/run/create.js +6 -1
  3. package/lib/commands/run/delete.js +6 -1
  4. package/lib/commands/run/image/common.js +1 -1
  5. package/lib/commands/run/image/delete.js +5 -0
  6. package/lib/commands/run/image/download.js +5 -0
  7. package/lib/commands/run/image/list.js +5 -0
  8. package/lib/commands/run/image/upload.js +5 -0
  9. package/lib/commands/run/index.js +1 -0
  10. package/lib/commands/run/list.js +7 -1
  11. package/lib/commands/run/service/config.js +112 -0
  12. package/lib/commands/run/service/create.js +140 -0
  13. package/lib/commands/run/service/deploy.js +145 -0
  14. package/lib/commands/run/service/index.js +21 -0
  15. package/lib/commands/run/service/list.js +115 -0
  16. package/lib/commands/run/service/update.js +132 -0
  17. package/lib/commands/run/version/common.js +1 -1
  18. package/lib/commands/run/version/create.js +5 -0
  19. package/lib/commands/run/version/delete.js +5 -0
  20. package/lib/commands/run/version/list.js +5 -0
  21. package/lib/commands/run/version/modify.js +5 -0
  22. package/lib/commands/run/version/update.js +5 -0
  23. package/lib/constant.js +20 -1
  24. package/lib/help.js +40 -38
  25. package/lib/run/index.js +1 -0
  26. package/lib/run/service/common.js +163 -0
  27. package/lib/run/service/config.js +70 -0
  28. package/lib/run/service/create.js +67 -0
  29. package/lib/run/service/deployPackage.js +89 -0
  30. package/lib/run/service/index.js +23 -0
  31. package/lib/run/service/list.js +31 -0
  32. package/lib/run/service/showLogs.js +116 -0
  33. package/lib/run/service/update.js +83 -0
  34. package/lib/utils/checkTcbrEnv.js +74 -0
  35. package/lib/utils/commonParamsCheck.js +48 -0
  36. package/lib/utils/index.js +3 -0
  37. package/lib/utils/net/http-request.js +4 -4
  38. package/lib/utils/tcbrApi/callTcbrApi.js +38 -0
  39. package/lib/utils/tcbrApi/index.js +17 -0
  40. package/lib/utils/tcbrApi/tcbr-cloud-api/cloud-api-service.js +268 -0
  41. package/lib/utils/tcbrApi/tcbr-cloud-api/error.js +17 -0
  42. package/lib/utils/tcbrApi/tcbr-cloud-api/index.js +17 -0
  43. package/lib/utils/tcbrApi/tcbr-cloud-api/request.js +40 -0
  44. package/lib/utils/tcbrApi/tcbr-cloud-api-request.js +61 -0
  45. package/lib/utils/validator.js +32 -1
  46. package/package.json +88 -88
  47. package/src/commands/run/create.ts +9 -2
  48. package/src/commands/run/delete.ts +8 -2
  49. package/src/commands/run/image/common.ts +1 -1
  50. package/src/commands/run/image/delete.ts +8 -1
  51. package/src/commands/run/image/download.ts +7 -1
  52. package/src/commands/run/image/list.ts +7 -2
  53. package/src/commands/run/image/upload.ts +8 -1
  54. package/src/commands/run/index.ts +2 -1
  55. package/src/commands/run/list.ts +11 -3
  56. package/src/commands/run/service/config.ts +81 -0
  57. package/src/commands/run/service/create.ts +118 -0
  58. package/src/commands/run/service/deploy.ts +121 -0
  59. package/src/commands/run/service/index.ts +5 -0
  60. package/src/commands/run/service/list.ts +94 -0
  61. package/src/commands/run/service/update.ts +104 -0
  62. package/src/commands/run/version/common.ts +1 -1
  63. package/src/commands/run/version/create.ts +8 -1
  64. package/src/commands/run/version/delete.ts +8 -2
  65. package/src/commands/run/version/list.ts +7 -1
  66. package/src/commands/run/version/modify.ts +8 -1
  67. package/src/commands/run/version/update.ts +8 -1
  68. package/src/constant.ts +35 -1
  69. package/src/help.ts +50 -48
  70. package/src/run/index.ts +2 -1
  71. package/src/run/service/common.ts +206 -0
  72. package/src/run/service/config.ts +77 -0
  73. package/src/run/service/create.ts +52 -0
  74. package/src/run/service/deployPackage.ts +65 -0
  75. package/src/run/service/index.ts +7 -0
  76. package/src/run/service/list.ts +29 -0
  77. package/src/run/service/showLogs.ts +98 -0
  78. package/src/run/service/update.ts +81 -0
  79. package/src/types.ts +128 -2
  80. package/src/utils/checkTcbrEnv.ts +67 -0
  81. package/src/utils/commonParamsCheck.ts +65 -0
  82. package/src/utils/index.ts +5 -1
  83. package/src/utils/net/http-request.ts +1 -1
  84. package/src/utils/tcbrApi/callTcbrApi.ts +28 -0
  85. package/src/utils/tcbrApi/index.ts +1 -0
  86. package/src/utils/tcbrApi/tcbr-cloud-api/cloud-api-service.ts +363 -0
  87. package/src/utils/tcbrApi/tcbr-cloud-api/error.ts +30 -0
  88. package/src/utils/tcbrApi/tcbr-cloud-api/index.ts +1 -0
  89. package/src/utils/tcbrApi/tcbr-cloud-api/request.ts +28 -0
  90. package/src/utils/tcbrApi/tcbr-cloud-api-request.ts +66 -0
  91. package/src/utils/validator.ts +64 -32
  92. package/types/commands/run/index.d.ts +1 -0
  93. package/types/commands/run/service/config.d.ts +14 -0
  94. package/types/commands/run/service/create.d.ts +13 -0
  95. package/types/commands/run/service/deploy.d.ts +13 -0
  96. package/types/commands/run/service/index.d.ts +5 -0
  97. package/types/commands/run/service/list.d.ts +13 -0
  98. package/types/commands/run/service/update.d.ts +13 -0
  99. package/types/constant.d.ts +18 -0
  100. package/types/run/index.d.ts +1 -0
  101. package/types/run/service/common.d.ts +32 -0
  102. package/types/run/service/config.d.ts +23 -0
  103. package/types/run/service/create.d.ts +7 -0
  104. package/types/run/service/deployPackage.d.ts +11 -0
  105. package/types/run/service/index.d.ts +7 -0
  106. package/types/run/service/list.d.ts +2 -0
  107. package/types/run/service/showLogs.d.ts +2 -0
  108. package/types/run/service/update.d.ts +2 -0
  109. package/types/types.d.ts +116 -2
  110. package/types/utils/checkTcbrEnv.d.ts +3 -0
  111. package/types/utils/commonParamsCheck.d.ts +3 -0
  112. package/types/utils/index.d.ts +3 -0
  113. package/types/utils/tcbrApi/callTcbrApi.d.ts +1 -0
  114. package/types/utils/tcbrApi/index.d.ts +1 -0
  115. package/types/utils/tcbrApi/tcbr-cloud-api/cloud-api-service.d.ts +51 -0
  116. package/types/utils/tcbrApi/tcbr-cloud-api/error.d.ts +20 -0
  117. package/types/utils/tcbrApi/tcbr-cloud-api/index.d.ts +1 -0
  118. package/types/utils/tcbrApi/tcbr-cloud-api/request.d.ts +4 -0
  119. package/types/utils/tcbrApi/tcbr-cloud-api-request.d.ts +9 -0
  120. 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
+ }
@@ -1,33 +1,65 @@
1
- import { CloudBaseError } from '../error'
2
-
3
- type SimpleValue = number | string | boolean
4
-
5
- export function assertTruthy(val: SimpleValue | SimpleValue[], errMsg: string) {
6
- let ok
7
- if (Array.isArray(val)) {
8
- ok = val.every(item => Boolean(val))
9
- } else {
10
- ok = Boolean(val)
11
- }
12
-
13
- if (!ok) {
14
- throw new CloudBaseError(errMsg)
15
- }
16
- }
17
-
18
- export function assertHas(obj: any, prop: string, errMsg): void {
19
- if (!obj[prop]) {
20
- throw new CloudBaseError(errMsg)
21
- }
22
- }
23
-
24
-
25
- export const validateIp = (ip: string): boolean => {
26
- if (Object.prototype.toString.call(ip) !== '[object String]') return false
27
- const fields = ip.split('.')
28
- if (
29
- fields.length !== 4 ||
30
- fields.find(item => isNaN(Number(item)) || Number(item) < 0 || Number(item) > 255)
31
- ) return false
32
- return true
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
  }
@@ -4,3 +4,4 @@ export * from './version';
4
4
  export * from './delete';
5
5
  export * from './image';
6
6
  export * from './standalonegateway';
7
+ export * from './service';
@@ -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,5 @@
1
+ export * from './list';
2
+ export * from './create';
3
+ export * from './update';
4
+ export * from './deploy';
5
+ export * from './config';
@@ -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
+ }
@@ -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
+ }[];
@@ -5,3 +5,4 @@ export * from './image';
5
5
  export * from './delete';
6
6
  export * from './repo';
7
7
  export * from './standalonegateway';
8
+ export * from './service';
@@ -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 {};
@@ -0,0 +1,7 @@
1
+ export * from './list';
2
+ export * from './create';
3
+ export * from './showLogs';
4
+ export * from './deployPackage';
5
+ export * from './common';
6
+ export * from './update';
7
+ export * from './config';
@@ -0,0 +1,2 @@
1
+ import { IServerInfo } from '../../types';
2
+ export declare const listService: (options: any) => Promise<IServerInfo[]>;
@@ -0,0 +1,2 @@
1
+ export declare function getBuildStatus(envId: string, serviceName: string): Promise<string>;
2
+ export declare function getLogs(options: any): Promise<void>;
@@ -0,0 +1,2 @@
1
+ export declare function updateCloudRunServer(serviceConfigOptions: any): Promise<any>;
2
+ export declare function updateTcbrService(options: any): Promise<void>;
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: number;
329
- offset: number;
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 { EnumEnvCheck } from '../constant';
2
+ export declare function checkTcbrEnv(envId: string | undefined, isTcbr: boolean): Promise<EnumEnvCheck> | never;
3
+ export declare function logEnvCheck(envId: string, warningType: EnumEnvCheck): void;
@@ -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;
@@ -16,3 +16,6 @@ export * from './auth';
16
16
  export * from './store';
17
17
  export * from './notice';
18
18
  export * from './parallel';
19
+ export * from './tcbrApi';
20
+ export * from './checkTcbrEnv';
21
+ export * from './commonParamsCheck';
@@ -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 {};