@readyfor/api-client-base 1.15.0-pr1261.b54f440 → 1.15.0-pr1262.7d84d2b
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/apiError.d.ts +10 -1
- package/dist/apiError.js +17 -2
- package/dist/apiError.mjs +9 -3
- package/dist/{chunk-AGGNJ74K.mjs → chunk-FNLUAQWC.mjs} +12 -0
- package/dist/{chunk-LWXQHOMM.mjs → chunk-OVR3ZT2S.mjs} +1 -1
- package/dist/fetcher.mjs +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +9 -3
- package/package.json +1 -1
package/dist/apiError.d.ts
CHANGED
|
@@ -26,6 +26,15 @@ declare class HTTPError extends Error {
|
|
|
26
26
|
constructor(status: ErrorStatusCode);
|
|
27
27
|
constructor(status: ErrorStatusCode, body: unknown);
|
|
28
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* duck typing で HTTPError の status を判定する。
|
|
31
|
+
* pnpm の strict isolation により instanceof HTTPError が
|
|
32
|
+
* 別バージョンのクラスと一致しないケースがあるため、
|
|
33
|
+
* プロパティベースで判定する。
|
|
34
|
+
*/
|
|
35
|
+
declare const isHttpErrorWithStatus: (error: unknown, status: number) => boolean;
|
|
36
|
+
declare const getHttpErrorBody: (error: unknown) => unknown;
|
|
37
|
+
declare const getHttpErrorBodyReason: (body: unknown) => string | undefined;
|
|
29
38
|
declare const getErrorStatus: (response: unknown) => ErrorStatusCode | undefined;
|
|
30
39
|
|
|
31
|
-
export { type ErrorStatusCode, HTTPError, errorStatusCode, errorTitle, getErrorStatus };
|
|
40
|
+
export { type ErrorStatusCode, HTTPError, errorStatusCode, errorTitle, getErrorStatus, getHttpErrorBody, getHttpErrorBodyReason, isHttpErrorWithStatus };
|
package/dist/apiError.js
CHANGED
|
@@ -21,7 +21,10 @@ __export(apiError_exports, {
|
|
|
21
21
|
HTTPError: () => HTTPError,
|
|
22
22
|
errorStatusCode: () => errorStatusCode,
|
|
23
23
|
errorTitle: () => errorTitle,
|
|
24
|
-
getErrorStatus: () => getErrorStatus
|
|
24
|
+
getErrorStatus: () => getErrorStatus,
|
|
25
|
+
getHttpErrorBody: () => getHttpErrorBody,
|
|
26
|
+
getHttpErrorBodyReason: () => getHttpErrorBodyReason,
|
|
27
|
+
isHttpErrorWithStatus: () => isHttpErrorWithStatus
|
|
25
28
|
});
|
|
26
29
|
module.exports = __toCommonJS(apiError_exports);
|
|
27
30
|
var import_zod = require("./zod");
|
|
@@ -71,6 +74,15 @@ class HTTPError extends Error {
|
|
|
71
74
|
this.body = body;
|
|
72
75
|
}
|
|
73
76
|
}
|
|
77
|
+
const isHttpErrorWithStatus = (error, status) => error instanceof Error && "status" in error && error.status === status;
|
|
78
|
+
const getHttpErrorBody = (error) => error instanceof Error && "body" in error ? error.body : void 0;
|
|
79
|
+
const getHttpErrorBodyReason = (body) => {
|
|
80
|
+
if (body !== null && typeof body === "object" && "reason" in body) {
|
|
81
|
+
const reason = body.reason;
|
|
82
|
+
return typeof reason === "string" ? reason : void 0;
|
|
83
|
+
}
|
|
84
|
+
return void 0;
|
|
85
|
+
};
|
|
74
86
|
const getErrorStatus = (response) => {
|
|
75
87
|
if (response instanceof Object && "status" in response && typeof response["status"] === "number") {
|
|
76
88
|
const status = Number(response["status"]);
|
|
@@ -86,5 +98,8 @@ const getErrorStatus = (response) => {
|
|
|
86
98
|
HTTPError,
|
|
87
99
|
errorStatusCode,
|
|
88
100
|
errorTitle,
|
|
89
|
-
getErrorStatus
|
|
101
|
+
getErrorStatus,
|
|
102
|
+
getHttpErrorBody,
|
|
103
|
+
getHttpErrorBodyReason,
|
|
104
|
+
isHttpErrorWithStatus
|
|
90
105
|
});
|
package/dist/apiError.mjs
CHANGED
|
@@ -2,12 +2,18 @@ import {
|
|
|
2
2
|
HTTPError,
|
|
3
3
|
errorStatusCode,
|
|
4
4
|
errorTitle,
|
|
5
|
-
getErrorStatus
|
|
6
|
-
|
|
5
|
+
getErrorStatus,
|
|
6
|
+
getHttpErrorBody,
|
|
7
|
+
getHttpErrorBodyReason,
|
|
8
|
+
isHttpErrorWithStatus
|
|
9
|
+
} from "./chunk-FNLUAQWC.mjs";
|
|
7
10
|
import "./chunk-JCZWXJBU.mjs";
|
|
8
11
|
export {
|
|
9
12
|
HTTPError,
|
|
10
13
|
errorStatusCode,
|
|
11
14
|
errorTitle,
|
|
12
|
-
getErrorStatus
|
|
15
|
+
getErrorStatus,
|
|
16
|
+
getHttpErrorBody,
|
|
17
|
+
getHttpErrorBodyReason,
|
|
18
|
+
isHttpErrorWithStatus
|
|
13
19
|
};
|
|
@@ -49,6 +49,15 @@ var HTTPError = class extends Error {
|
|
|
49
49
|
this.body = body;
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
|
+
var isHttpErrorWithStatus = (error, status) => error instanceof Error && "status" in error && error.status === status;
|
|
53
|
+
var getHttpErrorBody = (error) => error instanceof Error && "body" in error ? error.body : void 0;
|
|
54
|
+
var getHttpErrorBodyReason = (body) => {
|
|
55
|
+
if (body !== null && typeof body === "object" && "reason" in body) {
|
|
56
|
+
const reason = body.reason;
|
|
57
|
+
return typeof reason === "string" ? reason : void 0;
|
|
58
|
+
}
|
|
59
|
+
return void 0;
|
|
60
|
+
};
|
|
52
61
|
var getErrorStatus = (response) => {
|
|
53
62
|
if (response instanceof Object && "status" in response && typeof response["status"] === "number") {
|
|
54
63
|
const status = Number(response["status"]);
|
|
@@ -64,5 +73,8 @@ export {
|
|
|
64
73
|
errorStatusCode,
|
|
65
74
|
errorTitle,
|
|
66
75
|
HTTPError,
|
|
76
|
+
isHttpErrorWithStatus,
|
|
77
|
+
getHttpErrorBody,
|
|
78
|
+
getHttpErrorBodyReason,
|
|
67
79
|
getErrorStatus
|
|
68
80
|
};
|
package/dist/fetcher.mjs
CHANGED
|
@@ -4,8 +4,8 @@ import {
|
|
|
4
4
|
createJsonFetcher,
|
|
5
5
|
createTextFetcher,
|
|
6
6
|
createVoidFetcher
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-OVR3ZT2S.mjs";
|
|
8
|
+
import "./chunk-FNLUAQWC.mjs";
|
|
9
9
|
import "./chunk-NOC6G3HZ.mjs";
|
|
10
10
|
import "./chunk-TZUKIYFN.mjs";
|
|
11
11
|
import "./chunk-NYICHGY2.mjs";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { Config, RequestConfig, buildRequestInitWithDefaultConfig, setApiClientConfig, store } from './apiClientConfigStore.js';
|
|
2
|
-
export { ErrorStatusCode, HTTPError, errorStatusCode, errorTitle, getErrorStatus } from './apiError.js';
|
|
2
|
+
export { ErrorStatusCode, HTTPError, errorStatusCode, errorTitle, getErrorStatus, getHttpErrorBody, getHttpErrorBodyReason, isHttpErrorWithStatus } from './apiError.js';
|
|
3
3
|
export { BlobFetcherResponse, FileOrBlobFetcherResponse, createBlobFetcher, createFileOrBlobFetcher, createJsonFetcher, createTextFetcher, createVoidFetcher } from './fetcher.js';
|
|
4
4
|
export { __internal__requestUrl } from './requestUrl.js';
|
|
5
5
|
export { Store, createStore } from './store.js';
|
package/dist/index.mjs
CHANGED
|
@@ -4,13 +4,16 @@ import {
|
|
|
4
4
|
createJsonFetcher,
|
|
5
5
|
createTextFetcher,
|
|
6
6
|
createVoidFetcher
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-OVR3ZT2S.mjs";
|
|
8
8
|
import {
|
|
9
9
|
HTTPError,
|
|
10
10
|
errorStatusCode,
|
|
11
11
|
errorTitle,
|
|
12
|
-
getErrorStatus
|
|
13
|
-
|
|
12
|
+
getErrorStatus,
|
|
13
|
+
getHttpErrorBody,
|
|
14
|
+
getHttpErrorBodyReason,
|
|
15
|
+
isHttpErrorWithStatus
|
|
16
|
+
} from "./chunk-FNLUAQWC.mjs";
|
|
14
17
|
import {
|
|
15
18
|
__internal__requestUrl
|
|
16
19
|
} from "./chunk-GD4RTKUU.mjs";
|
|
@@ -47,6 +50,9 @@ export {
|
|
|
47
50
|
errorStatusCode,
|
|
48
51
|
errorTitle,
|
|
49
52
|
getErrorStatus,
|
|
53
|
+
getHttpErrorBody,
|
|
54
|
+
getHttpErrorBodyReason,
|
|
55
|
+
isHttpErrorWithStatus,
|
|
50
56
|
isZodError,
|
|
51
57
|
mergeHeadersInit,
|
|
52
58
|
mergeRequestInit,
|