@cloudbase/manager-node 5.8.1 → 5.8.2

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/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## @cloudbase/manager-node v5.8.1 版本发布 🚀(2026-08-21)
2
+
3
+ - 新增 支持一致性发布
4
+
5
+ ---
6
+
1
7
  ## @cloudbase/manager-node v5.8.0 版本发布 🚀(2026-08-20)
2
8
 
3
9
  - 新增 声明式部署编排(hosting 本地构建/gateway 域名绑定/certId 自动查询)
package/lib/context.js CHANGED
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CloudBaseContext = void 0;
4
4
  const constant_1 = require("./constant");
5
5
  class CloudBaseContext {
6
- constructor({ secretId = '', secretKey = '', token = '', proxy = '', region = '', envType = '', useInternalEndpoint = undefined, internalEndpointRegion = undefined }) {
6
+ constructor({ secretId = '', secretKey = '', token = '', proxy = '', region = '', envType = '', useInternalEndpoint = undefined, internalEndpointRegion = undefined, requestFn = undefined }) {
7
7
  this.secretId = secretId;
8
8
  this.secretKey = secretKey;
9
9
  this.token = token;
@@ -12,6 +12,7 @@ class CloudBaseContext {
12
12
  this.envType = envType;
13
13
  this.useInternalEndpoint = useInternalEndpoint;
14
14
  this.internalEndpointRegion = internalEndpointRegion;
15
+ this.requestFn = requestFn;
15
16
  }
16
17
  isInternalEndpoint() {
17
18
  return this.useInternalEndpoint !== undefined ? this.useInternalEndpoint : constant_1.USE_INTERNAL_ENDPOINT;
package/lib/index.js CHANGED
@@ -21,9 +21,9 @@ class CloudBase {
21
21
  }
22
22
  constructor(config = {}) {
23
23
  this.cloudBaseConfig = {};
24
- let { secretId, secretKey, token, envId, proxy, region, envType, useInternalEndpoint, internalEndpointRegion } = config;
25
- // config 中传入的 secretId secretkey 必须同时存在
26
- if ((secretId && !secretKey) || (!secretId && secretKey)) {
24
+ let { secretId, secretKey, token, envId, proxy, region, envType, useInternalEndpoint, internalEndpointRegion, requestFn } = config;
25
+ // config 中传入的 secretId secretkey 必须同时存在(有 requestFn 时可以不传)
26
+ if (!requestFn && ((secretId && !secretKey) || (!secretId && secretKey))) {
27
27
  throw new Error('secretId and secretKey must be a pair');
28
28
  }
29
29
  this.cloudBaseConfig = {
@@ -36,6 +36,7 @@ class CloudBase {
36
36
  region,
37
37
  useInternalEndpoint,
38
38
  internalEndpointRegion,
39
+ requestFn,
39
40
  };
40
41
  // 初始化 context
41
42
  this.context = new context_1.CloudBaseContext(this.cloudBaseConfig);
@@ -53,12 +53,13 @@ function getDate(timestamp) {
53
53
  }
54
54
  class CloudService {
55
55
  /* eslint-disable-next-line */
56
- constructor(context, service, version, baseParams) {
56
+ constructor(context, service, version, baseParams, requestFn) {
57
57
  this.service = service;
58
58
  this.version = version;
59
59
  this.timeout = 60000;
60
60
  this.baseParams = baseParams || {};
61
61
  this.cloudBaseContext = context;
62
+ this.requestFn = requestFn !== null && requestFn !== void 0 ? requestFn : context === null || context === void 0 ? void 0 : context.requestFn;
62
63
  }
63
64
  get baseUrl() {
64
65
  const internalEndpoint = this.cloudBaseContext.isInternalEndpoint();
@@ -90,9 +91,32 @@ class CloudService {
90
91
  }
91
92
  }
92
93
  async request(action, data = {}, method = 'POST') {
94
+ var _a;
93
95
  this.action = action;
94
- this.data = deepRemoveVoid(Object.assign(Object.assign({}, data), this.baseParams));
95
96
  this.method = method;
97
+ this.data = deepRemoveVoid(Object.assign(Object.assign({}, data), this.baseParams));
98
+ // 如果注入了 requestFn,直接委托,跳过 TC3 签名逻辑
99
+ if (this.requestFn) {
100
+ try {
101
+ const result = await this.requestFn({
102
+ service: this.service,
103
+ action,
104
+ version: this.version,
105
+ region: (_a = this.cloudBaseContext.region) !== null && _a !== void 0 ? _a : '',
106
+ payload: this.data,
107
+ });
108
+ return result;
109
+ }
110
+ catch (e) {
111
+ if (e.name === 'CloudBaseError') {
112
+ throw e;
113
+ }
114
+ throw new error_1.CloudBaseError(e.message, {
115
+ action,
116
+ code: e.code
117
+ });
118
+ }
119
+ }
96
120
  this.url = this.baseUrl;
97
121
  let { secretId, secretKey, token } = this.cloudBaseContext;
98
122
  // 当在云函数环境下执行时,可init时不传入密钥,取环境变量中密钥使用
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/manager-node",
3
- "version": "5.8.1",
3
+ "version": "5.8.2",
4
4
  "description": "The node manage service api for cloudbase.",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -1,3 +1,15 @@
1
+ /**
2
+ * 自定义 API 请求函数,由外部注入,替代 TC3 签名发请求。
3
+ * 入参对齐 CAPI 模式:service + action + version + region + payload。
4
+ * 返回腾讯云 API 响应中 Response 字段的内容(已解包,不含 Response 包装层)。
5
+ */
6
+ export type CloudApiRequestFn = (params: {
7
+ service: string;
8
+ action: string;
9
+ version: string;
10
+ region: string;
11
+ payload: Record<string, any>;
12
+ }) => Promise<any>;
1
13
  export declare class CloudBaseContext {
2
14
  readonly secretId: string;
3
15
  readonly secretKey: string;
@@ -8,15 +20,17 @@ export declare class CloudBaseContext {
8
20
  readonly envType: string;
9
21
  readonly useInternalEndpoint?: boolean;
10
22
  readonly internalEndpointRegion?: string;
11
- constructor({ secretId, secretKey, token, proxy, region, envType, useInternalEndpoint, internalEndpointRegion }: {
23
+ readonly requestFn?: CloudApiRequestFn;
24
+ constructor({ secretId, secretKey, token, proxy, region, envType, useInternalEndpoint, internalEndpointRegion, requestFn }: {
12
25
  secretId?: string;
13
26
  secretKey?: string;
14
27
  token?: string;
15
28
  proxy?: string;
16
29
  region?: string;
17
30
  envType?: string;
18
- useInternalEndpoint?: any;
19
- internalEndpointRegion?: any;
31
+ useInternalEndpoint?: boolean;
32
+ internalEndpointRegion?: string;
33
+ requestFn?: CloudApiRequestFn;
20
34
  });
21
35
  isInternalEndpoint(): boolean;
22
36
  getInternalEndpointRegion(): string;
package/types/index.d.ts CHANGED
@@ -6,6 +6,7 @@ import { AgentService } from './agent';
6
6
  import { StorageService } from './storage';
7
7
  import { DatabaseService } from './database';
8
8
  import { LogService } from './log';
9
+ import { CloudApiRequestFn } from './context';
9
10
  import { CommonService } from './common';
10
11
  import { HostingService } from './hosting';
11
12
  import { Environment } from './environment';
@@ -34,6 +35,7 @@ interface CloudBaseConfig {
34
35
  envType?: string;
35
36
  useInternalEndpoint?: boolean;
36
37
  internalEndpointRegion?: string;
38
+ requestFn?: CloudApiRequestFn;
37
39
  }
38
40
  declare class CloudBase {
39
41
  private static cloudBase;
@@ -123,4 +125,7 @@ declare class CloudBase {
123
125
  getManagerConfig(): CloudBaseConfig;
124
126
  get isInternalEndpoint(): Boolean;
125
127
  }
128
+ declare namespace CloudBase {
129
+ type RequestFn = CloudApiRequestFn;
130
+ }
126
131
  export = CloudBase;
@@ -1,4 +1,4 @@
1
- import { CloudBaseContext } from '../context';
1
+ import { CloudBaseContext, CloudApiRequestFn } from '../context';
2
2
  export declare class CloudService {
3
3
  service: string;
4
4
  version: string;
@@ -13,7 +13,8 @@ export declare class CloudService {
13
13
  payload: Record<string, any>;
14
14
  baseParams: Record<string, any>;
15
15
  cloudBaseContext: CloudBaseContext;
16
- constructor(context: CloudBaseContext, service: string, version: string, baseParams?: Record<string, any>);
16
+ private requestFn?;
17
+ constructor(context: CloudBaseContext, service: string, version: string, baseParams?: Record<string, any>, requestFn?: CloudApiRequestFn);
17
18
  get baseUrl(): any;
18
19
  request<T extends {}>(action: string, data?: Record<string, any>, method?: 'POST' | 'GET'): Promise<T>;
19
20
  requestWithSign(): Promise<any>;