@readyfor/api-client-base 0.239.0 → 0.240.0-pr981.89e7f00
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 +2 -1
- package/dist/apiClientConfigStore.d.ts +2 -1
- package/dist/apiClientConfigStore.js +26 -0
- package/dist/apiClientConfigStore.mjs +4 -1
- package/dist/chunk-BKGI64NY.mjs +37 -0
- package/dist/chunk-NDBDIHHK.mjs +21 -0
- package/dist/{chunk-5ZI7SAUQ.mjs → chunk-QJGJPJUF.mjs} +1 -1
- package/dist/chunk-SE2OY7FZ.mjs +23 -0
- package/dist/{chunk-RGDL3AEX.mjs → chunk-W6BWZ3JJ.mjs} +1 -1
- package/dist/{chunk-BNXKKSJH.mjs → chunk-YGQL4FPZ.mjs} +1 -1
- package/dist/fetcher.mjs +3 -2
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +26 -0
- package/dist/index.mjs +6 -3
- package/dist/react/ApiClientConfigProvider.mjs +3 -2
- package/dist/react/index.js +22 -30
- package/dist/react/index.mjs +4 -3
- package/dist/react/useApiClientConfig.js +22 -30
- package/dist/react/useApiClientConfig.mjs +4 -3
- package/dist/requestUrl.mjs +3 -2
- package/dist/requestUrl.test.mjs +3 -2
- package/dist/utils/requestInit.d.mts +3 -0
- package/dist/utils/requestInit.d.ts +3 -0
- package/dist/utils/requestInit.js +47 -0
- package/dist/utils/requestInit.mjs +6 -0
- package/package.json +8 -9
- package/dist/chunk-472P3XVV.mjs +0 -13
- package/dist/chunk-JOSDYCJN.mjs +0 -62
|
@@ -17,5 +17,6 @@ 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;
|
|
20
21
|
|
|
21
|
-
export { type Config, type RequestConfig, setApiClientConfig, store };
|
|
22
|
+
export { type Config, type RequestConfig, buildRequestInitWithDefaultConfig, setApiClientConfig, store };
|
|
@@ -17,5 +17,6 @@ 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;
|
|
20
21
|
|
|
21
|
-
export { type Config, type RequestConfig, setApiClientConfig, store };
|
|
22
|
+
export { type Config, type RequestConfig, buildRequestInitWithDefaultConfig, setApiClientConfig, store };
|
|
@@ -20,6 +20,7 @@ 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,
|
|
23
24
|
setApiClientConfig: () => setApiClientConfig,
|
|
24
25
|
store: () => store
|
|
25
26
|
});
|
|
@@ -45,12 +46,37 @@ var createStore = (initialState) => {
|
|
|
45
46
|
};
|
|
46
47
|
};
|
|
47
48
|
|
|
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
|
+
|
|
48
69
|
// src/apiClientConfigStore.ts
|
|
49
70
|
var defaultConfig = {};
|
|
50
71
|
var store = createStore(defaultConfig);
|
|
51
72
|
var setApiClientConfig = (config) => store.setState(() => config);
|
|
73
|
+
var buildRequestInitWithDefaultConfig = (customRequestInit = {}) => {
|
|
74
|
+
const { defaultRequestInit = {} } = store.getState();
|
|
75
|
+
return mergeRequestInit(defaultRequestInit, customRequestInit);
|
|
76
|
+
};
|
|
52
77
|
// Annotate the CommonJS export names for ESM import in node:
|
|
53
78
|
0 && (module.exports = {
|
|
79
|
+
buildRequestInitWithDefaultConfig,
|
|
54
80
|
setApiClientConfig,
|
|
55
81
|
store
|
|
56
82
|
});
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
|
+
buildRequestInitWithDefaultConfig,
|
|
2
3
|
setApiClientConfig,
|
|
3
4
|
store
|
|
4
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-NDBDIHHK.mjs";
|
|
6
|
+
import "./chunk-SE2OY7FZ.mjs";
|
|
5
7
|
import "./chunk-3SEO7S3Q.mjs";
|
|
6
8
|
export {
|
|
9
|
+
buildRequestInitWithDefaultConfig,
|
|
7
10
|
setApiClientConfig,
|
|
8
11
|
store
|
|
9
12
|
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useApiClientConfigContext
|
|
3
|
+
} from "./chunk-QJGJPJUF.mjs";
|
|
4
|
+
import {
|
|
5
|
+
mergeRequestInit
|
|
6
|
+
} from "./chunk-SE2OY7FZ.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
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import {
|
|
2
|
+
mergeRequestInit
|
|
3
|
+
} from "./chunk-SE2OY7FZ.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
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
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/fetcher.mjs
CHANGED
|
@@ -3,10 +3,11 @@ import {
|
|
|
3
3
|
createJsonFetcher,
|
|
4
4
|
createTextFetcher,
|
|
5
5
|
createVoidFetcher
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-YGQL4FPZ.mjs";
|
|
7
7
|
import "./chunk-PY35XWDS.mjs";
|
|
8
8
|
import "./chunk-JCZWXJBU.mjs";
|
|
9
|
-
import "./chunk-
|
|
9
|
+
import "./chunk-NDBDIHHK.mjs";
|
|
10
|
+
import "./chunk-SE2OY7FZ.mjs";
|
|
10
11
|
import "./chunk-3SEO7S3Q.mjs";
|
|
11
12
|
export {
|
|
12
13
|
createBlobFetcher,
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { Config, RequestConfig, setApiClientConfig, store } from './apiClientConfigStore.mjs';
|
|
1
|
+
export { Config, RequestConfig, buildRequestInitWithDefaultConfig, 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, setApiClientConfig, store } from './apiClientConfigStore.js';
|
|
1
|
+
export { Config, RequestConfig, buildRequestInitWithDefaultConfig, 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,6 +32,7 @@ var index_exports = {};
|
|
|
32
32
|
__export(index_exports, {
|
|
33
33
|
HTTPError: () => HTTPError,
|
|
34
34
|
__internal__requestUrl: () => __internal__requestUrl,
|
|
35
|
+
buildRequestInitWithDefaultConfig: () => buildRequestInitWithDefaultConfig,
|
|
35
36
|
createBlobFetcher: () => createBlobFetcher,
|
|
36
37
|
createJsonFetcher: () => createJsonFetcher,
|
|
37
38
|
createStore: () => createStore,
|
|
@@ -67,10 +68,34 @@ var createStore = (initialState) => {
|
|
|
67
68
|
};
|
|
68
69
|
};
|
|
69
70
|
|
|
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
|
+
|
|
70
91
|
// src/apiClientConfigStore.ts
|
|
71
92
|
var defaultConfig = {};
|
|
72
93
|
var store = createStore(defaultConfig);
|
|
73
94
|
var setApiClientConfig = (config) => store.setState(() => config);
|
|
95
|
+
var buildRequestInitWithDefaultConfig = (customRequestInit = {}) => {
|
|
96
|
+
const { defaultRequestInit: defaultRequestInit2 = {} } = store.getState();
|
|
97
|
+
return mergeRequestInit(defaultRequestInit2, customRequestInit);
|
|
98
|
+
};
|
|
74
99
|
|
|
75
100
|
// src/zod.ts
|
|
76
101
|
var schemaForType = () => (arg) => {
|
|
@@ -247,6 +272,7 @@ function __internal__requestUrl(...args) {
|
|
|
247
272
|
0 && (module.exports = {
|
|
248
273
|
HTTPError,
|
|
249
274
|
__internal__requestUrl,
|
|
275
|
+
buildRequestInitWithDefaultConfig,
|
|
250
276
|
createBlobFetcher,
|
|
251
277
|
createJsonFetcher,
|
|
252
278
|
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-YGQL4FPZ.mjs";
|
|
7
7
|
import {
|
|
8
8
|
HTTPError,
|
|
9
9
|
errorStatusCode,
|
|
@@ -16,11 +16,13 @@ import {
|
|
|
16
16
|
} from "./chunk-JCZWXJBU.mjs";
|
|
17
17
|
import {
|
|
18
18
|
__internal__requestUrl
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-W6BWZ3JJ.mjs";
|
|
20
20
|
import {
|
|
21
|
+
buildRequestInitWithDefaultConfig,
|
|
21
22
|
setApiClientConfig,
|
|
22
23
|
store
|
|
23
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-NDBDIHHK.mjs";
|
|
25
|
+
import "./chunk-SE2OY7FZ.mjs";
|
|
24
26
|
import {
|
|
25
27
|
createStore
|
|
26
28
|
} from "./chunk-3SEO7S3Q.mjs";
|
|
@@ -28,6 +30,7 @@ import "./chunk-WBQAMGXK.mjs";
|
|
|
28
30
|
export {
|
|
29
31
|
HTTPError,
|
|
30
32
|
__internal__requestUrl,
|
|
33
|
+
buildRequestInitWithDefaultConfig,
|
|
31
34
|
createBlobFetcher,
|
|
32
35
|
createJsonFetcher,
|
|
33
36
|
createStore,
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ApiClientConfigProvider,
|
|
3
3
|
useApiClientConfigContext
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-QJGJPJUF.mjs";
|
|
5
5
|
import "../chunk-DH33ZDBG.mjs";
|
|
6
|
-
import "../chunk-
|
|
6
|
+
import "../chunk-NDBDIHHK.mjs";
|
|
7
|
+
import "../chunk-SE2OY7FZ.mjs";
|
|
7
8
|
import "../chunk-3SEO7S3Q.mjs";
|
|
8
9
|
export {
|
|
9
10
|
ApiClientConfigProvider,
|
package/dist/react/index.js
CHANGED
|
@@ -52,6 +52,26 @@ 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
|
+
|
|
55
75
|
// src/apiClientConfigStore.ts
|
|
56
76
|
var defaultConfig = {};
|
|
57
77
|
var store = createStore(defaultConfig);
|
|
@@ -106,37 +126,9 @@ var useApiClientConfigWithSelector = (selector) => {
|
|
|
106
126
|
};
|
|
107
127
|
var useRequestInit = (customRequestInit = {}) => {
|
|
108
128
|
const { defaultRequestInit = {} } = useApiClientConfig();
|
|
109
|
-
const keys = (0, import_react3.useMemo)(
|
|
110
|
-
() => Object.keys({
|
|
111
|
-
...defaultRequestInit,
|
|
112
|
-
...customRequestInit
|
|
113
|
-
}),
|
|
114
|
-
[defaultRequestInit, customRequestInit]
|
|
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
129
|
return (0, import_react3.useMemo)(
|
|
132
|
-
() =>
|
|
133
|
-
|
|
134
|
-
...acc,
|
|
135
|
-
[key]: get(key)
|
|
136
|
-
}),
|
|
137
|
-
{}
|
|
138
|
-
),
|
|
139
|
-
[keys, get]
|
|
130
|
+
() => mergeRequestInit(defaultRequestInit, customRequestInit),
|
|
131
|
+
[defaultRequestInit, customRequestInit]
|
|
140
132
|
);
|
|
141
133
|
};
|
|
142
134
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/react/index.mjs
CHANGED
|
@@ -2,15 +2,16 @@ import {
|
|
|
2
2
|
useApiClientConfig,
|
|
3
3
|
useApiClientConfigWithSelector,
|
|
4
4
|
useRequestInit
|
|
5
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-BKGI64NY.mjs";
|
|
6
6
|
import {
|
|
7
7
|
ApiClientConfigProvider,
|
|
8
8
|
useApiClientConfigContext
|
|
9
|
-
} from "../chunk-
|
|
9
|
+
} from "../chunk-QJGJPJUF.mjs";
|
|
10
10
|
import {
|
|
11
11
|
createSwrConfig
|
|
12
12
|
} from "../chunk-DH33ZDBG.mjs";
|
|
13
|
-
import "../chunk-
|
|
13
|
+
import "../chunk-NDBDIHHK.mjs";
|
|
14
|
+
import "../chunk-SE2OY7FZ.mjs";
|
|
14
15
|
import "../chunk-3SEO7S3Q.mjs";
|
|
15
16
|
export {
|
|
16
17
|
ApiClientConfigProvider,
|
|
@@ -49,6 +49,26 @@ 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
|
+
|
|
52
72
|
// src/apiClientConfigStore.ts
|
|
53
73
|
var defaultConfig = {};
|
|
54
74
|
var store = createStore(defaultConfig);
|
|
@@ -83,37 +103,9 @@ var useApiClientConfigWithSelector = (selector) => {
|
|
|
83
103
|
};
|
|
84
104
|
var useRequestInit = (customRequestInit = {}) => {
|
|
85
105
|
const { defaultRequestInit = {} } = useApiClientConfig();
|
|
86
|
-
const keys = (0, import_react3.useMemo)(
|
|
87
|
-
() => Object.keys({
|
|
88
|
-
...defaultRequestInit,
|
|
89
|
-
...customRequestInit
|
|
90
|
-
}),
|
|
91
|
-
[defaultRequestInit, customRequestInit]
|
|
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
106
|
return (0, import_react3.useMemo)(
|
|
109
|
-
() =>
|
|
110
|
-
|
|
111
|
-
...acc,
|
|
112
|
-
[key]: get(key)
|
|
113
|
-
}),
|
|
114
|
-
{}
|
|
115
|
-
),
|
|
116
|
-
[keys, get]
|
|
107
|
+
() => mergeRequestInit(defaultRequestInit, customRequestInit),
|
|
108
|
+
[defaultRequestInit, customRequestInit]
|
|
117
109
|
);
|
|
118
110
|
};
|
|
119
111
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -2,10 +2,11 @@ import {
|
|
|
2
2
|
useApiClientConfig,
|
|
3
3
|
useApiClientConfigWithSelector,
|
|
4
4
|
useRequestInit
|
|
5
|
-
} from "../chunk-
|
|
6
|
-
import "../chunk-
|
|
5
|
+
} from "../chunk-BKGI64NY.mjs";
|
|
6
|
+
import "../chunk-QJGJPJUF.mjs";
|
|
7
7
|
import "../chunk-DH33ZDBG.mjs";
|
|
8
|
-
import "../chunk-
|
|
8
|
+
import "../chunk-NDBDIHHK.mjs";
|
|
9
|
+
import "../chunk-SE2OY7FZ.mjs";
|
|
9
10
|
import "../chunk-3SEO7S3Q.mjs";
|
|
10
11
|
export {
|
|
11
12
|
useApiClientConfig,
|
package/dist/requestUrl.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
__internal__requestUrl
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-W6BWZ3JJ.mjs";
|
|
4
|
+
import "./chunk-NDBDIHHK.mjs";
|
|
5
|
+
import "./chunk-SE2OY7FZ.mjs";
|
|
5
6
|
import "./chunk-3SEO7S3Q.mjs";
|
|
6
7
|
export {
|
|
7
8
|
__internal__requestUrl
|
package/dist/requestUrl.test.mjs
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
__internal__requestUrl
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-W6BWZ3JJ.mjs";
|
|
4
4
|
import {
|
|
5
5
|
store
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-NDBDIHHK.mjs";
|
|
7
|
+
import "./chunk-SE2OY7FZ.mjs";
|
|
7
8
|
import "./chunk-3SEO7S3Q.mjs";
|
|
8
9
|
|
|
9
10
|
// src/requestUrl.test.ts
|
|
@@ -0,0 +1,47 @@
|
|
|
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
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@readyfor/api-client-base",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.240.0-pr981.89e7f00",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -20,9 +20,6 @@
|
|
|
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"
|
|
@@ -31,9 +28,9 @@
|
|
|
31
28
|
"@types/qs": "6.9.18",
|
|
32
29
|
"@types/react": "19.1.2",
|
|
33
30
|
"@types/use-sync-external-store": "1.5.0",
|
|
34
|
-
"react": "
|
|
35
|
-
"swr": "
|
|
36
|
-
"use-sync-external-store": "
|
|
31
|
+
"react": "19.1.0",
|
|
32
|
+
"swr": "2.3.3",
|
|
33
|
+
"use-sync-external-store": "1.5.0"
|
|
37
34
|
},
|
|
38
35
|
"peerDependencies": {
|
|
39
36
|
"react": ">=18.x <=19.x",
|
|
@@ -63,5 +60,7 @@
|
|
|
63
60
|
"src"
|
|
64
61
|
]
|
|
65
62
|
},
|
|
66
|
-
"
|
|
67
|
-
|
|
63
|
+
"scripts": {
|
|
64
|
+
"build": "tsup"
|
|
65
|
+
}
|
|
66
|
+
}
|
package/dist/chunk-472P3XVV.mjs
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
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
|
-
};
|
package/dist/chunk-JOSDYCJN.mjs
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
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
|
-
};
|