@be-link/ecommerce-backend-bff-service-node-sdk 0.0.6 → 0.0.7
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 +2 -0
- package/cjs/bff/request/client.js +1 -1
- package/cjs/index.d.ts +2 -0
- package/cjs/index.js +2 -0
- package/cjs/types/index.d.ts +5 -1
- package/esm/bff/request/client.mjs +1 -1
- package/esm/index.d.ts +2 -0
- package/esm/index.mjs +2 -0
- package/esm/types/index.d.ts +5 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -26,6 +26,7 @@ import { EcommerceBackendBffSDK } from '@be-link/ecommerce-backend-bff-service-n
|
|
|
26
26
|
const sdk = new EcommerceBackendBffSDK({
|
|
27
27
|
getToken: async () => localStorage.getItem('token') || '',
|
|
28
28
|
getUserId: async () => localStorage.getItem('userId') || '',
|
|
29
|
+
getRuleId: async () => localStorage.getItem('ruleId') || '',
|
|
29
30
|
environment: 'production'
|
|
30
31
|
})
|
|
31
32
|
|
|
@@ -44,6 +45,7 @@ import { EcommerceBackendBffSDK } from '@be-link/ecommerce-backend-bff-service-n
|
|
|
44
45
|
const sdk = new EcommerceBackendBffSDK({
|
|
45
46
|
getToken: async () => wx.getStorageSync('token') || '',
|
|
46
47
|
getUserId: async () => wx.getStorageSync('userId') || '',
|
|
48
|
+
getRuleId: async () => wx.getStorageSync('ruleId') || '',
|
|
47
49
|
environment: 'test'
|
|
48
50
|
})
|
|
49
51
|
|
|
@@ -41,7 +41,7 @@ class HttpClient {
|
|
|
41
41
|
const [token, userId, ruleId] = await Promise.all([
|
|
42
42
|
Promise.resolve(this.options.getToken()).catch(() => ''),
|
|
43
43
|
Promise.resolve(this.options.getUserId()).catch(() => ''),
|
|
44
|
-
Promise.resolve(this.options.getRuleId
|
|
44
|
+
Promise.resolve(this.options.getRuleId()).catch(() => ''),
|
|
45
45
|
]);
|
|
46
46
|
// 生成唯一的请求 ID(兼容所有环境)
|
|
47
47
|
const requestId = `b-${(0, string_1.generateUUID)()}`;
|
package/cjs/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ import type { SdkOptions } from './types';
|
|
|
11
11
|
* const sdk = new EcommerceBackendBffSDK({
|
|
12
12
|
* getToken: async () => localStorage.getItem('token') || '',
|
|
13
13
|
* getUserId: async () => localStorage.getItem('userId') || '',
|
|
14
|
+
* getRuleId: async () => localStorage.getItem('ruleId') || '',
|
|
14
15
|
* environment: 'production'
|
|
15
16
|
* })
|
|
16
17
|
*
|
|
@@ -18,6 +19,7 @@ import type { SdkOptions } from './types';
|
|
|
18
19
|
* const sdk = new EcommerceBackendBffSDK({
|
|
19
20
|
* getToken: async () => wx.getStorageSync('token') || '',
|
|
20
21
|
* getUserId: async () => wx.getStorageSync('userId') || '',
|
|
22
|
+
* getRuleId: async () => wx.getStorageSync('ruleId') || '',
|
|
21
23
|
* environment: 'test'
|
|
22
24
|
* })
|
|
23
25
|
*
|
package/cjs/index.js
CHANGED
|
@@ -17,6 +17,7 @@ const service_2 = __importDefault(require("./bff/modules/demo/service"));
|
|
|
17
17
|
* const sdk = new EcommerceBackendBffSDK({
|
|
18
18
|
* getToken: async () => localStorage.getItem('token') || '',
|
|
19
19
|
* getUserId: async () => localStorage.getItem('userId') || '',
|
|
20
|
+
* getRuleId: async () => localStorage.getItem('ruleId') || '',
|
|
20
21
|
* environment: 'production'
|
|
21
22
|
* })
|
|
22
23
|
*
|
|
@@ -24,6 +25,7 @@ const service_2 = __importDefault(require("./bff/modules/demo/service"));
|
|
|
24
25
|
* const sdk = new EcommerceBackendBffSDK({
|
|
25
26
|
* getToken: async () => wx.getStorageSync('token') || '',
|
|
26
27
|
* getUserId: async () => wx.getStorageSync('userId') || '',
|
|
28
|
+
* getRuleId: async () => wx.getStorageSync('ruleId') || '',
|
|
27
29
|
* environment: 'test'
|
|
28
30
|
* })
|
|
29
31
|
*
|
package/cjs/types/index.d.ts
CHANGED
|
@@ -12,7 +12,11 @@ export interface SdkOptions {
|
|
|
12
12
|
* 可以是同步或异步的
|
|
13
13
|
*/
|
|
14
14
|
getUserId: () => string | Promise<string>;
|
|
15
|
-
|
|
15
|
+
/**
|
|
16
|
+
* 获取规则 ID 的回调函数
|
|
17
|
+
* 可以是同步或异步的
|
|
18
|
+
*/
|
|
19
|
+
getRuleId: () => string | Promise<string>;
|
|
16
20
|
/**
|
|
17
21
|
* 运行环境配置(必传)
|
|
18
22
|
* - 'production': 生产环境
|
|
@@ -38,7 +38,7 @@ export class HttpClient {
|
|
|
38
38
|
const [token, userId, ruleId] = await Promise.all([
|
|
39
39
|
Promise.resolve(this.options.getToken()).catch(() => ''),
|
|
40
40
|
Promise.resolve(this.options.getUserId()).catch(() => ''),
|
|
41
|
-
Promise.resolve(this.options.getRuleId
|
|
41
|
+
Promise.resolve(this.options.getRuleId()).catch(() => ''),
|
|
42
42
|
]);
|
|
43
43
|
// 生成唯一的请求 ID(兼容所有环境)
|
|
44
44
|
const requestId = `b-${generateUUID()}`;
|
package/esm/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ import type { SdkOptions } from './types';
|
|
|
11
11
|
* const sdk = new EcommerceBackendBffSDK({
|
|
12
12
|
* getToken: async () => localStorage.getItem('token') || '',
|
|
13
13
|
* getUserId: async () => localStorage.getItem('userId') || '',
|
|
14
|
+
* getRuleId: async () => localStorage.getItem('ruleId') || '',
|
|
14
15
|
* environment: 'production'
|
|
15
16
|
* })
|
|
16
17
|
*
|
|
@@ -18,6 +19,7 @@ import type { SdkOptions } from './types';
|
|
|
18
19
|
* const sdk = new EcommerceBackendBffSDK({
|
|
19
20
|
* getToken: async () => wx.getStorageSync('token') || '',
|
|
20
21
|
* getUserId: async () => wx.getStorageSync('userId') || '',
|
|
22
|
+
* getRuleId: async () => wx.getStorageSync('ruleId') || '',
|
|
21
23
|
* environment: 'test'
|
|
22
24
|
* })
|
|
23
25
|
*
|
package/esm/index.mjs
CHANGED
|
@@ -11,6 +11,7 @@ import DemoService from './bff/modules/demo/service.mjs';
|
|
|
11
11
|
* const sdk = new EcommerceBackendBffSDK({
|
|
12
12
|
* getToken: async () => localStorage.getItem('token') || '',
|
|
13
13
|
* getUserId: async () => localStorage.getItem('userId') || '',
|
|
14
|
+
* getRuleId: async () => localStorage.getItem('ruleId') || '',
|
|
14
15
|
* environment: 'production'
|
|
15
16
|
* })
|
|
16
17
|
*
|
|
@@ -18,6 +19,7 @@ import DemoService from './bff/modules/demo/service.mjs';
|
|
|
18
19
|
* const sdk = new EcommerceBackendBffSDK({
|
|
19
20
|
* getToken: async () => wx.getStorageSync('token') || '',
|
|
20
21
|
* getUserId: async () => wx.getStorageSync('userId') || '',
|
|
22
|
+
* getRuleId: async () => wx.getStorageSync('ruleId') || '',
|
|
21
23
|
* environment: 'test'
|
|
22
24
|
* })
|
|
23
25
|
*
|
package/esm/types/index.d.ts
CHANGED
|
@@ -12,7 +12,11 @@ export interface SdkOptions {
|
|
|
12
12
|
* 可以是同步或异步的
|
|
13
13
|
*/
|
|
14
14
|
getUserId: () => string | Promise<string>;
|
|
15
|
-
|
|
15
|
+
/**
|
|
16
|
+
* 获取规则 ID 的回调函数
|
|
17
|
+
* 可以是同步或异步的
|
|
18
|
+
*/
|
|
19
|
+
getRuleId: () => string | Promise<string>;
|
|
16
20
|
/**
|
|
17
21
|
* 运行环境配置(必传)
|
|
18
22
|
* - 'production': 生产环境
|