@yeepay/client-utils 2.0.2 → 2.1.0

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/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { AxiosResponse, InternalAxiosRequestConfig } from 'axios';
1
+ import { AxiosInstance, AxiosResponse, InternalAxiosRequestConfig } from 'axios';
2
2
 
3
3
  declare function getQueryObject(url?: string): Record<string, string>;
4
4
 
@@ -7,6 +7,7 @@ interface ServiceFactoryOptions {
7
7
  timeout?: number;
8
8
  headers?: Record<string, string>;
9
9
  code?: string | number;
10
+ debug?: boolean;
10
11
  }
11
12
  interface ServiceFactoryCallbacks {
12
13
  successCallback?: (response: AxiosResponse<any>) => any;
@@ -18,8 +19,8 @@ interface ServiceFactoryCallbacks {
18
19
  responseInterceptor?: (response: AxiosResponse<any>) => AxiosResponse<any>;
19
20
  }
20
21
  type ServiceFactoryCallbacksCompatible = [ServiceFactoryCallbacks['successCallback']?, ServiceFactoryCallbacks['failCallback']?, ServiceFactoryCallbacks['unauthorizedCallback']?, ServiceFactoryCallbacks['forbiddenCallback']?, ServiceFactoryCallbacks['notfoundCallback']?, ServiceFactoryCallbacks['requestInterceptor']?, ServiceFactoryCallbacks['responseInterceptor']?];
21
- declare function serviceFactory(options: ServiceFactoryOptions, callbacks: ServiceFactoryCallbacks): any;
22
- declare function serviceFactory(options: ServiceFactoryOptions, ...callbacks: ServiceFactoryCallbacksCompatible): any;
22
+ declare function serviceFactory(options: ServiceFactoryOptions, callbacks: ServiceFactoryCallbacks): AxiosInstance;
23
+ declare function serviceFactory(options: ServiceFactoryOptions, ...callbacks: ServiceFactoryCallbacksCompatible): AxiosInstance;
23
24
 
24
25
  declare function getToken(): string | undefined;
25
26
  /**
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { AxiosResponse, InternalAxiosRequestConfig } from 'axios';
1
+ import { AxiosInstance, AxiosResponse, InternalAxiosRequestConfig } from 'axios';
2
2
 
3
3
  declare function getQueryObject(url?: string): Record<string, string>;
4
4
 
@@ -7,6 +7,7 @@ interface ServiceFactoryOptions {
7
7
  timeout?: number;
8
8
  headers?: Record<string, string>;
9
9
  code?: string | number;
10
+ debug?: boolean;
10
11
  }
11
12
  interface ServiceFactoryCallbacks {
12
13
  successCallback?: (response: AxiosResponse<any>) => any;
@@ -18,8 +19,8 @@ interface ServiceFactoryCallbacks {
18
19
  responseInterceptor?: (response: AxiosResponse<any>) => AxiosResponse<any>;
19
20
  }
20
21
  type ServiceFactoryCallbacksCompatible = [ServiceFactoryCallbacks['successCallback']?, ServiceFactoryCallbacks['failCallback']?, ServiceFactoryCallbacks['unauthorizedCallback']?, ServiceFactoryCallbacks['forbiddenCallback']?, ServiceFactoryCallbacks['notfoundCallback']?, ServiceFactoryCallbacks['requestInterceptor']?, ServiceFactoryCallbacks['responseInterceptor']?];
21
- declare function serviceFactory(options: ServiceFactoryOptions, callbacks: ServiceFactoryCallbacks): any;
22
- declare function serviceFactory(options: ServiceFactoryOptions, ...callbacks: ServiceFactoryCallbacksCompatible): any;
22
+ declare function serviceFactory(options: ServiceFactoryOptions, callbacks: ServiceFactoryCallbacks): AxiosInstance;
23
+ declare function serviceFactory(options: ServiceFactoryOptions, ...callbacks: ServiceFactoryCallbacksCompatible): AxiosInstance;
23
24
 
24
25
  declare function getToken(): string | undefined;
25
26
  /**
package/dist/index.js CHANGED
@@ -112,7 +112,8 @@ function serviceFactory(options, ...callbacks) {
112
112
  timeout = 12e5,
113
113
  // 默认 2 分钟
114
114
  headers,
115
- code
115
+ code,
116
+ debug
116
117
  } = options;
117
118
  const {
118
119
  successCallback = (_response) => ({}),
@@ -141,10 +142,12 @@ function serviceFactory(options, ...callbacks) {
141
142
  config.headers.Authorization = getToken();
142
143
  const { method, url = "" } = config;
143
144
  if (method === "get") {
144
- if (url.includes("?"))
145
- config.url = `${url}&_t=${(/* @__PURE__ */ new Date()).getTime()}`;
146
- else
147
- config.url = `${url}?_t=${(/* @__PURE__ */ new Date()).getTime()}`;
145
+ if (!debug) {
146
+ if (url.includes("?"))
147
+ config.url = `${url}&_t=${(/* @__PURE__ */ new Date()).getTime()}`;
148
+ else
149
+ config.url = `${url}?_t=${(/* @__PURE__ */ new Date()).getTime()}`;
150
+ }
148
151
  }
149
152
  return config;
150
153
  },
package/dist/index.mjs CHANGED
@@ -72,7 +72,8 @@ function serviceFactory(options, ...callbacks) {
72
72
  timeout = 12e5,
73
73
  // 默认 2 分钟
74
74
  headers,
75
- code
75
+ code,
76
+ debug
76
77
  } = options;
77
78
  const {
78
79
  successCallback = (_response) => ({}),
@@ -101,10 +102,12 @@ function serviceFactory(options, ...callbacks) {
101
102
  config.headers.Authorization = getToken();
102
103
  const { method, url = "" } = config;
103
104
  if (method === "get") {
104
- if (url.includes("?"))
105
- config.url = `${url}&_t=${(/* @__PURE__ */ new Date()).getTime()}`;
106
- else
107
- config.url = `${url}?_t=${(/* @__PURE__ */ new Date()).getTime()}`;
105
+ if (!debug) {
106
+ if (url.includes("?"))
107
+ config.url = `${url}&_t=${(/* @__PURE__ */ new Date()).getTime()}`;
108
+ else
109
+ config.url = `${url}?_t=${(/* @__PURE__ */ new Date()).getTime()}`;
110
+ }
108
111
  }
109
112
  return config;
110
113
  },
package/package.json CHANGED
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "name": "@yeepay/client-utils",
3
- "version": "2.0.2",
4
- "packageManager": "pnpm@8.15.6",
3
+ "version": "2.1.0",
5
4
  "description": "shared utilities for yeepay client packages",
6
5
  "author": "Angus Yang",
7
6
  "homepage": "http://gitlab.yeepay.com/ued/client-utils#readme",
@@ -21,24 +20,22 @@
21
20
  "dist"
22
21
  ],
23
22
  "dependencies": {
24
- "@imyangyong/utils": "^0.6.0",
25
- "apollo-boost": "^0.4.9",
26
- "axios": "^1.6.8",
27
- "graphql": "^16.8.1",
28
- "js-cookie": "^3.0.5",
29
- "unfetch": "^5.0.0"
23
+ "@imyangyong/utils": "^0.8.0",
24
+ "axios": "^1.7.0",
25
+ "js-cookie": "^3.0.5"
30
26
  },
31
27
  "devDependencies": {
32
28
  "@antfu/ni": "^0.21.12",
33
29
  "@types/js-cookie": "^3.0.6",
34
- "@yeepay/eslint-config": "^1.5.0",
35
- "bumpp": "^9.4.0",
36
- "eslint-plugin-format": "^0.1.0",
30
+ "@yeepay/eslint-config": "^1.7.0",
31
+ "bumpp": "^9.4.1",
32
+ "eslint": "^9.3.0",
33
+ "eslint-plugin-format": "^0.1.1",
37
34
  "lint-staged": "^15.2.2",
38
35
  "simple-git-hooks": "^2.11.1",
39
36
  "tsup": "^8.0.2",
40
- "typescript": "^5.4.3",
41
- "vitest": "^1.4.0"
37
+ "typescript": "^5.4.5",
38
+ "vitest": "^1.6.0"
42
39
  },
43
40
  "simple-git-hooks": {
44
41
  "pre-commit": "pnpm lint-staged"