@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.
@@ -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
- throw new HTTPError(code, body);
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
- throw new HTTPError(code, body);
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
- throw new HTTPError(code, body);
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
- throw new HTTPError(code, body);
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
- throw new HTTPError(code, body);
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
- throw new HTTPError(code, body);
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
@@ -3,7 +3,7 @@ import {
3
3
  createJsonFetcher,
4
4
  createTextFetcher,
5
5
  createVoidFetcher
6
- } from "./chunk-GD73YYGW.mjs";
6
+ } from "./chunk-HBZIYFCM.mjs";
7
7
  import "./chunk-PY35XWDS.mjs";
8
8
  import "./chunk-JCZWXJBU.mjs";
9
9
  import "./chunk-472P3XVV.mjs";
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
- throw new HTTPError(code, body);
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
- throw new HTTPError(code, body);
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
- throw new HTTPError(code, body);
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
@@ -3,7 +3,7 @@ import {
3
3
  createJsonFetcher,
4
4
  createTextFetcher,
5
5
  createVoidFetcher
6
- } from "./chunk-GD73YYGW.mjs";
6
+ } from "./chunk-HBZIYFCM.mjs";
7
7
  import {
8
8
  HTTPError,
9
9
  errorStatusCode,
@@ -2,6 +2,7 @@ import { FC, ReactNode } from 'react';
2
2
  import { Config } from '../apiClientConfigStore.mjs';
3
3
  import { Store } from '../store.mjs';
4
4
  import { SWRConfiguration } from 'swr';
5
+ import '../apiError.mjs';
5
6
 
6
7
  type Configuration = Config & {
7
8
  swr?: SWRConfiguration;
@@ -2,6 +2,7 @@ import { FC, ReactNode } from 'react';
2
2
  import { Config } from '../apiClientConfigStore.js';
3
3
  import { Store } from '../store.js';
4
4
  import { SWRConfiguration } from 'swr';
5
+ import '../apiError.js';
5
6
 
6
7
  type Configuration = Config & {
7
8
  swr?: SWRConfiguration;
@@ -4,4 +4,5 @@ export { useApiClientConfig, useApiClientConfigWithSelector, useRequestInit } fr
4
4
  import 'react';
5
5
  import '../apiClientConfigStore.mjs';
6
6
  import '../store.mjs';
7
+ import '../apiError.mjs';
7
8
  import 'swr';
@@ -4,4 +4,5 @@ export { useApiClientConfig, useApiClientConfigWithSelector, useRequestInit } fr
4
4
  import 'react';
5
5
  import '../apiClientConfigStore.js';
6
6
  import '../store.js';
7
+ import '../apiError.js';
7
8
  import 'swr';
@@ -1,5 +1,6 @@
1
1
  import { Config } from '../apiClientConfigStore.mjs';
2
2
  import '../store.mjs';
3
+ import '../apiError.mjs';
3
4
 
4
5
  declare const useApiClientConfig: () => Config;
5
6
  declare const useApiClientConfigWithSelector: <T>(selector: (state: Config) => T) => T;
@@ -1,5 +1,6 @@
1
1
  import { Config } from '../apiClientConfigStore.js';
2
2
  import '../store.js';
3
+ import '../apiError.js';
3
4
 
4
5
  declare const useApiClientConfig: () => Config;
5
6
  declare const useApiClientConfigWithSelector: <T>(selector: (state: Config) => T) => T;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@readyfor/api-client-base",
3
- "version": "0.205.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": "19.1.0",
33
- "@types/use-sync-external-store": "1.5.0",
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
- "gitHead": "1d3c5b146865e1107e3f85af7ca61e7344da0425"
67
- }
63
+ "scripts": {
64
+ "build": "tsup"
65
+ }
66
+ }