@cloudbase/manager-node 4.11.0-alpha.1 → 4.11.0-alpha.10

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 (52) hide show
  1. package/.claude/settings.local.json +9 -0
  2. package/lib/agent/index.js +607 -16
  3. package/lib/agent/type.js +1 -0
  4. package/lib/cloudApp/index.js +243 -0
  5. package/lib/cloudApp/types.js +10 -0
  6. package/lib/database/index.js +79 -0
  7. package/lib/docs/index.js +288 -0
  8. package/lib/docs/types.js +2 -0
  9. package/lib/env/index.js +94 -0
  10. package/lib/environment.js +20 -0
  11. package/lib/function/index.js +97 -33
  12. package/lib/index.js +34 -0
  13. package/lib/interfaces/cloudApp.interface.js +20 -0
  14. package/lib/interfaces/index.js +1 -0
  15. package/lib/log/index.js +105 -0
  16. package/lib/log/types.js +24 -0
  17. package/lib/mysql/index.js +551 -0
  18. package/lib/mysql/types/account.js +2 -0
  19. package/lib/mysql/types/backup.js +2 -0
  20. package/lib/mysql/types/base.js +2 -0
  21. package/lib/mysql/types/index.js +19 -0
  22. package/lib/permission/index.js +313 -0
  23. package/lib/permission/types.js +2 -0
  24. package/lib/storage/index.js +424 -10
  25. package/lib/user/index.js +200 -0
  26. package/package.json +1 -1
  27. package/types/agent/index.d.ts +115 -5
  28. package/types/agent/type.d.ts +389 -0
  29. package/types/cloudApp/index.d.ts +73 -0
  30. package/types/cloudApp/types.d.ts +325 -0
  31. package/types/database/index.d.ts +112 -0
  32. package/types/docs/index.d.ts +37 -0
  33. package/types/docs/types.d.ts +24 -0
  34. package/types/env/index.d.ts +39 -1
  35. package/types/env/type.d.ts +187 -0
  36. package/types/environment.d.ts +12 -0
  37. package/types/function/index.d.ts +34 -5
  38. package/types/index.d.ts +26 -0
  39. package/types/interfaces/cloudApp.interface.d.ts +4 -0
  40. package/types/interfaces/index.d.ts +1 -0
  41. package/types/log/index.d.ts +53 -0
  42. package/types/log/types.d.ts +177 -0
  43. package/types/mysql/index.d.ts +261 -0
  44. package/types/mysql/types/account.d.ts +160 -0
  45. package/types/mysql/types/backup.d.ts +161 -0
  46. package/types/mysql/types/base.d.ts +579 -0
  47. package/types/mysql/types/index.d.ts +3 -0
  48. package/types/permission/index.d.ts +31 -0
  49. package/types/permission/types.d.ts +127 -0
  50. package/types/storage/index.d.ts +151 -3
  51. package/types/user/index.d.ts +17 -1
  52. package/types/user/types.d.ts +62 -0
@@ -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
+ }
@@ -66,6 +66,82 @@ export interface IStorageAclRule {
66
66
  /** 写权限规则,true 表示所有用户可写,字符串表示自定义规则表达式 */
67
67
  write: boolean | string;
68
68
  }
69
+ /** 复制文件选项 */
70
+ export interface ICopyOptions {
71
+ /** 源路径(云端路径,如 images/a.jpg) */
72
+ sourcePath: string;
73
+ /** 目标路径(云端路径,如 backup/a.jpg) */
74
+ destPath: string;
75
+ /** 是否强制覆盖已存在的文件 */
76
+ force?: boolean;
77
+ /** 是否跳过已存在的文件 */
78
+ skipExisting?: boolean;
79
+ }
80
+ /** 复制目录选项 */
81
+ export interface ICopyDirectoryOptions extends ICopyOptions {
82
+ /** 包含模式(glob 格式) */
83
+ include?: string | string[];
84
+ /** 排除模式(glob 格式) */
85
+ exclude?: string | string[];
86
+ /** 并发数,默认 20 */
87
+ parallel?: number;
88
+ /** 进度回调 */
89
+ onProgress?: (info: ICopyProgress) => void;
90
+ }
91
+ /** 复制进度信息 */
92
+ export interface ICopyProgress {
93
+ /** 已复制数量 */
94
+ copied: number;
95
+ /** 已跳过数量 */
96
+ skipped: number;
97
+ /** 总数量 */
98
+ total: number;
99
+ /** 当前正在处理的文件 */
100
+ currentFile: string;
101
+ }
102
+ /** 复制结果状态 */
103
+ export type CopyStatus = 'copied' | 'skipped' | 'failed';
104
+ /** 复制结果 */
105
+ export interface ICopyResult {
106
+ /** 是否成功 */
107
+ success: boolean;
108
+ /** 源路径 */
109
+ sourcePath: string;
110
+ /** 目标路径 */
111
+ destPath: string;
112
+ /** 文件大小 (bytes) */
113
+ size?: number;
114
+ /** 复制状态 */
115
+ status: CopyStatus;
116
+ /** 失败时的错误信息 */
117
+ error?: string;
118
+ }
119
+ /** 搜索文件选项 */
120
+ export interface ISearchOptions {
121
+ /** 搜索模式(glob 或正则表达式) */
122
+ pattern: string;
123
+ /** 搜索目录路径(不指定则搜索根目录) */
124
+ path?: string;
125
+ /** 是否为正则表达式 */
126
+ isRegex?: boolean;
127
+ /** 文件类型过滤(如 jpg, png) */
128
+ fileType?: string;
129
+ /** 限制数量,默认 100 */
130
+ limit?: number;
131
+ /** 是否包含详细信息 */
132
+ includeDetails?: boolean;
133
+ }
134
+ /** 搜索结果 */
135
+ export interface ISearchResult {
136
+ /** 文件路径(云端路径) */
137
+ key: string;
138
+ /** 类型:file 或 directory */
139
+ type: 'file' | 'directory';
140
+ /** 文件大小 (bytes),仅文件有效 */
141
+ size?: number;
142
+ /** 最后修改时间 (ISO 格式),仅文件有效 */
143
+ lastModified?: string;
144
+ }
69
145
  type OnProgress = (progressData: IProgressData) => void;
70
146
  type OnFileFinish = (error: Error, res: any, fileData: any) => void;
71
147
  export declare class StorageService {
@@ -227,9 +303,23 @@ export declare class StorageService {
227
303
  * ADMINWRITE:所有用户可读,仅管理员可写
228
304
  * ADMINONLY:仅管理员可读写
229
305
  * CUSTOM:自定义安全规则
230
- * @returns {Promise<{ acl: AclType, rule?: IStorageAclRule }>}
231
- */
232
- getStorageAcl(): Promise<{
306
+ *
307
+ * @param options.withRule 是否返回自定义安全规则,默认 false 以保持向后兼容
308
+ * @returns 不传参数时返回 AclType(向后兼容),传入 { withRule: true } 时返回 { acl: AclType, rule?: IStorageAclRule }
309
+ *
310
+ * @example
311
+ * // 向后兼容的简单用法(返回 AclType)
312
+ * const acl = await storage.getStorageAcl()
313
+ * if (acl === 'READONLY') { ... }
314
+ *
315
+ * // 获取自定义安全规则(返回对象)
316
+ * const result = await storage.getStorageAcl({ withRule: true })
317
+ * console.log(result.acl, result.rule)
318
+ */
319
+ getStorageAcl(): Promise<AclType>;
320
+ getStorageAcl(options: {
321
+ withRule: true;
322
+ }): Promise<{
233
323
  acl: AclType;
234
324
  rule?: IStorageAclRule;
235
325
  }>;
@@ -270,6 +360,16 @@ export declare class StorageService {
270
360
  * @returns {Promise<IListFileInfo[]>}
271
361
  */
272
362
  walkCloudDirCustom(options: IWalkCloudDirOptions): Promise<IListFileInfo[]>;
363
+ /**
364
+ * 列出指定目录下的文件和子目录(不递归,只列当前层)
365
+ * 使用 COS Delimiter 参数实现
366
+ * @param {string} dirPath 目录路径,空字符串表示根目录
367
+ * @returns {Promise<{ files: IListFileInfo[], directories: string[] }>}
368
+ */
369
+ listCurrentDirectory(dirPath?: string): Promise<{
370
+ files: IListFileInfo[];
371
+ directories: string[];
372
+ }>;
273
373
  /**
274
374
  * 遍历本地文件夹
275
375
  * 忽略不包含 dir 路径,即如果 ignore 匹配 dir,dir 也不会被忽略
@@ -300,6 +400,54 @@ export declare class StorageService {
300
400
  * @memberof StorageService
301
401
  */
302
402
  getBucket(options: IGetBucketOpions): Promise<any>;
403
+ /**
404
+ * 复制单个文件
405
+ * @param options.sourcePath 源文件路径(云端路径,如 images/a.jpg)
406
+ * @param options.destPath 目标文件路径(云端路径,如 backup/a.jpg)
407
+ * @param options.force 是否强制覆盖
408
+ * @param options.skipExisting 是否跳过已存在的文件
409
+ * @returns 复制结果
410
+ */
411
+ copyFile(options: ICopyOptions): Promise<ICopyResult>;
412
+ /**
413
+ * 复制目录
414
+ * 遍历源目录下的所有文件,并行复制到目标目录
415
+ * @param options.sourcePath 源目录路径
416
+ * @param options.destPath 目标目录路径
417
+ * @param options.include 包含模式(glob 格式)
418
+ * @param options.exclude 排除模式(glob 格式)
419
+ * @param options.force 是否强制覆盖
420
+ * @param options.skipExisting 是否跳过已存在的文件
421
+ * @param options.parallel 并发数,默认 20
422
+ * @param options.onProgress 进度回调
423
+ * @returns 复制结果数组
424
+ */
425
+ copyDirectory(options: ICopyDirectoryOptions): Promise<ICopyResult[]>;
426
+ /**
427
+ * 移动文件(复制后删除源文件)
428
+ * 注意:移动操作是「复制 + 删除」的两步操作,如果删除失败,文件会同时存在于源和目标位置
429
+ * @param options 与 copyFile 相同的选项
430
+ * @returns 移动结果,如果删除源文件失败会在 error 字段说明
431
+ */
432
+ moveFile(options: ICopyOptions): Promise<ICopyResult>;
433
+ /**
434
+ * 移动目录(复制后删除源目录)
435
+ * 注意:移动操作是「复制 + 删除」的两步操作,如果部分删除失败,文件会同时存在于源和目标位置
436
+ * @param options 与 copyDirectory 相同的选项
437
+ * @returns 移动结果数组,删除失败的文件会在对应结果的 error 字段说明
438
+ */
439
+ moveDirectory(options: ICopyDirectoryOptions): Promise<ICopyResult[]>;
440
+ /**
441
+ * 搜索文件和目录(只搜索当前目录,不递归)
442
+ * @param options.pattern 搜索模式(支持 glob 或正则表达式)
443
+ * @param options.path 搜索目录路径(不指定则搜索根目录)
444
+ * @param options.isRegex 是否为正则表达式模式
445
+ * @param options.fileType 文件类型过滤
446
+ * @param options.limit 限制返回数量,默认 100
447
+ * @param options.includeDetails 是否包含详细信息(大小、修改时间)
448
+ * @returns 搜索结果数组(包含文件和目录)
449
+ */
450
+ searchFiles(options: ISearchOptions): Promise<ISearchResult[]>;
303
451
  /**
304
452
  * 获取 COS 配置
305
453
  */
@@ -1,5 +1,5 @@
1
1
  import { Environment } from '../environment';
2
- import { EndUserInfo, EndUserStatus } from './types';
2
+ import { EndUserInfo, EndUserStatus, CreateUserOptions, CreateUserResp, DescribeUserListOptions, DescribeUserListResp, ModifyUserOptions, ModifyUserResp, DeleteUsersOptions, DeleteUsersResp } from './types';
3
3
  export declare class UserService {
4
4
  private environment;
5
5
  private tcbService;
@@ -54,5 +54,21 @@ export declare class UserService {
54
54
  WxAppId: string;
55
55
  Channel: "ide" | "low_code";
56
56
  }>;
57
+ createUser(options: CreateUserOptions): Promise<{
58
+ Data: CreateUserResp;
59
+ RequestId: string;
60
+ }>;
61
+ describeUserList(options?: DescribeUserListOptions): Promise<{
62
+ Data: DescribeUserListResp;
63
+ RequestId: string;
64
+ }>;
65
+ modifyUser(options: ModifyUserOptions): Promise<{
66
+ Data: ModifyUserResp | null;
67
+ RequestId: string;
68
+ }>;
69
+ deleteUsers(options: DeleteUsersOptions): Promise<{
70
+ Data: DeleteUsersResp;
71
+ RequestId: string;
72
+ }>;
57
73
  private isValidStr;
58
74
  }
@@ -18,3 +18,65 @@ export interface EndUserInfo {
18
18
  UserName: string;
19
19
  }
20
20
  export type EndUserStatus = 'ENABLE' | 'DISABLE';
21
+ export type TcbUserType = 'internalUser' | 'externalUser';
22
+ export type TcbUserStatus = 'ACTIVE' | 'BLOCKED';
23
+ export interface CreateUserOptions {
24
+ name: string;
25
+ uid?: string;
26
+ type?: TcbUserType;
27
+ password?: string;
28
+ userStatus?: TcbUserStatus;
29
+ nickName?: string;
30
+ phone?: string;
31
+ email?: string;
32
+ avatarUrl?: string;
33
+ description?: string;
34
+ }
35
+ export interface CreateUserResp {
36
+ Uid: string;
37
+ }
38
+ export interface DescribeUserListOptions {
39
+ pageNo?: number;
40
+ pageSize?: number;
41
+ name?: string;
42
+ nickName?: string;
43
+ phone?: string;
44
+ email?: string;
45
+ }
46
+ export interface TcbUserItem {
47
+ Uid?: string;
48
+ Name?: string;
49
+ Type?: 'internalUser' | 'externalUser';
50
+ UserStatus?: 'ACTIVE' | 'BLOCKED';
51
+ NickName?: string;
52
+ Phone?: string;
53
+ Email?: string;
54
+ AvatarUrl?: string;
55
+ Description?: string;
56
+ }
57
+ export interface DescribeUserListResp {
58
+ Total: number;
59
+ UserList: TcbUserItem[];
60
+ }
61
+ export interface ModifyUserOptions {
62
+ uid: string;
63
+ name?: string;
64
+ type?: TcbUserType;
65
+ password?: string;
66
+ userStatus?: TcbUserStatus;
67
+ nickName?: string;
68
+ phone?: string;
69
+ email?: string;
70
+ avatarUrl?: string;
71
+ description?: string;
72
+ }
73
+ export interface ModifyUserResp {
74
+ Success: boolean;
75
+ }
76
+ export interface DeleteUsersOptions {
77
+ uids: string[];
78
+ }
79
+ export interface DeleteUsersResp {
80
+ SuccessCount: number;
81
+ FailedCount: number;
82
+ }