@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/fetcher.js
CHANGED
|
@@ -1,136 +1,68 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var fetcher_exports = {};
|
|
20
|
-
__export(fetcher_exports, {
|
|
21
|
-
createBlobFetcher: () => createBlobFetcher,
|
|
22
|
-
createFileOrBlobFetcher: () => createFileOrBlobFetcher,
|
|
23
|
-
createJsonFetcher: () => createJsonFetcher,
|
|
24
|
-
createTextFetcher: () => createTextFetcher,
|
|
25
|
-
createVoidFetcher: () => createVoidFetcher
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(fetcher_exports);
|
|
28
|
-
var import_apiError = require("./apiError");
|
|
29
|
-
var import_apiClientConfigStore = require("./apiClientConfigStore");
|
|
30
|
-
var import_requestInit = require("./utils/requestInit");
|
|
31
|
-
const defaultRequestInit = {
|
|
32
|
-
credentials: "include"
|
|
33
|
-
};
|
|
34
|
-
const createJsonFetcher = (schema, customRequestInit = {}) => (input, requestInit = {}) => fetch(
|
|
35
|
-
input,
|
|
36
|
-
(0, import_requestInit.mergeRequestInit)(
|
|
37
|
-
defaultRequestInit,
|
|
38
|
-
(0, import_requestInit.mergeRequestInit)(customRequestInit, requestInit)
|
|
39
|
-
)
|
|
40
|
-
).then(async (res) => {
|
|
41
|
-
const text = await res.text();
|
|
42
|
-
const body = text ? JSON.parse(text) : {};
|
|
43
|
-
if (res.ok) return body;
|
|
44
|
-
const code = Object.values(import_apiError.errorStatusCode).includes(res.status) ? res.status : 999;
|
|
45
|
-
const error = new import_apiError.HTTPError(code, body);
|
|
46
|
-
throw error;
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_utils_requestInit = require("./utils/requestInit.js");
|
|
3
|
+
const require_apiClientConfigStore = require("./apiClientConfigStore.js");
|
|
4
|
+
const require_apiError = require("./apiError.js");
|
|
5
|
+
//#region src/fetcher.ts
|
|
6
|
+
const defaultRequestInit = { credentials: "include" };
|
|
7
|
+
const createJsonFetcher = (schema, customRequestInit = {}) => (input, requestInit = {}) => fetch(input, require_utils_requestInit.mergeRequestInit(defaultRequestInit, require_utils_requestInit.mergeRequestInit(customRequestInit, requestInit))).then(async (res) => {
|
|
8
|
+
const text = await res.text();
|
|
9
|
+
const body = text ? JSON.parse(text) : {};
|
|
10
|
+
if (res.ok) return body;
|
|
11
|
+
throw new require_apiError.HTTPError(Object.values(require_apiError.errorStatusCode).includes(res.status) ? res.status : 999, body);
|
|
47
12
|
}).catch((error) => {
|
|
48
|
-
|
|
49
|
-
|
|
13
|
+
require_apiClientConfigStore.store.getState().onError?.(error);
|
|
14
|
+
throw error;
|
|
50
15
|
}).then((parsedResponse) => {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
config.onFailedDeserializeResponse(input, result.error);
|
|
61
|
-
return parsedResponse;
|
|
62
|
-
}
|
|
63
|
-
throw result.error;
|
|
16
|
+
const result = schema.safeParse(parsedResponse);
|
|
17
|
+
const config = require_apiClientConfigStore.store.getState();
|
|
18
|
+
if (result.success) return result.data;
|
|
19
|
+
if (config.showsSchemaParseError) console.error(result.error);
|
|
20
|
+
if (config.forceDeserializeResponse) {
|
|
21
|
+
config.onFailedDeserializeResponse(input, result.error);
|
|
22
|
+
return parsedResponse;
|
|
23
|
+
}
|
|
24
|
+
throw result.error;
|
|
64
25
|
});
|
|
65
|
-
const createTextFetcher = (customRequestInit = {}) => (input, requestInit = {}) => fetch(
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
(0, import_requestInit.mergeRequestInit)(customRequestInit, requestInit)
|
|
70
|
-
)
|
|
71
|
-
).then(async (res) => {
|
|
72
|
-
const body = await res.text();
|
|
73
|
-
if (res.ok) return body;
|
|
74
|
-
const code = Object.values(import_apiError.errorStatusCode).includes(res.status) ? res.status : 999;
|
|
75
|
-
const error = new import_apiError.HTTPError(code, body);
|
|
76
|
-
throw error;
|
|
26
|
+
const createTextFetcher = (customRequestInit = {}) => (input, requestInit = {}) => fetch(input, require_utils_requestInit.mergeRequestInit(defaultRequestInit, require_utils_requestInit.mergeRequestInit(customRequestInit, requestInit))).then(async (res) => {
|
|
27
|
+
const body = await res.text();
|
|
28
|
+
if (res.ok) return body;
|
|
29
|
+
throw new require_apiError.HTTPError(Object.values(require_apiError.errorStatusCode).includes(res.status) ? res.status : 999, body);
|
|
77
30
|
}).catch((error) => {
|
|
78
|
-
|
|
79
|
-
|
|
31
|
+
require_apiClientConfigStore.store.getState().onError?.(error);
|
|
32
|
+
throw error;
|
|
80
33
|
});
|
|
81
|
-
const createBlobFetcher = (customRequestInit = {}) => (input, requestInit = {}) => fetch(
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
).
|
|
88
|
-
const body = await res.blob();
|
|
89
|
-
if (res.ok) return { body, headers: res.headers };
|
|
90
|
-
const code = Object.values(import_apiError.errorStatusCode).includes(res.status) ? res.status : 999;
|
|
91
|
-
const error = new import_apiError.HTTPError(code, body);
|
|
92
|
-
throw error;
|
|
34
|
+
const createBlobFetcher = (customRequestInit = {}) => (input, requestInit = {}) => fetch(input, require_utils_requestInit.mergeRequestInit(defaultRequestInit, require_utils_requestInit.mergeRequestInit(customRequestInit, requestInit))).then(async (res) => {
|
|
35
|
+
const body = await res.blob();
|
|
36
|
+
if (res.ok) return {
|
|
37
|
+
body,
|
|
38
|
+
headers: res.headers
|
|
39
|
+
};
|
|
40
|
+
throw new require_apiError.HTTPError(Object.values(require_apiError.errorStatusCode).includes(res.status) ? res.status : 999, body);
|
|
93
41
|
}).catch((error) => {
|
|
94
|
-
|
|
95
|
-
|
|
42
|
+
require_apiClientConfigStore.store.getState().onError?.(error);
|
|
43
|
+
throw error;
|
|
96
44
|
});
|
|
97
|
-
const createFileOrBlobFetcher = (customRequestInit = {}) => (input, requestInit = {}) => fetch(
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
).
|
|
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;
|
|
45
|
+
const createFileOrBlobFetcher = (customRequestInit = {}) => (input, requestInit = {}) => fetch(input, require_utils_requestInit.mergeRequestInit(defaultRequestInit, require_utils_requestInit.mergeRequestInit(customRequestInit, requestInit))).then(async (res) => {
|
|
46
|
+
const body = await res.blob();
|
|
47
|
+
if (res.ok) return {
|
|
48
|
+
body,
|
|
49
|
+
headers: res.headers
|
|
50
|
+
};
|
|
51
|
+
throw new require_apiError.HTTPError(Object.values(require_apiError.errorStatusCode).includes(res.status) ? res.status : 999, body);
|
|
109
52
|
}).catch((error) => {
|
|
110
|
-
|
|
111
|
-
|
|
53
|
+
require_apiClientConfigStore.store.getState().onError?.(error);
|
|
54
|
+
throw error;
|
|
112
55
|
});
|
|
113
|
-
const createVoidFetcher = (customRequestInit = {}) => (input, requestInit = {}) => fetch(
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
defaultRequestInit,
|
|
117
|
-
(0, import_requestInit.mergeRequestInit)(customRequestInit, requestInit)
|
|
118
|
-
)
|
|
119
|
-
).then(async (res) => {
|
|
120
|
-
if (res.ok) return;
|
|
121
|
-
const code = Object.values(import_apiError.errorStatusCode).includes(res.status) ? res.status : 999;
|
|
122
|
-
const body = await res.text();
|
|
123
|
-
const error = new import_apiError.HTTPError(code, body);
|
|
124
|
-
throw error;
|
|
56
|
+
const createVoidFetcher = (customRequestInit = {}) => (input, requestInit = {}) => fetch(input, require_utils_requestInit.mergeRequestInit(defaultRequestInit, require_utils_requestInit.mergeRequestInit(customRequestInit, requestInit))).then(async (res) => {
|
|
57
|
+
if (res.ok) return;
|
|
58
|
+
throw new require_apiError.HTTPError(Object.values(require_apiError.errorStatusCode).includes(res.status) ? res.status : 999, await res.text());
|
|
125
59
|
}).catch((error) => {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
});
|
|
129
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
130
|
-
0 && (module.exports = {
|
|
131
|
-
createBlobFetcher,
|
|
132
|
-
createFileOrBlobFetcher,
|
|
133
|
-
createJsonFetcher,
|
|
134
|
-
createTextFetcher,
|
|
135
|
-
createVoidFetcher
|
|
60
|
+
require_apiClientConfigStore.store.getState().onError?.(error);
|
|
61
|
+
throw error;
|
|
136
62
|
});
|
|
63
|
+
//#endregion
|
|
64
|
+
exports.createBlobFetcher = createBlobFetcher;
|
|
65
|
+
exports.createFileOrBlobFetcher = createFileOrBlobFetcher;
|
|
66
|
+
exports.createJsonFetcher = createJsonFetcher;
|
|
67
|
+
exports.createTextFetcher = createTextFetcher;
|
|
68
|
+
exports.createVoidFetcher = createVoidFetcher;
|
package/dist/fetcher.mjs
CHANGED
|
@@ -1,20 +1,63 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
import { mergeRequestInit } from "./utils/requestInit.mjs";
|
|
2
|
+
import { store } from "./apiClientConfigStore.mjs";
|
|
3
|
+
import { HTTPError, errorStatusCode } from "./apiError.mjs";
|
|
4
|
+
//#region src/fetcher.ts
|
|
5
|
+
const defaultRequestInit = { credentials: "include" };
|
|
6
|
+
const createJsonFetcher = (schema, customRequestInit = {}) => (input, requestInit = {}) => fetch(input, mergeRequestInit(defaultRequestInit, mergeRequestInit(customRequestInit, requestInit))).then(async (res) => {
|
|
7
|
+
const text = await res.text();
|
|
8
|
+
const body = text ? JSON.parse(text) : {};
|
|
9
|
+
if (res.ok) return body;
|
|
10
|
+
throw new HTTPError(Object.values(errorStatusCode).includes(res.status) ? res.status : 999, body);
|
|
11
|
+
}).catch((error) => {
|
|
12
|
+
store.getState().onError?.(error);
|
|
13
|
+
throw error;
|
|
14
|
+
}).then((parsedResponse) => {
|
|
15
|
+
const result = schema.safeParse(parsedResponse);
|
|
16
|
+
const config = store.getState();
|
|
17
|
+
if (result.success) return result.data;
|
|
18
|
+
if (config.showsSchemaParseError) console.error(result.error);
|
|
19
|
+
if (config.forceDeserializeResponse) {
|
|
20
|
+
config.onFailedDeserializeResponse(input, result.error);
|
|
21
|
+
return parsedResponse;
|
|
22
|
+
}
|
|
23
|
+
throw result.error;
|
|
24
|
+
});
|
|
25
|
+
const createTextFetcher = (customRequestInit = {}) => (input, requestInit = {}) => fetch(input, mergeRequestInit(defaultRequestInit, mergeRequestInit(customRequestInit, requestInit))).then(async (res) => {
|
|
26
|
+
const body = await res.text();
|
|
27
|
+
if (res.ok) return body;
|
|
28
|
+
throw new HTTPError(Object.values(errorStatusCode).includes(res.status) ? res.status : 999, body);
|
|
29
|
+
}).catch((error) => {
|
|
30
|
+
store.getState().onError?.(error);
|
|
31
|
+
throw error;
|
|
32
|
+
});
|
|
33
|
+
const createBlobFetcher = (customRequestInit = {}) => (input, requestInit = {}) => fetch(input, mergeRequestInit(defaultRequestInit, mergeRequestInit(customRequestInit, requestInit))).then(async (res) => {
|
|
34
|
+
const body = await res.blob();
|
|
35
|
+
if (res.ok) return {
|
|
36
|
+
body,
|
|
37
|
+
headers: res.headers
|
|
38
|
+
};
|
|
39
|
+
throw new HTTPError(Object.values(errorStatusCode).includes(res.status) ? res.status : 999, body);
|
|
40
|
+
}).catch((error) => {
|
|
41
|
+
store.getState().onError?.(error);
|
|
42
|
+
throw error;
|
|
43
|
+
});
|
|
44
|
+
const createFileOrBlobFetcher = (customRequestInit = {}) => (input, requestInit = {}) => fetch(input, mergeRequestInit(defaultRequestInit, mergeRequestInit(customRequestInit, requestInit))).then(async (res) => {
|
|
45
|
+
const body = await res.blob();
|
|
46
|
+
if (res.ok) return {
|
|
47
|
+
body,
|
|
48
|
+
headers: res.headers
|
|
49
|
+
};
|
|
50
|
+
throw new HTTPError(Object.values(errorStatusCode).includes(res.status) ? res.status : 999, body);
|
|
51
|
+
}).catch((error) => {
|
|
52
|
+
store.getState().onError?.(error);
|
|
53
|
+
throw error;
|
|
54
|
+
});
|
|
55
|
+
const createVoidFetcher = (customRequestInit = {}) => (input, requestInit = {}) => fetch(input, mergeRequestInit(defaultRequestInit, mergeRequestInit(customRequestInit, requestInit))).then(async (res) => {
|
|
56
|
+
if (res.ok) return;
|
|
57
|
+
throw new HTTPError(Object.values(errorStatusCode).includes(res.status) ? res.status : 999, await res.text());
|
|
58
|
+
}).catch((error) => {
|
|
59
|
+
store.getState().onError?.(error);
|
|
60
|
+
throw error;
|
|
61
|
+
});
|
|
62
|
+
//#endregion
|
|
63
|
+
export { createBlobFetcher, createFileOrBlobFetcher, createJsonFetcher, createTextFetcher, createVoidFetcher };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { Store, createStore } from "./store.js";
|
|
2
|
+
import { Config, RequestConfig, buildRequestInitWithDefaultConfig, setApiClientConfig, store } from "./apiClientConfigStore.js";
|
|
3
|
+
import { ErrorStatusCode, HTTPError, errorStatusCode, errorTitle, getErrorStatus, getHttpErrorBody, getHttpErrorBodyReason, isHttpErrorWithStatus } from "./apiError.js";
|
|
4
|
+
import { BlobFetcherResponse, FileOrBlobFetcherResponse, createBlobFetcher, createFileOrBlobFetcher, createJsonFetcher, createTextFetcher, createVoidFetcher } from "./fetcher.js";
|
|
5
|
+
import { __internal__requestUrl } from "./requestUrl.js";
|
|
6
|
+
import { ForceDig, QueryPropsFor } from "./types.js";
|
|
7
|
+
import { isZodError, schemaForType } from "./zod.js";
|
|
8
|
+
import { mergeRequestInit } from "./utils/requestInit.js";
|
|
9
|
+
import { mergeHeadersInit, toHeadersInit } from "./utils/headersInit.js";
|
|
10
|
+
export { BlobFetcherResponse, Config, ErrorStatusCode, FileOrBlobFetcherResponse, ForceDig, HTTPError, QueryPropsFor, RequestConfig, Store, __internal__requestUrl, buildRequestInitWithDefaultConfig, createBlobFetcher, createFileOrBlobFetcher, createJsonFetcher, createStore, createTextFetcher, createVoidFetcher, errorStatusCode, errorTitle, getErrorStatus, getHttpErrorBody, getHttpErrorBodyReason, isHttpErrorWithStatus, isZodError, mergeHeadersInit, mergeRequestInit, schemaForType, setApiClientConfig, store, toHeadersInit };
|
package/dist/index.js
CHANGED
|
@@ -1,38 +1,31 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
...require("./requestUrl"),
|
|
33
|
-
...require("./store"),
|
|
34
|
-
...require("./types"),
|
|
35
|
-
...require("./zod"),
|
|
36
|
-
...require("./utils/requestInit"),
|
|
37
|
-
...require("./utils/headersInit")
|
|
38
|
-
});
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_store = require("./store.js");
|
|
3
|
+
const require_utils_headersInit = require("./utils/headersInit.js");
|
|
4
|
+
const require_utils_requestInit = require("./utils/requestInit.js");
|
|
5
|
+
const require_apiClientConfigStore = require("./apiClientConfigStore.js");
|
|
6
|
+
const require_zod = require("./zod.js");
|
|
7
|
+
const require_apiError = require("./apiError.js");
|
|
8
|
+
const require_fetcher = require("./fetcher.js");
|
|
9
|
+
const require_requestUrl = require("./requestUrl.js");
|
|
10
|
+
exports.HTTPError = require_apiError.HTTPError;
|
|
11
|
+
exports.__internal__requestUrl = require_requestUrl.__internal__requestUrl;
|
|
12
|
+
exports.buildRequestInitWithDefaultConfig = require_apiClientConfigStore.buildRequestInitWithDefaultConfig;
|
|
13
|
+
exports.createBlobFetcher = require_fetcher.createBlobFetcher;
|
|
14
|
+
exports.createFileOrBlobFetcher = require_fetcher.createFileOrBlobFetcher;
|
|
15
|
+
exports.createJsonFetcher = require_fetcher.createJsonFetcher;
|
|
16
|
+
exports.createStore = require_store.createStore;
|
|
17
|
+
exports.createTextFetcher = require_fetcher.createTextFetcher;
|
|
18
|
+
exports.createVoidFetcher = require_fetcher.createVoidFetcher;
|
|
19
|
+
exports.errorStatusCode = require_apiError.errorStatusCode;
|
|
20
|
+
exports.errorTitle = require_apiError.errorTitle;
|
|
21
|
+
exports.getErrorStatus = require_apiError.getErrorStatus;
|
|
22
|
+
exports.getHttpErrorBody = require_apiError.getHttpErrorBody;
|
|
23
|
+
exports.getHttpErrorBodyReason = require_apiError.getHttpErrorBodyReason;
|
|
24
|
+
exports.isHttpErrorWithStatus = require_apiError.isHttpErrorWithStatus;
|
|
25
|
+
exports.isZodError = require_zod.isZodError;
|
|
26
|
+
exports.mergeHeadersInit = require_utils_headersInit.mergeHeadersInit;
|
|
27
|
+
exports.mergeRequestInit = require_utils_requestInit.mergeRequestInit;
|
|
28
|
+
exports.schemaForType = require_zod.schemaForType;
|
|
29
|
+
exports.setApiClientConfig = require_apiClientConfigStore.setApiClientConfig;
|
|
30
|
+
exports.store = require_apiClientConfigStore.store;
|
|
31
|
+
exports.toHeadersInit = require_utils_headersInit.toHeadersInit;
|
package/dist/index.mjs
CHANGED
|
@@ -1,63 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from "./
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
errorTitle,
|
|
12
|
-
getErrorStatus,
|
|
13
|
-
getHttpErrorBody,
|
|
14
|
-
getHttpErrorBodyReason,
|
|
15
|
-
isHttpErrorWithStatus
|
|
16
|
-
} from "./chunk-FNLUAQWC.mjs";
|
|
17
|
-
import {
|
|
18
|
-
__internal__requestUrl
|
|
19
|
-
} from "./chunk-GD4RTKUU.mjs";
|
|
20
|
-
import {
|
|
21
|
-
buildRequestInitWithDefaultConfig,
|
|
22
|
-
setApiClientConfig,
|
|
23
|
-
store
|
|
24
|
-
} from "./chunk-NOC6G3HZ.mjs";
|
|
25
|
-
import {
|
|
26
|
-
mergeRequestInit
|
|
27
|
-
} from "./chunk-TZUKIYFN.mjs";
|
|
28
|
-
import {
|
|
29
|
-
mergeHeadersInit,
|
|
30
|
-
toHeadersInit
|
|
31
|
-
} from "./chunk-NYICHGY2.mjs";
|
|
32
|
-
import {
|
|
33
|
-
createStore
|
|
34
|
-
} from "./chunk-3SEO7S3Q.mjs";
|
|
35
|
-
import "./chunk-WBQAMGXK.mjs";
|
|
36
|
-
import {
|
|
37
|
-
isZodError,
|
|
38
|
-
schemaForType
|
|
39
|
-
} from "./chunk-JCZWXJBU.mjs";
|
|
40
|
-
export {
|
|
41
|
-
HTTPError,
|
|
42
|
-
__internal__requestUrl,
|
|
43
|
-
buildRequestInitWithDefaultConfig,
|
|
44
|
-
createBlobFetcher,
|
|
45
|
-
createFileOrBlobFetcher,
|
|
46
|
-
createJsonFetcher,
|
|
47
|
-
createStore,
|
|
48
|
-
createTextFetcher,
|
|
49
|
-
createVoidFetcher,
|
|
50
|
-
errorStatusCode,
|
|
51
|
-
errorTitle,
|
|
52
|
-
getErrorStatus,
|
|
53
|
-
getHttpErrorBody,
|
|
54
|
-
getHttpErrorBodyReason,
|
|
55
|
-
isHttpErrorWithStatus,
|
|
56
|
-
isZodError,
|
|
57
|
-
mergeHeadersInit,
|
|
58
|
-
mergeRequestInit,
|
|
59
|
-
schemaForType,
|
|
60
|
-
setApiClientConfig,
|
|
61
|
-
store,
|
|
62
|
-
toHeadersInit
|
|
63
|
-
};
|
|
1
|
+
import { createStore } from "./store.mjs";
|
|
2
|
+
import { mergeHeadersInit, toHeadersInit } from "./utils/headersInit.mjs";
|
|
3
|
+
import { mergeRequestInit } from "./utils/requestInit.mjs";
|
|
4
|
+
import { buildRequestInitWithDefaultConfig, setApiClientConfig, store } from "./apiClientConfigStore.mjs";
|
|
5
|
+
import { isZodError, schemaForType } from "./zod.mjs";
|
|
6
|
+
import { HTTPError, errorStatusCode, errorTitle, getErrorStatus, getHttpErrorBody, getHttpErrorBodyReason, isHttpErrorWithStatus } from "./apiError.mjs";
|
|
7
|
+
import { createBlobFetcher, createFileOrBlobFetcher, createJsonFetcher, createTextFetcher, createVoidFetcher } from "./fetcher.mjs";
|
|
8
|
+
import { __internal__requestUrl } from "./requestUrl.mjs";
|
|
9
|
+
import "./types.mjs";
|
|
10
|
+
export { HTTPError, __internal__requestUrl, buildRequestInitWithDefaultConfig, createBlobFetcher, createFileOrBlobFetcher, createJsonFetcher, createStore, createTextFetcher, createVoidFetcher, errorStatusCode, errorTitle, getErrorStatus, getHttpErrorBody, getHttpErrorBodyReason, isHttpErrorWithStatus, isZodError, mergeHeadersInit, mergeRequestInit, schemaForType, setApiClientConfig, store, toHeadersInit };
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Config } from
|
|
3
|
-
import {
|
|
4
|
-
import { SWRConfiguration } from
|
|
1
|
+
import { Store } from "../store.js";
|
|
2
|
+
import { Config } from "../apiClientConfigStore.js";
|
|
3
|
+
import { FC, ReactNode } from "react";
|
|
4
|
+
import { SWRConfiguration } from "swr";
|
|
5
5
|
|
|
6
|
+
//#region src/react/ApiClientConfigProvider.d.ts
|
|
6
7
|
type Configuration = Config & {
|
|
7
|
-
|
|
8
|
+
swr?: SWRConfiguration;
|
|
8
9
|
};
|
|
9
10
|
type Props = {
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
config: Configuration;
|
|
12
|
+
children: ReactNode;
|
|
12
13
|
};
|
|
13
14
|
declare const ApiClientConfigProvider: FC<Props>;
|
|
14
15
|
declare const useApiClientConfigContext: () => Store<Config>;
|
|
15
|
-
|
|
16
|
-
export { ApiClientConfigProvider, useApiClientConfigContext };
|
|
16
|
+
//#endregion
|
|
17
|
+
export { ApiClientConfigProvider, useApiClientConfigContext };
|
|
@@ -1,43 +1,26 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var ApiClientConfigProvider_exports = {};
|
|
20
|
-
__export(ApiClientConfigProvider_exports, {
|
|
21
|
-
ApiClientConfigProvider: () => ApiClientConfigProvider,
|
|
22
|
-
useApiClientConfigContext: () => useApiClientConfigContext
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(ApiClientConfigProvider_exports);
|
|
25
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
26
|
-
var import_react = require("react");
|
|
27
|
-
var import_apiClientConfigStore = require("../apiClientConfigStore");
|
|
28
|
-
var import_swr = require("swr");
|
|
29
|
-
var import_swr2 = require("./swr");
|
|
30
|
-
const ApiClientConfigContext = (0, import_react.createContext)(import_apiClientConfigStore.store);
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
require("../_virtual/_rolldown/runtime.js");
|
|
3
|
+
const require_apiClientConfigStore = require("../apiClientConfigStore.js");
|
|
4
|
+
const require_react_swr = require("./swr.js");
|
|
5
|
+
let react = require("react");
|
|
6
|
+
let swr = require("swr");
|
|
7
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
8
|
+
//#region src/react/ApiClientConfigProvider.tsx
|
|
9
|
+
const ApiClientConfigContext = (0, react.createContext)(require_apiClientConfigStore.store);
|
|
31
10
|
const ApiClientConfigProvider = (props) => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
11
|
+
const { swr: swr$1, ...config } = props.config;
|
|
12
|
+
(0, react.useEffect)(() => {
|
|
13
|
+
require_apiClientConfigStore.store.setState(() => config);
|
|
14
|
+
}, [config]);
|
|
15
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ApiClientConfigContext.Provider, {
|
|
16
|
+
value: require_apiClientConfigStore.store,
|
|
17
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(swr.SWRConfig, {
|
|
18
|
+
value: require_react_swr.createSwrConfig(swr$1),
|
|
19
|
+
children: props.children
|
|
20
|
+
})
|
|
21
|
+
});
|
|
37
22
|
};
|
|
38
|
-
const useApiClientConfigContext = () => (0,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
useApiClientConfigContext
|
|
43
|
-
});
|
|
23
|
+
const useApiClientConfigContext = () => (0, react.useContext)(ApiClientConfigContext) || require_apiClientConfigStore.store;
|
|
24
|
+
//#endregion
|
|
25
|
+
exports.ApiClientConfigProvider = ApiClientConfigProvider;
|
|
26
|
+
exports.useApiClientConfigContext = useApiClientConfigContext;
|
|
@@ -1,13 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
} from "
|
|
5
|
-
import "
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { store } from "../apiClientConfigStore.mjs";
|
|
2
|
+
import { createSwrConfig } from "./swr.mjs";
|
|
3
|
+
import { createContext, useContext, useEffect } from "react";
|
|
4
|
+
import { SWRConfig } from "swr";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
//#region src/react/ApiClientConfigProvider.tsx
|
|
7
|
+
const ApiClientConfigContext = createContext(store);
|
|
8
|
+
const ApiClientConfigProvider = (props) => {
|
|
9
|
+
const { swr, ...config } = props.config;
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
store.setState(() => config);
|
|
12
|
+
}, [config]);
|
|
13
|
+
return /* @__PURE__ */ jsx(ApiClientConfigContext.Provider, {
|
|
14
|
+
value: store,
|
|
15
|
+
children: /* @__PURE__ */ jsx(SWRConfig, {
|
|
16
|
+
value: createSwrConfig(swr),
|
|
17
|
+
children: props.children
|
|
18
|
+
})
|
|
19
|
+
});
|
|
13
20
|
};
|
|
21
|
+
const useApiClientConfigContext = () => useContext(ApiClientConfigContext) || store;
|
|
22
|
+
//#endregion
|
|
23
|
+
export { ApiClientConfigProvider, useApiClientConfigContext };
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import '../apiClientConfigStore.js';
|
|
6
|
-
import '../store.js';
|
|
7
|
-
import 'swr';
|
|
1
|
+
import { ApiClientConfigProvider, useApiClientConfigContext } from "./ApiClientConfigProvider.js";
|
|
2
|
+
import { Configuration, createSwrConfig } from "./swr.js";
|
|
3
|
+
import { useApiClientConfig, useApiClientConfigWithSelector, useRequestInit } from "./useApiClientConfig.js";
|
|
4
|
+
export { ApiClientConfigProvider, Configuration, createSwrConfig, useApiClientConfig, useApiClientConfigContext, useApiClientConfigWithSelector, useRequestInit };
|
package/dist/react/index.js
CHANGED
|
@@ -1,26 +1,10 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
-
var react_exports = {};
|
|
17
|
-
module.exports = __toCommonJS(react_exports);
|
|
18
|
-
__reExport(react_exports, require("./ApiClientConfigProvider"), module.exports);
|
|
19
|
-
__reExport(react_exports, require("./swr"), module.exports);
|
|
20
|
-
__reExport(react_exports, require("./useApiClientConfig"), module.exports);
|
|
21
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
22
|
-
0 && (module.exports = {
|
|
23
|
-
...require("./ApiClientConfigProvider"),
|
|
24
|
-
...require("./swr"),
|
|
25
|
-
...require("./useApiClientConfig")
|
|
26
|
-
});
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_react_swr = require("./swr.js");
|
|
3
|
+
const require_react_ApiClientConfigProvider = require("./ApiClientConfigProvider.js");
|
|
4
|
+
const require_react_useApiClientConfig = require("./useApiClientConfig.js");
|
|
5
|
+
exports.ApiClientConfigProvider = require_react_ApiClientConfigProvider.ApiClientConfigProvider;
|
|
6
|
+
exports.createSwrConfig = require_react_swr.createSwrConfig;
|
|
7
|
+
exports.useApiClientConfig = require_react_useApiClientConfig.useApiClientConfig;
|
|
8
|
+
exports.useApiClientConfigContext = require_react_ApiClientConfigProvider.useApiClientConfigContext;
|
|
9
|
+
exports.useApiClientConfigWithSelector = require_react_useApiClientConfig.useApiClientConfigWithSelector;
|
|
10
|
+
exports.useRequestInit = require_react_useApiClientConfig.useRequestInit;
|