@readyfor/api-client-base 0.276.0 → 0.277.0-pr1081.12d8724
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/{chunk-4HID36YE.mjs → chunk-3CIIRYKM.mjs} +17 -0
- package/dist/fetcher.d.ts +6 -1
- package/dist/fetcher.js +18 -0
- package/dist/fetcher.mjs +3 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +3 -1
- package/package.json +1 -1
|
@@ -76,6 +76,22 @@ var createBlobFetcher = (customRequestInit = {}) => (input, requestInit = {}) =>
|
|
|
76
76
|
store.getState().onError?.(error);
|
|
77
77
|
throw error;
|
|
78
78
|
});
|
|
79
|
+
var createFileOrBlobFetcher = (customRequestInit = {}) => (input, requestInit = {}) => fetch(
|
|
80
|
+
input,
|
|
81
|
+
mergeRequestInit(
|
|
82
|
+
defaultRequestInit,
|
|
83
|
+
mergeRequestInit(customRequestInit, requestInit)
|
|
84
|
+
)
|
|
85
|
+
).then(async (res) => {
|
|
86
|
+
const body = await res.blob();
|
|
87
|
+
if (res.ok) return { body, headers: res.headers };
|
|
88
|
+
const code = Object.values(errorStatusCode).includes(res.status) ? res.status : 999;
|
|
89
|
+
const error = new HTTPError(code, body);
|
|
90
|
+
throw error;
|
|
91
|
+
}).catch((error) => {
|
|
92
|
+
store.getState().onError?.(error);
|
|
93
|
+
throw error;
|
|
94
|
+
});
|
|
79
95
|
var createVoidFetcher = (customRequestInit = {}) => (input, requestInit = {}) => fetch(
|
|
80
96
|
input,
|
|
81
97
|
mergeRequestInit(
|
|
@@ -97,5 +113,6 @@ export {
|
|
|
97
113
|
createJsonFetcher,
|
|
98
114
|
createTextFetcher,
|
|
99
115
|
createBlobFetcher,
|
|
116
|
+
createFileOrBlobFetcher,
|
|
100
117
|
createVoidFetcher
|
|
101
118
|
};
|
package/dist/fetcher.d.ts
CHANGED
|
@@ -7,6 +7,11 @@ type BlobFetcherResponse = {
|
|
|
7
7
|
headers: Headers;
|
|
8
8
|
};
|
|
9
9
|
declare const createBlobFetcher: (customRequestInit?: RequestInit) => (input: RequestInfo, requestInit?: RequestInit) => Promise<BlobFetcherResponse>;
|
|
10
|
+
type FileOrBlobFetcherResponse = {
|
|
11
|
+
body: File | Blob;
|
|
12
|
+
headers: Headers;
|
|
13
|
+
};
|
|
14
|
+
declare const createFileOrBlobFetcher: (customRequestInit?: RequestInit) => (input: RequestInfo, requestInit?: RequestInit) => Promise<FileOrBlobFetcherResponse>;
|
|
10
15
|
declare const createVoidFetcher: (customRequestInit?: RequestInit) => (input: RequestInfo, requestInit?: RequestInit) => Promise<void>;
|
|
11
16
|
|
|
12
|
-
export { type BlobFetcherResponse, createBlobFetcher, createJsonFetcher, createTextFetcher, createVoidFetcher };
|
|
17
|
+
export { type BlobFetcherResponse, type FileOrBlobFetcherResponse, createBlobFetcher, createFileOrBlobFetcher, createJsonFetcher, createTextFetcher, createVoidFetcher };
|
package/dist/fetcher.js
CHANGED
|
@@ -19,6 +19,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
var fetcher_exports = {};
|
|
20
20
|
__export(fetcher_exports, {
|
|
21
21
|
createBlobFetcher: () => createBlobFetcher,
|
|
22
|
+
createFileOrBlobFetcher: () => createFileOrBlobFetcher,
|
|
22
23
|
createJsonFetcher: () => createJsonFetcher,
|
|
23
24
|
createTextFetcher: () => createTextFetcher,
|
|
24
25
|
createVoidFetcher: () => createVoidFetcher
|
|
@@ -93,6 +94,22 @@ const createBlobFetcher = (customRequestInit = {}) => (input, requestInit = {})
|
|
|
93
94
|
import_apiClientConfigStore.store.getState().onError?.(error);
|
|
94
95
|
throw error;
|
|
95
96
|
});
|
|
97
|
+
const createFileOrBlobFetcher = (customRequestInit = {}) => (input, requestInit = {}) => fetch(
|
|
98
|
+
input,
|
|
99
|
+
(0, import_requestInit.mergeRequestInit)(
|
|
100
|
+
defaultRequestInit,
|
|
101
|
+
(0, import_requestInit.mergeRequestInit)(customRequestInit, requestInit)
|
|
102
|
+
)
|
|
103
|
+
).then(async (res) => {
|
|
104
|
+
const body = await res.blob();
|
|
105
|
+
if (res.ok) return { body, headers: res.headers };
|
|
106
|
+
const code = Object.values(import_apiError.errorStatusCode).includes(res.status) ? res.status : 999;
|
|
107
|
+
const error = new import_apiError.HTTPError(code, body);
|
|
108
|
+
throw error;
|
|
109
|
+
}).catch((error) => {
|
|
110
|
+
import_apiClientConfigStore.store.getState().onError?.(error);
|
|
111
|
+
throw error;
|
|
112
|
+
});
|
|
96
113
|
const createVoidFetcher = (customRequestInit = {}) => (input, requestInit = {}) => fetch(
|
|
97
114
|
input,
|
|
98
115
|
(0, import_requestInit.mergeRequestInit)(
|
|
@@ -112,6 +129,7 @@ const createVoidFetcher = (customRequestInit = {}) => (input, requestInit = {})
|
|
|
112
129
|
// Annotate the CommonJS export names for ESM import in node:
|
|
113
130
|
0 && (module.exports = {
|
|
114
131
|
createBlobFetcher,
|
|
132
|
+
createFileOrBlobFetcher,
|
|
115
133
|
createJsonFetcher,
|
|
116
134
|
createTextFetcher,
|
|
117
135
|
createVoidFetcher
|
package/dist/fetcher.mjs
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createBlobFetcher,
|
|
3
|
+
createFileOrBlobFetcher,
|
|
3
4
|
createJsonFetcher,
|
|
4
5
|
createTextFetcher,
|
|
5
6
|
createVoidFetcher
|
|
6
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-3CIIRYKM.mjs";
|
|
7
8
|
import "./chunk-PY35XWDS.mjs";
|
|
8
9
|
import "./chunk-F77IR5JD.mjs";
|
|
9
10
|
import "./chunk-2ORFVC4H.mjs";
|
|
@@ -12,6 +13,7 @@ import "./chunk-3SEO7S3Q.mjs";
|
|
|
12
13
|
import "./chunk-JCZWXJBU.mjs";
|
|
13
14
|
export {
|
|
14
15
|
createBlobFetcher,
|
|
16
|
+
createFileOrBlobFetcher,
|
|
15
17
|
createJsonFetcher,
|
|
16
18
|
createTextFetcher,
|
|
17
19
|
createVoidFetcher
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { Config, RequestConfig, buildRequestInitWithDefaultConfig, setApiClientConfig, store } from './apiClientConfigStore.js';
|
|
2
2
|
export { ErrorStatusCode, HTTPError, errorStatusCode, errorTitle, getErrorStatus } from './apiError.js';
|
|
3
|
-
export { BlobFetcherResponse, createBlobFetcher, createJsonFetcher, createTextFetcher, createVoidFetcher } from './fetcher.js';
|
|
3
|
+
export { BlobFetcherResponse, FileOrBlobFetcherResponse, createBlobFetcher, createFileOrBlobFetcher, createJsonFetcher, createTextFetcher, createVoidFetcher } from './fetcher.js';
|
|
4
4
|
export { __internal__requestUrl } from './requestUrl.js';
|
|
5
5
|
export { Store, createStore } from './store.js';
|
|
6
6
|
export { ForceDig, QueryPropsFor } from './types.js';
|
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createBlobFetcher,
|
|
3
|
+
createFileOrBlobFetcher,
|
|
3
4
|
createJsonFetcher,
|
|
4
5
|
createTextFetcher,
|
|
5
6
|
createVoidFetcher
|
|
6
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-3CIIRYKM.mjs";
|
|
7
8
|
import {
|
|
8
9
|
HTTPError,
|
|
9
10
|
errorStatusCode,
|
|
@@ -35,6 +36,7 @@ export {
|
|
|
35
36
|
__internal__requestUrl,
|
|
36
37
|
buildRequestInitWithDefaultConfig,
|
|
37
38
|
createBlobFetcher,
|
|
39
|
+
createFileOrBlobFetcher,
|
|
38
40
|
createJsonFetcher,
|
|
39
41
|
createStore,
|
|
40
42
|
createTextFetcher,
|