@be-link/pos-cli-nodejs 0.0.61 → 0.0.63

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.
@@ -1,3 +1,4 @@
1
1
  export default class PosError extends Error {
2
- constructor(message: string);
2
+ code: number;
3
+ constructor(message: string, code?: number);
3
4
  }
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  class PosError extends Error {
4
- constructor(message) {
4
+ constructor(message, code = 500) {
5
5
  super(message);
6
+ this.code = code;
6
7
  this.name = 'PosError';
7
8
  }
8
9
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@be-link/pos-cli-nodejs",
3
- "version": "0.0.61",
3
+ "version": "0.0.63",
4
4
  "description": "正向订单服务Nodejs客户端",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -25,6 +25,7 @@
25
25
  "devDependencies": {
26
26
  "@types/jest": "29.5.6",
27
27
  "@types/node": "20.8.9",
28
+ "@types/uuid": "^9.0.6",
28
29
  "jest": "29.7.0",
29
30
  "ts-jest": "29.1.1",
30
31
  "typedoc": "0.25.2",
@@ -33,6 +34,7 @@
33
34
  },
34
35
  "dependencies": {
35
36
  "axios": "0.27.2",
37
+ "uuid": "^9.0.1",
36
38
  "vitality-meta": "latest"
37
39
  }
38
40
  }
package/pos/http.js CHANGED
@@ -6,9 +6,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.callApi = void 0;
7
7
  const axios_1 = __importDefault(require("axios"));
8
8
  const PosError_1 = __importDefault(require("../errors/PosError"));
9
+ const uuid_1 = require("uuid");
9
10
  async function callApi(url, ...request) {
10
11
  try {
11
- const response = await axios_1.default.post(url, request[0]);
12
+ const requestId = (0, uuid_1.v4)();
13
+ console.info(`准备发起POS请求[${requestId}]: ${url}, 参数: ${JSON.stringify(request)}`);
14
+ const response = await axios_1.default.post(url, request[0], {
15
+ headers: {
16
+ 'X-Request-Id': requestId
17
+ }
18
+ });
12
19
  const responseData = response.data;
13
20
  return responseData.data;
14
21
  }
@@ -17,7 +24,7 @@ async function callApi(url, ...request) {
17
24
  if (axiosError.response) {
18
25
  const response = axiosError.response;
19
26
  const data = response.data;
20
- throw new PosError_1.default(`POS API 异常: ${response.status} ${data.message}`);
27
+ throw new PosError_1.default(data?.message || 'Pos Error', response.status);
21
28
  }
22
29
  console.error(`POS 未知异常: ${axiosError.message}`, error.stack);
23
30
  throw error;
package/types.d.ts CHANGED
@@ -322,6 +322,8 @@ export interface IPositiveSkuInfo {
322
322
  categoryOne: string;
323
323
  /** 二级类目 */
324
324
  categoryTwo: string;
325
+ /** 是否有班车 */
326
+ hasShuttleBus: number;
325
327
  }
326
328
  export interface IWxPaymentInfo {
327
329
  appId: string;