@yeepay/client-utils 2.0.0 → 2.0.1
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 +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/index.mjs +2 -2
- package/package.json +3 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as axios from 'axios';
|
|
2
2
|
import { AxiosResponse, InternalAxiosRequestConfig } from 'axios';
|
|
3
3
|
|
|
4
|
-
declare function getQueryObject(url
|
|
4
|
+
declare function getQueryObject(url?: string): Record<string, string>;
|
|
5
5
|
|
|
6
6
|
interface ServiceFactoryOptions {
|
|
7
7
|
baseUrl?: string;
|
|
@@ -19,7 +19,7 @@ interface ServiceFactoryCallbacks {
|
|
|
19
19
|
responseInterceptor: (response: AxiosResponse<any>) => AxiosResponse<any>;
|
|
20
20
|
}
|
|
21
21
|
type ServiceFactoryCallbacksCompatible = [ServiceFactoryCallbacks['failCallback']?, ServiceFactoryCallbacks['unauthorizedCallback']?, ServiceFactoryCallbacks['forbiddenCallback']?, ServiceFactoryCallbacks['notfoundCallback']?, ServiceFactoryCallbacks['requestInterceptor']?, ServiceFactoryCallbacks['responseInterceptor']?];
|
|
22
|
-
declare function serviceFactory(options: ServiceFactoryOptions, callbacks
|
|
22
|
+
declare function serviceFactory(options: ServiceFactoryOptions, callbacks?: ServiceFactoryCallbacks['successCallback'], ...compatibleCallbacks: ServiceFactoryCallbacksCompatible): axios.AxiosInstance;
|
|
23
23
|
|
|
24
24
|
declare function getToken(): string | undefined;
|
|
25
25
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as axios from 'axios';
|
|
2
2
|
import { AxiosResponse, InternalAxiosRequestConfig } from 'axios';
|
|
3
3
|
|
|
4
|
-
declare function getQueryObject(url
|
|
4
|
+
declare function getQueryObject(url?: string): Record<string, string>;
|
|
5
5
|
|
|
6
6
|
interface ServiceFactoryOptions {
|
|
7
7
|
baseUrl?: string;
|
|
@@ -19,7 +19,7 @@ interface ServiceFactoryCallbacks {
|
|
|
19
19
|
responseInterceptor: (response: AxiosResponse<any>) => AxiosResponse<any>;
|
|
20
20
|
}
|
|
21
21
|
type ServiceFactoryCallbacksCompatible = [ServiceFactoryCallbacks['failCallback']?, ServiceFactoryCallbacks['unauthorizedCallback']?, ServiceFactoryCallbacks['forbiddenCallback']?, ServiceFactoryCallbacks['notfoundCallback']?, ServiceFactoryCallbacks['requestInterceptor']?, ServiceFactoryCallbacks['responseInterceptor']?];
|
|
22
|
-
declare function serviceFactory(options: ServiceFactoryOptions, callbacks
|
|
22
|
+
declare function serviceFactory(options: ServiceFactoryOptions, callbacks?: ServiceFactoryCallbacks['successCallback'], ...compatibleCallbacks: ServiceFactoryCallbacksCompatible): axios.AxiosInstance;
|
|
23
23
|
|
|
24
24
|
declare function getToken(): string | undefined;
|
|
25
25
|
/**
|
package/dist/index.js
CHANGED
|
@@ -40,7 +40,7 @@ module.exports = __toCommonJS(src_exports);
|
|
|
40
40
|
|
|
41
41
|
// src/utils.ts
|
|
42
42
|
function getQueryObject(url) {
|
|
43
|
-
url = url
|
|
43
|
+
url = !url ? window.location.href : url;
|
|
44
44
|
const search = url.substring(url.lastIndexOf("?") + 1);
|
|
45
45
|
const obj = {};
|
|
46
46
|
const reg = /([^?&=]+)=([^?&=]*)/g;
|
|
@@ -91,7 +91,7 @@ function verifySuccessCode(code, customCode) {
|
|
|
91
91
|
return (0, import_utils2.toArray)(customCode).includes(code) || !code;
|
|
92
92
|
return code === 0 || code === "0" || code === "000000" || code === 200 || !code;
|
|
93
93
|
}
|
|
94
|
-
function compatibleCallback(callbacks, compatibleCallbacks) {
|
|
94
|
+
function compatibleCallback(callbacks, compatibleCallbacks = []) {
|
|
95
95
|
if (typeof callbacks === "function" || !callbacks) {
|
|
96
96
|
return {
|
|
97
97
|
successCallback: callbacks || (() => ({})),
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/utils.ts
|
|
2
2
|
function getQueryObject(url) {
|
|
3
|
-
url = url
|
|
3
|
+
url = !url ? window.location.href : url;
|
|
4
4
|
const search = url.substring(url.lastIndexOf("?") + 1);
|
|
5
5
|
const obj = {};
|
|
6
6
|
const reg = /([^?&=]+)=([^?&=]*)/g;
|
|
@@ -51,7 +51,7 @@ function verifySuccessCode(code, customCode) {
|
|
|
51
51
|
return toArray(customCode).includes(code) || !code;
|
|
52
52
|
return code === 0 || code === "0" || code === "000000" || code === 200 || !code;
|
|
53
53
|
}
|
|
54
|
-
function compatibleCallback(callbacks, compatibleCallbacks) {
|
|
54
|
+
function compatibleCallback(callbacks, compatibleCallbacks = []) {
|
|
55
55
|
if (typeof callbacks === "function" || !callbacks) {
|
|
56
56
|
return {
|
|
57
57
|
successCallback: callbacks || (() => ({})),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yeepay/client-utils",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"packageManager": "pnpm@8.12.1",
|
|
5
5
|
"description": "shared utilities for yeepay client packages",
|
|
6
6
|
"author": "Angus Yang",
|
|
@@ -22,7 +22,6 @@
|
|
|
22
22
|
],
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@imyangyong/utils": "^0.4.1",
|
|
25
|
-
"@types/js-cookie": "^3.0.6",
|
|
26
25
|
"apollo-boost": "^0.4.9",
|
|
27
26
|
"axios": "^1.6.3",
|
|
28
27
|
"graphql": "^15.6.0",
|
|
@@ -31,9 +30,11 @@
|
|
|
31
30
|
},
|
|
32
31
|
"devDependencies": {
|
|
33
32
|
"@antfu/ni": "^0.21.12",
|
|
33
|
+
"@types/js-cookie": "^3.0.6",
|
|
34
34
|
"@yeepay/eslint-config": "^1.4.0",
|
|
35
35
|
"bumpp": "^9.2.1",
|
|
36
36
|
"eslint-plugin-format": "^0.1.0",
|
|
37
|
+
"lint-staged": "^15.2.0",
|
|
37
38
|
"simple-git-hooks": "^2.9.0",
|
|
38
39
|
"tsup": "^8.0.1",
|
|
39
40
|
"typescript": "^5.3.3",
|