@be-link/ecommerce-backend-bff-service-node-sdk 0.0.1 → 0.0.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.
@@ -85,5 +85,5 @@ __decorate([
85
85
  ], ExampleService.prototype, "getOrderList", null);
86
86
  exports.ExampleService = ExampleService = __decorate([
87
87
  (0, tsoa_1.Route)('api/v1/user'),
88
- (0, tsoa_1.Tags)('User')
88
+ (0, tsoa_1.Tags)('用户')
89
89
  ], ExampleService);
@@ -37,9 +37,10 @@ class HttpClient {
37
37
  */
38
38
  async request(opts) {
39
39
  // 并发获取凭证,带错误处理
40
- const [token, userId] = await Promise.all([
40
+ const [token, userId, ruleId] = await Promise.all([
41
41
  Promise.resolve(this.options.getToken()).catch(() => ''),
42
42
  Promise.resolve(this.options.getUserId()).catch(() => ''),
43
+ Promise.resolve(this.options.getRuleId?.() ?? '').catch(() => ''),
43
44
  ]);
44
45
  // 生成唯一的请求 ID
45
46
  const requestId = `b-${crypto.randomUUID()}`;
@@ -48,7 +49,8 @@ class HttpClient {
48
49
  'Content-Type': 'application/json',
49
50
  'X-Request-Id': requestId,
50
51
  'x-belink-authorization': token,
51
- 'x-belink-userId': userId,
52
+ 'x-belink-pandora-userId': userId,
53
+ 'x-belink-pandora-ruleId': ruleId,
52
54
  };
53
55
  // 合并自定义请求头(自定义请求头优先)
54
56
  const headers = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@be-link/ecommerce-backend-bff-service-node-sdk",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "EcommerceBackendBffService Node.js SDK",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
package/types/index.d.ts CHANGED
@@ -12,6 +12,7 @@ export interface SdkOptions {
12
12
  * 可以是同步或异步的
13
13
  */
14
14
  getUserId: () => string | Promise<string>;
15
+ getRuleId?: () => string | Promise<string>;
15
16
  /**
16
17
  * 运行环境配置(必传)
17
18
  * - 'production': 生产环境
package/utils/env.js CHANGED
@@ -18,23 +18,28 @@ function isMiniProgram() {
18
18
  */
19
19
  function getContainerHost(environment) {
20
20
  // 生产环境和测试环境使用不同的主机地址
21
+ // TODO 生产url
21
22
  return environment === 'production'
22
23
  ? 'http://bxbvjnca.tfs.cwl9ok0a.mk2u3r3l.com:8090' // 生产环境
23
- : 'http://bxbvjnca.tfs.cwl9ok0a.mk2u3r3l.com:8090'; // 测试环境
24
+ : 'https://backend-bff-service-196345-5-1304510571.sh.run.tcloudbase.com'; // 测试环境
24
25
  }
25
26
  /**
26
27
  * 根据环境获取微信云环境标识符
27
28
  * @param environment - 运行环境 ('production' 或 'test')
28
29
  * @returns 云环境标识符
29
30
  */
31
+ // TODO 生产改
30
32
  function getContainerEnv(environment) {
31
- return environment === 'production' ? 'prod-1g8x9y7z' : 'test-2h3j4k5l';
33
+ return environment === 'production'
34
+ ? 'ecommerce-dev-1g0iert2838e56dd'
35
+ : 'ecommerce-dev-1g0iert2838e56dd';
32
36
  }
33
37
  /**
34
38
  * 根据环境获取微信云服务名称
35
39
  * @param environment - 运行环境 ('production' 或 'test')
36
40
  * @returns 云服务名称
37
41
  */
42
+ // TODO 生产改
38
43
  function getContainerService(environment) {
39
- return environment === 'production' ? 'bff-container-prod' : 'bff-container-test';
44
+ return environment === 'production' ? 'backend-bff-service' : 'backend-bff-service';
40
45
  }