@readyfor/api-client-base 0.205.0 → 0.206.0-pr972.a0fd0c3
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/apiClientConfigStore.d.mts +2 -0
- package/dist/apiClientConfigStore.d.ts +2 -0
- package/dist/{chunk-GD73YYGW.mjs → chunk-HBZIYFCM.mjs} +9 -3
- package/dist/fetcher.js +9 -3
- package/dist/fetcher.mjs +1 -1
- package/dist/index.js +9 -3
- package/dist/index.mjs +1 -1
- package/dist/react/ApiClientConfigProvider.d.mts +1 -0
- package/dist/react/ApiClientConfigProvider.d.ts +1 -0
- package/dist/react/index.d.mts +1 -0
- package/dist/react/index.d.ts +1 -0
- package/dist/react/useApiClientConfig.d.mts +1 -0
- package/dist/react/useApiClientConfig.d.ts +1 -0
- package/package.json +7 -8
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Store } from './store.mjs';
|
|
2
|
+
import { HTTPError } from './apiError.mjs';
|
|
2
3
|
|
|
3
4
|
type DeserializeResponseConfig = {
|
|
4
5
|
forceDeserializeResponse?: false;
|
|
@@ -12,6 +13,7 @@ type LoggingConfig = {
|
|
|
12
13
|
type RequestConfig = {
|
|
13
14
|
hostName?: string | ((path: string) => string);
|
|
14
15
|
defaultRequestInit?: RequestInit;
|
|
16
|
+
onError?: (error: HTTPError) => void;
|
|
15
17
|
};
|
|
16
18
|
type Config = RequestConfig & DeserializeResponseConfig & LoggingConfig;
|
|
17
19
|
declare const store: Store<Config>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Store } from './store.js';
|
|
2
|
+
import { HTTPError } from './apiError.js';
|
|
2
3
|
|
|
3
4
|
type DeserializeResponseConfig = {
|
|
4
5
|
forceDeserializeResponse?: false;
|
|
@@ -12,6 +13,7 @@ type LoggingConfig = {
|
|
|
12
13
|
type RequestConfig = {
|
|
13
14
|
hostName?: string | ((path: string) => string);
|
|
14
15
|
defaultRequestInit?: RequestInit;
|
|
16
|
+
onError?: (error: HTTPError) => void;
|
|
15
17
|
};
|
|
16
18
|
type Config = RequestConfig & DeserializeResponseConfig & LoggingConfig;
|
|
17
19
|
declare const store: Store<Config>;
|
|
@@ -39,7 +39,9 @@ var createTextFetcher = (customRequestInit = {}) => (input, requestInit = {}) =>
|
|
|
39
39
|
const body = await res.text();
|
|
40
40
|
if (res.ok) return body;
|
|
41
41
|
const code = Object.values(errorStatusCode).includes(res.status) ? res.status : 999;
|
|
42
|
-
|
|
42
|
+
const error = new HTTPError(code, body);
|
|
43
|
+
store.getState().onError?.(error);
|
|
44
|
+
throw error;
|
|
43
45
|
});
|
|
44
46
|
var createBlobFetcher = (customRequestInit = {}) => (input, requestInit = {}) => fetch(input, {
|
|
45
47
|
...defaultRequestInit,
|
|
@@ -54,7 +56,9 @@ var createBlobFetcher = (customRequestInit = {}) => (input, requestInit = {}) =>
|
|
|
54
56
|
const body = await res.blob();
|
|
55
57
|
if (res.ok) return { body, headers: res.headers };
|
|
56
58
|
const code = Object.values(errorStatusCode).includes(res.status) ? res.status : 999;
|
|
57
|
-
|
|
59
|
+
const error = new HTTPError(code, body);
|
|
60
|
+
store.getState().onError?.(error);
|
|
61
|
+
throw error;
|
|
58
62
|
});
|
|
59
63
|
var createVoidFetcher = (customRequestInit = {}) => (input, requestInit = {}) => fetch(input, {
|
|
60
64
|
...defaultRequestInit,
|
|
@@ -69,7 +73,9 @@ var createVoidFetcher = (customRequestInit = {}) => (input, requestInit = {}) =>
|
|
|
69
73
|
if (res.ok) return;
|
|
70
74
|
const code = Object.values(errorStatusCode).includes(res.status) ? res.status : 999;
|
|
71
75
|
const body = await res.text();
|
|
72
|
-
|
|
76
|
+
const error = new HTTPError(code, body);
|
|
77
|
+
store.getState().onError?.(error);
|
|
78
|
+
throw error;
|
|
73
79
|
});
|
|
74
80
|
|
|
75
81
|
export {
|
package/dist/fetcher.js
CHANGED
|
@@ -130,7 +130,9 @@ var createTextFetcher = (customRequestInit = {}) => (input, requestInit = {}) =>
|
|
|
130
130
|
const body = await res.text();
|
|
131
131
|
if (res.ok) return body;
|
|
132
132
|
const code = Object.values(errorStatusCode).includes(res.status) ? res.status : 999;
|
|
133
|
-
|
|
133
|
+
const error = new HTTPError(code, body);
|
|
134
|
+
store.getState().onError?.(error);
|
|
135
|
+
throw error;
|
|
134
136
|
});
|
|
135
137
|
var createBlobFetcher = (customRequestInit = {}) => (input, requestInit = {}) => fetch(input, {
|
|
136
138
|
...defaultRequestInit,
|
|
@@ -145,7 +147,9 @@ var createBlobFetcher = (customRequestInit = {}) => (input, requestInit = {}) =>
|
|
|
145
147
|
const body = await res.blob();
|
|
146
148
|
if (res.ok) return { body, headers: res.headers };
|
|
147
149
|
const code = Object.values(errorStatusCode).includes(res.status) ? res.status : 999;
|
|
148
|
-
|
|
150
|
+
const error = new HTTPError(code, body);
|
|
151
|
+
store.getState().onError?.(error);
|
|
152
|
+
throw error;
|
|
149
153
|
});
|
|
150
154
|
var createVoidFetcher = (customRequestInit = {}) => (input, requestInit = {}) => fetch(input, {
|
|
151
155
|
...defaultRequestInit,
|
|
@@ -160,7 +164,9 @@ var createVoidFetcher = (customRequestInit = {}) => (input, requestInit = {}) =>
|
|
|
160
164
|
if (res.ok) return;
|
|
161
165
|
const code = Object.values(errorStatusCode).includes(res.status) ? res.status : 999;
|
|
162
166
|
const body = await res.text();
|
|
163
|
-
|
|
167
|
+
const error = new HTTPError(code, body);
|
|
168
|
+
store.getState().onError?.(error);
|
|
169
|
+
throw error;
|
|
164
170
|
});
|
|
165
171
|
// Annotate the CommonJS export names for ESM import in node:
|
|
166
172
|
0 && (module.exports = {
|
package/dist/fetcher.mjs
CHANGED
package/dist/index.js
CHANGED
|
@@ -167,7 +167,9 @@ var createTextFetcher = (customRequestInit = {}) => (input, requestInit = {}) =>
|
|
|
167
167
|
const body = await res.text();
|
|
168
168
|
if (res.ok) return body;
|
|
169
169
|
const code = Object.values(errorStatusCode).includes(res.status) ? res.status : 999;
|
|
170
|
-
|
|
170
|
+
const error = new HTTPError(code, body);
|
|
171
|
+
store.getState().onError?.(error);
|
|
172
|
+
throw error;
|
|
171
173
|
});
|
|
172
174
|
var createBlobFetcher = (customRequestInit = {}) => (input, requestInit = {}) => fetch(input, {
|
|
173
175
|
...defaultRequestInit,
|
|
@@ -182,7 +184,9 @@ var createBlobFetcher = (customRequestInit = {}) => (input, requestInit = {}) =>
|
|
|
182
184
|
const body = await res.blob();
|
|
183
185
|
if (res.ok) return { body, headers: res.headers };
|
|
184
186
|
const code = Object.values(errorStatusCode).includes(res.status) ? res.status : 999;
|
|
185
|
-
|
|
187
|
+
const error = new HTTPError(code, body);
|
|
188
|
+
store.getState().onError?.(error);
|
|
189
|
+
throw error;
|
|
186
190
|
});
|
|
187
191
|
var createVoidFetcher = (customRequestInit = {}) => (input, requestInit = {}) => fetch(input, {
|
|
188
192
|
...defaultRequestInit,
|
|
@@ -197,7 +201,9 @@ var createVoidFetcher = (customRequestInit = {}) => (input, requestInit = {}) =>
|
|
|
197
201
|
if (res.ok) return;
|
|
198
202
|
const code = Object.values(errorStatusCode).includes(res.status) ? res.status : 999;
|
|
199
203
|
const body = await res.text();
|
|
200
|
-
|
|
204
|
+
const error = new HTTPError(code, body);
|
|
205
|
+
store.getState().onError?.(error);
|
|
206
|
+
throw error;
|
|
201
207
|
});
|
|
202
208
|
|
|
203
209
|
// src/requestUrl.ts
|
package/dist/index.mjs
CHANGED
package/dist/react/index.d.mts
CHANGED
package/dist/react/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@readyfor/api-client-base",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.206.0-pr972.a0fd0c3",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -20,17 +20,14 @@
|
|
|
20
20
|
"require": "./dist/react/index.js"
|
|
21
21
|
}
|
|
22
22
|
},
|
|
23
|
-
"scripts": {
|
|
24
|
-
"build": "tsup"
|
|
25
|
-
},
|
|
26
23
|
"dependencies": {
|
|
27
24
|
"qs": "6.14.0",
|
|
28
25
|
"zod": "^3.24.1"
|
|
29
26
|
},
|
|
30
27
|
"devDependencies": {
|
|
31
28
|
"@types/qs": "6.9.18",
|
|
32
|
-
"@types/react": "
|
|
33
|
-
"@types/use-sync-external-store": "
|
|
29
|
+
"@types/react": "catalog:react19",
|
|
30
|
+
"@types/use-sync-external-store": "catalog:use-sync-external-store",
|
|
34
31
|
"react": "catalog:react19",
|
|
35
32
|
"swr": "catalog:",
|
|
36
33
|
"use-sync-external-store": "catalog:use-sync-external-store"
|
|
@@ -63,5 +60,7 @@
|
|
|
63
60
|
"src"
|
|
64
61
|
]
|
|
65
62
|
},
|
|
66
|
-
"
|
|
67
|
-
|
|
63
|
+
"scripts": {
|
|
64
|
+
"build": "tsup"
|
|
65
|
+
}
|
|
66
|
+
}
|