@readyfor/api-client-base 0.156.0-pr911.80e14d4 → 0.156.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.
@@ -1,4 +1,5 @@
1
1
  import { Store } from './store.mjs';
2
+ import { UrlConfig } from './requestUrl.mjs';
2
3
 
3
4
  type DeserializeResponseConfig = {
4
5
  forceDeserializeResponse?: false;
@@ -9,12 +10,8 @@ type DeserializeResponseConfig = {
9
10
  type LoggingConfig = {
10
11
  showsSchemaParseError?: boolean;
11
12
  };
12
- type RequestConfig = {
13
- hostName?: string | ((path: string) => string);
14
- defaultRequestInit?: RequestInit;
15
- };
16
- type Config = RequestConfig & DeserializeResponseConfig & LoggingConfig;
13
+ type Config = UrlConfig & DeserializeResponseConfig & LoggingConfig;
17
14
  declare const store: Store<Config>;
18
15
  declare const setApiClientConfig: (config: Config) => void;
19
16
 
20
- export { type Config, type RequestConfig, setApiClientConfig, store };
17
+ export { type Config, setApiClientConfig, store };
@@ -1,4 +1,5 @@
1
1
  import { Store } from './store.js';
2
+ import { UrlConfig } from './requestUrl.js';
2
3
 
3
4
  type DeserializeResponseConfig = {
4
5
  forceDeserializeResponse?: false;
@@ -9,12 +10,8 @@ type DeserializeResponseConfig = {
9
10
  type LoggingConfig = {
10
11
  showsSchemaParseError?: boolean;
11
12
  };
12
- type RequestConfig = {
13
- hostName?: string | ((path: string) => string);
14
- defaultRequestInit?: RequestInit;
15
- };
16
- type Config = RequestConfig & DeserializeResponseConfig & LoggingConfig;
13
+ type Config = UrlConfig & DeserializeResponseConfig & LoggingConfig;
17
14
  declare const store: Store<Config>;
18
15
  declare const setApiClientConfig: (config: Config) => void;
19
16
 
20
- export { type Config, type RequestConfig, setApiClientConfig, store };
17
+ export { type Config, setApiClientConfig, store };
@@ -0,0 +1,25 @@
1
+ import {
2
+ useApiClientConfigContext
3
+ } from "./chunk-VVRQ7D57.mjs";
4
+
5
+ // src/react/useApiClientConfig.ts
6
+ import { useSyncExternalStore } from "use-sync-external-store/shim";
7
+ import { useSyncExternalStoreWithSelector } from "use-sync-external-store/shim/with-selector";
8
+ var useApiClientConfig = () => {
9
+ const store = useApiClientConfigContext();
10
+ return useSyncExternalStore(store.subscribe, store.getState);
11
+ };
12
+ var useApiClientConfigWithSelector = (selector) => {
13
+ const store = useApiClientConfigContext();
14
+ return useSyncExternalStoreWithSelector(
15
+ store.subscribe,
16
+ store.getState,
17
+ null,
18
+ selector
19
+ );
20
+ };
21
+
22
+ export {
23
+ useApiClientConfig,
24
+ useApiClientConfigWithSelector
25
+ };
package/dist/index.d.mts CHANGED
@@ -1,7 +1,7 @@
1
- export { Config, RequestConfig, setApiClientConfig, store } from './apiClientConfigStore.mjs';
1
+ export { Config, 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
- export { __internal__requestUrl } from './requestUrl.mjs';
4
+ export { UrlConfig, __internal__requestUrl } from './requestUrl.mjs';
5
5
  export { Store, createStore } from './store.mjs';
6
6
  export { ForceDig, QueryPropsFor } from './types.mjs';
7
7
  export { isZodError, schemaForType } from './zod.mjs';
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- export { Config, RequestConfig, setApiClientConfig, store } from './apiClientConfigStore.js';
1
+ export { Config, 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
- export { __internal__requestUrl } from './requestUrl.js';
4
+ export { UrlConfig, __internal__requestUrl } from './requestUrl.js';
5
5
  export { Store, createStore } from './store.js';
6
6
  export { ForceDig, QueryPropsFor } from './types.js';
7
7
  export { isZodError, schemaForType } from './zod.js';
@@ -2,6 +2,7 @@ import { FC, ReactNode } from 'react';
2
2
  import { Config } from '../apiClientConfigStore.mjs';
3
3
  import { Store } from '../store.mjs';
4
4
  import { SWRConfiguration } from 'swr';
5
+ import '../requestUrl.mjs';
5
6
 
6
7
  type Configuration = Config & {
7
8
  swr?: SWRConfiguration;
@@ -2,6 +2,7 @@ import { FC, ReactNode } from 'react';
2
2
  import { Config } from '../apiClientConfigStore.js';
3
3
  import { Store } from '../store.js';
4
4
  import { SWRConfiguration } from 'swr';
5
+ import '../requestUrl.js';
5
6
 
6
7
  type Configuration = Config & {
7
8
  swr?: SWRConfiguration;
@@ -1,7 +1,8 @@
1
1
  export { ApiClientConfigProvider, useApiClientConfigContext } from './ApiClientConfigProvider.mjs';
2
2
  export { Configuration, createSwrConfig } from './swr.mjs';
3
- export { useApiClientConfig, useApiClientConfigWithSelector, useRequestInit } from './useApiClientConfig.mjs';
3
+ export { useApiClientConfig, useApiClientConfigWithSelector } from './useApiClientConfig.mjs';
4
4
  import 'react';
5
5
  import '../apiClientConfigStore.mjs';
6
6
  import '../store.mjs';
7
+ import '../requestUrl.mjs';
7
8
  import 'swr';
@@ -1,7 +1,8 @@
1
1
  export { ApiClientConfigProvider, useApiClientConfigContext } from './ApiClientConfigProvider.js';
2
2
  export { Configuration, createSwrConfig } from './swr.js';
3
- export { useApiClientConfig, useApiClientConfigWithSelector, useRequestInit } from './useApiClientConfig.js';
3
+ export { useApiClientConfig, useApiClientConfigWithSelector } from './useApiClientConfig.js';
4
4
  import 'react';
5
5
  import '../apiClientConfigStore.js';
6
6
  import '../store.js';
7
+ import '../requestUrl.js';
7
8
  import 'swr';
@@ -24,8 +24,7 @@ __export(react_exports, {
24
24
  createSwrConfig: () => createSwrConfig,
25
25
  useApiClientConfig: () => useApiClientConfig,
26
26
  useApiClientConfigContext: () => useApiClientConfigContext,
27
- useApiClientConfigWithSelector: () => useApiClientConfigWithSelector,
28
- useRequestInit: () => useRequestInit
27
+ useApiClientConfigWithSelector: () => useApiClientConfigWithSelector
29
28
  });
30
29
  module.exports = __toCommonJS(react_exports);
31
30
 
@@ -90,7 +89,6 @@ var useApiClientConfigContext = () => (0, import_react2.useContext)(ApiClientCon
90
89
  // src/react/useApiClientConfig.ts
91
90
  var import_shim = require("use-sync-external-store/shim");
92
91
  var import_with_selector = require("use-sync-external-store/shim/with-selector");
93
- var import_react3 = require("react");
94
92
  var useApiClientConfig = () => {
95
93
  const store2 = useApiClientConfigContext();
96
94
  return (0, import_shim.useSyncExternalStore)(store2.subscribe, store2.getState);
@@ -104,47 +102,11 @@ var useApiClientConfigWithSelector = (selector) => {
104
102
  selector
105
103
  );
106
104
  };
107
- var useRequestInit = (customRequestInit = {}) => {
108
- 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
- return (0, import_react3.useMemo)(
132
- () => keys.reduce(
133
- (acc, key) => ({
134
- ...acc,
135
- [key]: get(key)
136
- }),
137
- {}
138
- ),
139
- [keys, get]
140
- );
141
- };
142
105
  // Annotate the CommonJS export names for ESM import in node:
143
106
  0 && (module.exports = {
144
107
  ApiClientConfigProvider,
145
108
  createSwrConfig,
146
109
  useApiClientConfig,
147
110
  useApiClientConfigContext,
148
- useApiClientConfigWithSelector,
149
- useRequestInit
111
+ useApiClientConfigWithSelector
150
112
  });
@@ -1,8 +1,7 @@
1
1
  import {
2
2
  useApiClientConfig,
3
- useApiClientConfigWithSelector,
4
- useRequestInit
5
- } from "../chunk-4D7SUTWE.mjs";
3
+ useApiClientConfigWithSelector
4
+ } from "../chunk-H3C7VSOJ.mjs";
6
5
  import {
7
6
  ApiClientConfigProvider,
8
7
  useApiClientConfigContext
@@ -17,6 +16,5 @@ export {
17
16
  createSwrConfig,
18
17
  useApiClientConfig,
19
18
  useApiClientConfigContext,
20
- useApiClientConfigWithSelector,
21
- useRequestInit
19
+ useApiClientConfigWithSelector
22
20
  };
@@ -1,8 +1,8 @@
1
1
  import { Config } from '../apiClientConfigStore.mjs';
2
2
  import '../store.mjs';
3
+ import '../requestUrl.mjs';
3
4
 
4
5
  declare const useApiClientConfig: () => Config;
5
6
  declare const useApiClientConfigWithSelector: <T>(selector: (state: Config) => T) => T;
6
- declare const useRequestInit: (customRequestInit?: RequestInit) => RequestInit;
7
7
 
8
- export { useApiClientConfig, useApiClientConfigWithSelector, useRequestInit };
8
+ export { useApiClientConfig, useApiClientConfigWithSelector };
@@ -1,8 +1,8 @@
1
1
  import { Config } from '../apiClientConfigStore.js';
2
2
  import '../store.js';
3
+ import '../requestUrl.js';
3
4
 
4
5
  declare const useApiClientConfig: () => Config;
5
6
  declare const useApiClientConfigWithSelector: <T>(selector: (state: Config) => T) => T;
6
- declare const useRequestInit: (customRequestInit?: RequestInit) => RequestInit;
7
7
 
8
- export { useApiClientConfig, useApiClientConfigWithSelector, useRequestInit };
8
+ export { useApiClientConfig, useApiClientConfigWithSelector };
@@ -21,8 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var useApiClientConfig_exports = {};
22
22
  __export(useApiClientConfig_exports, {
23
23
  useApiClientConfig: () => useApiClientConfig,
24
- useApiClientConfigWithSelector: () => useApiClientConfigWithSelector,
25
- useRequestInit: () => useRequestInit
24
+ useApiClientConfigWithSelector: () => useApiClientConfigWithSelector
26
25
  });
27
26
  module.exports = __toCommonJS(useApiClientConfig_exports);
28
27
 
@@ -67,7 +66,6 @@ var useApiClientConfigContext = () => (0, import_react2.useContext)(ApiClientCon
67
66
  // src/react/useApiClientConfig.ts
68
67
  var import_shim = require("use-sync-external-store/shim");
69
68
  var import_with_selector = require("use-sync-external-store/shim/with-selector");
70
- var import_react3 = require("react");
71
69
  var useApiClientConfig = () => {
72
70
  const store2 = useApiClientConfigContext();
73
71
  return (0, import_shim.useSyncExternalStore)(store2.subscribe, store2.getState);
@@ -81,44 +79,8 @@ var useApiClientConfigWithSelector = (selector) => {
81
79
  selector
82
80
  );
83
81
  };
84
- var useRequestInit = (customRequestInit = {}) => {
85
- 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
- return (0, import_react3.useMemo)(
109
- () => keys.reduce(
110
- (acc, key) => ({
111
- ...acc,
112
- [key]: get(key)
113
- }),
114
- {}
115
- ),
116
- [keys, get]
117
- );
118
- };
119
82
  // Annotate the CommonJS export names for ESM import in node:
120
83
  0 && (module.exports = {
121
84
  useApiClientConfig,
122
- useApiClientConfigWithSelector,
123
- useRequestInit
85
+ useApiClientConfigWithSelector
124
86
  });
@@ -1,14 +1,12 @@
1
1
  import {
2
2
  useApiClientConfig,
3
- useApiClientConfigWithSelector,
4
- useRequestInit
5
- } from "../chunk-4D7SUTWE.mjs";
3
+ useApiClientConfigWithSelector
4
+ } from "../chunk-H3C7VSOJ.mjs";
6
5
  import "../chunk-VVRQ7D57.mjs";
7
6
  import "../chunk-DHYJM4DQ.mjs";
8
7
  import "../chunk-472P3XVV.mjs";
9
8
  import "../chunk-3SEO7S3Q.mjs";
10
9
  export {
11
10
  useApiClientConfig,
12
- useApiClientConfigWithSelector,
13
- useRequestInit
11
+ useApiClientConfigWithSelector
14
12
  };
@@ -1,3 +1,6 @@
1
+ type UrlConfig = {
2
+ hostName?: string | ((path: string) => string);
3
+ };
1
4
  declare function __internal__requestUrl(...args: any[]): string;
2
5
 
3
- export { __internal__requestUrl };
6
+ export { type UrlConfig, __internal__requestUrl };
@@ -1,3 +1,6 @@
1
+ type UrlConfig = {
2
+ hostName?: string | ((path: string) => string);
3
+ };
1
4
  declare function __internal__requestUrl(...args: any[]): string;
2
5
 
3
- export { __internal__requestUrl };
6
+ export { type UrlConfig, __internal__requestUrl };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@readyfor/api-client-base",
3
- "version": "0.156.0-pr911.80e14d4",
3
+ "version": "0.156.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.13.1",
25
28
  "zod": "3.23.8"
@@ -60,7 +63,5 @@
60
63
  "src"
61
64
  ]
62
65
  },
63
- "scripts": {
64
- "build": "tsup"
65
- }
66
- }
66
+ "gitHead": "73b4ee95269b24cc802c1457a331e9e44c8b9e27"
67
+ }
@@ -1,62 +0,0 @@
1
- import {
2
- useApiClientConfigContext
3
- } from "./chunk-VVRQ7D57.mjs";
4
-
5
- // src/react/useApiClientConfig.ts
6
- import { useSyncExternalStore } from "use-sync-external-store/shim";
7
- import { useSyncExternalStoreWithSelector } from "use-sync-external-store/shim/with-selector";
8
- import { useCallback, useMemo } from "react";
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
- };