@cloudbase/manager-node 4.2.10 → 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/access/index.js +9 -9
- package/lib/cloudBaseRun/index.js +3 -3
- package/lib/cloudrun/index.js +157 -0
- package/lib/cloudrun/type.js +14 -0
- package/lib/database/index.js +1 -1
- package/lib/env/index.js +9 -8
- package/lib/environment.js +9 -4
- package/lib/function/index.js +39 -36
- package/lib/function/packer.js +42 -9
- package/lib/hosting/index.js +19 -19
- package/lib/index.js +17 -14
- package/lib/interfaces/index.js +6 -2
- package/lib/storage/index.js +38 -38
- package/lib/user/index.js +7 -7
- package/lib/utils/auth.js +1 -2
- package/lib/utils/cloud-api-request.js +5 -5
- package/lib/utils/cloudbase-request.js +3 -4
- package/lib/utils/envLazy.js +1 -2
- package/lib/utils/fs.js +5 -6
- package/lib/utils/http-request.js +6 -7
- package/lib/utils/index.js +70 -17
- package/lib/utils/runenv.js +1 -2
- package/lib/utils/uuid.js +2 -3
- package/package.json +16 -6
- package/scripts/link.js +98 -0
- package/tsconfig.json +2 -1
- package/types/cloudrun/index.d.ts +81 -0
- package/types/cloudrun/type.d.ts +315 -0
- package/types/env/index.d.ts +1 -1
- package/types/environment.d.ts +3 -0
- package/types/function/types.d.ts +1 -1
- package/types/hosting/index.d.ts +3 -4
- package/types/index.d.ts +2 -0
- package/types/storage/index.d.ts +3 -4
- package/types/user/types.d.ts +1 -1
- package/types/utils/fs.d.ts +1 -1
- package/types/utils/http-request.d.ts +3 -2
- package/types/utils/index.d.ts +18 -3
- package/types/utils/parallel.d.ts +1 -1
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
export declare enum CloudrunServerType {
|
|
2
|
+
/**
|
|
3
|
+
* 函数型服务
|
|
4
|
+
*/
|
|
5
|
+
Function = "function",
|
|
6
|
+
/**
|
|
7
|
+
* 容器型服务
|
|
8
|
+
*/
|
|
9
|
+
Container = "container"
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* 服务基础信息接口
|
|
13
|
+
*/
|
|
14
|
+
export interface ICloudrunServerBaseInfo {
|
|
15
|
+
/**
|
|
16
|
+
* 服务名称
|
|
17
|
+
* @example "serverName"
|
|
18
|
+
*/
|
|
19
|
+
ServerName: string;
|
|
20
|
+
/**
|
|
21
|
+
* 默认服务域名
|
|
22
|
+
* @example "http://xxx.xxx.xxx"
|
|
23
|
+
*/
|
|
24
|
+
DefaultDomainName: string;
|
|
25
|
+
/**
|
|
26
|
+
* 自定义域名
|
|
27
|
+
* @example "http://xxx.xxx.xxx"
|
|
28
|
+
*/
|
|
29
|
+
CustomDomainName: string;
|
|
30
|
+
/**
|
|
31
|
+
* 服务状态
|
|
32
|
+
* @example "running" | "deploying" | "deploy_failed"
|
|
33
|
+
*/
|
|
34
|
+
Status: 'running' | 'deploying' | 'deploy_failed';
|
|
35
|
+
/**
|
|
36
|
+
* 更新时间
|
|
37
|
+
* @example "2022-03-09 14:00:00"
|
|
38
|
+
*/
|
|
39
|
+
UpdateTime: string;
|
|
40
|
+
/**
|
|
41
|
+
* 公网访问类型数组
|
|
42
|
+
* @example ["OA","MINIAPP","VPC"]
|
|
43
|
+
*/
|
|
44
|
+
AccessTypes: string[];
|
|
45
|
+
/**
|
|
46
|
+
* 展示自定义域名数组
|
|
47
|
+
* @example ["http://xxx.xxx.xxx","http://xxx.xxx.xxx"]
|
|
48
|
+
*/
|
|
49
|
+
CustomDomainNames: string[];
|
|
50
|
+
/**
|
|
51
|
+
* 服务类型
|
|
52
|
+
* @example "function" | "container"
|
|
53
|
+
*/
|
|
54
|
+
ServerType: CloudrunServerType;
|
|
55
|
+
/**
|
|
56
|
+
* 流量类型(请根据实际业务补充具体类型定义)
|
|
57
|
+
*/
|
|
58
|
+
TrafficType?: string;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* 扩缩容策略配置
|
|
62
|
+
*/
|
|
63
|
+
export interface ICloudrunHpaPolicy {
|
|
64
|
+
/**
|
|
65
|
+
* 扩缩容类型
|
|
66
|
+
* @example "cpu" | "mem" | "cpu/mem"
|
|
67
|
+
*/
|
|
68
|
+
PolicyType: string;
|
|
69
|
+
/**
|
|
70
|
+
* 扩缩容阈值(百分比)
|
|
71
|
+
* @example 60
|
|
72
|
+
*/
|
|
73
|
+
PolicyThreshold: number;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* 定时扩缩容配置
|
|
77
|
+
*/
|
|
78
|
+
export interface ICloudrunTimerScale {
|
|
79
|
+
/**
|
|
80
|
+
* 循环类型
|
|
81
|
+
* @example "none"
|
|
82
|
+
*/
|
|
83
|
+
CycleType?: string;
|
|
84
|
+
/**
|
|
85
|
+
* 循环起始日期
|
|
86
|
+
* @example "2022-09-08"
|
|
87
|
+
*/
|
|
88
|
+
StartDate?: string;
|
|
89
|
+
/**
|
|
90
|
+
* 循环结束日期
|
|
91
|
+
* @example "2022-09-08"
|
|
92
|
+
*/
|
|
93
|
+
EndDate?: string;
|
|
94
|
+
/**
|
|
95
|
+
* 起始时间
|
|
96
|
+
* @example "00:00:00"
|
|
97
|
+
*/
|
|
98
|
+
StartTime?: string;
|
|
99
|
+
/**
|
|
100
|
+
* 结束时间
|
|
101
|
+
* @example "23:59:00"
|
|
102
|
+
*/
|
|
103
|
+
EndTime?: string;
|
|
104
|
+
/**
|
|
105
|
+
* 副本个数
|
|
106
|
+
* @example 1
|
|
107
|
+
*/
|
|
108
|
+
ReplicaNum?: number;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* 服务基础配置信息
|
|
112
|
+
*/
|
|
113
|
+
export interface ICloudrunServerBaseConfig {
|
|
114
|
+
/**
|
|
115
|
+
* 环境 ID
|
|
116
|
+
* @example "test-1gbtbgkjf8f48e2c"
|
|
117
|
+
*/
|
|
118
|
+
EnvId: string;
|
|
119
|
+
/**
|
|
120
|
+
* 服务名称
|
|
121
|
+
* @example "server-name"
|
|
122
|
+
*/
|
|
123
|
+
ServerName: string;
|
|
124
|
+
/**
|
|
125
|
+
* 公网访问类型数组
|
|
126
|
+
* @example ["PUBLIC", "OA", "MINIAPP", "VPC", ""]
|
|
127
|
+
*/
|
|
128
|
+
OpenAccessTypes: string[];
|
|
129
|
+
/**
|
|
130
|
+
* CPU 规格
|
|
131
|
+
* @example 0.25
|
|
132
|
+
*/
|
|
133
|
+
Cpu: number;
|
|
134
|
+
/**
|
|
135
|
+
* 内存规格
|
|
136
|
+
* @example 0.25
|
|
137
|
+
*/
|
|
138
|
+
Mem: number;
|
|
139
|
+
/**
|
|
140
|
+
* 最小副本数
|
|
141
|
+
* @example 1
|
|
142
|
+
*/
|
|
143
|
+
MinNum: number;
|
|
144
|
+
/**
|
|
145
|
+
* 最大副本数
|
|
146
|
+
* @example 2
|
|
147
|
+
*/
|
|
148
|
+
MaxNum: number;
|
|
149
|
+
/**
|
|
150
|
+
* 扩缩容配置
|
|
151
|
+
* @example cpu, mem, cpu/mem
|
|
152
|
+
*/
|
|
153
|
+
PolicyDetails: ICloudrunHpaPolicy[];
|
|
154
|
+
/**
|
|
155
|
+
* 日志采集路径
|
|
156
|
+
* @example "stdout"
|
|
157
|
+
*/
|
|
158
|
+
CustomLogs: string;
|
|
159
|
+
/**
|
|
160
|
+
* 环境变量
|
|
161
|
+
* @example {"MYSQL_USERNAME":"root"}
|
|
162
|
+
*/
|
|
163
|
+
EnvParams: string;
|
|
164
|
+
/**
|
|
165
|
+
* 延迟检测时间(秒)
|
|
166
|
+
* @example 2
|
|
167
|
+
*/
|
|
168
|
+
InitialDelaySeconds: number;
|
|
169
|
+
/**
|
|
170
|
+
* 创建时间
|
|
171
|
+
* @example "2022-03-10 19:44:07"
|
|
172
|
+
*/
|
|
173
|
+
CreateTime: string;
|
|
174
|
+
/**
|
|
175
|
+
* 服务端口
|
|
176
|
+
* @example 8080
|
|
177
|
+
*/
|
|
178
|
+
Port: number;
|
|
179
|
+
/**
|
|
180
|
+
* 是否有 Dockerfile
|
|
181
|
+
* @example true
|
|
182
|
+
*/
|
|
183
|
+
HasDockerfile: boolean;
|
|
184
|
+
/**
|
|
185
|
+
* Dockerfile 文件名
|
|
186
|
+
* @example "Dockerfile"
|
|
187
|
+
*/
|
|
188
|
+
Dockerfile: string;
|
|
189
|
+
/**
|
|
190
|
+
* 构建目录
|
|
191
|
+
* @example "src/"
|
|
192
|
+
*/
|
|
193
|
+
BuildDir: string;
|
|
194
|
+
/**
|
|
195
|
+
* 日志类型
|
|
196
|
+
* @example "none" | "default" | "custom"
|
|
197
|
+
*/
|
|
198
|
+
LogType?: string;
|
|
199
|
+
/**
|
|
200
|
+
* CLS 日志集 ID
|
|
201
|
+
* @example "dafslakfjkdal"
|
|
202
|
+
*/
|
|
203
|
+
LogSetId?: string;
|
|
204
|
+
/**
|
|
205
|
+
* CLS 主题 ID
|
|
206
|
+
* @example "sfafkslkfj"
|
|
207
|
+
*/
|
|
208
|
+
LogTopicId?: string;
|
|
209
|
+
/**
|
|
210
|
+
* 日志解析类型
|
|
211
|
+
* @example "json" | "line"
|
|
212
|
+
*/
|
|
213
|
+
LogParseType?: string;
|
|
214
|
+
/**
|
|
215
|
+
* 服务标签
|
|
216
|
+
* @example "function"
|
|
217
|
+
*/
|
|
218
|
+
Tag?: string;
|
|
219
|
+
/**
|
|
220
|
+
* 内网访问开关
|
|
221
|
+
* @example "close" | "open"
|
|
222
|
+
*/
|
|
223
|
+
InternalAccess?: string;
|
|
224
|
+
/**
|
|
225
|
+
* 内网域名
|
|
226
|
+
* @example "https://sdfsdf"
|
|
227
|
+
*/
|
|
228
|
+
InternalDomain?: string;
|
|
229
|
+
/**
|
|
230
|
+
* 运行模式
|
|
231
|
+
* @example "custom"
|
|
232
|
+
*/
|
|
233
|
+
OperationMode?: string;
|
|
234
|
+
/**
|
|
235
|
+
* 定时扩缩容配置
|
|
236
|
+
*/
|
|
237
|
+
TimerScale?: ICloudrunTimerScale[];
|
|
238
|
+
/**
|
|
239
|
+
* Dockerfile EntryPoint 参数
|
|
240
|
+
* @example ["echo", "test"]
|
|
241
|
+
*/
|
|
242
|
+
EntryPoint?: string[];
|
|
243
|
+
/**
|
|
244
|
+
* Dockerfile Cmd 参数
|
|
245
|
+
* @example ["echo", "test"]
|
|
246
|
+
*/
|
|
247
|
+
Cmd?: string[];
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* 在线版本信息
|
|
251
|
+
*/
|
|
252
|
+
export interface ICloudrunOnlineVersionInfo {
|
|
253
|
+
/**
|
|
254
|
+
* 版本名称
|
|
255
|
+
* @example "test-001"
|
|
256
|
+
*/
|
|
257
|
+
VersionName: string;
|
|
258
|
+
/**
|
|
259
|
+
* 镜像URL
|
|
260
|
+
* @example "imageurl"
|
|
261
|
+
*/
|
|
262
|
+
ImageUrl: string;
|
|
263
|
+
/**
|
|
264
|
+
* 流量比例
|
|
265
|
+
* @example "100"
|
|
266
|
+
*/
|
|
267
|
+
FlowRatio: string;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* 服务列表响应接口
|
|
271
|
+
*/
|
|
272
|
+
export interface ICloudrunListResponse {
|
|
273
|
+
/**
|
|
274
|
+
* 服务列表数组
|
|
275
|
+
*/
|
|
276
|
+
ServerList: ICloudrunServerBaseInfo[];
|
|
277
|
+
/**
|
|
278
|
+
* 服务总数
|
|
279
|
+
* @example 10
|
|
280
|
+
*/
|
|
281
|
+
Total: number;
|
|
282
|
+
/**
|
|
283
|
+
* 请求ID
|
|
284
|
+
*/
|
|
285
|
+
RequestId: string;
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* 服务详情响应接口
|
|
289
|
+
*/
|
|
290
|
+
export interface ICloudrunDetailResponse {
|
|
291
|
+
/**
|
|
292
|
+
* 服务基本信息
|
|
293
|
+
*/
|
|
294
|
+
BaseInfo: ICloudrunServerBaseInfo;
|
|
295
|
+
/**
|
|
296
|
+
* 服务配置信息
|
|
297
|
+
*/
|
|
298
|
+
ServerConfig: ICloudrunServerBaseConfig;
|
|
299
|
+
/**
|
|
300
|
+
* 在线版本信息
|
|
301
|
+
*/
|
|
302
|
+
OnlineVersionInfos: ICloudrunOnlineVersionInfo[];
|
|
303
|
+
/**
|
|
304
|
+
* 请求ID
|
|
305
|
+
*/
|
|
306
|
+
RequestId: string;
|
|
307
|
+
}
|
|
308
|
+
export interface ITemplate {
|
|
309
|
+
identifier: string;
|
|
310
|
+
title: string;
|
|
311
|
+
description: string;
|
|
312
|
+
runtimeVersion: string;
|
|
313
|
+
language: string;
|
|
314
|
+
zipFileStore: string;
|
|
315
|
+
}
|
package/types/env/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Environment } from '../environment';
|
|
2
2
|
import { IResponseInfo, AuthDomain, EnvInfo, LoginConfigItem, ICheckTcbServiceRes, ICreatePostpayRes } from '../interfaces';
|
|
3
|
-
|
|
3
|
+
type SOURCE = 'miniapp' | 'qcloud';
|
|
4
4
|
interface IDeleteDomainRes {
|
|
5
5
|
RequestId: string;
|
|
6
6
|
Deleted: number;
|
package/types/environment.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DatabaseService } from './database';
|
|
2
2
|
import { FunctionService } from './function';
|
|
3
|
+
import { CloudRunService } from './cloudrun';
|
|
3
4
|
import { StorageService } from './storage';
|
|
4
5
|
import { EnvService } from './env';
|
|
5
6
|
import { CommonService } from './common';
|
|
@@ -17,6 +18,7 @@ export declare class Environment {
|
|
|
17
18
|
private envId;
|
|
18
19
|
private envType?;
|
|
19
20
|
private functionService;
|
|
21
|
+
private cloudRunService;
|
|
20
22
|
private databaseService;
|
|
21
23
|
private storageService;
|
|
22
24
|
private envService;
|
|
@@ -32,6 +34,7 @@ export declare class Environment {
|
|
|
32
34
|
getStorageService(): StorageService;
|
|
33
35
|
getDatabaseService(): DatabaseService;
|
|
34
36
|
getFunctionService(): FunctionService;
|
|
37
|
+
getCloudRunService(): CloudRunService;
|
|
35
38
|
getEnvService(): EnvService;
|
|
36
39
|
getHostingService(): HostingService;
|
|
37
40
|
getThirdService(): ThirdService;
|
|
@@ -60,7 +60,7 @@ export interface IFunctionLog {
|
|
|
60
60
|
export interface ILogFilter {
|
|
61
61
|
RetCode?: 'not0' | 'is0' | 'TimeLimitExceeded' | 'ResourceLimitExceeded' | 'UserCodeException';
|
|
62
62
|
}
|
|
63
|
-
export
|
|
63
|
+
export type IRegion = number;
|
|
64
64
|
export interface IEnvVariable {
|
|
65
65
|
Key: string;
|
|
66
66
|
Value: string;
|
package/types/hosting/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { Environment } from '../environment';
|
|
3
2
|
import { IListFileInfo } from '../interfaces';
|
|
4
3
|
export interface IProgressData {
|
|
@@ -7,8 +6,8 @@ export interface IProgressData {
|
|
|
7
6
|
speed: number;
|
|
8
7
|
percent: number;
|
|
9
8
|
}
|
|
10
|
-
export
|
|
11
|
-
export
|
|
9
|
+
export type OnProgress = (progressData: IProgressData) => void;
|
|
10
|
+
export type OnFileFinish = (error: Error, res: any, fileData: any) => void;
|
|
12
11
|
export interface IHostingFileOptions {
|
|
13
12
|
localPath: string;
|
|
14
13
|
cloudPath?: string;
|
|
@@ -37,7 +36,7 @@ export interface IHostingFilesOptions {
|
|
|
37
36
|
retryCount?: number;
|
|
38
37
|
retryInterval?: number;
|
|
39
38
|
}
|
|
40
|
-
export
|
|
39
|
+
export type IHostingOptions = IHostingFileOptions | IHostingFilesOptions;
|
|
41
40
|
export interface IHostingCloudOptions {
|
|
42
41
|
cloudPath: string;
|
|
43
42
|
isDir: boolean;
|
package/types/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { EnvService } from './env';
|
|
2
2
|
import { FunctionService } from './function';
|
|
3
|
+
import { CloudRunService } from './cloudrun';
|
|
3
4
|
import { StorageService } from './storage';
|
|
4
5
|
import { DatabaseService } from './database';
|
|
5
6
|
import { CommonService } from './common';
|
|
@@ -37,6 +38,7 @@ declare class CloudBase {
|
|
|
37
38
|
addEnvironment(envId: string): void;
|
|
38
39
|
currentEnvironment(): Environment;
|
|
39
40
|
get functions(): FunctionService;
|
|
41
|
+
get cloudrun(): CloudRunService;
|
|
40
42
|
get storage(): StorageService;
|
|
41
43
|
get database(): DatabaseService;
|
|
42
44
|
get hosting(): HostingService;
|
package/types/storage/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { Environment } from '../environment';
|
|
3
2
|
import { IUploadMetadata, IListFileInfo, IFileInfo, ITempUrlInfo, IResponseInfo } from '../interfaces';
|
|
4
3
|
export interface IProgressData {
|
|
@@ -60,9 +59,9 @@ export interface IGetBucketOpions {
|
|
|
60
59
|
marker?: string;
|
|
61
60
|
maxKeys?: number;
|
|
62
61
|
}
|
|
63
|
-
export
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
export type AclType = 'READONLY' | 'PRIVATE' | 'ADMINWRITE' | 'ADMINONLY';
|
|
63
|
+
type OnProgress = (progressData: IProgressData) => void;
|
|
64
|
+
type OnFileFinish = (error: Error, res: any, fileData: any) => void;
|
|
66
65
|
export declare class StorageService {
|
|
67
66
|
private environment;
|
|
68
67
|
private tcbService;
|
package/types/user/types.d.ts
CHANGED
package/types/utils/fs.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
type SizeUnit = 'MB' | 'GB';
|
|
2
2
|
export declare function checkFullAccess(dest: string, throwError?: boolean): boolean;
|
|
3
3
|
export declare function checkReadable(dest: string, throwError?: boolean): boolean;
|
|
4
4
|
export declare function isDirectory(dest: string): boolean;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function
|
|
1
|
+
import _fetch from 'node-fetch';
|
|
2
|
+
export declare function fetch(url: string, config?: Record<string, any>, proxy?: any): Promise<any>;
|
|
3
|
+
export declare function fetchStream(url: string, config?: Record<string, any>, proxy?: any): Promise<_fetch.Response>;
|
package/types/utils/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
export * from './cloud-api-request';
|
|
1
|
+
import { ITemplate } from '../cloudrun/type';
|
|
3
2
|
export * from './auth';
|
|
3
|
+
export * from './cloud-api-request';
|
|
4
4
|
export * from './cloudbase-request';
|
|
5
|
-
export * from './http-request';
|
|
6
5
|
export * from './envLazy';
|
|
7
6
|
export * from './fs';
|
|
7
|
+
export * from './http-request';
|
|
8
|
+
export { guid6 } from './uuid';
|
|
8
9
|
interface IZipOption {
|
|
9
10
|
dirPath: string;
|
|
10
11
|
outputPath: string;
|
|
@@ -12,9 +13,23 @@ interface IZipOption {
|
|
|
12
13
|
pattern?: string;
|
|
13
14
|
}
|
|
14
15
|
export declare function compressToZip(option: IZipOption): Promise<unknown>;
|
|
16
|
+
/**
|
|
17
|
+
* 下载并解压云托管模板到指定目录
|
|
18
|
+
* @param {string} downloadUrl 模板下载地址
|
|
19
|
+
* @param {string} targetPath 目标路径
|
|
20
|
+
* @returns {Promise<void>}
|
|
21
|
+
* @throws 当下载失败或解压失败时抛出错误
|
|
22
|
+
*/
|
|
23
|
+
export declare function downloadAndExtractRemoteZip(downloadUrl: string, targetPath: string): Promise<void>;
|
|
15
24
|
export declare function getRuntime(): string;
|
|
16
25
|
export declare function getEnvVar(envName: string): string;
|
|
17
26
|
export declare function rsaEncrypt(data: string): string;
|
|
18
27
|
export declare function sleep(time: number): Promise<void>;
|
|
19
28
|
export declare function upperCaseStringFisrt(str: string): string;
|
|
20
29
|
export declare function upperCaseObjKey(object: any): any;
|
|
30
|
+
/**
|
|
31
|
+
* 获取函数模板列表
|
|
32
|
+
* @param type 函数模板类型,支持 'scfFunc' 和 'tcbrFunc'
|
|
33
|
+
* @returns
|
|
34
|
+
*/
|
|
35
|
+
export declare function fetchTemplates(types: ('scfFunc' | 'tcbrFunc' | 'tcbrContainer')[]): Promise<ITemplate[]>;
|