@be-link/ecommerce-backend-bff-service-node-sdk 0.0.16 → 0.0.17

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 (41) hide show
  1. package/cjs/bff/modules/pandora/product/service.d.ts +1 -1
  2. package/cjs/bff/modules/pandora/product/types.d.ts +12 -12
  3. package/cjs/bff/modules/pandora/productExp/service.d.ts +1 -1
  4. package/cjs/bff/modules/pandora/productExp/types.d.ts +7 -7
  5. package/cjs/bff/modules/pandora/productLive/service.d.ts +1 -1
  6. package/cjs/bff/modules/pandora/productLive/types.d.ts +4 -4
  7. package/cjs/bff/request/client.js +1 -1
  8. package/cjs/bff/request/strategy.d.ts +2 -2
  9. package/cjs/bff/request/strategy.js +107 -27
  10. package/cjs/index.d.ts +3 -15
  11. package/cjs/index.js +9 -17
  12. package/cjs/utils/string.js +33 -4
  13. package/esm/bff/modules/pandora/product/service.d.ts +1 -1
  14. package/esm/bff/modules/pandora/product/types.d.ts +12 -12
  15. package/esm/bff/modules/pandora/productExp/service.d.ts +1 -1
  16. package/esm/bff/modules/pandora/productExp/types.d.ts +7 -7
  17. package/esm/bff/modules/pandora/productLive/service.d.ts +1 -1
  18. package/esm/bff/modules/pandora/productLive/types.d.ts +4 -4
  19. package/esm/bff/request/client.mjs +1 -1
  20. package/esm/bff/request/strategy.d.ts +2 -2
  21. package/esm/bff/request/strategy.mjs +108 -28
  22. package/esm/index.d.ts +3 -15
  23. package/esm/index.mjs +0 -6
  24. package/esm/utils/string.mjs +33 -4
  25. package/package.json +3 -2
  26. package/cjs/bff/modules/pandora/store/service.d.ts +0 -77
  27. package/cjs/bff/modules/pandora/store/service.js +0 -107
  28. package/cjs/bff/modules/pandora/store/types.d.ts +0 -628
  29. package/cjs/bff/modules/pandora/store/types.js +0 -25
  30. package/cjs/bff/modules/pandora/storeSelection/service.d.ts +0 -47
  31. package/cjs/bff/modules/pandora/storeSelection/service.js +0 -67
  32. package/cjs/bff/modules/pandora/storeSelection/types.d.ts +0 -274
  33. package/cjs/bff/modules/pandora/storeSelection/types.js +0 -28
  34. package/esm/bff/modules/pandora/store/service.d.ts +0 -77
  35. package/esm/bff/modules/pandora/store/service.mjs +0 -100
  36. package/esm/bff/modules/pandora/store/types.d.ts +0 -628
  37. package/esm/bff/modules/pandora/store/types.mjs +0 -22
  38. package/esm/bff/modules/pandora/storeSelection/service.d.ts +0 -47
  39. package/esm/bff/modules/pandora/storeSelection/service.mjs +0 -60
  40. package/esm/bff/modules/pandora/storeSelection/types.d.ts +0 -274
  41. package/esm/bff/modules/pandora/storeSelection/types.mjs +0 -25
@@ -1,4 +1,4 @@
1
- import { ProductService as Service } from './types';
1
+ import { PandoraProductService as Service } from './types';
2
2
  import BaseService from '../../BaseService';
3
3
  import type { StandardResponse } from '../../../../types';
4
4
  /**
@@ -1,5 +1,5 @@
1
1
  import { StandardResponse } from '../../../../types';
2
- export declare namespace ProductService {
2
+ export declare namespace PandoraProductService {
3
3
  /**
4
4
  * 核销期限接口
5
5
  */
@@ -202,46 +202,46 @@ export declare namespace ProductService {
202
202
  /**
203
203
  * 商品列表
204
204
  */
205
- list(request: ProductService.Request.list): Promise<StandardResponse<ProductService.Response.list>>;
205
+ list(request: PandoraProductService.Request.list): Promise<StandardResponse<PandoraProductService.Response.list>>;
206
206
  /**
207
207
  * 创建商品
208
208
  */
209
- create(request: ProductService.ProductData): Promise<StandardResponse<ProductService.Response.create>>;
209
+ create(request: PandoraProductService.ProductData): Promise<StandardResponse<PandoraProductService.Response.create>>;
210
210
  /**
211
211
  * 商品详情
212
212
  */
213
- detail(request: ProductService.Request.detail): Promise<StandardResponse<ProductService.ProductData>>;
213
+ detail(request: PandoraProductService.Request.detail): Promise<StandardResponse<PandoraProductService.ProductData>>;
214
214
  /**
215
215
  * 商品更新
216
216
  */
217
- update(request: ProductService.ProductData): Promise<StandardResponse<void>>;
217
+ update(request: PandoraProductService.ProductData): Promise<StandardResponse<void>>;
218
218
  /**
219
219
  * 批量更新
220
220
  */
221
- batchUpdate(request: ProductService.Request.batchUpdate): Promise<StandardResponse<void>>;
221
+ batchUpdate(request: PandoraProductService.Request.batchUpdate): Promise<StandardResponse<void>>;
222
222
  /**
223
223
  * 查询定时任务任务
224
224
  */
225
- queryScheduledTask(request: ProductService.Request.queryScheduledTask): Promise<StandardResponse<ProductService.Response.queryScheduledTask[]>>;
225
+ queryScheduledTask(request: PandoraProductService.Request.queryScheduledTask): Promise<StandardResponse<PandoraProductService.Response.queryScheduledTask[]>>;
226
226
  /**
227
227
  * 校验69码是否重复
228
228
  */
229
- checkSkuCode(request: ProductService.Request.checkSkuCode): Promise<StandardResponse<ProductService.Response.checkSkuCode>>;
229
+ checkSkuCode(request: PandoraProductService.Request.checkSkuCode): Promise<StandardResponse<PandoraProductService.Response.checkSkuCode>>;
230
230
  /**
231
231
  * 商品导出
232
232
  */
233
- export(request: ProductService.Request.list): Promise<StandardResponse<void>>;
233
+ export(request: PandoraProductService.Request.list): Promise<StandardResponse<void>>;
234
234
  /**
235
235
  * 获取商品信息(不含规格信息)
236
236
  */
237
- queryProductList(request: ProductService.Request.queryProductList): Promise<StandardResponse<ProductService.Response.queryProductList>>;
237
+ queryProductList(request: PandoraProductService.Request.queryProductList): Promise<StandardResponse<PandoraProductService.Response.queryProductList>>;
238
238
  /**
239
239
  * 获取商品+规格信息
240
240
  */
241
- queryProductSkuList(request: ProductService.Request.queryProductList): Promise<StandardResponse<ProductService.Response.queryProductSkuList>>;
241
+ queryProductSkuList(request: PandoraProductService.Request.queryProductList): Promise<StandardResponse<PandoraProductService.Response.queryProductSkuList>>;
242
242
  /**
243
243
  * 商品二维码
244
244
  */
245
- productQrCode(request: ProductService.Request.productQrCode): Promise<StandardResponse<ProductService.Response.productQrCode>>;
245
+ productQrCode(request: PandoraProductService.Request.productQrCode): Promise<StandardResponse<PandoraProductService.Response.productQrCode>>;
246
246
  }
247
247
  }
@@ -1,4 +1,4 @@
1
- import { ProductExpService as Service } from './types';
1
+ import { PandoraProductExpService as Service } from './types';
2
2
  import BaseService from '../../BaseService';
3
3
  import type { StandardResponse } from '../../../../types';
4
4
  /**
@@ -1,5 +1,5 @@
1
1
  import { StandardResponse } from '../../../../types';
2
- export declare namespace ProductExpService {
2
+ export declare namespace PandoraProductExpService {
3
3
  interface ProductCategory {
4
4
  id: string;
5
5
  parentId: string;
@@ -56,26 +56,26 @@ export declare namespace ProductExpService {
56
56
  /**
57
57
  * 获取供应商列表
58
58
  */
59
- getSupplierList(): Promise<StandardResponse<ProductExpService.Response.getSupplierList[]>>;
59
+ getSupplierList(): Promise<StandardResponse<PandoraProductExpService.Response.getSupplierList[]>>;
60
60
  /**
61
61
  * 新增供应商
62
62
  */
63
- addSupplier(request: ProductExpService.Request.addSupplier): Promise<StandardResponse<ProductExpService.Response.addSupplier>>;
63
+ addSupplier(request: PandoraProductExpService.Request.addSupplier): Promise<StandardResponse<PandoraProductExpService.Response.addSupplier>>;
64
64
  /**
65
65
  * 获取直播分组列表
66
66
  */
67
- getLiveGroupList(): Promise<StandardResponse<ProductExpService.Response.getLiveGroupList[]>>;
67
+ getLiveGroupList(): Promise<StandardResponse<PandoraProductExpService.Response.getLiveGroupList[]>>;
68
68
  /**
69
69
  * 新增直播分组
70
70
  */
71
- addLiveGroup(request: ProductExpService.Request.addLiveGroup): Promise<StandardResponse<ProductExpService.Response.addLiveGroup>>;
71
+ addLiveGroup(request: PandoraProductExpService.Request.addLiveGroup): Promise<StandardResponse<PandoraProductExpService.Response.addLiveGroup>>;
72
72
  /**
73
73
  * 商品分类 树结构
74
74
  */
75
- productCategoryTree(): Promise<StandardResponse<ProductExpService.Response.ProductCategoryTree>>;
75
+ productCategoryTree(): Promise<StandardResponse<PandoraProductExpService.Response.ProductCategoryTree>>;
76
76
  /**
77
77
  * 获取产品经理列表
78
78
  */
79
- getProductManagerList(): Promise<StandardResponse<ProductExpService.Response.getProductManagerList>>;
79
+ getProductManagerList(): Promise<StandardResponse<PandoraProductExpService.Response.getProductManagerList>>;
80
80
  }
81
81
  }
@@ -1,4 +1,4 @@
1
- import { ProductLiveService as Service } from './types';
1
+ import { PandoraProductLiveService as Service } from './types';
2
2
  import BaseService from '../../BaseService';
3
3
  import type { StandardResponse } from '../../../../types';
4
4
  /**
@@ -1,5 +1,5 @@
1
1
  import { StandardResponse } from '../../../../types';
2
- export declare namespace ProductLiveService {
2
+ export declare namespace PandoraProductLiveService {
3
3
  namespace Request {
4
4
  interface list {
5
5
  pageIndex: number;
@@ -30,14 +30,14 @@ export declare namespace ProductLiveService {
30
30
  /**
31
31
  * 商品列表
32
32
  */
33
- list(request: ProductLiveService.Request.list): Promise<StandardResponse<ProductLiveService.Response.list>>;
33
+ list(request: PandoraProductLiveService.Request.list): Promise<StandardResponse<PandoraProductLiveService.Response.list>>;
34
34
  /**
35
35
  * 新增商品
36
36
  */
37
- add(request: ProductLiveService.Request.operate): Promise<StandardResponse<void>>;
37
+ add(request: PandoraProductLiveService.Request.operate): Promise<StandardResponse<void>>;
38
38
  /**
39
39
  * 删除商品
40
40
  */
41
- remove(request: ProductLiveService.Request.operate): Promise<StandardResponse<void>>;
41
+ remove(request: PandoraProductLiveService.Request.operate): Promise<StandardResponse<void>>;
42
42
  }
43
43
  }
@@ -48,7 +48,7 @@ class HttpClient {
48
48
  // 构造标准请求头
49
49
  const standardHeaders = {
50
50
  'Content-Type': 'application/json',
51
- 'X-Request-Id': requestId,
51
+ 'x-request-id': requestId,
52
52
  'x-belink-authorization': token,
53
53
  'x-belink-pandora-userid': userId,
54
54
  'x-belink-pandora-roleid': roleId,
@@ -34,12 +34,12 @@ export declare class WebRequestStrategy extends BaseRequestStrategy {
34
34
  request<T>(path: string, data?: any, headers?: Record<string, string>): Promise<T>;
35
35
  }
36
36
  /**
37
- * 微信小程序请求策略,使用 wx.cloud.callContainer
37
+ * 微信小程序请求策略,使用 wx.request
38
38
  * 为微信小程序环境实现请求策略
39
39
  */
40
40
  export declare class MiniProgramRequestStrategy extends BaseRequestStrategy {
41
41
  /**
42
- * 使用微信云托管容器 API 执行请求
42
+ * 使用 wx.request 执行 HTTP 请求
43
43
  * @param path - API 端点路径
44
44
  * @param data - 请求负载(可选)
45
45
  * @param headers - 要包含在请求中的额外请求头(可选)
@@ -36,7 +36,7 @@ class WebRequestStrategy extends BaseRequestStrategy {
36
36
  * @throws SystemError 如果是 5xx 服务器错误或网络错误
37
37
  */
38
38
  async request(path, data, headers = {}) {
39
- const requestId = headers['X-Request-Id'] || 'unknown';
39
+ const requestId = headers['x-request-id'] || 'unknown';
40
40
  const url = `${(0, env_1.getContainerHost)(this.environment)}${path}`;
41
41
  try {
42
42
  if (console?.info) {
@@ -100,12 +100,12 @@ class WebRequestStrategy extends BaseRequestStrategy {
100
100
  }
101
101
  exports.WebRequestStrategy = WebRequestStrategy;
102
102
  /**
103
- * 微信小程序请求策略,使用 wx.cloud.callContainer
103
+ * 微信小程序请求策略,使用 wx.request
104
104
  * 为微信小程序环境实现请求策略
105
105
  */
106
106
  class MiniProgramRequestStrategy extends BaseRequestStrategy {
107
107
  /**
108
- * 使用微信云托管容器 API 执行请求
108
+ * 使用 wx.request 执行 HTTP 请求
109
109
  * @param path - API 端点路径
110
110
  * @param data - 请求负载(可选)
111
111
  * @param headers - 要包含在请求中的额外请求头(可选)
@@ -114,40 +114,36 @@ class MiniProgramRequestStrategy extends BaseRequestStrategy {
114
114
  * @throws SystemError 如果是 5xx 服务器错误或微信 API 错误
115
115
  */
116
116
  async request(path, data, headers = {}) {
117
- const requestId = headers['X-Request-Id'] || 'unknown';
117
+ const requestId = headers['x-request-id'] || 'unknown';
118
118
  try {
119
119
  // 类型守卫,确保 wx 可用
120
- // 使用 any 类型避免类型定义冲突
121
120
  const wxGlobal = typeof wx !== 'undefined' ? wx : null;
122
- if (!wxGlobal || !wxGlobal.cloud) {
121
+ if (!wxGlobal || !wxGlobal.request) {
123
122
  if (console?.error) {
124
123
  console.error(`[SDK][${requestId}] 微信小程序环境不可用`);
125
124
  }
126
125
  throw new errors_1.SystemError('微信小程序环境不可用', 500);
127
126
  }
128
- // 构造包含微信特定字段的请求头
129
- const requestHeaders = {
130
- ...headers,
131
- 'X-WX-SERVICE': (0, env_1.getContainerService)(this.environment),
132
- };
127
+ // 构造完整的 URL
128
+ const url = `${(0, env_1.getContainerHost)(this.environment)}${path}`;
133
129
  if (console?.info) {
134
- console.info(`[SDK][${requestId}] 发起小程序云调用: ${path}`, `环境: ${(0, env_1.getContainerEnv)(this.environment)}`, data ? `参数: ${JSON.stringify(data)}` : '');
130
+ console.info(`[SDK][${requestId}] 发起小程序请求: ${url}`, data ? `参数: ${JSON.stringify(data)}` : '');
135
131
  }
136
- // 调用微信云托管容器
137
- const response = await wxGlobal.cloud.callContainer({
138
- config: {
139
- env: (0, env_1.getContainerEnv)(this.environment),
140
- },
141
- path,
142
- method: 'POST',
143
- header: requestHeaders,
144
- data,
145
- timeout: 100000, // 100 秒超时
132
+ // 使用 Promise 包装 wx.request
133
+ const response = await new Promise((resolve, reject) => {
134
+ wxGlobal.request({
135
+ url,
136
+ method: 'POST',
137
+ data,
138
+ header: {
139
+ 'content-type': 'application/json',
140
+ ...headers,
141
+ },
142
+ timeout: 60000, // 60 秒超时
143
+ success: (res) => resolve(res),
144
+ fail: (err) => reject(err),
145
+ });
146
146
  });
147
- // 记录微信云调用 ID
148
- if (console?.info && response.callID) {
149
- console.info(`[SDK][${requestId}] 微信云调用 ID: ${response.callID}`);
150
- }
151
147
  // 检查响应状态码是否表示成功
152
148
  if (response.statusCode >= 200 && response.statusCode < 300) {
153
149
  const responseData = response.data;
@@ -158,7 +154,7 @@ class MiniProgramRequestStrategy extends BaseRequestStrategy {
158
154
  // 非 2xx 状态码
159
155
  const errorMessage = response.data?.message || '请求失败';
160
156
  if (console?.error) {
161
- console.error(`[SDK][${requestId}] HTTP 错误: ${errorMessage}`, `状态码: ${response.statusCode}`, `微信云调用 ID: ${response.callID || 'unknown'}`, `响应数据: ${JSON.stringify(response.data)}`);
157
+ console.error(`[SDK][${requestId}] HTTP 错误: ${errorMessage}`, `状态码: ${response.statusCode}`, `响应数据: ${JSON.stringify(response.data)}`);
162
158
  }
163
159
  const ErrorClass = response.statusCode >= 400 && response.statusCode < 500 ? errors_1.BizError : errors_1.SystemError;
164
160
  throw new ErrorClass(errorMessage, response.statusCode);
@@ -186,3 +182,87 @@ class MiniProgramRequestStrategy extends BaseRequestStrategy {
186
182
  }
187
183
  }
188
184
  exports.MiniProgramRequestStrategy = MiniProgramRequestStrategy;
185
+ /* ============================================
186
+ * 旧版本:使用 wx.cloud.callContainer(已废弃)
187
+ * ============================================
188
+ *
189
+ * export class MiniProgramRequestStrategy extends BaseRequestStrategy {
190
+ * async request<T>(path: string, data?: any, headers: Record<string, string> = {}): Promise<T> {
191
+ * const requestId = headers['x-request-id'] || 'unknown'
192
+ *
193
+ * try {
194
+ * const wxGlobal = typeof wx !== 'undefined' ? (wx as any) : null
195
+ * if (!wxGlobal || !wxGlobal.cloud) {
196
+ * if (console?.error) {
197
+ * console.error(`[SDK][${requestId}] 微信小程序环境不可用`)
198
+ * }
199
+ * throw new SystemError('微信小程序环境不可用', 500)
200
+ * }
201
+ *
202
+ * const requestHeaders = {
203
+ * ...headers,
204
+ * 'X-WX-SERVICE': getContainerService(this.environment),
205
+ * }
206
+ *
207
+ * if (console?.info) {
208
+ * console.info(
209
+ * `[SDK][${requestId}] 发起小程序云调用: ${path}`,
210
+ * `环境: ${getContainerEnv(this.environment)}`,
211
+ * data ? `参数: ${JSON.stringify(data)}` : '',
212
+ * )
213
+ * }
214
+ *
215
+ * const response = await wxGlobal.cloud.callContainer({
216
+ * config: {
217
+ * env: getContainerEnv(this.environment),
218
+ * },
219
+ * path,
220
+ * method: 'POST',
221
+ * header: requestHeaders,
222
+ * data,
223
+ * timeout: 100000,
224
+ * })
225
+ *
226
+ * if (console?.info && response.callID) {
227
+ * console.info(`[SDK][${requestId}] 微信云调用 ID: ${response.callID}`)
228
+ * }
229
+ *
230
+ * if (response.statusCode >= 200 && response.statusCode < 300) {
231
+ * const responseData = response.data
232
+ * return responseData as T
233
+ * }
234
+ *
235
+ * const errorMessage = response.data?.message || '请求失败'
236
+ * if (console?.error) {
237
+ * console.error(
238
+ * `[SDK][${requestId}] HTTP 错误: ${errorMessage}`,
239
+ * `状态码: ${response.statusCode}`,
240
+ * `微信云调用 ID: ${response.callID || 'unknown'}`,
241
+ * `响应数据: ${JSON.stringify(response.data)}`,
242
+ * )
243
+ * }
244
+ * const ErrorClass =
245
+ * response.statusCode >= 400 && response.statusCode < 500 ? BizError : SystemError
246
+ * throw new ErrorClass(errorMessage, response.statusCode)
247
+ * } catch (error) {
248
+ * if (error instanceof SdkError) {
249
+ * throw error
250
+ * }
251
+ *
252
+ * if (error && typeof error === 'object' && 'errMsg' in error) {
253
+ * const errorMessage = (error as any).errMsg || '微信 API 调用失败'
254
+ * if (console?.error) {
255
+ * console.error(`[SDK][${requestId}] 微信 API 错误: ${errorMessage}`)
256
+ * }
257
+ * throw new SystemError(errorMessage, 500)
258
+ * }
259
+ *
260
+ * const errorMessage = error instanceof Error ? error.message : '发生未知错误'
261
+ * if (console?.error) {
262
+ * console.error(`[SDK][${requestId}] 未知错误: ${errorMessage}`)
263
+ * }
264
+ * throw new SystemError(errorMessage, 500)
265
+ * }
266
+ * }
267
+ * }
268
+ */
package/cjs/index.d.ts CHANGED
@@ -1,6 +1,4 @@
1
1
  import { PandoraExampleService } from './bff/modules/pandora/example/service';
2
- import { PandoraStoreService } from './bff/modules/pandora/store/service';
3
- import { PandoraStoreSelectionService } from './bff/modules/pandora/storeSelection/service';
4
2
  import { MiniProgramDemoService } from './bff/modules/miniprogram/demo/service';
5
3
  import { PandoraProductService } from './bff/modules/pandora/product/service';
6
4
  import { PandoraProductExpService } from './bff/modules/pandora/productExp/service';
@@ -22,14 +20,6 @@ export declare class PandoraSDK {
22
20
  product: PandoraProductService;
23
21
  productExp: PandoraProductExpService;
24
22
  productLive: PandoraProductLiveService;
25
- /**
26
- * Pandora 门店服务模块
27
- */
28
- store: PandoraStoreService;
29
- /**
30
- * Pandora 圈选门店服务模块
31
- */
32
- storeSelection: PandoraStoreSelectionService;
33
23
  /**
34
24
  * 使用配置选项初始化 Pandora SDK
35
25
  * @param options - SDK 配置,包含凭证回调函数
@@ -60,8 +50,6 @@ export { SdkOptions, IRequestStrategy, StandardResponse } from './types';
60
50
  export * from './enums';
61
51
  export { Service as MiniProgramDemoTypes } from './bff/modules/miniprogram/demo/types';
62
52
  export { Service as PandoraExampleTypes } from './bff/modules/pandora/example/types';
63
- export { Service as PandoraStoreTypes } from './bff/modules/pandora/store/types';
64
- export { Service as PandoraStoreSelectionTypes } from './bff/modules/pandora/storeSelection/types';
65
- export { ProductService as PandoraProductServiceTypes } from './bff/modules/pandora/product/types';
66
- export { ProductExpService as PandoraProductExpServiceTypes } from './bff/modules/pandora/productExp/types';
67
- export { ProductLiveService as PandoraProductLiveServiceTypes } from './bff/modules/pandora/productLive/types';
53
+ export { PandoraProductService as PandoraProductServiceTypes } from './bff/modules/pandora/product/types';
54
+ export { PandoraProductExpService as PandoraProductExpServiceTypes } from './bff/modules/pandora/productExp/types';
55
+ export { PandoraProductLiveService as PandoraProductLiveServiceTypes } from './bff/modules/pandora/productLive/types';
package/cjs/index.js CHANGED
@@ -14,15 +14,13 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.PandoraStoreSelectionTypes = exports.PandoraStoreTypes = exports.SystemError = exports.BizError = exports.SdkError = exports.MiniProgramSDK = exports.PandoraSDK = void 0;
17
+ exports.SystemError = exports.BizError = exports.SdkError = exports.MiniProgramSDK = exports.PandoraSDK = void 0;
18
18
  const client_1 = require("./bff/request/client");
19
19
  const service_1 = require("./bff/modules/pandora/example/service");
20
- const service_2 = require("./bff/modules/pandora/store/service");
21
- const service_3 = require("./bff/modules/pandora/storeSelection/service");
22
- const service_4 = require("./bff/modules/miniprogram/demo/service");
23
- const service_5 = require("./bff/modules/pandora/product/service");
24
- const service_6 = require("./bff/modules/pandora/productExp/service");
25
- const service_7 = require("./bff/modules/pandora/productLive/service");
20
+ const service_2 = require("./bff/modules/miniprogram/demo/service");
21
+ const service_3 = require("./bff/modules/pandora/product/service");
22
+ const service_4 = require("./bff/modules/pandora/productExp/service");
23
+ const service_5 = require("./bff/modules/pandora/productLive/service");
26
24
  /**
27
25
  * Pandora 平台 SDK(管理后台)
28
26
  * 包含所有 Pandora 平台相关的服务
@@ -37,11 +35,9 @@ class PandoraSDK {
37
35
  this.http = new client_1.HttpClient(options);
38
36
  // 使用 HttpClient 实例化所有 Pandora 服务模块
39
37
  this.example = new service_1.PandoraExampleService(this.http);
40
- this.store = new service_2.PandoraStoreService(this.http);
41
- this.storeSelection = new service_3.PandoraStoreSelectionService(this.http);
42
- this.product = new service_5.PandoraProductService(this.http);
43
- this.productExp = new service_6.PandoraProductExpService(this.http);
44
- this.productLive = new service_7.PandoraProductLiveService(this.http);
38
+ this.product = new service_3.PandoraProductService(this.http);
39
+ this.productExp = new service_4.PandoraProductExpService(this.http);
40
+ this.productLive = new service_5.PandoraProductLiveService(this.http);
45
41
  }
46
42
  }
47
43
  exports.PandoraSDK = PandoraSDK;
@@ -58,7 +54,7 @@ class MiniProgramSDK {
58
54
  // 使用提供的选项初始化 HttpClient
59
55
  this.http = new client_1.HttpClient(options);
60
56
  // 使用 HttpClient 实例化所有小程序服务模块
61
- this.demo = new service_4.MiniProgramDemoService(this.http);
57
+ this.demo = new service_2.MiniProgramDemoService(this.http);
62
58
  }
63
59
  }
64
60
  exports.MiniProgramSDK = MiniProgramSDK;
@@ -70,7 +66,3 @@ Object.defineProperty(exports, "BizError", { enumerable: true, get: function ()
70
66
  Object.defineProperty(exports, "SystemError", { enumerable: true, get: function () { return errors_1.SystemError; } });
71
67
  // 枚举和常量
72
68
  __exportStar(require("./enums"), exports);
73
- var types_1 = require("./bff/modules/pandora/store/types");
74
- Object.defineProperty(exports, "PandoraStoreTypes", { enumerable: true, get: function () { return types_1.Service; } });
75
- var types_2 = require("./bff/modules/pandora/storeSelection/types");
76
- Object.defineProperty(exports, "PandoraStoreSelectionTypes", { enumerable: true, get: function () { return types_2.Service; } });
@@ -31,10 +31,39 @@ function generateUUID() {
31
31
  if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {
32
32
  return crypto.randomUUID();
33
33
  }
34
- // 降级方案:使用 Math.random() 生成 UUID v4
35
- // 格式:xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx
36
- return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
37
- const r = (Math.random() * 16) | 0;
34
+ // 降级方案 1:使用 crypto.getRandomValues(浏览器和 Node.js)
35
+ if (typeof crypto !== 'undefined' && typeof crypto.getRandomValues === 'function') {
36
+ const bytes = new Uint8Array(16);
37
+ crypto.getRandomValues(bytes);
38
+ // 设置 UUID v4 的版本位和变体位
39
+ bytes[6] = (bytes[6] & 0x0f) | 0x40; // 版本 4
40
+ bytes[8] = (bytes[8] & 0x3f) | 0x80; // 变体 10
41
+ // 转换为 UUID 字符串格式
42
+ const hex = Array.from(bytes, (byte) => byte.toString(16).padStart(2, '0')).join('');
43
+ return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20, 32)}`;
44
+ }
45
+ // 降级方案 2:微信小程序环境(尝试使用 wx.getRandomValues)
46
+ if (typeof wx !== 'undefined' && typeof wx.getRandomValues === 'function') {
47
+ try {
48
+ const bytes = new Uint8Array(16);
49
+ wx.getRandomValues(bytes);
50
+ bytes[6] = (bytes[6] & 0x0f) | 0x40;
51
+ bytes[8] = (bytes[8] & 0x3f) | 0x80;
52
+ const hex = Array.from(bytes, (byte) => byte.toString(16).padStart(2, '0')).join('');
53
+ return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20, 32)}`;
54
+ }
55
+ catch (e) {
56
+ // 如果失败,继续使用最后的降级方案
57
+ }
58
+ }
59
+ // 最后的降级方案:使用增强的 Math.random()
60
+ // 结合时间戳和计数器来减少碰撞概率
61
+ const timestamp = Date.now();
62
+ const counter = generateUUID._counter || 0;
63
+ generateUUID._counter = (counter + 1) % 10000;
64
+ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c, i) => {
65
+ // 混合时间戳、计数器和随机数
66
+ const r = ((Math.random() * 16) | 0) ^ ((timestamp >> (i * 2)) & 0xf) ^ (counter & 0xf);
38
67
  const v = c === 'x' ? r : (r & 0x3) | 0x8;
39
68
  return v.toString(16);
40
69
  });
@@ -1,4 +1,4 @@
1
- import { ProductService as Service } from './types';
1
+ import { PandoraProductService as Service } from './types';
2
2
  import BaseService from '../../BaseService';
3
3
  import type { StandardResponse } from '../../../../types';
4
4
  /**
@@ -1,5 +1,5 @@
1
1
  import { StandardResponse } from '../../../../types';
2
- export declare namespace ProductService {
2
+ export declare namespace PandoraProductService {
3
3
  /**
4
4
  * 核销期限接口
5
5
  */
@@ -202,46 +202,46 @@ export declare namespace ProductService {
202
202
  /**
203
203
  * 商品列表
204
204
  */
205
- list(request: ProductService.Request.list): Promise<StandardResponse<ProductService.Response.list>>;
205
+ list(request: PandoraProductService.Request.list): Promise<StandardResponse<PandoraProductService.Response.list>>;
206
206
  /**
207
207
  * 创建商品
208
208
  */
209
- create(request: ProductService.ProductData): Promise<StandardResponse<ProductService.Response.create>>;
209
+ create(request: PandoraProductService.ProductData): Promise<StandardResponse<PandoraProductService.Response.create>>;
210
210
  /**
211
211
  * 商品详情
212
212
  */
213
- detail(request: ProductService.Request.detail): Promise<StandardResponse<ProductService.ProductData>>;
213
+ detail(request: PandoraProductService.Request.detail): Promise<StandardResponse<PandoraProductService.ProductData>>;
214
214
  /**
215
215
  * 商品更新
216
216
  */
217
- update(request: ProductService.ProductData): Promise<StandardResponse<void>>;
217
+ update(request: PandoraProductService.ProductData): Promise<StandardResponse<void>>;
218
218
  /**
219
219
  * 批量更新
220
220
  */
221
- batchUpdate(request: ProductService.Request.batchUpdate): Promise<StandardResponse<void>>;
221
+ batchUpdate(request: PandoraProductService.Request.batchUpdate): Promise<StandardResponse<void>>;
222
222
  /**
223
223
  * 查询定时任务任务
224
224
  */
225
- queryScheduledTask(request: ProductService.Request.queryScheduledTask): Promise<StandardResponse<ProductService.Response.queryScheduledTask[]>>;
225
+ queryScheduledTask(request: PandoraProductService.Request.queryScheduledTask): Promise<StandardResponse<PandoraProductService.Response.queryScheduledTask[]>>;
226
226
  /**
227
227
  * 校验69码是否重复
228
228
  */
229
- checkSkuCode(request: ProductService.Request.checkSkuCode): Promise<StandardResponse<ProductService.Response.checkSkuCode>>;
229
+ checkSkuCode(request: PandoraProductService.Request.checkSkuCode): Promise<StandardResponse<PandoraProductService.Response.checkSkuCode>>;
230
230
  /**
231
231
  * 商品导出
232
232
  */
233
- export(request: ProductService.Request.list): Promise<StandardResponse<void>>;
233
+ export(request: PandoraProductService.Request.list): Promise<StandardResponse<void>>;
234
234
  /**
235
235
  * 获取商品信息(不含规格信息)
236
236
  */
237
- queryProductList(request: ProductService.Request.queryProductList): Promise<StandardResponse<ProductService.Response.queryProductList>>;
237
+ queryProductList(request: PandoraProductService.Request.queryProductList): Promise<StandardResponse<PandoraProductService.Response.queryProductList>>;
238
238
  /**
239
239
  * 获取商品+规格信息
240
240
  */
241
- queryProductSkuList(request: ProductService.Request.queryProductList): Promise<StandardResponse<ProductService.Response.queryProductSkuList>>;
241
+ queryProductSkuList(request: PandoraProductService.Request.queryProductList): Promise<StandardResponse<PandoraProductService.Response.queryProductSkuList>>;
242
242
  /**
243
243
  * 商品二维码
244
244
  */
245
- productQrCode(request: ProductService.Request.productQrCode): Promise<StandardResponse<ProductService.Response.productQrCode>>;
245
+ productQrCode(request: PandoraProductService.Request.productQrCode): Promise<StandardResponse<PandoraProductService.Response.productQrCode>>;
246
246
  }
247
247
  }
@@ -1,4 +1,4 @@
1
- import { ProductExpService as Service } from './types';
1
+ import { PandoraProductExpService as Service } from './types';
2
2
  import BaseService from '../../BaseService';
3
3
  import type { StandardResponse } from '../../../../types';
4
4
  /**
@@ -1,5 +1,5 @@
1
1
  import { StandardResponse } from '../../../../types';
2
- export declare namespace ProductExpService {
2
+ export declare namespace PandoraProductExpService {
3
3
  interface ProductCategory {
4
4
  id: string;
5
5
  parentId: string;
@@ -56,26 +56,26 @@ export declare namespace ProductExpService {
56
56
  /**
57
57
  * 获取供应商列表
58
58
  */
59
- getSupplierList(): Promise<StandardResponse<ProductExpService.Response.getSupplierList[]>>;
59
+ getSupplierList(): Promise<StandardResponse<PandoraProductExpService.Response.getSupplierList[]>>;
60
60
  /**
61
61
  * 新增供应商
62
62
  */
63
- addSupplier(request: ProductExpService.Request.addSupplier): Promise<StandardResponse<ProductExpService.Response.addSupplier>>;
63
+ addSupplier(request: PandoraProductExpService.Request.addSupplier): Promise<StandardResponse<PandoraProductExpService.Response.addSupplier>>;
64
64
  /**
65
65
  * 获取直播分组列表
66
66
  */
67
- getLiveGroupList(): Promise<StandardResponse<ProductExpService.Response.getLiveGroupList[]>>;
67
+ getLiveGroupList(): Promise<StandardResponse<PandoraProductExpService.Response.getLiveGroupList[]>>;
68
68
  /**
69
69
  * 新增直播分组
70
70
  */
71
- addLiveGroup(request: ProductExpService.Request.addLiveGroup): Promise<StandardResponse<ProductExpService.Response.addLiveGroup>>;
71
+ addLiveGroup(request: PandoraProductExpService.Request.addLiveGroup): Promise<StandardResponse<PandoraProductExpService.Response.addLiveGroup>>;
72
72
  /**
73
73
  * 商品分类 树结构
74
74
  */
75
- productCategoryTree(): Promise<StandardResponse<ProductExpService.Response.ProductCategoryTree>>;
75
+ productCategoryTree(): Promise<StandardResponse<PandoraProductExpService.Response.ProductCategoryTree>>;
76
76
  /**
77
77
  * 获取产品经理列表
78
78
  */
79
- getProductManagerList(): Promise<StandardResponse<ProductExpService.Response.getProductManagerList>>;
79
+ getProductManagerList(): Promise<StandardResponse<PandoraProductExpService.Response.getProductManagerList>>;
80
80
  }
81
81
  }
@@ -1,4 +1,4 @@
1
- import { ProductLiveService as Service } from './types';
1
+ import { PandoraProductLiveService as Service } from './types';
2
2
  import BaseService from '../../BaseService';
3
3
  import type { StandardResponse } from '../../../../types';
4
4
  /**