@readyfor/api-client-base 0.240.0-pr982.47c0748 → 0.241.0
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 +1 -2
- package/dist/apiClientConfigStore.d.ts +1 -2
- package/dist/apiClientConfigStore.js +0 -26
- package/dist/apiClientConfigStore.mjs +1 -4
- package/dist/chunk-472P3XVV.mjs +13 -0
- package/dist/{chunk-EUWRRSKU.mjs → chunk-5ZI7SAUQ.mjs} +1 -1
- package/dist/{chunk-75FRDEPQ.mjs → chunk-BNXKKSJH.mjs} +1 -1
- package/dist/chunk-JOSDYCJN.mjs +62 -0
- package/dist/{chunk-I7IHBG7V.mjs → chunk-RGDL3AEX.mjs} +1 -1
- package/dist/fetcher.mjs +2 -3
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +0 -26
- package/dist/index.mjs +3 -6
- package/dist/react/ApiClientConfigProvider.mjs +2 -3
- package/dist/react/index.js +30 -22
- package/dist/react/index.mjs +3 -4
- package/dist/react/useApiClientConfig.js +30 -22
- package/dist/react/useApiClientConfig.mjs +3 -4
- package/dist/requestUrl.mjs +2 -3
- package/dist/requestUrl.test.mjs +2 -3
- package/package.json +9 -8
- package/dist/chunk-6LWQJVNG.mjs +0 -37
- package/dist/chunk-AY5SE6GE.mjs +0 -23
- package/dist/chunk-VC2N3UT3.mjs +0 -21
- package/dist/utils/requestInit.d.mts +0 -3
- package/dist/utils/requestInit.d.ts +0 -3
- package/dist/utils/requestInit.js +0 -47
- package/dist/utils/requestInit.mjs +0 -6
|
@@ -17,6 +17,5 @@ type RequestConfig = {
|
|
|
17
17
|
type Config = RequestConfig & DeserializeResponseConfig & LoggingConfig;
|
|
18
18
|
declare const store: Store<Config>;
|
|
19
19
|
declare const setApiClientConfig: (config: Config) => void;
|
|
20
|
-
declare const buildRequestInitWithDefaultConfig: (customRequestInit?: RequestInit) => RequestInit;
|
|
21
20
|
|
|
22
|
-
export { type Config, type RequestConfig,
|
|
21
|
+
export { type Config, type RequestConfig, setApiClientConfig, store };
|
|
@@ -17,6 +17,5 @@ type RequestConfig = {
|
|
|
17
17
|
type Config = RequestConfig & DeserializeResponseConfig & LoggingConfig;
|
|
18
18
|
declare const store: Store<Config>;
|
|
19
19
|
declare const setApiClientConfig: (config: Config) => void;
|
|
20
|
-
declare const buildRequestInitWithDefaultConfig: (customRequestInit?: RequestInit) => RequestInit;
|
|
21
20
|
|
|
22
|
-
export { type Config, type RequestConfig,
|
|
21
|
+
export { type Config, type RequestConfig, setApiClientConfig, store };
|
|
@@ -20,7 +20,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/apiClientConfigStore.ts
|
|
21
21
|
var apiClientConfigStore_exports = {};
|
|
22
22
|
__export(apiClientConfigStore_exports, {
|
|
23
|
-
buildRequestInitWithDefaultConfig: () => buildRequestInitWithDefaultConfig,
|
|
24
23
|
setApiClientConfig: () => setApiClientConfig,
|
|
25
24
|
store: () => store
|
|
26
25
|
});
|
|
@@ -46,37 +45,12 @@ var createStore = (initialState) => {
|
|
|
46
45
|
};
|
|
47
46
|
};
|
|
48
47
|
|
|
49
|
-
// src/utils/requestInit.ts
|
|
50
|
-
var mergeRequestInit = (a, b) => {
|
|
51
|
-
const keys = Object.keys({ ...a, ...b });
|
|
52
|
-
return keys.reduce((acc, key) => {
|
|
53
|
-
if (key in b) {
|
|
54
|
-
return { ...acc, [key]: a[key] };
|
|
55
|
-
}
|
|
56
|
-
if (key in a) {
|
|
57
|
-
return { ...acc, [key]: b[key] };
|
|
58
|
-
}
|
|
59
|
-
if (Array.isArray(a[key]) && Array.isArray(b[key])) {
|
|
60
|
-
return { ...acc, [key]: [...a[key], ...b[key]] };
|
|
61
|
-
}
|
|
62
|
-
if (typeof a[key] === "object" && typeof b[key] === "object") {
|
|
63
|
-
return { ...acc, [key]: { ...a[key], ...b[key] } };
|
|
64
|
-
}
|
|
65
|
-
return { ...acc, [key]: b[key] };
|
|
66
|
-
}, {});
|
|
67
|
-
};
|
|
68
|
-
|
|
69
48
|
// src/apiClientConfigStore.ts
|
|
70
49
|
var defaultConfig = {};
|
|
71
50
|
var store = createStore(defaultConfig);
|
|
72
51
|
var setApiClientConfig = (config) => store.setState(() => config);
|
|
73
|
-
var buildRequestInitWithDefaultConfig = (customRequestInit = {}) => {
|
|
74
|
-
const { defaultRequestInit = {} } = store.getState();
|
|
75
|
-
return mergeRequestInit(defaultRequestInit, customRequestInit);
|
|
76
|
-
};
|
|
77
52
|
// Annotate the CommonJS export names for ESM import in node:
|
|
78
53
|
0 && (module.exports = {
|
|
79
|
-
buildRequestInitWithDefaultConfig,
|
|
80
54
|
setApiClientConfig,
|
|
81
55
|
store
|
|
82
56
|
});
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
|
-
buildRequestInitWithDefaultConfig,
|
|
3
2
|
setApiClientConfig,
|
|
4
3
|
store
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-AY5SE6GE.mjs";
|
|
4
|
+
} from "./chunk-472P3XVV.mjs";
|
|
7
5
|
import "./chunk-3SEO7S3Q.mjs";
|
|
8
6
|
export {
|
|
9
|
-
buildRequestInitWithDefaultConfig,
|
|
10
7
|
setApiClientConfig,
|
|
11
8
|
store
|
|
12
9
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createStore
|
|
3
|
+
} from "./chunk-3SEO7S3Q.mjs";
|
|
4
|
+
|
|
5
|
+
// src/apiClientConfigStore.ts
|
|
6
|
+
var defaultConfig = {};
|
|
7
|
+
var store = createStore(defaultConfig);
|
|
8
|
+
var setApiClientConfig = (config) => store.setState(() => config);
|
|
9
|
+
|
|
10
|
+
export {
|
|
11
|
+
store,
|
|
12
|
+
setApiClientConfig
|
|
13
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useApiClientConfigContext
|
|
3
|
+
} from "./chunk-5ZI7SAUQ.mjs";
|
|
4
|
+
|
|
5
|
+
// src/react/useApiClientConfig.ts
|
|
6
|
+
import { useCallback, useMemo } from "react";
|
|
7
|
+
import { useSyncExternalStore } from "use-sync-external-store/shim/index.js";
|
|
8
|
+
import { useSyncExternalStoreWithSelector } from "use-sync-external-store/shim/with-selector.js";
|
|
9
|
+
var useApiClientConfig = () => {
|
|
10
|
+
const store = useApiClientConfigContext();
|
|
11
|
+
return useSyncExternalStore(store.subscribe, store.getState);
|
|
12
|
+
};
|
|
13
|
+
var useApiClientConfigWithSelector = (selector) => {
|
|
14
|
+
const store = useApiClientConfigContext();
|
|
15
|
+
return useSyncExternalStoreWithSelector(
|
|
16
|
+
store.subscribe,
|
|
17
|
+
store.getState,
|
|
18
|
+
null,
|
|
19
|
+
selector
|
|
20
|
+
);
|
|
21
|
+
};
|
|
22
|
+
var useRequestInit = (customRequestInit = {}) => {
|
|
23
|
+
const { defaultRequestInit = {} } = useApiClientConfig();
|
|
24
|
+
const keys = useMemo(
|
|
25
|
+
() => Object.keys({
|
|
26
|
+
...defaultRequestInit,
|
|
27
|
+
...customRequestInit
|
|
28
|
+
}),
|
|
29
|
+
[defaultRequestInit, customRequestInit]
|
|
30
|
+
);
|
|
31
|
+
const get = useCallback((key) => {
|
|
32
|
+
if (customRequestInit[key] === void 0) {
|
|
33
|
+
return defaultRequestInit[key];
|
|
34
|
+
}
|
|
35
|
+
if (defaultRequestInit[key] === void 0) {
|
|
36
|
+
return customRequestInit[key];
|
|
37
|
+
}
|
|
38
|
+
if (typeof customRequestInit[key] === "object" && typeof defaultRequestInit[key] === "object") {
|
|
39
|
+
return { ...defaultRequestInit[key], ...customRequestInit[key] };
|
|
40
|
+
}
|
|
41
|
+
if (Array.isArray(customRequestInit[key]) && Array.isArray(defaultRequestInit[key])) {
|
|
42
|
+
return [...defaultRequestInit[key], ...customRequestInit[key]];
|
|
43
|
+
}
|
|
44
|
+
return customRequestInit[key] ?? defaultRequestInit[key];
|
|
45
|
+
}, []);
|
|
46
|
+
return useMemo(
|
|
47
|
+
() => keys.reduce(
|
|
48
|
+
(acc, key) => ({
|
|
49
|
+
...acc,
|
|
50
|
+
[key]: get(key)
|
|
51
|
+
}),
|
|
52
|
+
{}
|
|
53
|
+
),
|
|
54
|
+
[keys, get]
|
|
55
|
+
);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export {
|
|
59
|
+
useApiClientConfig,
|
|
60
|
+
useApiClientConfigWithSelector,
|
|
61
|
+
useRequestInit
|
|
62
|
+
};
|
package/dist/fetcher.mjs
CHANGED
|
@@ -3,11 +3,10 @@ import {
|
|
|
3
3
|
createJsonFetcher,
|
|
4
4
|
createTextFetcher,
|
|
5
5
|
createVoidFetcher
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-BNXKKSJH.mjs";
|
|
7
7
|
import "./chunk-PY35XWDS.mjs";
|
|
8
8
|
import "./chunk-JCZWXJBU.mjs";
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-AY5SE6GE.mjs";
|
|
9
|
+
import "./chunk-472P3XVV.mjs";
|
|
11
10
|
import "./chunk-3SEO7S3Q.mjs";
|
|
12
11
|
export {
|
|
13
12
|
createBlobFetcher,
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { Config, RequestConfig,
|
|
1
|
+
export { Config, RequestConfig, setApiClientConfig, store } from './apiClientConfigStore.mjs';
|
|
2
2
|
export { ErrorStatusCode, HTTPError, errorStatusCode, errorTitle, getErrorStatus } from './apiError.mjs';
|
|
3
3
|
export { BlobFetcherResponse, createBlobFetcher, createJsonFetcher, createTextFetcher, createVoidFetcher } from './fetcher.mjs';
|
|
4
4
|
export { __internal__requestUrl } from './requestUrl.mjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { Config, RequestConfig,
|
|
1
|
+
export { Config, RequestConfig, setApiClientConfig, store } from './apiClientConfigStore.js';
|
|
2
2
|
export { ErrorStatusCode, HTTPError, errorStatusCode, errorTitle, getErrorStatus } from './apiError.js';
|
|
3
3
|
export { BlobFetcherResponse, createBlobFetcher, createJsonFetcher, createTextFetcher, createVoidFetcher } from './fetcher.js';
|
|
4
4
|
export { __internal__requestUrl } from './requestUrl.js';
|
package/dist/index.js
CHANGED
|
@@ -32,7 +32,6 @@ var index_exports = {};
|
|
|
32
32
|
__export(index_exports, {
|
|
33
33
|
HTTPError: () => HTTPError,
|
|
34
34
|
__internal__requestUrl: () => __internal__requestUrl,
|
|
35
|
-
buildRequestInitWithDefaultConfig: () => buildRequestInitWithDefaultConfig,
|
|
36
35
|
createBlobFetcher: () => createBlobFetcher,
|
|
37
36
|
createJsonFetcher: () => createJsonFetcher,
|
|
38
37
|
createStore: () => createStore,
|
|
@@ -68,34 +67,10 @@ var createStore = (initialState) => {
|
|
|
68
67
|
};
|
|
69
68
|
};
|
|
70
69
|
|
|
71
|
-
// src/utils/requestInit.ts
|
|
72
|
-
var mergeRequestInit = (a, b) => {
|
|
73
|
-
const keys = Object.keys({ ...a, ...b });
|
|
74
|
-
return keys.reduce((acc, key) => {
|
|
75
|
-
if (key in b) {
|
|
76
|
-
return { ...acc, [key]: a[key] };
|
|
77
|
-
}
|
|
78
|
-
if (key in a) {
|
|
79
|
-
return { ...acc, [key]: b[key] };
|
|
80
|
-
}
|
|
81
|
-
if (Array.isArray(a[key]) && Array.isArray(b[key])) {
|
|
82
|
-
return { ...acc, [key]: [...a[key], ...b[key]] };
|
|
83
|
-
}
|
|
84
|
-
if (typeof a[key] === "object" && typeof b[key] === "object") {
|
|
85
|
-
return { ...acc, [key]: { ...a[key], ...b[key] } };
|
|
86
|
-
}
|
|
87
|
-
return { ...acc, [key]: b[key] };
|
|
88
|
-
}, {});
|
|
89
|
-
};
|
|
90
|
-
|
|
91
70
|
// src/apiClientConfigStore.ts
|
|
92
71
|
var defaultConfig = {};
|
|
93
72
|
var store = createStore(defaultConfig);
|
|
94
73
|
var setApiClientConfig = (config) => store.setState(() => config);
|
|
95
|
-
var buildRequestInitWithDefaultConfig = (customRequestInit = {}) => {
|
|
96
|
-
const { defaultRequestInit: defaultRequestInit2 = {} } = store.getState();
|
|
97
|
-
return mergeRequestInit(defaultRequestInit2, customRequestInit);
|
|
98
|
-
};
|
|
99
74
|
|
|
100
75
|
// src/zod.ts
|
|
101
76
|
var schemaForType = () => (arg) => {
|
|
@@ -272,7 +247,6 @@ function __internal__requestUrl(...args) {
|
|
|
272
247
|
0 && (module.exports = {
|
|
273
248
|
HTTPError,
|
|
274
249
|
__internal__requestUrl,
|
|
275
|
-
buildRequestInitWithDefaultConfig,
|
|
276
250
|
createBlobFetcher,
|
|
277
251
|
createJsonFetcher,
|
|
278
252
|
createStore,
|
package/dist/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
createJsonFetcher,
|
|
4
4
|
createTextFetcher,
|
|
5
5
|
createVoidFetcher
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-BNXKKSJH.mjs";
|
|
7
7
|
import {
|
|
8
8
|
HTTPError,
|
|
9
9
|
errorStatusCode,
|
|
@@ -16,13 +16,11 @@ import {
|
|
|
16
16
|
} from "./chunk-JCZWXJBU.mjs";
|
|
17
17
|
import {
|
|
18
18
|
__internal__requestUrl
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-RGDL3AEX.mjs";
|
|
20
20
|
import {
|
|
21
|
-
buildRequestInitWithDefaultConfig,
|
|
22
21
|
setApiClientConfig,
|
|
23
22
|
store
|
|
24
|
-
} from "./chunk-
|
|
25
|
-
import "./chunk-AY5SE6GE.mjs";
|
|
23
|
+
} from "./chunk-472P3XVV.mjs";
|
|
26
24
|
import {
|
|
27
25
|
createStore
|
|
28
26
|
} from "./chunk-3SEO7S3Q.mjs";
|
|
@@ -30,7 +28,6 @@ import "./chunk-WBQAMGXK.mjs";
|
|
|
30
28
|
export {
|
|
31
29
|
HTTPError,
|
|
32
30
|
__internal__requestUrl,
|
|
33
|
-
buildRequestInitWithDefaultConfig,
|
|
34
31
|
createBlobFetcher,
|
|
35
32
|
createJsonFetcher,
|
|
36
33
|
createStore,
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ApiClientConfigProvider,
|
|
3
3
|
useApiClientConfigContext
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-5ZI7SAUQ.mjs";
|
|
5
5
|
import "../chunk-DH33ZDBG.mjs";
|
|
6
|
-
import "../chunk-
|
|
7
|
-
import "../chunk-AY5SE6GE.mjs";
|
|
6
|
+
import "../chunk-472P3XVV.mjs";
|
|
8
7
|
import "../chunk-3SEO7S3Q.mjs";
|
|
9
8
|
export {
|
|
10
9
|
ApiClientConfigProvider,
|
package/dist/react/index.js
CHANGED
|
@@ -52,26 +52,6 @@ var createStore = (initialState) => {
|
|
|
52
52
|
};
|
|
53
53
|
};
|
|
54
54
|
|
|
55
|
-
// src/utils/requestInit.ts
|
|
56
|
-
var mergeRequestInit = (a, b) => {
|
|
57
|
-
const keys = Object.keys({ ...a, ...b });
|
|
58
|
-
return keys.reduce((acc, key) => {
|
|
59
|
-
if (key in b) {
|
|
60
|
-
return { ...acc, [key]: a[key] };
|
|
61
|
-
}
|
|
62
|
-
if (key in a) {
|
|
63
|
-
return { ...acc, [key]: b[key] };
|
|
64
|
-
}
|
|
65
|
-
if (Array.isArray(a[key]) && Array.isArray(b[key])) {
|
|
66
|
-
return { ...acc, [key]: [...a[key], ...b[key]] };
|
|
67
|
-
}
|
|
68
|
-
if (typeof a[key] === "object" && typeof b[key] === "object") {
|
|
69
|
-
return { ...acc, [key]: { ...a[key], ...b[key] } };
|
|
70
|
-
}
|
|
71
|
-
return { ...acc, [key]: b[key] };
|
|
72
|
-
}, {});
|
|
73
|
-
};
|
|
74
|
-
|
|
75
55
|
// src/apiClientConfigStore.ts
|
|
76
56
|
var defaultConfig = {};
|
|
77
57
|
var store = createStore(defaultConfig);
|
|
@@ -126,10 +106,38 @@ var useApiClientConfigWithSelector = (selector) => {
|
|
|
126
106
|
};
|
|
127
107
|
var useRequestInit = (customRequestInit = {}) => {
|
|
128
108
|
const { defaultRequestInit = {} } = useApiClientConfig();
|
|
129
|
-
|
|
130
|
-
() =>
|
|
109
|
+
const keys = (0, import_react3.useMemo)(
|
|
110
|
+
() => Object.keys({
|
|
111
|
+
...defaultRequestInit,
|
|
112
|
+
...customRequestInit
|
|
113
|
+
}),
|
|
131
114
|
[defaultRequestInit, customRequestInit]
|
|
132
115
|
);
|
|
116
|
+
const get = (0, import_react3.useCallback)((key) => {
|
|
117
|
+
if (customRequestInit[key] === void 0) {
|
|
118
|
+
return defaultRequestInit[key];
|
|
119
|
+
}
|
|
120
|
+
if (defaultRequestInit[key] === void 0) {
|
|
121
|
+
return customRequestInit[key];
|
|
122
|
+
}
|
|
123
|
+
if (typeof customRequestInit[key] === "object" && typeof defaultRequestInit[key] === "object") {
|
|
124
|
+
return { ...defaultRequestInit[key], ...customRequestInit[key] };
|
|
125
|
+
}
|
|
126
|
+
if (Array.isArray(customRequestInit[key]) && Array.isArray(defaultRequestInit[key])) {
|
|
127
|
+
return [...defaultRequestInit[key], ...customRequestInit[key]];
|
|
128
|
+
}
|
|
129
|
+
return customRequestInit[key] ?? defaultRequestInit[key];
|
|
130
|
+
}, []);
|
|
131
|
+
return (0, import_react3.useMemo)(
|
|
132
|
+
() => keys.reduce(
|
|
133
|
+
(acc, key) => ({
|
|
134
|
+
...acc,
|
|
135
|
+
[key]: get(key)
|
|
136
|
+
}),
|
|
137
|
+
{}
|
|
138
|
+
),
|
|
139
|
+
[keys, get]
|
|
140
|
+
);
|
|
133
141
|
};
|
|
134
142
|
// Annotate the CommonJS export names for ESM import in node:
|
|
135
143
|
0 && (module.exports = {
|
package/dist/react/index.mjs
CHANGED
|
@@ -2,16 +2,15 @@ import {
|
|
|
2
2
|
useApiClientConfig,
|
|
3
3
|
useApiClientConfigWithSelector,
|
|
4
4
|
useRequestInit
|
|
5
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-JOSDYCJN.mjs";
|
|
6
6
|
import {
|
|
7
7
|
ApiClientConfigProvider,
|
|
8
8
|
useApiClientConfigContext
|
|
9
|
-
} from "../chunk-
|
|
9
|
+
} from "../chunk-5ZI7SAUQ.mjs";
|
|
10
10
|
import {
|
|
11
11
|
createSwrConfig
|
|
12
12
|
} from "../chunk-DH33ZDBG.mjs";
|
|
13
|
-
import "../chunk-
|
|
14
|
-
import "../chunk-AY5SE6GE.mjs";
|
|
13
|
+
import "../chunk-472P3XVV.mjs";
|
|
15
14
|
import "../chunk-3SEO7S3Q.mjs";
|
|
16
15
|
export {
|
|
17
16
|
ApiClientConfigProvider,
|
|
@@ -49,26 +49,6 @@ var createStore = (initialState) => {
|
|
|
49
49
|
};
|
|
50
50
|
};
|
|
51
51
|
|
|
52
|
-
// src/utils/requestInit.ts
|
|
53
|
-
var mergeRequestInit = (a, b) => {
|
|
54
|
-
const keys = Object.keys({ ...a, ...b });
|
|
55
|
-
return keys.reduce((acc, key) => {
|
|
56
|
-
if (key in b) {
|
|
57
|
-
return { ...acc, [key]: a[key] };
|
|
58
|
-
}
|
|
59
|
-
if (key in a) {
|
|
60
|
-
return { ...acc, [key]: b[key] };
|
|
61
|
-
}
|
|
62
|
-
if (Array.isArray(a[key]) && Array.isArray(b[key])) {
|
|
63
|
-
return { ...acc, [key]: [...a[key], ...b[key]] };
|
|
64
|
-
}
|
|
65
|
-
if (typeof a[key] === "object" && typeof b[key] === "object") {
|
|
66
|
-
return { ...acc, [key]: { ...a[key], ...b[key] } };
|
|
67
|
-
}
|
|
68
|
-
return { ...acc, [key]: b[key] };
|
|
69
|
-
}, {});
|
|
70
|
-
};
|
|
71
|
-
|
|
72
52
|
// src/apiClientConfigStore.ts
|
|
73
53
|
var defaultConfig = {};
|
|
74
54
|
var store = createStore(defaultConfig);
|
|
@@ -103,10 +83,38 @@ var useApiClientConfigWithSelector = (selector) => {
|
|
|
103
83
|
};
|
|
104
84
|
var useRequestInit = (customRequestInit = {}) => {
|
|
105
85
|
const { defaultRequestInit = {} } = useApiClientConfig();
|
|
106
|
-
|
|
107
|
-
() =>
|
|
86
|
+
const keys = (0, import_react3.useMemo)(
|
|
87
|
+
() => Object.keys({
|
|
88
|
+
...defaultRequestInit,
|
|
89
|
+
...customRequestInit
|
|
90
|
+
}),
|
|
108
91
|
[defaultRequestInit, customRequestInit]
|
|
109
92
|
);
|
|
93
|
+
const get = (0, import_react3.useCallback)((key) => {
|
|
94
|
+
if (customRequestInit[key] === void 0) {
|
|
95
|
+
return defaultRequestInit[key];
|
|
96
|
+
}
|
|
97
|
+
if (defaultRequestInit[key] === void 0) {
|
|
98
|
+
return customRequestInit[key];
|
|
99
|
+
}
|
|
100
|
+
if (typeof customRequestInit[key] === "object" && typeof defaultRequestInit[key] === "object") {
|
|
101
|
+
return { ...defaultRequestInit[key], ...customRequestInit[key] };
|
|
102
|
+
}
|
|
103
|
+
if (Array.isArray(customRequestInit[key]) && Array.isArray(defaultRequestInit[key])) {
|
|
104
|
+
return [...defaultRequestInit[key], ...customRequestInit[key]];
|
|
105
|
+
}
|
|
106
|
+
return customRequestInit[key] ?? defaultRequestInit[key];
|
|
107
|
+
}, []);
|
|
108
|
+
return (0, import_react3.useMemo)(
|
|
109
|
+
() => keys.reduce(
|
|
110
|
+
(acc, key) => ({
|
|
111
|
+
...acc,
|
|
112
|
+
[key]: get(key)
|
|
113
|
+
}),
|
|
114
|
+
{}
|
|
115
|
+
),
|
|
116
|
+
[keys, get]
|
|
117
|
+
);
|
|
110
118
|
};
|
|
111
119
|
// Annotate the CommonJS export names for ESM import in node:
|
|
112
120
|
0 && (module.exports = {
|
|
@@ -2,11 +2,10 @@ import {
|
|
|
2
2
|
useApiClientConfig,
|
|
3
3
|
useApiClientConfigWithSelector,
|
|
4
4
|
useRequestInit
|
|
5
|
-
} from "../chunk-
|
|
6
|
-
import "../chunk-
|
|
5
|
+
} from "../chunk-JOSDYCJN.mjs";
|
|
6
|
+
import "../chunk-5ZI7SAUQ.mjs";
|
|
7
7
|
import "../chunk-DH33ZDBG.mjs";
|
|
8
|
-
import "../chunk-
|
|
9
|
-
import "../chunk-AY5SE6GE.mjs";
|
|
8
|
+
import "../chunk-472P3XVV.mjs";
|
|
10
9
|
import "../chunk-3SEO7S3Q.mjs";
|
|
11
10
|
export {
|
|
12
11
|
useApiClientConfig,
|
package/dist/requestUrl.mjs
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
__internal__requestUrl
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-AY5SE6GE.mjs";
|
|
3
|
+
} from "./chunk-RGDL3AEX.mjs";
|
|
4
|
+
import "./chunk-472P3XVV.mjs";
|
|
6
5
|
import "./chunk-3SEO7S3Q.mjs";
|
|
7
6
|
export {
|
|
8
7
|
__internal__requestUrl
|
package/dist/requestUrl.test.mjs
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
__internal__requestUrl
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-RGDL3AEX.mjs";
|
|
4
4
|
import {
|
|
5
5
|
store
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-AY5SE6GE.mjs";
|
|
6
|
+
} from "./chunk-472P3XVV.mjs";
|
|
8
7
|
import "./chunk-3SEO7S3Q.mjs";
|
|
9
8
|
|
|
10
9
|
// src/requestUrl.test.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@readyfor/api-client-base",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.241.0",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -20,6 +20,9 @@
|
|
|
20
20
|
"require": "./dist/react/index.js"
|
|
21
21
|
}
|
|
22
22
|
},
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "tsup"
|
|
25
|
+
},
|
|
23
26
|
"dependencies": {
|
|
24
27
|
"qs": "6.14.0",
|
|
25
28
|
"zod": "^3.24.1"
|
|
@@ -28,9 +31,9 @@
|
|
|
28
31
|
"@types/qs": "6.9.18",
|
|
29
32
|
"@types/react": "19.1.2",
|
|
30
33
|
"@types/use-sync-external-store": "1.5.0",
|
|
31
|
-
"react": "
|
|
32
|
-
"swr": "
|
|
33
|
-
"use-sync-external-store": "
|
|
34
|
+
"react": "catalog:react19",
|
|
35
|
+
"swr": "catalog:",
|
|
36
|
+
"use-sync-external-store": "catalog:use-sync-external-store"
|
|
34
37
|
},
|
|
35
38
|
"peerDependencies": {
|
|
36
39
|
"react": ">=18.x <=19.x",
|
|
@@ -60,7 +63,5 @@
|
|
|
60
63
|
"src"
|
|
61
64
|
]
|
|
62
65
|
},
|
|
63
|
-
"
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
}
|
|
66
|
+
"gitHead": "f1022b2e216e1b8200db48ca5762a61dd16a50d1"
|
|
67
|
+
}
|
package/dist/chunk-6LWQJVNG.mjs
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
useApiClientConfigContext
|
|
3
|
-
} from "./chunk-EUWRRSKU.mjs";
|
|
4
|
-
import {
|
|
5
|
-
mergeRequestInit
|
|
6
|
-
} from "./chunk-AY5SE6GE.mjs";
|
|
7
|
-
|
|
8
|
-
// src/react/useApiClientConfig.ts
|
|
9
|
-
import { useMemo } from "react";
|
|
10
|
-
import { useSyncExternalStore } from "use-sync-external-store/shim/index.js";
|
|
11
|
-
import { useSyncExternalStoreWithSelector } from "use-sync-external-store/shim/with-selector.js";
|
|
12
|
-
var useApiClientConfig = () => {
|
|
13
|
-
const store = useApiClientConfigContext();
|
|
14
|
-
return useSyncExternalStore(store.subscribe, store.getState);
|
|
15
|
-
};
|
|
16
|
-
var useApiClientConfigWithSelector = (selector) => {
|
|
17
|
-
const store = useApiClientConfigContext();
|
|
18
|
-
return useSyncExternalStoreWithSelector(
|
|
19
|
-
store.subscribe,
|
|
20
|
-
store.getState,
|
|
21
|
-
null,
|
|
22
|
-
selector
|
|
23
|
-
);
|
|
24
|
-
};
|
|
25
|
-
var useRequestInit = (customRequestInit = {}) => {
|
|
26
|
-
const { defaultRequestInit = {} } = useApiClientConfig();
|
|
27
|
-
return useMemo(
|
|
28
|
-
() => mergeRequestInit(defaultRequestInit, customRequestInit),
|
|
29
|
-
[defaultRequestInit, customRequestInit]
|
|
30
|
-
);
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export {
|
|
34
|
-
useApiClientConfig,
|
|
35
|
-
useApiClientConfigWithSelector,
|
|
36
|
-
useRequestInit
|
|
37
|
-
};
|
package/dist/chunk-AY5SE6GE.mjs
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
// src/utils/requestInit.ts
|
|
2
|
-
var mergeRequestInit = (a, b) => {
|
|
3
|
-
const keys = Object.keys({ ...a, ...b });
|
|
4
|
-
return keys.reduce((acc, key) => {
|
|
5
|
-
if (key in b) {
|
|
6
|
-
return { ...acc, [key]: a[key] };
|
|
7
|
-
}
|
|
8
|
-
if (key in a) {
|
|
9
|
-
return { ...acc, [key]: b[key] };
|
|
10
|
-
}
|
|
11
|
-
if (Array.isArray(a[key]) && Array.isArray(b[key])) {
|
|
12
|
-
return { ...acc, [key]: [...a[key], ...b[key]] };
|
|
13
|
-
}
|
|
14
|
-
if (typeof a[key] === "object" && typeof b[key] === "object") {
|
|
15
|
-
return { ...acc, [key]: { ...a[key], ...b[key] } };
|
|
16
|
-
}
|
|
17
|
-
return { ...acc, [key]: b[key] };
|
|
18
|
-
}, {});
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export {
|
|
22
|
-
mergeRequestInit
|
|
23
|
-
};
|
package/dist/chunk-VC2N3UT3.mjs
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
mergeRequestInit
|
|
3
|
-
} from "./chunk-AY5SE6GE.mjs";
|
|
4
|
-
import {
|
|
5
|
-
createStore
|
|
6
|
-
} from "./chunk-3SEO7S3Q.mjs";
|
|
7
|
-
|
|
8
|
-
// src/apiClientConfigStore.ts
|
|
9
|
-
var defaultConfig = {};
|
|
10
|
-
var store = createStore(defaultConfig);
|
|
11
|
-
var setApiClientConfig = (config) => store.setState(() => config);
|
|
12
|
-
var buildRequestInitWithDefaultConfig = (customRequestInit = {}) => {
|
|
13
|
-
const { defaultRequestInit = {} } = store.getState();
|
|
14
|
-
return mergeRequestInit(defaultRequestInit, customRequestInit);
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export {
|
|
18
|
-
store,
|
|
19
|
-
setApiClientConfig,
|
|
20
|
-
buildRequestInitWithDefaultConfig
|
|
21
|
-
};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
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
|
-
|
|
20
|
-
// src/utils/requestInit.ts
|
|
21
|
-
var requestInit_exports = {};
|
|
22
|
-
__export(requestInit_exports, {
|
|
23
|
-
mergeRequestInit: () => mergeRequestInit
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(requestInit_exports);
|
|
26
|
-
var mergeRequestInit = (a, b) => {
|
|
27
|
-
const keys = Object.keys({ ...a, ...b });
|
|
28
|
-
return keys.reduce((acc, key) => {
|
|
29
|
-
if (key in b) {
|
|
30
|
-
return { ...acc, [key]: a[key] };
|
|
31
|
-
}
|
|
32
|
-
if (key in a) {
|
|
33
|
-
return { ...acc, [key]: b[key] };
|
|
34
|
-
}
|
|
35
|
-
if (Array.isArray(a[key]) && Array.isArray(b[key])) {
|
|
36
|
-
return { ...acc, [key]: [...a[key], ...b[key]] };
|
|
37
|
-
}
|
|
38
|
-
if (typeof a[key] === "object" && typeof b[key] === "object") {
|
|
39
|
-
return { ...acc, [key]: { ...a[key], ...b[key] } };
|
|
40
|
-
}
|
|
41
|
-
return { ...acc, [key]: b[key] };
|
|
42
|
-
}, {});
|
|
43
|
-
};
|
|
44
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
45
|
-
0 && (module.exports = {
|
|
46
|
-
mergeRequestInit
|
|
47
|
-
});
|