@cloudbase/manager-node 4.11.0-alpha.10 → 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/jest.config.js CHANGED
@@ -10,6 +10,7 @@ module.exports = {
10
10
  },
11
11
  transformIgnorePatterns: ['node_modules'],
12
12
  testEnvironment: 'node',
13
+ forceExit: true,
13
14
  // https://github.com/facebook/jest/issues/5164
14
15
  globalSetup: './test/global-setup-hook.ts',
15
16
  // globalTeardown: './test/global-teardown-hook.js',
@@ -28,14 +28,14 @@ class AgentService {
28
28
  }
29
29
  // ==================== SCF 云函数部署 ====================
30
30
  /**
31
- * 创建 SCF Agent
31
+ * 创建 Agent
32
32
  * 支持两种方式:
33
33
  * 1. 传入 cwd 代码目录,自动打包上传
34
34
  * 2. 传入 ZipFile / CosBucketRegion + TempCosObjectName,直接上传
35
35
  * @param params 创建参数
36
36
  * @returns Agent 创建结果
37
37
  */
38
- async createScfAgent(params) {
38
+ async createAgent(params) {
39
39
  const envConfig = this.environment.lazyEnvironmentConfig;
40
40
  // 默认会话配置
41
41
  const defaultSessionConfig = {
@@ -622,7 +622,7 @@ class AgentService {
622
622
  exports.AgentService = AgentService;
623
623
  __decorate([
624
624
  (0, utils_1.preLazy)()
625
- ], AgentService.prototype, "createScfAgent", null);
625
+ ], AgentService.prototype, "createAgent", null);
626
626
  __decorate([
627
627
  (0, utils_1.preLazy)()
628
628
  ], AgentService.prototype, "describeAgentList", null);
package/lib/env/index.js CHANGED
@@ -573,7 +573,7 @@ class EnvService {
573
573
  */
574
574
  async deleteCustomDomain(params) {
575
575
  const { EnvId, Domain } = params;
576
- // 先查询域名下是否有路由绑定
576
+ // 查询domain下的路由
577
577
  const queryRes = await this.describeHttpServiceRoute({
578
578
  EnvId,
579
579
  Filters: [
@@ -581,20 +581,18 @@ class EnvService {
581
581
  Name: 'Domain',
582
582
  Values: [Domain]
583
583
  }
584
- ],
585
- Limit: 1
584
+ ]
586
585
  });
587
- // 检查域名是否存在
588
586
  const domains = queryRes.Domains || [];
589
587
  const targetDomain = domains.find(d => d.Domain === Domain);
590
588
  if (!targetDomain) {
591
- throw new error_1.CloudBaseError(`域名 ${Domain} 不存在`);
589
+ throw new error_1.CloudBaseError(`Domain ${Domain} does not exist`);
592
590
  }
593
- // 检查域名下是否有路由绑定
591
+ // 检查是否有路由绑定
594
592
  const routes = targetDomain.Routes || [];
595
593
  if (routes.length > 0) {
596
594
  const routePaths = routes.map(r => r.Path).join(', ');
597
- throw new error_1.CloudBaseError(`域名 ${Domain} 下还有 ${routes.length} 个路由绑定(${routePaths}),请先删除路由后再删除域名`);
595
+ throw new error_1.CloudBaseError(`Domain ${Domain} has ${routes.length} route binding(s) (${routePaths}). Please delete the routes before deleting the domain.`);
598
596
  }
599
597
  // 无路由绑定,可以删除域名
600
598
  return this.cloudService.request('DeleteHTTPServiceRoute', {
@@ -25,7 +25,9 @@ class PermissionService {
25
25
  if (!resourceType || !PERMISSION_BY_RESOURCE[resourceType]) {
26
26
  throw new Error('Invalid resourceType');
27
27
  }
28
- if (typeof resource !== 'string' || resource.trim().length === 0) {
28
+ const isFunctionResourceType = resourceType === 'function';
29
+ const hasValidResourceValue = typeof resource === 'string' && resource.trim().length > 0;
30
+ if (!isFunctionResourceType && !hasValidResourceValue) {
29
31
  throw new Error('Invalid resource');
30
32
  }
31
33
  const allowed = PERMISSION_BY_RESOURCE[resourceType];
@@ -43,12 +45,7 @@ class PermissionService {
43
45
  // throw new Error('securityRule must be a valid JSON string')
44
46
  // }
45
47
  }
46
- const reqData = {
47
- EnvId,
48
- ResourceType: resourceType,
49
- Resource: resource,
50
- Permission: permission
51
- };
48
+ const reqData = Object.assign({ EnvId, ResourceType: resourceType, Permission: permission }, (hasValidResourceValue || !isFunctionResourceType ? { Resource: resource } : {}));
52
49
  if (permission === 'CUSTOM') {
53
50
  reqData.SecurityRule = securityRule;
54
51
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/manager-node",
3
- "version": "4.11.0-alpha.10",
3
+ "version": "4.11.0-alpha.11",
4
4
  "description": "The node manage service api for cloudbase.",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -1,5 +1,5 @@
1
1
  import { Environment } from '../environment';
2
- import { ICreateFunctionAgentParams, ICreateScfAgentParams, ICreateTcbrAgentByImageParams, ICreateTcbrAgentByPackageParams, ICreateTcbrAgentByCodeParams, IDescribeAgentListParams, IDescribeAgentListResponse, IDescribeAgentResponse, IDeleteAgentParams, IDescribeCloudBaseBuildServiceParams, IDescribeCloudBaseBuildServiceResponse, ICreateAgentResponse, IDeleteAgentResponse, ICommonResponse, IUpdateAgentParams, IUpdateScfAgentParams, IUpdateScfAgentResponse, IUpdateTcbrAgentParams, IGetAgentLogsParams } from './type';
2
+ import { ICreateFunctionAgentParams, ICreateAgentParams, ICreateTcbrAgentByImageParams, ICreateTcbrAgentByPackageParams, ICreateTcbrAgentByCodeParams, IDescribeAgentListParams, IDescribeAgentListResponse, IDescribeAgentResponse, IDeleteAgentParams, IDescribeCloudBaseBuildServiceParams, IDescribeCloudBaseBuildServiceResponse, ICreateAgentResponse, IDeleteAgentResponse, ICommonResponse, IUpdateAgentParams, IUpdateScfAgentParams, IUpdateScfAgentResponse, IUpdateTcbrAgentParams, IGetAgentLogsParams } from './type';
3
3
  /**
4
4
  * Agent 管理类
5
5
  * 支持三种部署方式:
@@ -12,14 +12,14 @@ export declare class AgentService {
12
12
  private tcbService;
13
13
  constructor(environment: Environment);
14
14
  /**
15
- * 创建 SCF Agent
15
+ * 创建 Agent
16
16
  * 支持两种方式:
17
17
  * 1. 传入 cwd 代码目录,自动打包上传
18
18
  * 2. 传入 ZipFile / CosBucketRegion + TempCosObjectName,直接上传
19
19
  * @param params 创建参数
20
20
  * @returns Agent 创建结果
21
21
  */
22
- createScfAgent(params: ICreateScfAgentParams): Promise<ICreateAgentResponse>;
22
+ createAgent(params: ICreateAgentParams): Promise<ICreateAgentResponse>;
23
23
  /**
24
24
  * 查询 Agent 列表
25
25
  * @param params 查询参数
@@ -28,12 +28,12 @@ export interface ISessionConfig {
28
28
  MaxConcurrency?: number;
29
29
  }
30
30
  /**
31
- * 创建 SCF Agent 的参数
31
+ * 创建 Agent 的参数
32
32
  * 支持两种方式:
33
33
  * 1. 传入 cwd 代码目录,自动打包上传
34
34
  * 2. 传入 ZipFile / CosBucketRegion + TempCosObjectName,直接上传
35
35
  */
36
- export interface ICreateScfAgentParams {
36
+ export interface ICreateAgentParams {
37
37
  /** Agent 名称 */
38
38
  Name: string;
39
39
  /** Agent ID,不传则自动生成 */
@@ -2,7 +2,7 @@ export type PermissionResourceType = 'function' | 'storage' | 'table' | 'collect
2
2
  export type BasePermission = 'READONLY' | 'PRIVATE' | 'ADMINWRITE' | 'ADMINONLY' | 'CUSTOM';
3
3
  export interface ModifyResourcePermissionOptions {
4
4
  resourceType: PermissionResourceType;
5
- resource: string;
5
+ resource?: string;
6
6
  permission: BasePermission;
7
7
  securityRule?: string;
8
8
  }