@readyfor/api-client-base 1.78.0-pr1477.d27f308 → 1.78.0-pr1478.5e8d53d
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 +1 -1
- package/dist/apiClientConfigStore.d.ts +7 -6
- package/dist/apiError.d.ts +10 -9
- package/dist/fetcher.d.ts +10 -9
- package/dist/fetcher.js +5 -11
- package/dist/react/ApiClientConfigProvider.d.ts +4 -3
- package/dist/react/swr.d.ts +4 -3
- package/dist/react/useApiClientConfig.d.ts +5 -4
- package/dist/requestUrl.d.ts +3 -2
- package/dist/store.d.ts +4 -3
- package/dist/types.d.ts +4 -3
- package/dist/utils/headersInit.d.ts +4 -3
- package/dist/utils/requestInit.d.ts +3 -2
- package/dist/zod.d.ts +4 -3
- package/package.json +1 -1
|
@@ -15,7 +15,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
15
|
}
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
19
|
value: mod,
|
|
20
20
|
enumerable: true
|
|
21
21
|
}) : target, mod));
|
|
@@ -9,13 +9,14 @@ type DeserializeResponseConfig = {
|
|
|
9
9
|
type LoggingConfig = {
|
|
10
10
|
showsSchemaParseError?: boolean;
|
|
11
11
|
};
|
|
12
|
-
|
|
12
|
+
type RequestConfig = {
|
|
13
13
|
hostName?: string | ((path: string) => string);
|
|
14
14
|
defaultRequestInit?: RequestInit;
|
|
15
15
|
onError?: (error: unknown) => void;
|
|
16
16
|
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
//#endregion
|
|
17
|
+
type Config = RequestConfig & DeserializeResponseConfig & LoggingConfig;
|
|
18
|
+
declare const store: Store<Config>;
|
|
19
|
+
declare const setApiClientConfig: (config: Config) => void;
|
|
20
|
+
declare const buildRequestInitWithDefaultConfig: (customRequestInit?: RequestInit) => RequestInit;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { Config, RequestConfig, buildRequestInitWithDefaultConfig, setApiClientConfig, store };
|
package/dist/apiError.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
//#region src/apiError.d.ts
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
type ErrorStatusCode = 301 | 302 | 400 | 401 | 403 | 404 | 409 | 413 | 418 | 422 | 500 | 502 | 503 | 504 | 540 | 901 | 999;
|
|
3
|
+
declare const errorStatusCode: {
|
|
4
4
|
readonly MOVED_PERMANENTLY: 301;
|
|
5
5
|
readonly FOUND: 302;
|
|
6
6
|
readonly BAD_REQUEST: 400;
|
|
@@ -19,8 +19,8 @@ export declare const errorStatusCode: {
|
|
|
19
19
|
readonly ZOD_ERROR: 901;
|
|
20
20
|
readonly UNHANDLED_ERROR: 999;
|
|
21
21
|
};
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
declare const errorTitle: { [key in ErrorStatusCode]: string; };
|
|
23
|
+
declare class HTTPError extends Error {
|
|
24
24
|
status: ErrorStatusCode;
|
|
25
25
|
body?: unknown;
|
|
26
26
|
constructor(status: ErrorStatusCode);
|
|
@@ -32,8 +32,9 @@ export declare class HTTPError extends Error {
|
|
|
32
32
|
* 別バージョンのクラスと一致しないケースがあるため、
|
|
33
33
|
* プロパティベースで判定する。
|
|
34
34
|
*/
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
//#endregion
|
|
35
|
+
declare const isHttpErrorWithStatus: (error: unknown, status: number) => boolean;
|
|
36
|
+
declare const getHttpErrorBody: (error: unknown) => unknown;
|
|
37
|
+
declare const getHttpErrorBodyReason: (body: unknown) => string | undefined;
|
|
38
|
+
declare const getErrorStatus: (response: unknown) => ErrorStatusCode | undefined;
|
|
39
|
+
//#endregion
|
|
40
|
+
export { ErrorStatusCode, HTTPError, errorStatusCode, errorTitle, getErrorStatus, getHttpErrorBody, getHttpErrorBodyReason, isHttpErrorWithStatus };
|
package/dist/fetcher.d.ts
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
//#region src/fetcher.d.ts
|
|
3
|
-
|
|
3
|
+
type FetcherOptions = {
|
|
4
4
|
/**
|
|
5
5
|
* フェッチャー本体が後段でボディを読むため、ここでボディを消費してはいけない。
|
|
6
6
|
*/
|
|
7
7
|
onResponse?: (res: Response) => void;
|
|
8
8
|
};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
declare const createJsonFetcher: <T = never>(schema: z.ZodType<T>, customRequestInit?: RequestInit, options?: FetcherOptions) => (input: RequestInfo, requestInit?: RequestInit) => Promise<T>;
|
|
10
|
+
declare const createTextFetcher: (customRequestInit?: RequestInit, options?: FetcherOptions) => (input: RequestInfo, requestInit?: RequestInit) => Promise<string>;
|
|
11
|
+
type BlobFetcherResponse = {
|
|
12
12
|
body: Blob;
|
|
13
13
|
headers: Headers;
|
|
14
14
|
};
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
declare const createBlobFetcher: (customRequestInit?: RequestInit, options?: FetcherOptions) => (input: RequestInfo, requestInit?: RequestInit) => Promise<BlobFetcherResponse>;
|
|
16
|
+
type FileOrBlobFetcherResponse = {
|
|
17
17
|
body: File | Blob;
|
|
18
18
|
headers: Headers;
|
|
19
19
|
};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
//#endregion
|
|
20
|
+
declare const createFileOrBlobFetcher: (customRequestInit?: RequestInit, options?: FetcherOptions) => (input: RequestInfo, requestInit?: RequestInit) => Promise<FileOrBlobFetcherResponse>;
|
|
21
|
+
declare const createVoidFetcher: (customRequestInit?: RequestInit, options?: FetcherOptions) => (input: RequestInfo, requestInit?: RequestInit) => Promise<void>;
|
|
22
|
+
//#endregion
|
|
23
|
+
export { BlobFetcherResponse, FetcherOptions, FileOrBlobFetcherResponse, createBlobFetcher, createFileOrBlobFetcher, createJsonFetcher, createTextFetcher, createVoidFetcher };
|
package/dist/fetcher.js
CHANGED
|
@@ -9,8 +9,7 @@ const createJsonFetcher = (schema, customRequestInit = {}, options = {}) => (inp
|
|
|
9
9
|
const text = await res.text();
|
|
10
10
|
const body = text ? JSON.parse(text) : {};
|
|
11
11
|
if (res.ok) return body;
|
|
12
|
-
|
|
13
|
-
throw new require_apiError.HTTPError(code, body);
|
|
12
|
+
throw new require_apiError.HTTPError(Object.values(require_apiError.errorStatusCode).includes(res.status) ? res.status : 999, body);
|
|
14
13
|
}).catch((error) => {
|
|
15
14
|
require_apiClientConfigStore.store.getState().onError?.(error);
|
|
16
15
|
throw error;
|
|
@@ -29,8 +28,7 @@ const createTextFetcher = (customRequestInit = {}, options = {}) => (input, requ
|
|
|
29
28
|
options.onResponse?.(res);
|
|
30
29
|
const body = await res.text();
|
|
31
30
|
if (res.ok) return body;
|
|
32
|
-
|
|
33
|
-
throw new require_apiError.HTTPError(code, body);
|
|
31
|
+
throw new require_apiError.HTTPError(Object.values(require_apiError.errorStatusCode).includes(res.status) ? res.status : 999, body);
|
|
34
32
|
}).catch((error) => {
|
|
35
33
|
require_apiClientConfigStore.store.getState().onError?.(error);
|
|
36
34
|
throw error;
|
|
@@ -42,8 +40,7 @@ const createBlobFetcher = (customRequestInit = {}, options = {}) => (input, requ
|
|
|
42
40
|
body,
|
|
43
41
|
headers: res.headers
|
|
44
42
|
};
|
|
45
|
-
|
|
46
|
-
throw new require_apiError.HTTPError(code, body);
|
|
43
|
+
throw new require_apiError.HTTPError(Object.values(require_apiError.errorStatusCode).includes(res.status) ? res.status : 999, body);
|
|
47
44
|
}).catch((error) => {
|
|
48
45
|
require_apiClientConfigStore.store.getState().onError?.(error);
|
|
49
46
|
throw error;
|
|
@@ -55,8 +52,7 @@ const createFileOrBlobFetcher = (customRequestInit = {}, options = {}) => (input
|
|
|
55
52
|
body,
|
|
56
53
|
headers: res.headers
|
|
57
54
|
};
|
|
58
|
-
|
|
59
|
-
throw new require_apiError.HTTPError(code, body);
|
|
55
|
+
throw new require_apiError.HTTPError(Object.values(require_apiError.errorStatusCode).includes(res.status) ? res.status : 999, body);
|
|
60
56
|
}).catch((error) => {
|
|
61
57
|
require_apiClientConfigStore.store.getState().onError?.(error);
|
|
62
58
|
throw error;
|
|
@@ -64,9 +60,7 @@ const createFileOrBlobFetcher = (customRequestInit = {}, options = {}) => (input
|
|
|
64
60
|
const createVoidFetcher = (customRequestInit = {}, options = {}) => (input, requestInit = {}) => fetch(input, require_utils_requestInit.mergeRequestInit(defaultRequestInit, require_utils_requestInit.mergeRequestInit(customRequestInit, requestInit))).then(async (res) => {
|
|
65
61
|
options.onResponse?.(res);
|
|
66
62
|
if (res.ok) return;
|
|
67
|
-
|
|
68
|
-
const body = await res.text();
|
|
69
|
-
throw new require_apiError.HTTPError(code, body);
|
|
63
|
+
throw new require_apiError.HTTPError(Object.values(require_apiError.errorStatusCode).includes(res.status) ? res.status : 999, await res.text());
|
|
70
64
|
}).catch((error) => {
|
|
71
65
|
require_apiClientConfigStore.store.getState().onError?.(error);
|
|
72
66
|
throw error;
|
|
@@ -10,6 +10,7 @@ type Props = {
|
|
|
10
10
|
config: Configuration;
|
|
11
11
|
children: ReactNode;
|
|
12
12
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
//#endregion
|
|
13
|
+
declare const ApiClientConfigProvider: FC<Props>;
|
|
14
|
+
declare const useApiClientConfigContext: () => Store<Config>;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { ApiClientConfigProvider, useApiClientConfigContext };
|
package/dist/react/swr.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SWRConfiguration } from "swr";
|
|
2
2
|
//#region src/react/swr.d.ts
|
|
3
|
-
|
|
3
|
+
type Configuration<T> = SWRConfiguration<T> & {
|
|
4
4
|
/**
|
|
5
5
|
* fetchを止めるかどうかのオプション
|
|
6
6
|
* trueの場合: useSWRの第一引数にnullが渡されます
|
|
@@ -8,5 +8,6 @@ export type Configuration<T> = SWRConfiguration<T> & {
|
|
|
8
8
|
*/
|
|
9
9
|
shouldNotFetch?: boolean;
|
|
10
10
|
};
|
|
11
|
-
|
|
12
|
-
//#endregion
|
|
11
|
+
declare const createSwrConfig: (config?: SWRConfiguration) => SWRConfiguration;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { Configuration, createSwrConfig };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Config } from "../apiClientConfigStore.js";
|
|
2
2
|
//#region src/react/useApiClientConfig.d.ts
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
//#endregion
|
|
3
|
+
declare const useApiClientConfig: () => any;
|
|
4
|
+
declare const useApiClientConfigWithSelector: <T>(selector: (state: Config) => T) => T;
|
|
5
|
+
declare const useRequestInit: (customRequestInit?: RequestInit) => RequestInit;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { useApiClientConfig, useApiClientConfigWithSelector, useRequestInit };
|
package/dist/requestUrl.d.ts
CHANGED
|
@@ -5,5 +5,6 @@ type UrlArgs = {
|
|
|
5
5
|
path?: PathParams;
|
|
6
6
|
query?: QueryParams;
|
|
7
7
|
};
|
|
8
|
-
|
|
9
|
-
//#endregion
|
|
8
|
+
declare const __internal__requestUrl: (rawPath: string, { path: pathParams, query }?: UrlArgs) => string;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { __internal__requestUrl };
|
package/dist/store.d.ts
CHANGED
|
@@ -4,10 +4,11 @@ type GetState<T> = () => T;
|
|
|
4
4
|
type SetState<T> = (fn: (state: T) => T) => void;
|
|
5
5
|
type Subscribe = (listener: Listener) => Unsubscribe;
|
|
6
6
|
type Unsubscribe = () => void;
|
|
7
|
-
|
|
7
|
+
type Store<T> = {
|
|
8
8
|
getState: GetState<T>;
|
|
9
9
|
setState: SetState<T>;
|
|
10
10
|
subscribe: Subscribe;
|
|
11
11
|
};
|
|
12
|
-
|
|
13
|
-
//#endregion
|
|
12
|
+
declare const createStore: <T>(initialState: T) => Store<T>;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { Store, createStore };
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
//#region src/types.d.ts
|
|
2
|
-
|
|
2
|
+
type ForceDig<T, K extends string[]> = K extends [infer P extends string, ...infer Rest extends string[]] ? T extends { [key in P]?: infer S; } ? ForceDig<Exclude<S, undefined>, Rest> : Record<string, never> : T;
|
|
3
3
|
type RemoveBracket<T> = T extends `${infer S}[]` ? S : T;
|
|
4
|
-
|
|
5
|
-
//#endregion
|
|
4
|
+
type QueryPropsFor<T extends Record<string, unknown>> = { [K in keyof T as RemoveBracket<K>]: K extends `${string}[]` ? Exclude<T[K], undefined>[] : T[K]; };
|
|
5
|
+
//#endregion
|
|
6
|
+
export { ForceDig, QueryPropsFor };
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* @param baseHeadersInit 元となるHeadersInit
|
|
14
14
|
* @param overrideHeadersInit 上書きしたいヘッダーを含むHeadersInit。
|
|
15
15
|
*/
|
|
16
|
-
|
|
16
|
+
declare const mergeHeadersInit: (baseHeadersInit: HeadersInit, overrideHeadersInit: HeadersInit) => HeadersInit;
|
|
17
17
|
/**
|
|
18
18
|
* OpenAPI から生成されたヘッダーオブジェクトを HeadersInit に変換する
|
|
19
19
|
*
|
|
@@ -24,5 +24,6 @@ export declare const mergeHeadersInit: (baseHeadersInit: HeadersInit, overrideHe
|
|
|
24
24
|
* @param headers OpenAPI から生成されたヘッダーオブジェクト
|
|
25
25
|
* @returns HeadersInit として使用可能なオブジェクト
|
|
26
26
|
*/
|
|
27
|
-
|
|
28
|
-
//#endregion
|
|
27
|
+
declare const toHeadersInit: (headers: Record<string, string | number | boolean | undefined>) => HeadersInit;
|
|
28
|
+
//#endregion
|
|
29
|
+
export { mergeHeadersInit, toHeadersInit };
|
|
@@ -5,5 +5,6 @@
|
|
|
5
5
|
* ただし、`headers`フィールドに関しては、`base`と`override`両方に有効なHeadersInitがある場合に限り、
|
|
6
6
|
* `mergeHeadersInit`を使用してヘッダーの内容をマージする
|
|
7
7
|
*/
|
|
8
|
-
|
|
9
|
-
//#endregion
|
|
8
|
+
declare const mergeRequestInit: ({ headers: baseHeaders, ...base }: RequestInit, { headers: overrideHeaders, ...override }: RequestInit) => RequestInit;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { mergeRequestInit };
|
package/dist/zod.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
//#region src/zod.d.ts
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
//#endregion
|
|
3
|
+
declare const schemaForType: <T>() => <S extends z.ZodType<T>>(arg: S) => S;
|
|
4
|
+
declare const isZodError: (obj: unknown) => obj is z.ZodError;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { isZodError, schemaForType };
|