@confighub/rtk-query 0.6.2 → 0.6.3
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 -1
- package/dist/index.cjs +3 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import * as _reduxjs_toolkit_query from '@reduxjs/toolkit/query';
|
|
2
|
+
import { FetchBaseQueryError } from '@reduxjs/toolkit/query';
|
|
1
3
|
import * as _reduxjs_toolkit from '@reduxjs/toolkit';
|
|
2
4
|
import * as _reduxjs_toolkit_query_react from '@reduxjs/toolkit/query/react';
|
|
3
|
-
import * as _reduxjs_toolkit_query from '@reduxjs/toolkit/query';
|
|
4
5
|
|
|
5
6
|
interface ConfigHubConfig {
|
|
6
7
|
/**
|
|
@@ -17,6 +18,12 @@ interface ConfigHubConfig {
|
|
|
17
18
|
getToken?: () => string | undefined | Promise<string | undefined>;
|
|
18
19
|
/** Called on a 401 so the app can refresh or re-login. The query is not retried. */
|
|
19
20
|
onUnauthorized?: () => void | Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Called on a 403 with the error, whose `data.message` says why (for example an
|
|
23
|
+
* account pending approval), so the app can send the user somewhere that explains
|
|
24
|
+
* it. The query still fails with the error.
|
|
25
|
+
*/
|
|
26
|
+
onForbidden?: (error: FetchBaseQueryError) => void | Promise<void>;
|
|
20
27
|
}
|
|
21
28
|
/**
|
|
22
29
|
* Configure the ConfigHub API before dispatching any query — call once at store setup.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import * as _reduxjs_toolkit_query from '@reduxjs/toolkit/query';
|
|
2
|
+
import { FetchBaseQueryError } from '@reduxjs/toolkit/query';
|
|
1
3
|
import * as _reduxjs_toolkit from '@reduxjs/toolkit';
|
|
2
4
|
import * as _reduxjs_toolkit_query_react from '@reduxjs/toolkit/query/react';
|
|
3
|
-
import * as _reduxjs_toolkit_query from '@reduxjs/toolkit/query';
|
|
4
5
|
|
|
5
6
|
interface ConfigHubConfig {
|
|
6
7
|
/**
|
|
@@ -17,6 +18,12 @@ interface ConfigHubConfig {
|
|
|
17
18
|
getToken?: () => string | undefined | Promise<string | undefined>;
|
|
18
19
|
/** Called on a 401 so the app can refresh or re-login. The query is not retried. */
|
|
19
20
|
onUnauthorized?: () => void | Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Called on a 403 with the error, whose `data.message` says why (for example an
|
|
23
|
+
* account pending approval), so the app can send the user somewhere that explains
|
|
24
|
+
* it. The query still fails with the error.
|
|
25
|
+
*/
|
|
26
|
+
onForbidden?: (error: FetchBaseQueryError) => void | Promise<void>;
|
|
20
27
|
}
|
|
21
28
|
/**
|
|
22
29
|
* Configure the ConfigHub API before dispatching any query — call once at store setup.
|
package/dist/index.js
CHANGED
|
@@ -45,6 +45,9 @@ var baseQuery = async (args, api, extraOptions) => {
|
|
|
45
45
|
if (result.error && result.error.status === 401) {
|
|
46
46
|
await config.onUnauthorized?.();
|
|
47
47
|
}
|
|
48
|
+
if (result.error && result.error.status === 403) {
|
|
49
|
+
await config.onForbidden?.(result.error);
|
|
50
|
+
}
|
|
48
51
|
return result;
|
|
49
52
|
};
|
|
50
53
|
var confighubApi = createApi({
|