kayto_ts 0.1.6 → 0.1.7
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/index.js +1 -4
- package/dist/types.d.ts +4 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -97,9 +97,6 @@ export function clientApi(config = {}) {
|
|
|
97
97
|
const responses = {
|
|
98
98
|
[response.status]: bodyResult.result,
|
|
99
99
|
};
|
|
100
|
-
const result = {
|
|
101
|
-
responses,
|
|
102
|
-
};
|
|
103
100
|
if (!response.ok) {
|
|
104
101
|
return {
|
|
105
102
|
ok: false,
|
|
@@ -107,7 +104,7 @@ export function clientApi(config = {}) {
|
|
|
107
104
|
response,
|
|
108
105
|
};
|
|
109
106
|
}
|
|
110
|
-
return { ok: true,
|
|
107
|
+
return { ok: true, responses, response };
|
|
111
108
|
};
|
|
112
109
|
return {
|
|
113
110
|
get: (path, ...args) => request("get", path, args[0]),
|
package/dist/types.d.ts
CHANGED
|
@@ -26,13 +26,13 @@ export type ClientError = {
|
|
|
26
26
|
cause?: unknown;
|
|
27
27
|
status?: number;
|
|
28
28
|
};
|
|
29
|
-
export type FetchResult<
|
|
29
|
+
export type FetchResult<E, Err = ClientError> = {
|
|
30
30
|
ok: true;
|
|
31
|
-
|
|
31
|
+
responses: EndpointResponseMap<E>;
|
|
32
32
|
response: Response;
|
|
33
33
|
} | {
|
|
34
34
|
ok: false;
|
|
35
|
-
error:
|
|
35
|
+
error: Err;
|
|
36
36
|
response?: Response;
|
|
37
37
|
};
|
|
38
38
|
export type Result<R, E = string> = {
|
|
@@ -55,7 +55,7 @@ export type RequestInput<E> = RequestOptions & ([EndpointParams<E>] extends [nev
|
|
|
55
55
|
});
|
|
56
56
|
export type RequestArgs<E> = [EndpointBody<E>] extends [never] ? [input?: RequestInput<E>] : [input: RequestInput<E>];
|
|
57
57
|
export type Api<Endpoints extends EndpointsMap> = {
|
|
58
|
-
[Method in keyof EndpointsMap]: <Path extends Extract<keyof Endpoints[Method], string>>(path: Path, ...args: RequestArgs<EndpointOf<Endpoints, Method, Path>>) => Promise<FetchResult<
|
|
58
|
+
[Method in keyof EndpointsMap]: <Path extends Extract<keyof Endpoints[Method], string>>(path: Path, ...args: RequestArgs<EndpointOf<Endpoints, Method, Path>>) => Promise<FetchResult<EndpointOf<Endpoints, Method, Path>>>;
|
|
59
59
|
};
|
|
60
60
|
export type RequestHookContext = {
|
|
61
61
|
method: keyof EndpointsMap;
|