@cloudbase/manager-node 4.11.0-alpha.1 → 4.11.0-alpha.11
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/.claude/settings.local.json +9 -0
- package/jest.config.js +1 -0
- package/lib/agent/index.js +607 -16
- package/lib/agent/type.js +1 -0
- package/lib/cloudApp/index.js +243 -0
- package/lib/cloudApp/types.js +10 -0
- package/lib/database/index.js +79 -0
- package/lib/docs/index.js +288 -0
- package/lib/docs/types.js +2 -0
- package/lib/env/index.js +92 -0
- package/lib/environment.js +20 -0
- package/lib/function/index.js +97 -33
- package/lib/index.js +34 -0
- package/lib/interfaces/cloudApp.interface.js +20 -0
- package/lib/interfaces/index.js +1 -0
- package/lib/log/index.js +105 -0
- package/lib/log/types.js +24 -0
- package/lib/mysql/index.js +551 -0
- package/lib/mysql/types/account.js +2 -0
- package/lib/mysql/types/backup.js +2 -0
- package/lib/mysql/types/base.js +2 -0
- package/lib/mysql/types/index.js +19 -0
- package/lib/permission/index.js +310 -0
- package/lib/permission/types.js +2 -0
- package/lib/storage/index.js +424 -10
- package/lib/user/index.js +200 -0
- package/package.json +1 -1
- package/types/agent/index.d.ts +115 -5
- package/types/agent/type.d.ts +389 -0
- package/types/cloudApp/index.d.ts +73 -0
- package/types/cloudApp/types.d.ts +325 -0
- package/types/database/index.d.ts +112 -0
- package/types/docs/index.d.ts +37 -0
- package/types/docs/types.d.ts +24 -0
- package/types/env/index.d.ts +39 -1
- package/types/env/type.d.ts +187 -0
- package/types/environment.d.ts +12 -0
- package/types/function/index.d.ts +34 -5
- package/types/index.d.ts +26 -0
- package/types/interfaces/cloudApp.interface.d.ts +4 -0
- package/types/interfaces/index.d.ts +1 -0
- package/types/log/index.d.ts +53 -0
- package/types/log/types.d.ts +177 -0
- package/types/mysql/index.d.ts +261 -0
- package/types/mysql/types/account.d.ts +160 -0
- package/types/mysql/types/backup.d.ts +161 -0
- package/types/mysql/types/base.d.ts +579 -0
- package/types/mysql/types/index.d.ts +3 -0
- package/types/permission/index.d.ts +31 -0
- package/types/permission/types.d.ts +127 -0
- package/types/storage/index.d.ts +151 -3
- package/types/user/index.d.ts +17 -1
- package/types/user/types.d.ts +62 -0
package/types/env/type.d.ts
CHANGED
|
@@ -14,3 +14,190 @@ export interface CalculatePackageModifyPriceParams {
|
|
|
14
14
|
envId: string;
|
|
15
15
|
currency?: 'CNY' | 'USD';
|
|
16
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* 客户端限频配置
|
|
19
|
+
*/
|
|
20
|
+
export interface HTTPServiceQPSPerClient {
|
|
21
|
+
LimitBy?: 'UserID' | 'ClientIP';
|
|
22
|
+
LimitValue?: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* QPS限频策略
|
|
26
|
+
*/
|
|
27
|
+
export interface HTTPServiceRouteQPSPolicy {
|
|
28
|
+
QPSTotal?: number;
|
|
29
|
+
QPSPerClient?: HTTPServiceQPSPerClient;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* 路径重写
|
|
33
|
+
*/
|
|
34
|
+
export interface HTTPServicePathRewrite {
|
|
35
|
+
StaticStorePrefix?: string;
|
|
36
|
+
Prefix?: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* HTTP访问服务路由信息
|
|
40
|
+
*/
|
|
41
|
+
export interface HTTPServiceRoute {
|
|
42
|
+
Path: string;
|
|
43
|
+
PathRewrite?: HTTPServicePathRewrite;
|
|
44
|
+
UpstreamResourceType: 'SCF' | 'CBR' | 'STATIC_STORE' | 'WEB_SCF' | 'LH';
|
|
45
|
+
UpstreamResourceName: string;
|
|
46
|
+
EnableSafeDomain: boolean;
|
|
47
|
+
EnableAuth: boolean;
|
|
48
|
+
EnablePathTransmission: boolean;
|
|
49
|
+
QPSPolicy?: HTTPServiceRouteQPSPolicy;
|
|
50
|
+
Enable: boolean;
|
|
51
|
+
CreateTime: string;
|
|
52
|
+
UpdateTime: string;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* 域名路由信息
|
|
56
|
+
*/
|
|
57
|
+
export interface HTTPServiceDomain {
|
|
58
|
+
Domain: string;
|
|
59
|
+
DomainType: 'HTTPSERVICE' | 'CBR' | 'ANYSERVICE' | 'AI_AGENT' | 'VM' | 'INTEGRATION_CALLBACK';
|
|
60
|
+
AccessType: 'DIRECT' | 'CDN' | 'CUSTOM';
|
|
61
|
+
CertId: string;
|
|
62
|
+
Protocol: 'HTTP_AND_HTTPS' | 'HTTP_TO_HTTPS' | 'HTTPS_TO_HTTP';
|
|
63
|
+
Cname: string;
|
|
64
|
+
IsDefault: boolean;
|
|
65
|
+
Enable: boolean;
|
|
66
|
+
Status: 'PROCESSING' | 'FAIL' | 'SUCCESS';
|
|
67
|
+
DNSStatus: 'OK' | 'INVALID';
|
|
68
|
+
Routes?: HTTPServiceRoute[];
|
|
69
|
+
CreateTime: string;
|
|
70
|
+
UpdateTime: string;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* 过滤条件
|
|
74
|
+
*/
|
|
75
|
+
export interface HTTPServiceRouteFilter {
|
|
76
|
+
Name?: 'Domain' | 'Path' | 'DomainType' | 'UpstreamResourceType';
|
|
77
|
+
Values?: string[];
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* DescribeHTTPServiceRoute 请求参数
|
|
81
|
+
*/
|
|
82
|
+
export interface DescribeHttpServiceRouteParams {
|
|
83
|
+
EnvId: string;
|
|
84
|
+
Filters?: HTTPServiceRouteFilter[];
|
|
85
|
+
Offset?: number;
|
|
86
|
+
Limit?: number;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* DescribeHTTPServiceRoute 返回结果
|
|
90
|
+
*/
|
|
91
|
+
export interface DescribeHttpServiceRouteRes {
|
|
92
|
+
Domains?: HTTPServiceDomain[];
|
|
93
|
+
OriginDomain: string;
|
|
94
|
+
TotalCount: number;
|
|
95
|
+
RequestId: string;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* HTTP访问服务路由参数(创建/修改)
|
|
99
|
+
*/
|
|
100
|
+
export interface HTTPServiceRouteParam {
|
|
101
|
+
Path: string;
|
|
102
|
+
UpstreamResourceType?: 'SCF' | 'CBR' | 'STATIC_STORE' | 'WEB_SCF' | 'LH';
|
|
103
|
+
UpstreamResourceName?: string;
|
|
104
|
+
PathRewrite?: HTTPServicePathRewrite;
|
|
105
|
+
EnableSafeDomain?: boolean;
|
|
106
|
+
EnableAuth?: boolean;
|
|
107
|
+
EnablePathTransmission?: boolean;
|
|
108
|
+
QPSPolicy?: HTTPServiceRouteQPSPolicy;
|
|
109
|
+
Enable?: boolean;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* HTTP访问服务域名参数(创建/修改)
|
|
113
|
+
*/
|
|
114
|
+
export interface HTTPServiceDomainParam {
|
|
115
|
+
Domain: string;
|
|
116
|
+
AccessType?: 'DIRECT' | 'CDN' | 'CUSTOM';
|
|
117
|
+
CertId?: string;
|
|
118
|
+
Protocol?: 'HTTP_AND_HTTPS' | 'HTTP_TO_HTTPS' | 'HTTPS_TO_HTTP';
|
|
119
|
+
CustomCname?: string;
|
|
120
|
+
Enable?: boolean;
|
|
121
|
+
Routes?: HTTPServiceRouteParam[];
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* CreateHTTPServiceRoute 请求参数
|
|
125
|
+
*/
|
|
126
|
+
export interface CreateHttpServiceRouteParams {
|
|
127
|
+
EnvId: string;
|
|
128
|
+
Domain: HTTPServiceDomainParam;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* CreateHTTPServiceRoute 返回结果
|
|
132
|
+
*/
|
|
133
|
+
export interface CreateHttpServiceRouteRes {
|
|
134
|
+
RequestId: string;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* ModifyHTTPServiceRoute 请求参数
|
|
138
|
+
*/
|
|
139
|
+
export interface ModifyHttpServiceRouteParams {
|
|
140
|
+
EnvId: string;
|
|
141
|
+
Domain: HTTPServiceDomainParam;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* ModifyHTTPServiceRoute 返回结果
|
|
145
|
+
*/
|
|
146
|
+
export interface ModifyHttpServiceRouteRes {
|
|
147
|
+
RequestId: string;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* DeleteHTTPServiceRoute 请求参数
|
|
151
|
+
*/
|
|
152
|
+
export interface DeleteHttpServiceRouteParams {
|
|
153
|
+
EnvId: string;
|
|
154
|
+
Domain: string;
|
|
155
|
+
Paths?: string[];
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* DeleteHTTPServiceRoute 返回结果
|
|
159
|
+
*/
|
|
160
|
+
export interface DeleteHttpServiceRouteRes {
|
|
161
|
+
RequestId: string;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* 绑定自定义域名的域名参数
|
|
165
|
+
* 与 HTTPServiceDomainParam 类似,但不包含 Routes(绑定域名场景)
|
|
166
|
+
*/
|
|
167
|
+
export interface BindCustomDomainDomainParam {
|
|
168
|
+
Domain: string;
|
|
169
|
+
CertId: string;
|
|
170
|
+
AccessType?: 'DIRECT' | 'CDN' | 'CUSTOM';
|
|
171
|
+
Protocol?: 'HTTP_AND_HTTPS' | 'HTTP_TO_HTTPS' | 'HTTPS_TO_HTTP';
|
|
172
|
+
Enable?: boolean;
|
|
173
|
+
CustomCname?: string;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* BindCustomDomain 请求参数
|
|
177
|
+
* 用于绑定自定义域名到 HTTP 访问服务
|
|
178
|
+
* 底层调用 CreateHTTPServiceRoute API,但参数配置不同
|
|
179
|
+
*/
|
|
180
|
+
export interface BindCustomDomainParams {
|
|
181
|
+
EnvId: string;
|
|
182
|
+
Domain: BindCustomDomainDomainParam;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* BindCustomDomain 返回结果
|
|
186
|
+
*/
|
|
187
|
+
export interface BindCustomDomainRes {
|
|
188
|
+
RequestId: string;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* DeleteCustomDomain 请求参数
|
|
192
|
+
* 用于删除自定义域名(仅当域名下无路由绑定时可删除)
|
|
193
|
+
*/
|
|
194
|
+
export interface DeleteCustomDomainParams {
|
|
195
|
+
EnvId: string;
|
|
196
|
+
Domain: string;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* DeleteCustomDomain 返回结果
|
|
200
|
+
*/
|
|
201
|
+
export interface DeleteCustomDomainRes {
|
|
202
|
+
RequestId: string;
|
|
203
|
+
}
|
package/types/environment.d.ts
CHANGED
|
@@ -5,13 +5,17 @@ import { AgentService } from './agent';
|
|
|
5
5
|
import { StorageService } from './storage';
|
|
6
6
|
import { EnvService } from './env';
|
|
7
7
|
import { CommonService } from './common';
|
|
8
|
+
import { LogService } from './log';
|
|
8
9
|
import { CloudBaseContext } from './context';
|
|
9
10
|
import { HostingService } from './hosting';
|
|
10
11
|
import { ThirdService } from './third';
|
|
11
12
|
import { AccessService } from './access';
|
|
12
13
|
import { UserService } from './user';
|
|
13
14
|
import { CloudBaseRunService } from './cloudBaseRun';
|
|
15
|
+
import { MysqlService } from './mysql';
|
|
16
|
+
import { CloudAppService } from './cloudApp';
|
|
14
17
|
import { EnvInfo } from './interfaces';
|
|
18
|
+
import { PermissionService } from './permission';
|
|
15
19
|
export declare class Environment {
|
|
16
20
|
inited: boolean;
|
|
17
21
|
cloudBaseContext: CloudBaseContext;
|
|
@@ -24,11 +28,15 @@ export declare class Environment {
|
|
|
24
28
|
private databaseService;
|
|
25
29
|
private storageService;
|
|
26
30
|
private envService;
|
|
31
|
+
private logService;
|
|
27
32
|
private hostingService;
|
|
28
33
|
private thirdService;
|
|
29
34
|
private accessService;
|
|
30
35
|
private userService;
|
|
31
36
|
private cloudBaseRunService;
|
|
37
|
+
private mysqlService;
|
|
38
|
+
private permissionService;
|
|
39
|
+
private cloudAppService;
|
|
32
40
|
constructor(context: CloudBaseContext, envId: string);
|
|
33
41
|
lazyInit(): Promise<any>;
|
|
34
42
|
getEnvId(): string;
|
|
@@ -39,11 +47,15 @@ export declare class Environment {
|
|
|
39
47
|
getCloudRunService(): CloudRunService;
|
|
40
48
|
getAgentService(): AgentService;
|
|
41
49
|
getEnvService(): EnvService;
|
|
50
|
+
getLogService(): LogService;
|
|
42
51
|
getHostingService(): HostingService;
|
|
43
52
|
getThirdService(): ThirdService;
|
|
44
53
|
getAccessService(): AccessService;
|
|
45
54
|
getUserService(): UserService;
|
|
46
55
|
getCloudBaseRunService(): CloudBaseRunService;
|
|
56
|
+
getMysqlService(): MysqlService;
|
|
57
|
+
getCloudAppService(): CloudAppService;
|
|
58
|
+
getPermissionService(): PermissionService;
|
|
47
59
|
getCommonService(serviceType: string, serviceVersion: any): CommonService;
|
|
48
60
|
getServicesEnvInfo(): Promise<any>;
|
|
49
61
|
getAuthConfig(): {
|
|
@@ -277,9 +277,9 @@ export declare class FunctionService {
|
|
|
277
277
|
* @param {string} qualifier 需要删除的版本号,不填默认删除函数下全部版本。
|
|
278
278
|
* @returns {Promise<IResponseInfo>}
|
|
279
279
|
*/
|
|
280
|
-
deleteFunction(
|
|
281
|
-
name:
|
|
282
|
-
}): Promise<
|
|
280
|
+
deleteFunction(name: string | {
|
|
281
|
+
name: string;
|
|
282
|
+
}): Promise<IResponseInfo>;
|
|
283
283
|
/**
|
|
284
284
|
* 批量删除云函数
|
|
285
285
|
* @param {Object} options
|
|
@@ -368,6 +368,27 @@ export declare class FunctionService {
|
|
|
368
368
|
* @memberof FunctionService
|
|
369
369
|
*/
|
|
370
370
|
updateFunctionCode(funcParam: IUpdateFunctionCodeParam): Promise<IResponseInfo>;
|
|
371
|
+
/**
|
|
372
|
+
* 更新函数代码和配置(带进度信息)
|
|
373
|
+
* 支持同时更新代码和配置,按顺序执行:等待就绪 → 更新代码 → 等待就绪 → 更新配置 → 等待就绪
|
|
374
|
+
* @param options 更新选项
|
|
375
|
+
* @returns 更新结果,包含耗时信息
|
|
376
|
+
*/
|
|
377
|
+
updateFunctionWithProgress(options: {
|
|
378
|
+
/** 函数名称 */
|
|
379
|
+
name: string;
|
|
380
|
+
/** 代码相关参数(可选),复用 IUpdateFunctionCodeParam(排除 func,由 name 替代) */
|
|
381
|
+
code?: Omit<IUpdateFunctionCodeParam, 'func'>;
|
|
382
|
+
/** 配置相关参数(可选),复用 ICloudFunction(排除 name,由外层 name 替代) */
|
|
383
|
+
config?: Omit<ICloudFunction, 'name'>;
|
|
384
|
+
}): Promise<{
|
|
385
|
+
/** 总耗时(毫秒) */
|
|
386
|
+
elapsedTime: number;
|
|
387
|
+
/** 结果消息 */
|
|
388
|
+
message: string;
|
|
389
|
+
/** 详细步骤信息 */
|
|
390
|
+
details: string[];
|
|
391
|
+
}>;
|
|
371
392
|
/**
|
|
372
393
|
* 调用云函数
|
|
373
394
|
* @param {string} name 云函数名称
|
|
@@ -404,7 +425,7 @@ export declare class FunctionService {
|
|
|
404
425
|
* @param {string} triggerName 云函数触发器名称
|
|
405
426
|
* @returns {Promise<IResponseInfo>}
|
|
406
427
|
*/
|
|
407
|
-
deleteFunctionTrigger(name: string, triggerName: string): Promise<
|
|
428
|
+
deleteFunctionTrigger(name: string, triggerName: string): Promise<IResponseInfo>;
|
|
408
429
|
batchDeleteTriggers(options: IFunctionBatchOptions): Promise<void>;
|
|
409
430
|
/**
|
|
410
431
|
* 下载云函数代码
|
|
@@ -496,8 +517,16 @@ export declare class FunctionService {
|
|
|
496
517
|
uploadFunctionZipToCos(options: IFunctionCode, installDependency: 'TRUE' | 'FALSE'): Promise<{
|
|
497
518
|
UnixTimestamp: string;
|
|
498
519
|
}>;
|
|
520
|
+
getCodeParams(options: IFunctionCode, installDependency: 'TRUE' | 'FALSE'): Promise<{
|
|
521
|
+
ZipFile: string;
|
|
522
|
+
CosBucketRegion?: undefined;
|
|
523
|
+
TempCosObjectName?: undefined;
|
|
524
|
+
} | {
|
|
525
|
+
CosBucketRegion: string;
|
|
526
|
+
TempCosObjectName: string;
|
|
527
|
+
ZipFile?: undefined;
|
|
528
|
+
}>;
|
|
499
529
|
private createAccessPath;
|
|
500
|
-
private getCodeParams;
|
|
501
530
|
private getTempCosInfo;
|
|
502
531
|
private retryCreateTrigger;
|
|
503
532
|
/**
|
package/types/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { CloudRunService } from './cloudrun';
|
|
|
4
4
|
import { AgentService } from './agent';
|
|
5
5
|
import { StorageService } from './storage';
|
|
6
6
|
import { DatabaseService } from './database';
|
|
7
|
+
import { LogService } from './log';
|
|
7
8
|
import { CommonService } from './common';
|
|
8
9
|
import { HostingService } from './hosting';
|
|
9
10
|
import { Environment } from './environment';
|
|
@@ -12,7 +13,10 @@ import { ThirdService } from './third';
|
|
|
12
13
|
import { AccessService } from './access';
|
|
13
14
|
import { UserService } from './user';
|
|
14
15
|
import { CloudBaseRunService } from './cloudBaseRun';
|
|
16
|
+
import { MysqlService } from './mysql';
|
|
15
17
|
import { DocsService } from './docs';
|
|
18
|
+
import { PermissionService } from './permission';
|
|
19
|
+
import { CloudAppService } from './cloudApp';
|
|
16
20
|
interface CloudBaseConfig {
|
|
17
21
|
secretId?: string;
|
|
18
22
|
secretKey?: string;
|
|
@@ -49,11 +53,33 @@ declare class CloudBase {
|
|
|
49
53
|
get database(): DatabaseService;
|
|
50
54
|
get hosting(): HostingService;
|
|
51
55
|
get access(): AccessService;
|
|
56
|
+
get mysql(): MysqlService;
|
|
57
|
+
/**
|
|
58
|
+
* 云托管服务(CloudBaseRun)
|
|
59
|
+
* 提供云托管版本流量配置等能力
|
|
60
|
+
* @deprecated 请使用 cloudBaseRun 代替,避免与 cloudAppService 混淆
|
|
61
|
+
*/
|
|
52
62
|
get cloudApp(): CloudBaseRunService;
|
|
63
|
+
/**
|
|
64
|
+
* 云托管服务(CloudBaseRun)
|
|
65
|
+
* 提供云托管版本流量配置等能力
|
|
66
|
+
*/
|
|
67
|
+
get cloudBaseRun(): CloudBaseRunService;
|
|
68
|
+
/**
|
|
69
|
+
* 云应用服务(CloudApp 统一部署)
|
|
70
|
+
* 提供 Web 应用的创建、部署、版本管理等能力
|
|
71
|
+
*/
|
|
72
|
+
get cloudAppService(): CloudAppService;
|
|
73
|
+
/**
|
|
74
|
+
* 获取云应用服务
|
|
75
|
+
*/
|
|
76
|
+
getCloudAppService(): CloudAppService;
|
|
53
77
|
commonService(service?: string, version?: string): CommonService;
|
|
54
78
|
get env(): EnvService;
|
|
79
|
+
get log(): LogService;
|
|
55
80
|
get third(): ThirdService;
|
|
56
81
|
get user(): UserService;
|
|
82
|
+
get permission(): PermissionService;
|
|
57
83
|
get docs(): DocsService;
|
|
58
84
|
getEnvironmentManager(): EnvironmentManager;
|
|
59
85
|
getManagerConfig(): CloudBaseConfig;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Environment } from '../environment';
|
|
2
|
+
import { ISearchClsLogParams, ISearchClsLogResponse } from './types';
|
|
3
|
+
export * from './types';
|
|
4
|
+
export interface ICreateEnvResourceResponse {
|
|
5
|
+
RequestId: string;
|
|
6
|
+
}
|
|
7
|
+
export interface ILogServiceEntry {
|
|
8
|
+
LogsetId?: string;
|
|
9
|
+
TopicId?: string;
|
|
10
|
+
TopicName?: string;
|
|
11
|
+
Region?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* 纯函数:根据 DescribeEnvs 返回的 LogServices 列表判断日志服务是否已开通。
|
|
15
|
+
* 已开通条件:至少一个条目有有效的 TopicId。
|
|
16
|
+
*/
|
|
17
|
+
export declare function isLogServiceEnabled(logServices?: ILogServiceEntry[]): boolean;
|
|
18
|
+
export declare class LogService {
|
|
19
|
+
private envId;
|
|
20
|
+
private cloudService;
|
|
21
|
+
private tcbrService;
|
|
22
|
+
constructor(environment: Environment);
|
|
23
|
+
/**
|
|
24
|
+
* 检查当前环境的日志服务是否已开通
|
|
25
|
+
*
|
|
26
|
+
* 通过 DescribeEnvs 接口获取环境信息,判断 LogServices 字段中是否包含有效的
|
|
27
|
+
* 日志主题(TopicId 不为空)。
|
|
28
|
+
*
|
|
29
|
+
* @returns true 表示已开通,false 表示未开通或开通中
|
|
30
|
+
*/
|
|
31
|
+
checkLogServiceEnabled(): Promise<boolean>;
|
|
32
|
+
/**
|
|
33
|
+
* 开通环境日志服务(异步操作)
|
|
34
|
+
*
|
|
35
|
+
* 调用 CreateEnvResource 接口开通日志资源。
|
|
36
|
+
* 注意:接口调用成功不代表日志资源立即可用,需通过 checkLogServiceEnabled() 轮询确认。
|
|
37
|
+
*
|
|
38
|
+
* @returns 请求 ID
|
|
39
|
+
*/
|
|
40
|
+
createLogService(): Promise<ICreateEnvResourceResponse>;
|
|
41
|
+
/**
|
|
42
|
+
* 搜索 CLS 日志
|
|
43
|
+
*
|
|
44
|
+
* @param params 查询参数,通过 queryString 使用 CLS 原生检索分析语法
|
|
45
|
+
* @returns 日志搜索结果
|
|
46
|
+
*
|
|
47
|
+
* @remarks
|
|
48
|
+
* - 纯检索结果在 `LogResults.Results` 中
|
|
49
|
+
* - SQL 分析结果(queryString 含 `| select ...`)在 `LogResults.AnalysisRecords` 中
|
|
50
|
+
* - 详细的 QueryString 语法参考见 README.md
|
|
51
|
+
*/
|
|
52
|
+
searchClsLog(params: ISearchClsLogParams): Promise<ISearchClsLogResponse>;
|
|
53
|
+
}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 单个 module 的查询 schema 描述
|
|
3
|
+
*/
|
|
4
|
+
export interface ClsModuleQuerySchema {
|
|
5
|
+
/** module 中文名 */
|
|
6
|
+
label: string;
|
|
7
|
+
/** 可用的 eventType(没有则为 never) */
|
|
8
|
+
eventType: string;
|
|
9
|
+
/** 可用的 logType(没有则为 never) */
|
|
10
|
+
logType: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* 各 module 的完整查询 schema 映射
|
|
14
|
+
*
|
|
15
|
+
* 用法示例:
|
|
16
|
+
* ```ts
|
|
17
|
+
* // 获取某个 module 下可用的 eventType
|
|
18
|
+
* type DbEvents = ClsModuleSchema['database']['eventType'] // 'MongoSlowQuery'
|
|
19
|
+
* type RdbEvents = ClsModuleSchema['rdb']['eventType'] // 'MysqlFreeze' | 'MysqlRecover' | 'MysqlSlowQuery'
|
|
20
|
+
* type AppEvents = ClsModuleSchema['app']['eventType'] // 'AppProdPub' | 'AppProdDel'
|
|
21
|
+
* type LlmLogType = ClsModuleSchema['llm']['logType'] // 'llm-tracelog'
|
|
22
|
+
*
|
|
23
|
+
* // 获取所有 module 名
|
|
24
|
+
* type Modules = ClsLogModule // 'database' | 'rdb' | 'model' | ...
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* 查询语句示例(CLS 语法):
|
|
28
|
+
* - 查询云数据库[文档型]:`module:database`
|
|
29
|
+
* - 查询文档型慢查询:`module:database AND eventType:MongoSlowQuery`
|
|
30
|
+
* - 查询云数据库[SQL型]:`module:rdb`
|
|
31
|
+
* - 查询SQL型事件:`module:rdb AND eventType:(MysqlFreeze OR MysqlRecover OR MysqlSlowQuery)`
|
|
32
|
+
* - 查询审批流:`module:workflow`
|
|
33
|
+
* - 查询数据模型:`module:model`
|
|
34
|
+
* - 查询用户权限:`module:auth`
|
|
35
|
+
* - 查询大模型:`module:llm AND logType:llm-tracelog`
|
|
36
|
+
* - 查询网关服务调用:`logType:accesslog`
|
|
37
|
+
* - 查询应用发布/删除:`module:app AND eventType:(AppProdPub OR AppProdDel)`
|
|
38
|
+
*/
|
|
39
|
+
export interface ClsModuleSchema {
|
|
40
|
+
/** 云数据库(文档型/MongoDB) */
|
|
41
|
+
database: {
|
|
42
|
+
label: '云数据库(文档型)';
|
|
43
|
+
/** MongoSlowQuery: 文档型数据库慢查询 */
|
|
44
|
+
eventType: 'MongoSlowQuery';
|
|
45
|
+
logType: never;
|
|
46
|
+
};
|
|
47
|
+
/** 云数据库(SQL型/MySQL) */
|
|
48
|
+
rdb: {
|
|
49
|
+
label: '云数据库(SQL型)';
|
|
50
|
+
/** MysqlFreeze: 数据库冻结 | MysqlRecover: 数据库恢复 | MysqlSlowQuery: 数据库慢查询 */
|
|
51
|
+
eventType: 'MysqlFreeze' | 'MysqlRecover' | 'MysqlSlowQuery';
|
|
52
|
+
logType: never;
|
|
53
|
+
};
|
|
54
|
+
/** 数据模型 */
|
|
55
|
+
model: {
|
|
56
|
+
label: '数据模型';
|
|
57
|
+
eventType: never;
|
|
58
|
+
logType: never;
|
|
59
|
+
};
|
|
60
|
+
/** 审批流 */
|
|
61
|
+
workflow: {
|
|
62
|
+
label: '审批流';
|
|
63
|
+
eventType: never;
|
|
64
|
+
logType: never;
|
|
65
|
+
};
|
|
66
|
+
/** 用户权限 */
|
|
67
|
+
auth: {
|
|
68
|
+
label: '用户权限';
|
|
69
|
+
eventType: never;
|
|
70
|
+
logType: never;
|
|
71
|
+
};
|
|
72
|
+
/** 大模型 */
|
|
73
|
+
llm: {
|
|
74
|
+
label: '大模型';
|
|
75
|
+
eventType: never;
|
|
76
|
+
/** llm-tracelog: 大模型追踪日志 */
|
|
77
|
+
logType: 'llm-tracelog';
|
|
78
|
+
};
|
|
79
|
+
/** 应用 */
|
|
80
|
+
app: {
|
|
81
|
+
label: '应用';
|
|
82
|
+
/** AppProdPub: 应用发布 | AppProdDel: 应用删除 */
|
|
83
|
+
eventType: 'AppProdPub' | 'AppProdDel';
|
|
84
|
+
logType: never;
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
/** CLS 日志模块 */
|
|
88
|
+
export type ClsLogModule = keyof ClsModuleSchema;
|
|
89
|
+
/** CLS 日志事件类型(所有 module 的 eventType 联合) */
|
|
90
|
+
export type ClsEventType = ClsModuleSchema[ClsLogModule]['eventType'];
|
|
91
|
+
/** CLS 日志类型 */
|
|
92
|
+
export type ClsLogType = ClsModuleSchema[ClsLogModule]['logType'] | 'accesslog';
|
|
93
|
+
/** 获取指定 module 的 eventType */
|
|
94
|
+
export type EventTypeOf<M extends ClsLogModule> = ClsModuleSchema[M]['eventType'];
|
|
95
|
+
/** 获取指定 module 的 logType */
|
|
96
|
+
export type LogTypeOf<M extends ClsLogModule> = ClsModuleSchema[M]['logType'];
|
|
97
|
+
/**
|
|
98
|
+
* CLS 日志搜索基础参数
|
|
99
|
+
*/
|
|
100
|
+
export interface ISearchClsLogBaseParams {
|
|
101
|
+
/** 查询起始时间,格式 'YYYY-MM-DD HH:mm:ss' */
|
|
102
|
+
StartTime: string;
|
|
103
|
+
/** 查询结束时间,格式 'YYYY-MM-DD HH:mm:ss' */
|
|
104
|
+
EndTime: string;
|
|
105
|
+
/** 单次返回条数,最大 100 */
|
|
106
|
+
Limit: number;
|
|
107
|
+
/** 分页游标,首次为空,后续透传上次返回的 Context */
|
|
108
|
+
Context?: string;
|
|
109
|
+
/** 排序方式:'asc' 升序 / 'desc' 降序(默认 desc) */
|
|
110
|
+
Sort?: 'asc' | 'desc';
|
|
111
|
+
/** 是否使用 Lucene 语法(默认 false) */
|
|
112
|
+
UseLucene?: boolean;
|
|
113
|
+
/**
|
|
114
|
+
* 指定调用的后端服务(默认 'tcb')
|
|
115
|
+
* - 'tcb': 云函数、数据库等日志(默认)
|
|
116
|
+
* - 'tcbr': 云托管日志
|
|
117
|
+
*/
|
|
118
|
+
service?: 'tcb' | 'tcbr';
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* CLS 日志搜索参数
|
|
122
|
+
*/
|
|
123
|
+
export interface ISearchClsLogParams extends ISearchClsLogBaseParams {
|
|
124
|
+
/** CLS 检索分析语句(支持 `| select ...` SQL 分析) */
|
|
125
|
+
queryString: string;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* CLS 日志对象
|
|
129
|
+
*/
|
|
130
|
+
export interface IClsLogObject {
|
|
131
|
+
/** 日志所属的 Topic ID */
|
|
132
|
+
TopicId: string;
|
|
133
|
+
/** Topic 名称 */
|
|
134
|
+
TopicName: string;
|
|
135
|
+
/** 日志时间 */
|
|
136
|
+
Timestamp: string;
|
|
137
|
+
/** 日志内容(JSON 字符串,需 JSON.parse) */
|
|
138
|
+
Content: string;
|
|
139
|
+
/** 采集路径 */
|
|
140
|
+
FileName: string;
|
|
141
|
+
/** 日志来源设备 */
|
|
142
|
+
Source: string;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* CLS 日志搜索响应
|
|
146
|
+
*/
|
|
147
|
+
export interface ISearchClsLogResponse {
|
|
148
|
+
/** 日志结果 */
|
|
149
|
+
LogResults: {
|
|
150
|
+
/** 分页游标,用于获取下一页 */
|
|
151
|
+
Context: string;
|
|
152
|
+
/** 是否已返回全部结果 */
|
|
153
|
+
ListOver: boolean;
|
|
154
|
+
/** 日志列表(纯检索模式的结果) */
|
|
155
|
+
Results: IClsLogObject[];
|
|
156
|
+
/**
|
|
157
|
+
* SQL 分析结果(当 QueryString 包含 `| select ...` 管道时返回)
|
|
158
|
+
*
|
|
159
|
+
* 每个元素是一个 JSON 字符串,需 JSON.parse 解析
|
|
160
|
+
* 纯检索模式(无 `|` 管道)时为空数组
|
|
161
|
+
*/
|
|
162
|
+
AnalysisRecords?: string[];
|
|
163
|
+
};
|
|
164
|
+
/** 请求 ID */
|
|
165
|
+
RequestId: string;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* ClsModuleSchema 的运行时版本,用于动态生成查询条件 / MCP tool description
|
|
169
|
+
*
|
|
170
|
+
* - key 与 ClsLogModule 类型保持同步
|
|
171
|
+
* - eventTypes / logTypes 为字符串数组,空数组表示该维度不可过滤
|
|
172
|
+
*/
|
|
173
|
+
export declare const CLS_MODULE_SCHEMA: Record<ClsLogModule, {
|
|
174
|
+
label: string;
|
|
175
|
+
eventTypes: string[];
|
|
176
|
+
logTypes: string[];
|
|
177
|
+
}>;
|