@cloudbase/manager-node 4.11.0-alpha.6 → 4.11.0-alpha.8
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/agent/index.js +607 -16
- package/lib/agent/type.js +1 -0
- package/lib/environment.js +10 -0
- package/lib/function/index.js +84 -25
- package/lib/index.js +6 -0
- package/lib/log/index.js +105 -0
- package/lib/log/types.js +24 -0
- package/lib/permission/index.js +313 -0
- package/lib/permission/types.js +2 -0
- package/package.json +1 -1
- package/types/agent/index.d.ts +115 -5
- package/types/agent/type.d.ts +389 -0
- package/types/environment.d.ts +6 -0
- package/types/function/index.d.ts +30 -1
- package/types/index.d.ts +4 -0
- package/types/log/index.d.ts +53 -0
- package/types/log/types.d.ts +177 -0
- package/types/permission/index.d.ts +31 -0
- package/types/permission/types.d.ts +127 -0
|
@@ -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
|
+
}>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Environment } from '../environment';
|
|
2
|
+
import { ModifyResourcePermissionOptions, ModifyResourcePermissionResp, DescribeResourcePermissionOptions, DescribeResourcePermissionResp, CreateRoleOptions, CreateRoleResp, DescribeRoleListOptions, DescribeRoleListResp, ModifyRoleOptions, ModifyRoleResp, DeleteRolesOptions, DeleteRolesResp } from './types';
|
|
3
|
+
export declare class PermissionService {
|
|
4
|
+
private environment;
|
|
5
|
+
private tcbService;
|
|
6
|
+
constructor(environment: Environment);
|
|
7
|
+
modifyResourcePermission(options: ModifyResourcePermissionOptions): Promise<{
|
|
8
|
+
Data: ModifyResourcePermissionResp;
|
|
9
|
+
RequestId: string;
|
|
10
|
+
}>;
|
|
11
|
+
describeResourcePermission(options: DescribeResourcePermissionOptions): Promise<{
|
|
12
|
+
Data: DescribeResourcePermissionResp;
|
|
13
|
+
RequestId: string;
|
|
14
|
+
}>;
|
|
15
|
+
createRole(options: CreateRoleOptions): Promise<{
|
|
16
|
+
Data: CreateRoleResp;
|
|
17
|
+
RequestId: string;
|
|
18
|
+
}>;
|
|
19
|
+
describeRoleList(options?: DescribeRoleListOptions): Promise<{
|
|
20
|
+
Data: DescribeRoleListResp;
|
|
21
|
+
RequestId: string;
|
|
22
|
+
}>;
|
|
23
|
+
modifyRole(options: ModifyRoleOptions): Promise<{
|
|
24
|
+
Data: ModifyRoleResp;
|
|
25
|
+
RequestId: string;
|
|
26
|
+
}>;
|
|
27
|
+
deleteRoles(options: DeleteRolesOptions): Promise<{
|
|
28
|
+
Data: DeleteRolesResp;
|
|
29
|
+
RequestId: string;
|
|
30
|
+
}>;
|
|
31
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
export type PermissionResourceType = 'function' | 'storage' | 'table' | 'collection';
|
|
2
|
+
export type BasePermission = 'READONLY' | 'PRIVATE' | 'ADMINWRITE' | 'ADMINONLY' | 'CUSTOM';
|
|
3
|
+
export interface ModifyResourcePermissionOptions {
|
|
4
|
+
resourceType: PermissionResourceType;
|
|
5
|
+
resource: string;
|
|
6
|
+
permission: BasePermission;
|
|
7
|
+
securityRule?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface ModifyResourcePermissionResp {
|
|
10
|
+
Success: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface DescribeResourcePermissionOptions {
|
|
13
|
+
resourceType: PermissionResourceType;
|
|
14
|
+
resources?: string[];
|
|
15
|
+
}
|
|
16
|
+
export interface ResourcePermission {
|
|
17
|
+
ResourceType?: PermissionResourceType;
|
|
18
|
+
Resource?: string;
|
|
19
|
+
Permission?: BasePermission | string;
|
|
20
|
+
SecurityRule?: string;
|
|
21
|
+
}
|
|
22
|
+
export interface DescribeResourcePermissionResp {
|
|
23
|
+
TotalCount: number;
|
|
24
|
+
PermissionList: ResourcePermission[];
|
|
25
|
+
}
|
|
26
|
+
export type QueryConditionRel = 'eq' | 'neq' | 'lt' | 'gt' | 'gte' | 'lte' | 'in' | 'nin' | 'search';
|
|
27
|
+
export interface QueryConditionItem {
|
|
28
|
+
Key: string;
|
|
29
|
+
Rel: QueryConditionRel;
|
|
30
|
+
Val: string;
|
|
31
|
+
ValueType?: string;
|
|
32
|
+
}
|
|
33
|
+
export interface QueryCondition {
|
|
34
|
+
Key: string;
|
|
35
|
+
Value: string;
|
|
36
|
+
QueryConditions?: QueryConditionItem[];
|
|
37
|
+
}
|
|
38
|
+
export interface WorkBenchFeatureItem {
|
|
39
|
+
Code?: string;
|
|
40
|
+
Name?: string;
|
|
41
|
+
IsAccess?: boolean;
|
|
42
|
+
ParentCode?: string;
|
|
43
|
+
SubPermissions?: WorkBenchFeatureItem[];
|
|
44
|
+
}
|
|
45
|
+
export interface WorkBenchPermission {
|
|
46
|
+
AllPermission?: boolean;
|
|
47
|
+
PartPermission?: boolean;
|
|
48
|
+
Permissions?: WorkBenchFeatureItem[];
|
|
49
|
+
}
|
|
50
|
+
export interface PermissionPolicyItem {
|
|
51
|
+
ResourceType: string;
|
|
52
|
+
Resource: string;
|
|
53
|
+
ResourceName?: string;
|
|
54
|
+
Permission?: string;
|
|
55
|
+
Effect?: string;
|
|
56
|
+
IsBindAllAccess?: boolean;
|
|
57
|
+
SubResourceIdList?: string[];
|
|
58
|
+
RowPermission?: QueryCondition[];
|
|
59
|
+
FeatureAuth?: WorkBenchPermission;
|
|
60
|
+
GatewayPolicyCode?: string;
|
|
61
|
+
GatewayPolicyName?: string;
|
|
62
|
+
GatewayPolicyDescription?: string;
|
|
63
|
+
GatewayPolicyExpression?: string;
|
|
64
|
+
}
|
|
65
|
+
export interface CreateRoleOptions {
|
|
66
|
+
roleName: string;
|
|
67
|
+
roleIdentity: string;
|
|
68
|
+
description?: string;
|
|
69
|
+
memberUids?: string[];
|
|
70
|
+
policies?: PermissionPolicyItem[];
|
|
71
|
+
}
|
|
72
|
+
export interface CreateRoleResp {
|
|
73
|
+
RoleId?: string;
|
|
74
|
+
MemberUids?: string[];
|
|
75
|
+
Policies?: PermissionPolicyItem[];
|
|
76
|
+
}
|
|
77
|
+
export interface MemberInfo {
|
|
78
|
+
Uid?: string;
|
|
79
|
+
Name?: string;
|
|
80
|
+
NickName?: string;
|
|
81
|
+
}
|
|
82
|
+
export interface RoleItem {
|
|
83
|
+
RoleId?: string;
|
|
84
|
+
RoleIdentity?: string;
|
|
85
|
+
RoleName?: string;
|
|
86
|
+
RoleType?: 'system' | 'custom';
|
|
87
|
+
Description?: string;
|
|
88
|
+
Members?: MemberInfo[];
|
|
89
|
+
Policies?: PermissionPolicyItem[];
|
|
90
|
+
}
|
|
91
|
+
export interface DescribeRoleListOptions {
|
|
92
|
+
pageNumber?: number;
|
|
93
|
+
pageSize?: number;
|
|
94
|
+
roleId?: string;
|
|
95
|
+
roleIdentity?: string;
|
|
96
|
+
roleName?: string;
|
|
97
|
+
loadDetails?: boolean;
|
|
98
|
+
}
|
|
99
|
+
export interface DescribeRoleListResp {
|
|
100
|
+
TotalCount?: number;
|
|
101
|
+
CustomTotalCount?: number;
|
|
102
|
+
SystemRoles?: RoleItem[];
|
|
103
|
+
CustomRoles?: RoleItem[];
|
|
104
|
+
}
|
|
105
|
+
export interface ModifyRoleOptions {
|
|
106
|
+
roleId: string;
|
|
107
|
+
roleName?: string;
|
|
108
|
+
description?: string;
|
|
109
|
+
addMemberUids?: string[];
|
|
110
|
+
removeMemberUids?: string[];
|
|
111
|
+
addPolicies?: PermissionPolicyItem[];
|
|
112
|
+
removePolicies?: PermissionPolicyItem[];
|
|
113
|
+
}
|
|
114
|
+
export interface ModifyRoleResp {
|
|
115
|
+
Success?: boolean;
|
|
116
|
+
AddedMemberUids?: string[];
|
|
117
|
+
RemovedMemberUids?: string[];
|
|
118
|
+
AddedPolicies?: PermissionPolicyItem[];
|
|
119
|
+
RemovedPolicies?: PermissionPolicyItem[];
|
|
120
|
+
}
|
|
121
|
+
export interface DeleteRolesOptions {
|
|
122
|
+
roleIds: string[];
|
|
123
|
+
}
|
|
124
|
+
export interface DeleteRolesResp {
|
|
125
|
+
SuccessCount?: number;
|
|
126
|
+
FailedCount?: number;
|
|
127
|
+
}
|