@cloudbase/manager-node 4.11.0-alpha.7 → 4.11.0-alpha.9
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/lib/cloudApp/index.js +243 -0
- package/lib/cloudApp/types.js +10 -0
- package/lib/environment.js +10 -0
- package/lib/index.js +28 -0
- package/lib/interfaces/cloudApp.interface.js +20 -0
- package/lib/interfaces/index.js +1 -0
- package/lib/log/index.js +48 -0
- package/lib/permission/index.js +313 -0
- package/lib/permission/types.js +2 -0
- package/package.json +1 -1
- package/types/cloudApp/index.d.ts +73 -0
- package/types/cloudApp/types.d.ts +325 -0
- package/types/environment.d.ts +6 -0
- package/types/index.d.ts +22 -0
- package/types/interfaces/cloudApp.interface.d.ts +4 -0
- package/types/interfaces/index.d.ts +1 -0
- package/types/log/index.d.ts +32 -0
- package/types/permission/index.d.ts +31 -0
- package/types/permission/types.d.ts +127 -0
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CloudApp 统一部署服务类型定义
|
|
3
|
+
* 支持 static-hosting(静态托管)和 http-function(预留)两种部署类型
|
|
4
|
+
*
|
|
5
|
+
* 命名规范:
|
|
6
|
+
* - 入参接口(IXxxParams):camelCase,通过 upperCaseObjKey 转换后透传给 API
|
|
7
|
+
* - 返回值接口(IXxxResult):PascalCase,与 API 响应字段保持一致
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* 部署类型
|
|
11
|
+
* - static-hosting: 静态托管部署
|
|
12
|
+
* - http-function: HTTP 云函数部署(预留)
|
|
13
|
+
*/
|
|
14
|
+
export type DeployType = 'static-hosting' | 'http-function';
|
|
15
|
+
/**
|
|
16
|
+
* 构建类型
|
|
17
|
+
* - GIT: 从 Git 仓库构建
|
|
18
|
+
* - ZIP: 从 ZIP 包构建
|
|
19
|
+
* - TEMPLATE: 从模板构建
|
|
20
|
+
*/
|
|
21
|
+
export type BuildType = 'GIT' | 'ZIP' | 'TEMPLATE';
|
|
22
|
+
/**
|
|
23
|
+
* 构建状态
|
|
24
|
+
*/
|
|
25
|
+
export type BuildStatus = 'BUILDING' | 'SUCCESS' | 'FAILED';
|
|
26
|
+
/**
|
|
27
|
+
* 构建命令配置(入参)
|
|
28
|
+
*/
|
|
29
|
+
export interface IStaticCmd {
|
|
30
|
+
buildCmd?: string;
|
|
31
|
+
installCmd?: string;
|
|
32
|
+
deployCmd?: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* 静态环境变量配置(入参)
|
|
36
|
+
*/
|
|
37
|
+
export interface IStaticEnv {
|
|
38
|
+
variables?: Array<{
|
|
39
|
+
key: string;
|
|
40
|
+
value: string;
|
|
41
|
+
}>;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* 静态托管配置(入参)
|
|
45
|
+
*/
|
|
46
|
+
export interface IStaticConfig {
|
|
47
|
+
/** 框架类型:vue、react、nextjs 等 */
|
|
48
|
+
framework?: string;
|
|
49
|
+
/** Node.js 版本,默认 20 */
|
|
50
|
+
nodeJsVersion?: string;
|
|
51
|
+
/** 访问路径 */
|
|
52
|
+
appPath?: string;
|
|
53
|
+
/** 构建目录 */
|
|
54
|
+
buildPath?: string;
|
|
55
|
+
/** ZIP 文件地址(BuildType=ZIP/TEMPLATE 时使用) */
|
|
56
|
+
zipFileUrl?: string;
|
|
57
|
+
/** COS 时间戳(通过 uploadCode 上传后获取,BuildType=ZIP 时使用) */
|
|
58
|
+
cosTimestamp?: string;
|
|
59
|
+
/** COS 文件后缀 */
|
|
60
|
+
cosSuffix?: string;
|
|
61
|
+
/** 代码源平台:github、gitlab、gitee */
|
|
62
|
+
codeSource?: string;
|
|
63
|
+
/** 代码仓库 */
|
|
64
|
+
codeRepo?: string;
|
|
65
|
+
/** 代码分支 */
|
|
66
|
+
codeBranch?: string;
|
|
67
|
+
/** 构建命令配置 */
|
|
68
|
+
staticCmd?: IStaticCmd;
|
|
69
|
+
/** 构建环境变量 */
|
|
70
|
+
staticEnv?: IStaticEnv;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* 静态托管构建命令配置(API 响应)
|
|
74
|
+
*/
|
|
75
|
+
export interface StaticCmd {
|
|
76
|
+
BuildCmd?: string;
|
|
77
|
+
InstallCmd?: string;
|
|
78
|
+
DeployCmd?: string;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* 静态托管环境变量配置(API 响应,对应文档 StaticEnvironment)
|
|
82
|
+
*/
|
|
83
|
+
export interface StaticEnv {
|
|
84
|
+
/** 环境变量数组,可能为 null */
|
|
85
|
+
Variables?: Array<{
|
|
86
|
+
Key: string;
|
|
87
|
+
Value: string;
|
|
88
|
+
}> | null;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* 静态托管配置(API 响应,对应文档 StaticConfig)
|
|
92
|
+
* 被 CreateCloudApp、DescribeCloudAppVersion、DescribeCloudAppVersionList 引用
|
|
93
|
+
* 注意:所有字段均可能返回 null
|
|
94
|
+
*/
|
|
95
|
+
export interface CloudAppStaticConfig {
|
|
96
|
+
/** 框架类型:vue、react、nextjs 等 */
|
|
97
|
+
Framework?: string | null;
|
|
98
|
+
/** Node.js 版本,默认 20 */
|
|
99
|
+
NodeJsVersion?: string | null;
|
|
100
|
+
/** 访问路径 */
|
|
101
|
+
AppPath?: string | null;
|
|
102
|
+
/** 构建目录 */
|
|
103
|
+
BuildPath?: string | null;
|
|
104
|
+
/** ZIP 文件地址(BuildType=ZIP/TEMPLATE 时使用) */
|
|
105
|
+
ZipFileUrl?: string | null;
|
|
106
|
+
/** COS 时间戳 */
|
|
107
|
+
CosTimestamp?: string | null;
|
|
108
|
+
/** COS 文件后缀 */
|
|
109
|
+
CosSuffix?: string | null;
|
|
110
|
+
/** 代码源平台:github、gitlab、gitee */
|
|
111
|
+
CodeSource?: string | null;
|
|
112
|
+
/** 代码仓库 */
|
|
113
|
+
CodeRepo?: string | null;
|
|
114
|
+
/** 代码分支 */
|
|
115
|
+
CodeBranch?: string | null;
|
|
116
|
+
/** 构建命令配置 */
|
|
117
|
+
StaticCmd?: StaticCmd | null;
|
|
118
|
+
/** 构建环境变量 */
|
|
119
|
+
StaticEnv?: StaticEnv | null;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* 应用列表项(API 响应 CloudAppServiceItem)
|
|
123
|
+
*/
|
|
124
|
+
export interface CloudAppServiceItem {
|
|
125
|
+
ServiceName: string;
|
|
126
|
+
DeployType: string;
|
|
127
|
+
Framework?: string;
|
|
128
|
+
Domain?: string;
|
|
129
|
+
AppPath?: string;
|
|
130
|
+
CreateTime: string;
|
|
131
|
+
LatestVersionName?: string;
|
|
132
|
+
LatestStatus?: string;
|
|
133
|
+
LatestBuildTime?: string;
|
|
134
|
+
}
|
|
135
|
+
/** @deprecated 请使用 CloudAppServiceItem */
|
|
136
|
+
export type CloudAppItem = CloudAppServiceItem;
|
|
137
|
+
/**
|
|
138
|
+
* 版本信息(API 响应 CloudAppVersionItem)
|
|
139
|
+
*/
|
|
140
|
+
export interface CloudAppVersion {
|
|
141
|
+
VersionName: string;
|
|
142
|
+
BuildId: string;
|
|
143
|
+
BuildType?: string;
|
|
144
|
+
Status: string;
|
|
145
|
+
Framework?: string;
|
|
146
|
+
BuildTime?: string;
|
|
147
|
+
StaticConfig?: CloudAppStaticConfig;
|
|
148
|
+
}
|
|
149
|
+
export interface ICreateCloudAppParams {
|
|
150
|
+
/** 环境 ID(可选,默认从 Environment 获取) */
|
|
151
|
+
envId?: string;
|
|
152
|
+
/** 部署类型:static-hosting / http-function */
|
|
153
|
+
deployType: DeployType;
|
|
154
|
+
/** 服务名称 */
|
|
155
|
+
serviceName: string;
|
|
156
|
+
/** 构建类型:GIT / ZIP / TEMPLATE */
|
|
157
|
+
buildType?: BuildType;
|
|
158
|
+
/** 静态托管配置(deployType 为 static-hosting 时使用) */
|
|
159
|
+
staticConfig?: IStaticConfig;
|
|
160
|
+
}
|
|
161
|
+
export interface ICreateCloudAppResult {
|
|
162
|
+
ServiceName: string;
|
|
163
|
+
BuildId: string;
|
|
164
|
+
VersionName: string;
|
|
165
|
+
RequestId: string;
|
|
166
|
+
}
|
|
167
|
+
export interface IDescribeCloudAppListParams {
|
|
168
|
+
/** 环境 ID(可选) */
|
|
169
|
+
envId?: string;
|
|
170
|
+
/** 部署类型 */
|
|
171
|
+
deployType: DeployType;
|
|
172
|
+
/** 页码(从 1 开始) */
|
|
173
|
+
pageNo?: number;
|
|
174
|
+
/** 每页大小 */
|
|
175
|
+
pageSize?: number;
|
|
176
|
+
/** 搜索关键字,按应用名模糊搜索 */
|
|
177
|
+
searchKey?: string;
|
|
178
|
+
}
|
|
179
|
+
export interface IDescribeCloudAppListResult {
|
|
180
|
+
Total: number;
|
|
181
|
+
ServiceList: CloudAppServiceItem[];
|
|
182
|
+
RequestId: string;
|
|
183
|
+
}
|
|
184
|
+
export interface IDescribeCloudAppInfoParams {
|
|
185
|
+
/** 环境 ID(可选) */
|
|
186
|
+
envId?: string;
|
|
187
|
+
/** 部署类型 */
|
|
188
|
+
deployType: DeployType;
|
|
189
|
+
/** 服务名称 */
|
|
190
|
+
serviceName: string;
|
|
191
|
+
}
|
|
192
|
+
export interface IDescribeCloudAppInfoResult {
|
|
193
|
+
ServiceName: string;
|
|
194
|
+
DeployType: string;
|
|
195
|
+
Framework?: string;
|
|
196
|
+
Domain?: string;
|
|
197
|
+
AppPath?: string;
|
|
198
|
+
CreateTime: string;
|
|
199
|
+
LatestVersionName?: string;
|
|
200
|
+
LatestStatus?: string;
|
|
201
|
+
LatestBuildTime?: string;
|
|
202
|
+
RequestId: string;
|
|
203
|
+
}
|
|
204
|
+
export interface IDeleteCloudAppParams {
|
|
205
|
+
/** 环境 ID(可选) */
|
|
206
|
+
envId?: string;
|
|
207
|
+
/** 部署类型 */
|
|
208
|
+
deployType: DeployType;
|
|
209
|
+
/** 服务名称 */
|
|
210
|
+
serviceName: string;
|
|
211
|
+
}
|
|
212
|
+
export interface IDeleteCloudAppResult {
|
|
213
|
+
Result: boolean;
|
|
214
|
+
RequestId: string;
|
|
215
|
+
}
|
|
216
|
+
export interface IDescribeCloudAppVersionParams {
|
|
217
|
+
/** 环境 ID(可选) */
|
|
218
|
+
envId?: string;
|
|
219
|
+
/** 部署类型 */
|
|
220
|
+
deployType: DeployType;
|
|
221
|
+
/** 服务名称 */
|
|
222
|
+
serviceName: string;
|
|
223
|
+
/** 版本名称(与 buildId 二选一) */
|
|
224
|
+
versionName?: string;
|
|
225
|
+
/** 构建 ID(与 versionName 二选一) */
|
|
226
|
+
buildId?: string;
|
|
227
|
+
}
|
|
228
|
+
export interface IDescribeCloudAppVersionResult {
|
|
229
|
+
BuildType: string;
|
|
230
|
+
BuildId: string;
|
|
231
|
+
Status: BuildStatus;
|
|
232
|
+
Framework?: string;
|
|
233
|
+
StaticConfig?: CloudAppStaticConfig;
|
|
234
|
+
BuildTime?: string;
|
|
235
|
+
RequestId: string;
|
|
236
|
+
}
|
|
237
|
+
export interface IDescribeCloudAppVersionListParams {
|
|
238
|
+
/** 环境 ID(可选) */
|
|
239
|
+
envId?: string;
|
|
240
|
+
/** 部署类型 */
|
|
241
|
+
deployType: DeployType;
|
|
242
|
+
/** 服务名称 */
|
|
243
|
+
serviceName: string;
|
|
244
|
+
/** 页码(从 1 开始) */
|
|
245
|
+
pageNo?: number;
|
|
246
|
+
/** 每页大小 */
|
|
247
|
+
pageSize?: number;
|
|
248
|
+
}
|
|
249
|
+
export interface IDescribeCloudAppVersionListResult {
|
|
250
|
+
Total: number;
|
|
251
|
+
VersionList: CloudAppVersion[] | null;
|
|
252
|
+
RequestId: string;
|
|
253
|
+
}
|
|
254
|
+
export interface IDeleteCloudAppVersionParams {
|
|
255
|
+
/** 环境 ID(可选) */
|
|
256
|
+
envId?: string;
|
|
257
|
+
/** 部署类型 */
|
|
258
|
+
deployType: DeployType;
|
|
259
|
+
/** 服务名称 */
|
|
260
|
+
serviceName: string;
|
|
261
|
+
/** 版本名称 */
|
|
262
|
+
versionName: string;
|
|
263
|
+
}
|
|
264
|
+
export interface IDeleteCloudAppVersionResult {
|
|
265
|
+
Result: boolean;
|
|
266
|
+
RequestId: string;
|
|
267
|
+
}
|
|
268
|
+
export interface IDescribeCloudAppCosInfoParams {
|
|
269
|
+
/** 环境 ID(可选) */
|
|
270
|
+
envId?: string;
|
|
271
|
+
/** 部署类型 */
|
|
272
|
+
deployType: DeployType;
|
|
273
|
+
/** 服务名称 */
|
|
274
|
+
serviceName: string;
|
|
275
|
+
/** Unix 时间戳(用于指定文件路径,不传则自动生成) */
|
|
276
|
+
unixTimestamp?: string;
|
|
277
|
+
/** 文件后缀(默认 .zip) */
|
|
278
|
+
suffix?: string;
|
|
279
|
+
/** 是否需要下载 URL */
|
|
280
|
+
needDownload?: boolean;
|
|
281
|
+
}
|
|
282
|
+
export interface CosHeader {
|
|
283
|
+
Key: string;
|
|
284
|
+
Value: string;
|
|
285
|
+
}
|
|
286
|
+
export interface IDescribeCloudAppCosInfoResult {
|
|
287
|
+
UploadUrl: string;
|
|
288
|
+
UploadHeaders?: CosHeader[];
|
|
289
|
+
DownloadUrl?: string;
|
|
290
|
+
DownloadHeaders?: CosHeader[];
|
|
291
|
+
UnixTimestamp: string;
|
|
292
|
+
RequestId: string;
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* 上传进度信息
|
|
296
|
+
*/
|
|
297
|
+
export interface IProgressData {
|
|
298
|
+
loaded: number;
|
|
299
|
+
total: number;
|
|
300
|
+
percent: number;
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* 上传代码参数
|
|
304
|
+
*/
|
|
305
|
+
export interface IUploadCloudAppCodeParams {
|
|
306
|
+
/** 部署类型 */
|
|
307
|
+
deployType: DeployType;
|
|
308
|
+
/** 服务名称 */
|
|
309
|
+
serviceName: string;
|
|
310
|
+
/** 本地文件夹路径 */
|
|
311
|
+
localPath: string;
|
|
312
|
+
/** 忽略的文件/目录模式 */
|
|
313
|
+
ignore?: string[];
|
|
314
|
+
/** 进度回调 */
|
|
315
|
+
onProgress?: (progress: IProgressData) => void;
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* 上传代码结果
|
|
319
|
+
*/
|
|
320
|
+
export interface IUploadCloudAppCodeResult {
|
|
321
|
+
/** COS 时间戳(用于 createApp 时传入 staticConfig.cosTimestamp) */
|
|
322
|
+
cosTimestamp: string;
|
|
323
|
+
/** Unix 时间戳(与 cosTimestamp 相同) */
|
|
324
|
+
unixTimestamp: string;
|
|
325
|
+
}
|
package/types/environment.d.ts
CHANGED
|
@@ -13,7 +13,9 @@ import { AccessService } from './access';
|
|
|
13
13
|
import { UserService } from './user';
|
|
14
14
|
import { CloudBaseRunService } from './cloudBaseRun';
|
|
15
15
|
import { MysqlService } from './mysql';
|
|
16
|
+
import { CloudAppService } from './cloudApp';
|
|
16
17
|
import { EnvInfo } from './interfaces';
|
|
18
|
+
import { PermissionService } from './permission';
|
|
17
19
|
export declare class Environment {
|
|
18
20
|
inited: boolean;
|
|
19
21
|
cloudBaseContext: CloudBaseContext;
|
|
@@ -33,6 +35,8 @@ export declare class Environment {
|
|
|
33
35
|
private userService;
|
|
34
36
|
private cloudBaseRunService;
|
|
35
37
|
private mysqlService;
|
|
38
|
+
private permissionService;
|
|
39
|
+
private cloudAppService;
|
|
36
40
|
constructor(context: CloudBaseContext, envId: string);
|
|
37
41
|
lazyInit(): Promise<any>;
|
|
38
42
|
getEnvId(): string;
|
|
@@ -50,6 +54,8 @@ export declare class Environment {
|
|
|
50
54
|
getUserService(): UserService;
|
|
51
55
|
getCloudBaseRunService(): CloudBaseRunService;
|
|
52
56
|
getMysqlService(): MysqlService;
|
|
57
|
+
getCloudAppService(): CloudAppService;
|
|
58
|
+
getPermissionService(): PermissionService;
|
|
53
59
|
getCommonService(serviceType: string, serviceVersion: any): CommonService;
|
|
54
60
|
getServicesEnvInfo(): Promise<any>;
|
|
55
61
|
getAuthConfig(): {
|
package/types/index.d.ts
CHANGED
|
@@ -15,6 +15,8 @@ import { UserService } from './user';
|
|
|
15
15
|
import { CloudBaseRunService } from './cloudBaseRun';
|
|
16
16
|
import { MysqlService } from './mysql';
|
|
17
17
|
import { DocsService } from './docs';
|
|
18
|
+
import { PermissionService } from './permission';
|
|
19
|
+
import { CloudAppService } from './cloudApp';
|
|
18
20
|
interface CloudBaseConfig {
|
|
19
21
|
secretId?: string;
|
|
20
22
|
secretKey?: string;
|
|
@@ -52,12 +54,32 @@ declare class CloudBase {
|
|
|
52
54
|
get hosting(): HostingService;
|
|
53
55
|
get access(): AccessService;
|
|
54
56
|
get mysql(): MysqlService;
|
|
57
|
+
/**
|
|
58
|
+
* 云托管服务(CloudBaseRun)
|
|
59
|
+
* 提供云托管版本流量配置等能力
|
|
60
|
+
* @deprecated 请使用 cloudBaseRun 代替,避免与 cloudAppService 混淆
|
|
61
|
+
*/
|
|
55
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;
|
|
56
77
|
commonService(service?: string, version?: string): CommonService;
|
|
57
78
|
get env(): EnvService;
|
|
58
79
|
get log(): LogService;
|
|
59
80
|
get third(): ThirdService;
|
|
60
81
|
get user(): UserService;
|
|
82
|
+
get permission(): PermissionService;
|
|
61
83
|
get docs(): DocsService;
|
|
62
84
|
getEnvironmentManager(): EnvironmentManager;
|
|
63
85
|
getManagerConfig(): CloudBaseConfig;
|
package/types/log/index.d.ts
CHANGED
|
@@ -1,11 +1,43 @@
|
|
|
1
1
|
import { Environment } from '../environment';
|
|
2
2
|
import { ISearchClsLogParams, ISearchClsLogResponse } from './types';
|
|
3
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;
|
|
4
18
|
export declare class LogService {
|
|
5
19
|
private envId;
|
|
6
20
|
private cloudService;
|
|
7
21
|
private tcbrService;
|
|
8
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>;
|
|
9
41
|
/**
|
|
10
42
|
* 搜索 CLS 日志
|
|
11
43
|
*
|
|
@@ -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
|
+
}
|