@be-link/ecommerce-backend-bff-service-node-sdk 0.0.11 → 0.0.12

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/README.md CHANGED
@@ -19,10 +19,11 @@
19
19
 
20
20
  # EcommerceBackendBffService SDK
21
21
 
22
- EcommerceBackendBffService Node.js SDK - 统一平台 SDK,支持 Web/H5 和微信小程序
22
+ EcommerceBackendBffService Node.js SDK - 按平台分离的 SDK,支持 Pandora 管理后台和微信小程序
23
23
 
24
24
  ## 特性
25
25
 
26
+ - ✅ **平台分离架构**:PandoraSDK 和 MiniProgramSDK 独立,避免命名冲突
26
27
  - ✅ **统一命名空间结构**:与后端 SDK 保持一致的类型定义
27
28
  - ✅ **自动生成 Swagger 文档**:使用 tsoa 自动生成 OpenAPI 3.0 文档
28
29
  - ✅ **双模块格式支持**:同时支持 ESM 和 CommonJS,兼容 Vite、Webpack 等现代构建工具
@@ -39,11 +40,46 @@ npm install @be-link/ecommerce-backend-bff-service-node-sdk
39
40
 
40
41
  ## 使用
41
42
 
42
- ### Web/H5 环境
43
+ > 💡 **重要变更**:SDK 现在按平台分离,请使用 `PandoraSDK` 或 `MiniProgramSDK`。详见 [平台 SDK 指南](./PLATFORM_SDK_GUIDE.md)
44
+
45
+ ### Pandora 管理后台
46
+
47
+ ```typescript
48
+ import { PandoraSDK } from '@be-link/ecommerce-backend-bff-service-node-sdk'
49
+
50
+ const sdk = new PandoraSDK({
51
+ getToken: async () => localStorage.getItem('token') || '',
52
+ getUserId: async () => localStorage.getItem('userId') || '',
53
+ getRoleId: async () => localStorage.getItem('roleId') || '',
54
+ environment: 'production'
55
+ })
56
+
57
+ // 使用 Pandora 服务
58
+ const result = await sdk.example.getExampleData({ id: '123' })
59
+ ```
60
+
61
+ ### 微信小程序
62
+
63
+ ```typescript
64
+ import { MiniProgramSDK } from '@be-link/ecommerce-backend-bff-service-node-sdk'
65
+
66
+ const sdk = new MiniProgramSDK({
67
+ getToken: async () => wx.getStorageSync('token') || '',
68
+ getUserId: async () => wx.getStorageSync('userId') || '',
69
+ getRoleId: async () => wx.getStorageSync('roleId') || '',
70
+ environment: 'production'
71
+ })
72
+
73
+ // 使用小程序服务
74
+ const result = await sdk.demo.getDemoData({ page: 1 })
75
+ ```
76
+
77
+ ### 旧版本兼容(不推荐)
43
78
 
44
79
  ```typescript
45
80
  import { EcommerceBackendBffSDK } from '@be-link/ecommerce-backend-bff-service-node-sdk'
46
81
 
82
+ // ⚠️ 已废弃,请迁移到 PandoraSDK 或 MiniProgramSDK
47
83
  const sdk = new EcommerceBackendBffSDK({
48
84
  getToken: async () => localStorage.getItem('token') || '',
49
85
  getUserId: async () => localStorage.getItem('userId') || '',
package/cjs/index.d.ts CHANGED
@@ -2,31 +2,10 @@ import { PandoraExampleService } from './bff/modules/pandora/example/service';
2
2
  import { MiniProgramDemoService } from './bff/modules/miniprogram/demo/service';
3
3
  import type { SdkOptions } from './types';
4
4
  /**
5
- * EcommerceBackendBffSDK - 统一平台 SDK 的主入口
6
- * 支持多平台:小程序、Pandora、H5
7
- *
8
- * @deprecated 建议使用平台专用的 SDK:MiniProgramSDK, PandoraSDK
9
- *
10
- * @example
11
- * ```typescript
12
- * // 小程序环境
13
- * const sdk = new EcommerceBackendBffSDK({
14
- * getToken: async () => wx.getStorageSync('token') || '',
15
- * getUserId: async () => wx.getStorageSync('userId') || '',
16
- * getRoleId: async () => wx.getStorageSync('roleId') || '',
17
- * environment: 'production'
18
- * })
19
- *
20
- * // Pandora 环境
21
- * const sdk = new EcommerceBackendBffSDK({
22
- * getToken: async () => localStorage.getItem('token') || '',
23
- * getUserId: async () => localStorage.getItem('userId') || '',
24
- * getRoleId: async () => localStorage.getItem('roleId') || '',
25
- * environment: 'production'
26
- * })
27
- * ```
5
+ * Pandora 平台 SDK(管理后台)
6
+ * 包含所有 Pandora 平台相关的服务
28
7
  */
29
- export declare class EcommerceBackendBffSDK {
8
+ export declare class PandoraSDK {
30
9
  /**
31
10
  * HttpClient 实例,管理平台特定的请求策略
32
11
  */
@@ -35,12 +14,27 @@ export declare class EcommerceBackendBffSDK {
35
14
  * Pandora 示例服务模块
36
15
  */
37
16
  example: PandoraExampleService;
17
+ /**
18
+ * 使用配置选项初始化 Pandora SDK
19
+ * @param options - SDK 配置,包含凭证回调函数
20
+ */
21
+ constructor(options: SdkOptions);
22
+ }
23
+ /**
24
+ * 小程序平台 SDK
25
+ * 包含所有小程序平台相关的服务
26
+ */
27
+ export declare class MiniProgramSDK {
28
+ /**
29
+ * HttpClient 实例,管理平台特定的请求策略
30
+ */
31
+ private http;
38
32
  /**
39
33
  * 小程序 Demo 服务模块
40
34
  */
41
35
  demo: MiniProgramDemoService;
42
36
  /**
43
- * 使用配置选项初始化 SDK
37
+ * 使用配置选项初始化小程序 SDK
44
38
  * @param options - SDK 配置,包含凭证回调函数
45
39
  */
46
40
  constructor(options: SdkOptions);
package/cjs/index.js CHANGED
@@ -1,48 +1,43 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PandoraExampleService = exports.MiniProgramDemoService = exports.SystemError = exports.BizError = exports.SdkError = exports.EcommerceBackendBffSDK = void 0;
3
+ exports.PandoraExampleService = exports.MiniProgramDemoService = exports.SystemError = exports.BizError = exports.SdkError = exports.MiniProgramSDK = exports.PandoraSDK = void 0;
4
4
  const client_1 = require("./bff/request/client");
5
5
  const service_1 = require("./bff/modules/pandora/example/service");
6
6
  const service_2 = require("./bff/modules/miniprogram/demo/service");
7
7
  /**
8
- * EcommerceBackendBffSDK - 统一平台 SDK 的主入口
9
- * 支持多平台:小程序、Pandora、H5
10
- *
11
- * @deprecated 建议使用平台专用的 SDK:MiniProgramSDK, PandoraSDK
12
- *
13
- * @example
14
- * ```typescript
15
- * // 小程序环境
16
- * const sdk = new EcommerceBackendBffSDK({
17
- * getToken: async () => wx.getStorageSync('token') || '',
18
- * getUserId: async () => wx.getStorageSync('userId') || '',
19
- * getRoleId: async () => wx.getStorageSync('roleId') || '',
20
- * environment: 'production'
21
- * })
22
- *
23
- * // Pandora 环境
24
- * const sdk = new EcommerceBackendBffSDK({
25
- * getToken: async () => localStorage.getItem('token') || '',
26
- * getUserId: async () => localStorage.getItem('userId') || '',
27
- * getRoleId: async () => localStorage.getItem('roleId') || '',
28
- * environment: 'production'
29
- * })
30
- * ```
8
+ * Pandora 平台 SDK(管理后台)
9
+ * 包含所有 Pandora 平台相关的服务
31
10
  */
32
- class EcommerceBackendBffSDK {
11
+ class PandoraSDK {
33
12
  /**
34
- * 使用配置选项初始化 SDK
13
+ * 使用配置选项初始化 Pandora SDK
35
14
  * @param options - SDK 配置,包含凭证回调函数
36
15
  */
37
16
  constructor(options) {
38
17
  // 使用提供的选项初始化 HttpClient
39
18
  this.http = new client_1.HttpClient(options);
40
- // 使用 HttpClient 实例化所有服务模块
19
+ // 使用 HttpClient 实例化所有 Pandora 服务模块
41
20
  this.example = new service_1.PandoraExampleService(this.http);
21
+ }
22
+ }
23
+ exports.PandoraSDK = PandoraSDK;
24
+ /**
25
+ * 小程序平台 SDK
26
+ * 包含所有小程序平台相关的服务
27
+ */
28
+ class MiniProgramSDK {
29
+ /**
30
+ * 使用配置选项初始化小程序 SDK
31
+ * @param options - SDK 配置,包含凭证回调函数
32
+ */
33
+ constructor(options) {
34
+ // 使用提供的选项初始化 HttpClient
35
+ this.http = new client_1.HttpClient(options);
36
+ // 使用 HttpClient 实例化所有小程序服务模块
42
37
  this.demo = new service_2.MiniProgramDemoService(this.http);
43
38
  }
44
39
  }
45
- exports.EcommerceBackendBffSDK = EcommerceBackendBffSDK;
40
+ exports.MiniProgramSDK = MiniProgramSDK;
46
41
  // ==================== 导出 ====================
47
42
  // 错误类
48
43
  var errors_1 = require("./errors");
package/esm/index.d.ts CHANGED
@@ -2,31 +2,10 @@ import { PandoraExampleService } from './bff/modules/pandora/example/service';
2
2
  import { MiniProgramDemoService } from './bff/modules/miniprogram/demo/service';
3
3
  import type { SdkOptions } from './types';
4
4
  /**
5
- * EcommerceBackendBffSDK - 统一平台 SDK 的主入口
6
- * 支持多平台:小程序、Pandora、H5
7
- *
8
- * @deprecated 建议使用平台专用的 SDK:MiniProgramSDK, PandoraSDK
9
- *
10
- * @example
11
- * ```typescript
12
- * // 小程序环境
13
- * const sdk = new EcommerceBackendBffSDK({
14
- * getToken: async () => wx.getStorageSync('token') || '',
15
- * getUserId: async () => wx.getStorageSync('userId') || '',
16
- * getRoleId: async () => wx.getStorageSync('roleId') || '',
17
- * environment: 'production'
18
- * })
19
- *
20
- * // Pandora 环境
21
- * const sdk = new EcommerceBackendBffSDK({
22
- * getToken: async () => localStorage.getItem('token') || '',
23
- * getUserId: async () => localStorage.getItem('userId') || '',
24
- * getRoleId: async () => localStorage.getItem('roleId') || '',
25
- * environment: 'production'
26
- * })
27
- * ```
5
+ * Pandora 平台 SDK(管理后台)
6
+ * 包含所有 Pandora 平台相关的服务
28
7
  */
29
- export declare class EcommerceBackendBffSDK {
8
+ export declare class PandoraSDK {
30
9
  /**
31
10
  * HttpClient 实例,管理平台特定的请求策略
32
11
  */
@@ -35,12 +14,27 @@ export declare class EcommerceBackendBffSDK {
35
14
  * Pandora 示例服务模块
36
15
  */
37
16
  example: PandoraExampleService;
17
+ /**
18
+ * 使用配置选项初始化 Pandora SDK
19
+ * @param options - SDK 配置,包含凭证回调函数
20
+ */
21
+ constructor(options: SdkOptions);
22
+ }
23
+ /**
24
+ * 小程序平台 SDK
25
+ * 包含所有小程序平台相关的服务
26
+ */
27
+ export declare class MiniProgramSDK {
28
+ /**
29
+ * HttpClient 实例,管理平台特定的请求策略
30
+ */
31
+ private http;
38
32
  /**
39
33
  * 小程序 Demo 服务模块
40
34
  */
41
35
  demo: MiniProgramDemoService;
42
36
  /**
43
- * 使用配置选项初始化 SDK
37
+ * 使用配置选项初始化小程序 SDK
44
38
  * @param options - SDK 配置,包含凭证回调函数
45
39
  */
46
40
  constructor(options: SdkOptions);
package/esm/index.mjs CHANGED
@@ -2,40 +2,34 @@ import { HttpClient } from './bff/request/client.mjs';
2
2
  import { PandoraExampleService } from './bff/modules/pandora/example/service.mjs';
3
3
  import { MiniProgramDemoService } from './bff/modules/miniprogram/demo/service.mjs';
4
4
  /**
5
- * EcommerceBackendBffSDK - 统一平台 SDK 的主入口
6
- * 支持多平台:小程序、Pandora、H5
7
- *
8
- * @deprecated 建议使用平台专用的 SDK:MiniProgramSDK, PandoraSDK
9
- *
10
- * @example
11
- * ```typescript
12
- * // 小程序环境
13
- * const sdk = new EcommerceBackendBffSDK({
14
- * getToken: async () => wx.getStorageSync('token') || '',
15
- * getUserId: async () => wx.getStorageSync('userId') || '',
16
- * getRoleId: async () => wx.getStorageSync('roleId') || '',
17
- * environment: 'production'
18
- * })
19
- *
20
- * // Pandora 环境
21
- * const sdk = new EcommerceBackendBffSDK({
22
- * getToken: async () => localStorage.getItem('token') || '',
23
- * getUserId: async () => localStorage.getItem('userId') || '',
24
- * getRoleId: async () => localStorage.getItem('roleId') || '',
25
- * environment: 'production'
26
- * })
27
- * ```
5
+ * Pandora 平台 SDK(管理后台)
6
+ * 包含所有 Pandora 平台相关的服务
28
7
  */
29
- export class EcommerceBackendBffSDK {
8
+ export class PandoraSDK {
30
9
  /**
31
- * 使用配置选项初始化 SDK
10
+ * 使用配置选项初始化 Pandora SDK
32
11
  * @param options - SDK 配置,包含凭证回调函数
33
12
  */
34
13
  constructor(options) {
35
14
  // 使用提供的选项初始化 HttpClient
36
15
  this.http = new HttpClient(options);
37
- // 使用 HttpClient 实例化所有服务模块
16
+ // 使用 HttpClient 实例化所有 Pandora 服务模块
38
17
  this.example = new PandoraExampleService(this.http);
18
+ }
19
+ }
20
+ /**
21
+ * 小程序平台 SDK
22
+ * 包含所有小程序平台相关的服务
23
+ */
24
+ export class MiniProgramSDK {
25
+ /**
26
+ * 使用配置选项初始化小程序 SDK
27
+ * @param options - SDK 配置,包含凭证回调函数
28
+ */
29
+ constructor(options) {
30
+ // 使用提供的选项初始化 HttpClient
31
+ this.http = new HttpClient(options);
32
+ // 使用 HttpClient 实例化所有小程序服务模块
39
33
  this.demo = new MiniProgramDemoService(this.http);
40
34
  }
41
35
  }
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.11",
3
+ "version": "0.0.12",
4
4
  "description": "EcommerceBackendBffService Node.js SDK",
5
5
  "type": "commonjs",
6
6
  "main": "./cjs/index.js",