@readyfor/api-client-base 1.22.0-pr1283.aab9646 → 1.22.0-pr1284.0666ff1
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/_virtual/_rolldown/runtime.js +23 -0
- package/dist/apiClientConfigStore.d.ts +11 -10
- package/dist/apiClientConfigStore.js +10 -37
- package/dist/apiClientConfigStore.mjs +9 -12
- package/dist/apiError.d.ts +24 -25
- package/dist/apiError.js +68 -95
- package/dist/apiError.mjs +70 -18
- package/dist/fetcher.d.ts +8 -7
- package/dist/fetcher.js +57 -125
- package/dist/fetcher.mjs +63 -20
- package/dist/index.d.ts +10 -10
- package/dist/index.js +31 -38
- package/dist/index.mjs +10 -63
- package/dist/react/ApiClientConfigProvider.d.ts +10 -9
- package/dist/react/ApiClientConfigProvider.js +24 -41
- package/dist/react/ApiClientConfigProvider.mjs +22 -12
- package/dist/react/index.d.ts +4 -7
- package/dist/react/index.js +10 -26
- package/dist/react/index.mjs +4 -24
- package/dist/react/swr.d.ts +10 -9
- package/dist/react/swr.js +24 -37
- package/dist/react/swr.mjs +25 -5
- package/dist/react/useApiClientConfig.d.ts +5 -5
- package/dist/react/useApiClientConfig.js +18 -50
- package/dist/react/useApiClientConfig.mjs +19 -15
- package/dist/requestUrl.d.ts +3 -2
- package/dist/requestUrl.js +14 -49
- package/dist/requestUrl.mjs +13 -10
- package/dist/store.d.ts +6 -5
- package/dist/store.js +20 -43
- package/dist/store.mjs +20 -5
- package/dist/types.d.ts +5 -11
- package/dist/types.js +0 -16
- package/dist/types.mjs +1 -1
- package/dist/utils/headersInit.d.ts +3 -2
- package/dist/utils/headersInit.js +45 -49
- package/dist/utils/headersInit.mjs +46 -7
- package/dist/utils/requestInit.d.ts +10 -3
- package/dist/utils/requestInit.js +14 -31
- package/dist/utils/requestInit.mjs +15 -7
- package/dist/zod.d.ts +4 -3
- package/dist/zod.js +6 -30
- package/dist/zod.mjs +6 -7
- package/package.json +2 -19
- package/dist/chunk-3SEO7S3Q.mjs +0 -23
- package/dist/chunk-5JS6U5IM.mjs +0 -37
- package/dist/chunk-DH33ZDBG.mjs +0 -19
- package/dist/chunk-FNLUAQWC.mjs +0 -80
- package/dist/chunk-GD4RTKUU.mjs +0 -22
- package/dist/chunk-JCZWXJBU.mjs +0 -10
- package/dist/chunk-NOC6G3HZ.mjs +0 -21
- package/dist/chunk-NYICHGY2.mjs +0 -30
- package/dist/chunk-OVR3ZT2S.mjs +0 -118
- package/dist/chunk-QXFPBYPL.mjs +0 -25
- package/dist/chunk-TZUKIYFN.mjs +0 -14
- package/dist/chunk-WBQAMGXK.mjs +0 -0
package/dist/chunk-OVR3ZT2S.mjs
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
HTTPError,
|
|
3
|
-
errorStatusCode
|
|
4
|
-
} from "./chunk-FNLUAQWC.mjs";
|
|
5
|
-
import {
|
|
6
|
-
store
|
|
7
|
-
} from "./chunk-NOC6G3HZ.mjs";
|
|
8
|
-
import {
|
|
9
|
-
mergeRequestInit
|
|
10
|
-
} from "./chunk-TZUKIYFN.mjs";
|
|
11
|
-
|
|
12
|
-
// src/fetcher.ts
|
|
13
|
-
var defaultRequestInit = {
|
|
14
|
-
credentials: "include"
|
|
15
|
-
};
|
|
16
|
-
var createJsonFetcher = (schema, customRequestInit = {}) => (input, requestInit = {}) => fetch(
|
|
17
|
-
input,
|
|
18
|
-
mergeRequestInit(
|
|
19
|
-
defaultRequestInit,
|
|
20
|
-
mergeRequestInit(customRequestInit, requestInit)
|
|
21
|
-
)
|
|
22
|
-
).then(async (res) => {
|
|
23
|
-
const text = await res.text();
|
|
24
|
-
const body = text ? JSON.parse(text) : {};
|
|
25
|
-
if (res.ok) return body;
|
|
26
|
-
const code = Object.values(errorStatusCode).includes(res.status) ? res.status : 999;
|
|
27
|
-
const error = new HTTPError(code, body);
|
|
28
|
-
throw error;
|
|
29
|
-
}).catch((error) => {
|
|
30
|
-
store.getState().onError?.(error);
|
|
31
|
-
throw error;
|
|
32
|
-
}).then((parsedResponse) => {
|
|
33
|
-
const result = schema.safeParse(parsedResponse);
|
|
34
|
-
const config = store.getState();
|
|
35
|
-
if (result.success) {
|
|
36
|
-
return result.data;
|
|
37
|
-
}
|
|
38
|
-
if (config.showsSchemaParseError) {
|
|
39
|
-
console.error(result.error);
|
|
40
|
-
}
|
|
41
|
-
if (config.forceDeserializeResponse) {
|
|
42
|
-
config.onFailedDeserializeResponse(input, result.error);
|
|
43
|
-
return parsedResponse;
|
|
44
|
-
}
|
|
45
|
-
throw result.error;
|
|
46
|
-
});
|
|
47
|
-
var createTextFetcher = (customRequestInit = {}) => (input, requestInit = {}) => fetch(
|
|
48
|
-
input,
|
|
49
|
-
mergeRequestInit(
|
|
50
|
-
defaultRequestInit,
|
|
51
|
-
mergeRequestInit(customRequestInit, requestInit)
|
|
52
|
-
)
|
|
53
|
-
).then(async (res) => {
|
|
54
|
-
const body = await res.text();
|
|
55
|
-
if (res.ok) return body;
|
|
56
|
-
const code = Object.values(errorStatusCode).includes(res.status) ? res.status : 999;
|
|
57
|
-
const error = new HTTPError(code, body);
|
|
58
|
-
throw error;
|
|
59
|
-
}).catch((error) => {
|
|
60
|
-
store.getState().onError?.(error);
|
|
61
|
-
throw error;
|
|
62
|
-
});
|
|
63
|
-
var createBlobFetcher = (customRequestInit = {}) => (input, requestInit = {}) => fetch(
|
|
64
|
-
input,
|
|
65
|
-
mergeRequestInit(
|
|
66
|
-
defaultRequestInit,
|
|
67
|
-
mergeRequestInit(customRequestInit, requestInit)
|
|
68
|
-
)
|
|
69
|
-
).then(async (res) => {
|
|
70
|
-
const body = await res.blob();
|
|
71
|
-
if (res.ok) return { body, headers: res.headers };
|
|
72
|
-
const code = Object.values(errorStatusCode).includes(res.status) ? res.status : 999;
|
|
73
|
-
const error = new HTTPError(code, body);
|
|
74
|
-
throw error;
|
|
75
|
-
}).catch((error) => {
|
|
76
|
-
store.getState().onError?.(error);
|
|
77
|
-
throw error;
|
|
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
|
-
});
|
|
95
|
-
var createVoidFetcher = (customRequestInit = {}) => (input, requestInit = {}) => fetch(
|
|
96
|
-
input,
|
|
97
|
-
mergeRequestInit(
|
|
98
|
-
defaultRequestInit,
|
|
99
|
-
mergeRequestInit(customRequestInit, requestInit)
|
|
100
|
-
)
|
|
101
|
-
).then(async (res) => {
|
|
102
|
-
if (res.ok) return;
|
|
103
|
-
const code = Object.values(errorStatusCode).includes(res.status) ? res.status : 999;
|
|
104
|
-
const body = await res.text();
|
|
105
|
-
const error = new HTTPError(code, body);
|
|
106
|
-
throw error;
|
|
107
|
-
}).catch((error) => {
|
|
108
|
-
store.getState().onError?.(error);
|
|
109
|
-
throw error;
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
export {
|
|
113
|
-
createJsonFetcher,
|
|
114
|
-
createTextFetcher,
|
|
115
|
-
createBlobFetcher,
|
|
116
|
-
createFileOrBlobFetcher,
|
|
117
|
-
createVoidFetcher
|
|
118
|
-
};
|
package/dist/chunk-QXFPBYPL.mjs
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createSwrConfig
|
|
3
|
-
} from "./chunk-DH33ZDBG.mjs";
|
|
4
|
-
import {
|
|
5
|
-
store
|
|
6
|
-
} from "./chunk-NOC6G3HZ.mjs";
|
|
7
|
-
|
|
8
|
-
// src/react/ApiClientConfigProvider.tsx
|
|
9
|
-
import { createContext, useContext, useEffect } from "react";
|
|
10
|
-
import { SWRConfig } from "swr";
|
|
11
|
-
import { jsx } from "react/jsx-runtime";
|
|
12
|
-
var ApiClientConfigContext = createContext(store);
|
|
13
|
-
var ApiClientConfigProvider = (props) => {
|
|
14
|
-
const { swr, ...config } = props.config;
|
|
15
|
-
useEffect(() => {
|
|
16
|
-
store.setState(() => config);
|
|
17
|
-
}, [config]);
|
|
18
|
-
return /* @__PURE__ */ jsx(ApiClientConfigContext.Provider, { value: store, children: /* @__PURE__ */ jsx(SWRConfig, { value: createSwrConfig(swr), children: props.children }) });
|
|
19
|
-
};
|
|
20
|
-
var useApiClientConfigContext = () => useContext(ApiClientConfigContext) || store;
|
|
21
|
-
|
|
22
|
-
export {
|
|
23
|
-
ApiClientConfigProvider,
|
|
24
|
-
useApiClientConfigContext
|
|
25
|
-
};
|
package/dist/chunk-TZUKIYFN.mjs
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
mergeHeadersInit
|
|
3
|
-
} from "./chunk-NYICHGY2.mjs";
|
|
4
|
-
|
|
5
|
-
// src/utils/requestInit.ts
|
|
6
|
-
var mergeRequestInit = ({ headers: baseHeaders, ...base }, { headers: overrideHeaders, ...override }) => ({
|
|
7
|
-
...base,
|
|
8
|
-
...override,
|
|
9
|
-
headers: baseHeaders === void 0 ? overrideHeaders : overrideHeaders === void 0 ? baseHeaders : mergeHeadersInit(baseHeaders, overrideHeaders)
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
export {
|
|
13
|
-
mergeRequestInit
|
|
14
|
-
};
|
package/dist/chunk-WBQAMGXK.mjs
DELETED
|
File without changes
|