@yeepay/client-utils 3.0.3 → 3.0.4
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.ts +2 -1
- package/dist/index.js +6 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ interface ServiceFactoryCallbacks {
|
|
|
19
19
|
responseInterceptor?: (response: AxiosResponse<any>) => AxiosResponse<any>;
|
|
20
20
|
}
|
|
21
21
|
type ServiceFactoryCallbacksCompatible = [ServiceFactoryCallbacks['successCallback']?, ServiceFactoryCallbacks['failCallback']?, ServiceFactoryCallbacks['unauthorizedCallback']?, ServiceFactoryCallbacks['forbiddenCallback']?, ServiceFactoryCallbacks['notfoundCallback']?, ServiceFactoryCallbacks['requestInterceptor']?, ServiceFactoryCallbacks['responseInterceptor']?];
|
|
22
|
+
declare function verifySuccessCode<T extends string | number>(code: T, customCode: T): boolean;
|
|
22
23
|
declare function serviceFactory(options: ServiceFactoryOptions, callbacks: ServiceFactoryCallbacks): AxiosInstance;
|
|
23
24
|
declare function serviceFactory(options: ServiceFactoryOptions, ...callbacks: ServiceFactoryCallbacksCompatible): AxiosInstance;
|
|
24
25
|
//#endregion
|
|
@@ -33,4 +34,4 @@ declare function removeToken(): void;
|
|
|
33
34
|
//#region src/utils.d.ts
|
|
34
35
|
declare function getQueryObject(url?: string): Record<string, string>;
|
|
35
36
|
//#endregion
|
|
36
|
-
export { getQueryObject, getToken, removeToken, serviceFactory, setTokenFromUrl };
|
|
37
|
+
export { getQueryObject, getToken, removeToken, serviceFactory, setTokenFromUrl, verifySuccessCode };
|
package/dist/index.js
CHANGED
|
@@ -17,8 +17,12 @@ function longestCommonPrefix(strs) {
|
|
|
17
17
|
}
|
|
18
18
|
return prefix;
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function isLocalhost() {
|
|
21
|
+
return window.location.hostname === "localhost";
|
|
22
|
+
}
|
|
23
|
+
async function setupMockAdapter(axiosInstance, mockModules) {
|
|
21
24
|
if (!mockModules) return;
|
|
25
|
+
if (!isLocalhost()) return;
|
|
22
26
|
const mock = new AxiosMockAdapter(axiosInstance);
|
|
23
27
|
const paths = Object.keys(mockModules);
|
|
24
28
|
const longestPrefix = longestCommonPrefix(paths);
|
|
@@ -203,4 +207,4 @@ function serviceFactory(options, ...callbacks) {
|
|
|
203
207
|
}
|
|
204
208
|
|
|
205
209
|
//#endregion
|
|
206
|
-
export { getQueryObject, getToken, removeToken, serviceFactory, setTokenFromUrl };
|
|
210
|
+
export { getQueryObject, getToken, removeToken, serviceFactory, setTokenFromUrl, verifySuccessCode };
|
package/package.json
CHANGED