@readyfor/api-client-base 1.70.0-pr1457.d1fc185 → 1.71.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/fetcher.d.ts CHANGED
@@ -1,23 +1,17 @@
1
1
  import { z } from "zod";
2
2
  //#region src/fetcher.d.ts
3
- type FetcherOptions = {
4
- /**
5
- * フェッチャー本体が後段でボディを読むため、ここでボディを消費してはいけない。
6
- */
7
- onResponse?: (res: Response) => void;
8
- };
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>;
3
+ declare const createJsonFetcher: <T = never>(schema: z.ZodType<T>, customRequestInit?: RequestInit) => (input: RequestInfo, requestInit?: RequestInit) => Promise<T>;
4
+ declare const createTextFetcher: (customRequestInit?: RequestInit) => (input: RequestInfo, requestInit?: RequestInit) => Promise<string>;
11
5
  type BlobFetcherResponse = {
12
6
  body: Blob;
13
7
  headers: Headers;
14
8
  };
15
- declare const createBlobFetcher: (customRequestInit?: RequestInit, options?: FetcherOptions) => (input: RequestInfo, requestInit?: RequestInit) => Promise<BlobFetcherResponse>;
9
+ declare const createBlobFetcher: (customRequestInit?: RequestInit) => (input: RequestInfo, requestInit?: RequestInit) => Promise<BlobFetcherResponse>;
16
10
  type FileOrBlobFetcherResponse = {
17
11
  body: File | Blob;
18
12
  headers: Headers;
19
13
  };
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>;
14
+ declare const createFileOrBlobFetcher: (customRequestInit?: RequestInit) => (input: RequestInfo, requestInit?: RequestInit) => Promise<FileOrBlobFetcherResponse>;
15
+ declare const createVoidFetcher: (customRequestInit?: RequestInit) => (input: RequestInfo, requestInit?: RequestInit) => Promise<void>;
22
16
  //#endregion
23
- export { BlobFetcherResponse, FetcherOptions, FileOrBlobFetcherResponse, createBlobFetcher, createFileOrBlobFetcher, createJsonFetcher, createTextFetcher, createVoidFetcher };
17
+ export { BlobFetcherResponse, FileOrBlobFetcherResponse, createBlobFetcher, createFileOrBlobFetcher, createJsonFetcher, createTextFetcher, createVoidFetcher };
package/dist/fetcher.js CHANGED
@@ -4,8 +4,7 @@ const require_apiClientConfigStore = require("./apiClientConfigStore.js");
4
4
  const require_apiError = require("./apiError.js");
5
5
  //#region src/fetcher.ts
6
6
  const defaultRequestInit = { credentials: "include" };
7
- const createJsonFetcher = (schema, customRequestInit = {}, options = {}) => (input, requestInit = {}) => fetch(input, require_utils_requestInit.mergeRequestInit(defaultRequestInit, require_utils_requestInit.mergeRequestInit(customRequestInit, requestInit))).then(async (res) => {
8
- options.onResponse?.(res);
7
+ const createJsonFetcher = (schema, customRequestInit = {}) => (input, requestInit = {}) => fetch(input, require_utils_requestInit.mergeRequestInit(defaultRequestInit, require_utils_requestInit.mergeRequestInit(customRequestInit, requestInit))).then(async (res) => {
9
8
  const text = await res.text();
10
9
  const body = text ? JSON.parse(text) : {};
11
10
  if (res.ok) return body;
@@ -24,8 +23,7 @@ const createJsonFetcher = (schema, customRequestInit = {}, options = {}) => (inp
24
23
  }
25
24
  throw result.error;
26
25
  });
27
- const createTextFetcher = (customRequestInit = {}, options = {}) => (input, requestInit = {}) => fetch(input, require_utils_requestInit.mergeRequestInit(defaultRequestInit, require_utils_requestInit.mergeRequestInit(customRequestInit, requestInit))).then(async (res) => {
28
- options.onResponse?.(res);
26
+ const createTextFetcher = (customRequestInit = {}) => (input, requestInit = {}) => fetch(input, require_utils_requestInit.mergeRequestInit(defaultRequestInit, require_utils_requestInit.mergeRequestInit(customRequestInit, requestInit))).then(async (res) => {
29
27
  const body = await res.text();
30
28
  if (res.ok) return body;
31
29
  throw new require_apiError.HTTPError(Object.values(require_apiError.errorStatusCode).includes(res.status) ? res.status : 999, body);
@@ -33,8 +31,7 @@ const createTextFetcher = (customRequestInit = {}, options = {}) => (input, requ
33
31
  require_apiClientConfigStore.store.getState().onError?.(error);
34
32
  throw error;
35
33
  });
36
- const createBlobFetcher = (customRequestInit = {}, options = {}) => (input, requestInit = {}) => fetch(input, require_utils_requestInit.mergeRequestInit(defaultRequestInit, require_utils_requestInit.mergeRequestInit(customRequestInit, requestInit))).then(async (res) => {
37
- options.onResponse?.(res);
34
+ const createBlobFetcher = (customRequestInit = {}) => (input, requestInit = {}) => fetch(input, require_utils_requestInit.mergeRequestInit(defaultRequestInit, require_utils_requestInit.mergeRequestInit(customRequestInit, requestInit))).then(async (res) => {
38
35
  const body = await res.blob();
39
36
  if (res.ok) return {
40
37
  body,
@@ -45,8 +42,7 @@ const createBlobFetcher = (customRequestInit = {}, options = {}) => (input, requ
45
42
  require_apiClientConfigStore.store.getState().onError?.(error);
46
43
  throw error;
47
44
  });
48
- const createFileOrBlobFetcher = (customRequestInit = {}, options = {}) => (input, requestInit = {}) => fetch(input, require_utils_requestInit.mergeRequestInit(defaultRequestInit, require_utils_requestInit.mergeRequestInit(customRequestInit, requestInit))).then(async (res) => {
49
- options.onResponse?.(res);
45
+ const createFileOrBlobFetcher = (customRequestInit = {}) => (input, requestInit = {}) => fetch(input, require_utils_requestInit.mergeRequestInit(defaultRequestInit, require_utils_requestInit.mergeRequestInit(customRequestInit, requestInit))).then(async (res) => {
50
46
  const body = await res.blob();
51
47
  if (res.ok) return {
52
48
  body,
@@ -57,8 +53,7 @@ const createFileOrBlobFetcher = (customRequestInit = {}, options = {}) => (input
57
53
  require_apiClientConfigStore.store.getState().onError?.(error);
58
54
  throw error;
59
55
  });
60
- const createVoidFetcher = (customRequestInit = {}, options = {}) => (input, requestInit = {}) => fetch(input, require_utils_requestInit.mergeRequestInit(defaultRequestInit, require_utils_requestInit.mergeRequestInit(customRequestInit, requestInit))).then(async (res) => {
61
- options.onResponse?.(res);
56
+ const createVoidFetcher = (customRequestInit = {}) => (input, requestInit = {}) => fetch(input, require_utils_requestInit.mergeRequestInit(defaultRequestInit, require_utils_requestInit.mergeRequestInit(customRequestInit, requestInit))).then(async (res) => {
62
57
  if (res.ok) return;
63
58
  throw new require_apiError.HTTPError(Object.values(require_apiError.errorStatusCode).includes(res.status) ? res.status : 999, await res.text());
64
59
  }).catch((error) => {
package/dist/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import { Store, createStore } from "./store.js";
2
2
  import { Config, RequestConfig, buildRequestInitWithDefaultConfig, setApiClientConfig, store } from "./apiClientConfigStore.js";
3
3
  import { ErrorStatusCode, HTTPError, errorStatusCode, errorTitle, getErrorStatus, getHttpErrorBody, getHttpErrorBodyReason, isHttpErrorWithStatus } from "./apiError.js";
4
- import { BlobFetcherResponse, FetcherOptions, FileOrBlobFetcherResponse, createBlobFetcher, createFileOrBlobFetcher, createJsonFetcher, createTextFetcher, createVoidFetcher } from "./fetcher.js";
4
+ import { BlobFetcherResponse, FileOrBlobFetcherResponse, createBlobFetcher, createFileOrBlobFetcher, createJsonFetcher, createTextFetcher, createVoidFetcher } from "./fetcher.js";
5
5
  import { __internal__requestUrl } from "./requestUrl.js";
6
6
  import { ForceDig, QueryPropsFor } from "./types.js";
7
7
  import { isZodError, schemaForType } from "./zod.js";
8
8
  import { mergeRequestInit } from "./utils/requestInit.js";
9
9
  import { mergeHeadersInit, toHeadersInit } from "./utils/headersInit.js";
10
- export { BlobFetcherResponse, Config, ErrorStatusCode, FetcherOptions, 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 };
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.mjs CHANGED
@@ -79,8 +79,7 @@ const getErrorStatus = (response) => {
79
79
  //#endregion
80
80
  //#region src/fetcher.ts
81
81
  const defaultRequestInit = { credentials: "include" };
82
- const createJsonFetcher = (schema, customRequestInit = {}, options = {}) => (input, requestInit = {}) => fetch(input, mergeRequestInit(defaultRequestInit, mergeRequestInit(customRequestInit, requestInit))).then(async (res) => {
83
- options.onResponse?.(res);
82
+ const createJsonFetcher = (schema, customRequestInit = {}) => (input, requestInit = {}) => fetch(input, mergeRequestInit(defaultRequestInit, mergeRequestInit(customRequestInit, requestInit))).then(async (res) => {
84
83
  const text = await res.text();
85
84
  const body = text ? JSON.parse(text) : {};
86
85
  if (res.ok) return body;
@@ -99,8 +98,7 @@ const createJsonFetcher = (schema, customRequestInit = {}, options = {}) => (inp
99
98
  }
100
99
  throw result.error;
101
100
  });
102
- const createTextFetcher = (customRequestInit = {}, options = {}) => (input, requestInit = {}) => fetch(input, mergeRequestInit(defaultRequestInit, mergeRequestInit(customRequestInit, requestInit))).then(async (res) => {
103
- options.onResponse?.(res);
101
+ const createTextFetcher = (customRequestInit = {}) => (input, requestInit = {}) => fetch(input, mergeRequestInit(defaultRequestInit, mergeRequestInit(customRequestInit, requestInit))).then(async (res) => {
104
102
  const body = await res.text();
105
103
  if (res.ok) return body;
106
104
  throw new HTTPError(Object.values(errorStatusCode).includes(res.status) ? res.status : 999, body);
@@ -108,8 +106,7 @@ const createTextFetcher = (customRequestInit = {}, options = {}) => (input, requ
108
106
  store.getState().onError?.(error);
109
107
  throw error;
110
108
  });
111
- const createBlobFetcher = (customRequestInit = {}, options = {}) => (input, requestInit = {}) => fetch(input, mergeRequestInit(defaultRequestInit, mergeRequestInit(customRequestInit, requestInit))).then(async (res) => {
112
- options.onResponse?.(res);
109
+ const createBlobFetcher = (customRequestInit = {}) => (input, requestInit = {}) => fetch(input, mergeRequestInit(defaultRequestInit, mergeRequestInit(customRequestInit, requestInit))).then(async (res) => {
113
110
  const body = await res.blob();
114
111
  if (res.ok) return {
115
112
  body,
@@ -120,8 +117,7 @@ const createBlobFetcher = (customRequestInit = {}, options = {}) => (input, requ
120
117
  store.getState().onError?.(error);
121
118
  throw error;
122
119
  });
123
- const createFileOrBlobFetcher = (customRequestInit = {}, options = {}) => (input, requestInit = {}) => fetch(input, mergeRequestInit(defaultRequestInit, mergeRequestInit(customRequestInit, requestInit))).then(async (res) => {
124
- options.onResponse?.(res);
120
+ const createFileOrBlobFetcher = (customRequestInit = {}) => (input, requestInit = {}) => fetch(input, mergeRequestInit(defaultRequestInit, mergeRequestInit(customRequestInit, requestInit))).then(async (res) => {
125
121
  const body = await res.blob();
126
122
  if (res.ok) return {
127
123
  body,
@@ -132,8 +128,7 @@ const createFileOrBlobFetcher = (customRequestInit = {}, options = {}) => (input
132
128
  store.getState().onError?.(error);
133
129
  throw error;
134
130
  });
135
- const createVoidFetcher = (customRequestInit = {}, options = {}) => (input, requestInit = {}) => fetch(input, mergeRequestInit(defaultRequestInit, mergeRequestInit(customRequestInit, requestInit))).then(async (res) => {
136
- options.onResponse?.(res);
131
+ const createVoidFetcher = (customRequestInit = {}) => (input, requestInit = {}) => fetch(input, mergeRequestInit(defaultRequestInit, mergeRequestInit(customRequestInit, requestInit))).then(async (res) => {
137
132
  if (res.ok) return;
138
133
  throw new HTTPError(Object.values(errorStatusCode).includes(res.status) ? res.status : 999, await res.text());
139
134
  }).catch((error) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@readyfor/api-client-base",
3
- "version": "1.70.0-pr1457.d1fc185",
3
+ "version": "1.71.0",
4
4
  "license": "SEE LICENSE IN LICENSE.md",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",