@geekmidas/client 0.1.0 → 0.1.1
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/auth-fetcher.d.cts +1 -1
- package/dist/auth-fetcher.d.mts +1 -1
- package/dist/endpoint-hooks.d.cts +1 -1
- package/dist/endpoint-hooks.d.mts +1 -1
- package/dist/fetcher.d.cts +1 -1
- package/dist/fetcher.d.mts +1 -1
- package/dist/openapi-hooks.d.cts +4 -4
- package/dist/openapi-hooks.d.mts +1 -1
- package/dist/react-query.d.cts +8 -8
- package/dist/react-query.d.mts +1 -1
- package/dist/{types-CyMkwV3g.d.mts → types-Cdv1XAWr.d.mts} +4 -4
- package/dist/{types-DVVUpwI4.d.cts → types-D4OSWveN.d.cts} +4 -4
- package/dist/types.d.cts +1 -1
- package/dist/types.d.mts +1 -1
- package/package.json +3 -3
- package/src/types.ts +16 -14
package/dist/auth-fetcher.d.cts
CHANGED
package/dist/auth-fetcher.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ExtractEndpointResponse, FilteredRequestConfig, IsConfigRequired, MutationEndpoint, QueryEndpoint, TypedApiFunction } from "./types-
|
|
1
|
+
import { ExtractEndpointResponse, FilteredRequestConfig, IsConfigRequired, MutationEndpoint, QueryEndpoint, TypedApiFunction } from "./types-D4OSWveN.cjs";
|
|
2
2
|
import { QueryClient, UseMutationOptions, UseQueryOptions, useMutation, useQuery } from "@tanstack/react-query";
|
|
3
3
|
|
|
4
4
|
//#region src/endpoint-hooks.d.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ExtractEndpointResponse, FilteredRequestConfig, IsConfigRequired, MutationEndpoint, QueryEndpoint, TypedApiFunction } from "./types-
|
|
1
|
+
import { ExtractEndpointResponse, FilteredRequestConfig, IsConfigRequired, MutationEndpoint, QueryEndpoint, TypedApiFunction } from "./types-Cdv1XAWr.mjs";
|
|
2
2
|
import { QueryClient, UseMutationOptions, UseQueryOptions, useMutation, useQuery } from "@tanstack/react-query";
|
|
3
3
|
|
|
4
4
|
//#region src/endpoint-hooks.d.ts
|
package/dist/fetcher.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ExtractEndpointResponse, FetcherOptions, FilteredRequestConfig, TypedEndpoint } from "./types-
|
|
1
|
+
import { ExtractEndpointResponse, FetcherOptions, FilteredRequestConfig, TypedEndpoint } from "./types-D4OSWveN.cjs";
|
|
2
2
|
|
|
3
3
|
//#region src/fetcher.d.ts
|
|
4
4
|
declare class TypedFetcher<Paths> {
|
package/dist/fetcher.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ExtractEndpointResponse, FetcherOptions, FilteredRequestConfig, TypedEndpoint } from "./types-
|
|
1
|
+
import { ExtractEndpointResponse, FetcherOptions, FilteredRequestConfig, TypedEndpoint } from "./types-Cdv1XAWr.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/fetcher.d.ts
|
|
4
4
|
declare class TypedFetcher<Paths> {
|
package/dist/openapi-hooks.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FetcherOptions } from "./types-
|
|
2
|
-
import * as
|
|
1
|
+
import { FetcherOptions } from "./types-D4OSWveN.cjs";
|
|
2
|
+
import * as _tanstack_react_query8 from "@tanstack/react-query";
|
|
3
3
|
import { UseMutationOptions, UseQueryOptions } from "@tanstack/react-query";
|
|
4
4
|
|
|
5
5
|
//#region src/openapi-hooks.d.ts
|
|
@@ -91,8 +91,8 @@ interface OperationRegistry {
|
|
|
91
91
|
declare function createOpenAPIHooks<Paths>(options?: FetcherOptions & {
|
|
92
92
|
operations?: OperationRegistry;
|
|
93
93
|
}): {
|
|
94
|
-
useQuery: <OpId extends OperationsByMethod<Paths, "get">>(operationId: OpId, config?: RemoveNever<OperationParams<Paths, OpId>>, options?: Omit<UseQueryOptions<OperationResponse<Paths, OpId>, Error>, "queryKey" | "queryFn">) =>
|
|
95
|
-
useMutation: <OpId extends Exclude<OperationId<Paths>, OperationsByMethod<Paths, "get">>>(operationId: OpId, options?: Omit<UseMutationOptions<OperationResponse<Paths, OpId>, Error, RemoveNever<OperationParams<Paths, OpId>>>, "mutationFn">) =>
|
|
94
|
+
useQuery: <OpId extends OperationsByMethod<Paths, "get">>(operationId: OpId, config?: RemoveNever<OperationParams<Paths, OpId>>, options?: Omit<UseQueryOptions<OperationResponse<Paths, OpId>, Error>, "queryKey" | "queryFn">) => _tanstack_react_query8.UseQueryResult<_tanstack_react_query8.NoInfer<OperationResponse<Paths, OpId>>, Error>;
|
|
95
|
+
useMutation: <OpId extends Exclude<OperationId<Paths>, OperationsByMethod<Paths, "get">>>(operationId: OpId, options?: Omit<UseMutationOptions<OperationResponse<Paths, OpId>, Error, RemoveNever<OperationParams<Paths, OpId>>>, "mutationFn">) => _tanstack_react_query8.UseMutationResult<OperationResponse<Paths, OpId>, Error, RemoveNever<OperationParams<Paths, OpId>>, unknown>;
|
|
96
96
|
};
|
|
97
97
|
//#endregion
|
|
98
98
|
export { createOpenAPIHooks };
|
package/dist/openapi-hooks.d.mts
CHANGED
package/dist/react-query.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ExtractEndpointResponse, FetcherOptions, FilteredRequestConfig, MutationEndpoint, QueryEndpoint, TypedEndpoint } from "./types-
|
|
2
|
-
import * as
|
|
1
|
+
import { ExtractEndpointResponse, FetcherOptions, FilteredRequestConfig, MutationEndpoint, QueryEndpoint, TypedEndpoint } from "./types-D4OSWveN.cjs";
|
|
2
|
+
import * as _tanstack_react_query0 from "@tanstack/react-query";
|
|
3
3
|
import { QueryClient, UseInfiniteQueryOptions, UseMutationOptions, UseQueryOptions } from "@tanstack/react-query";
|
|
4
4
|
|
|
5
5
|
//#region src/react-query.d.ts
|
|
@@ -10,15 +10,15 @@ declare class TypedQueryClient<Paths> {
|
|
|
10
10
|
private fetcher;
|
|
11
11
|
private queryClient?;
|
|
12
12
|
constructor(options?: TypedQueryClientOptions);
|
|
13
|
-
useQuery<T extends QueryEndpoint<Paths>>(endpoint: T, config?: FilteredRequestConfig<Paths, T>, options?: Omit<UseQueryOptions<ExtractEndpointResponse<Paths, T>, Response>, 'queryKey' | 'queryFn'>):
|
|
14
|
-
useMutation<T extends MutationEndpoint<Paths>>(endpoint: T, options?: Omit<UseMutationOptions<ExtractEndpointResponse<Paths, T>, Response, FilteredRequestConfig<Paths, T>>, 'mutationFn'>):
|
|
13
|
+
useQuery<T extends QueryEndpoint<Paths>>(endpoint: T, config?: FilteredRequestConfig<Paths, T>, options?: Omit<UseQueryOptions<ExtractEndpointResponse<Paths, T>, Response>, 'queryKey' | 'queryFn'>): _tanstack_react_query0.UseQueryResult<_tanstack_react_query0.NoInfer<ExtractEndpointResponse<Paths, T>>, Response>;
|
|
14
|
+
useMutation<T extends MutationEndpoint<Paths>>(endpoint: T, options?: Omit<UseMutationOptions<ExtractEndpointResponse<Paths, T>, Response, FilteredRequestConfig<Paths, T>>, 'mutationFn'>): _tanstack_react_query0.UseMutationResult<ExtractEndpointResponse<Paths, T>, Response, FilteredRequestConfig<Paths, T>, unknown>;
|
|
15
15
|
useInfiniteQuery<T extends QueryEndpoint<Paths>, TPageData = ExtractEndpointResponse<Paths, T>, TPageParam = unknown>(endpoint: T, options: Omit<UseInfiniteQueryOptions<TPageData, Response, {
|
|
16
16
|
pages: TPageData[];
|
|
17
17
|
pageParams: TPageParam[];
|
|
18
18
|
}, unknown[], TPageParam>, 'queryKey' | 'queryFn' | 'getNextPageParam' | 'initialPageParam'> & {
|
|
19
19
|
getNextPageParam: (lastPage: TPageData, allPages: TPageData[], lastPageParam: TPageParam, allPageParams: TPageParam[]) => TPageParam | undefined;
|
|
20
20
|
initialPageParam: TPageParam;
|
|
21
|
-
}, config?: FilteredRequestConfig<Paths, T>):
|
|
21
|
+
}, config?: FilteredRequestConfig<Paths, T>): _tanstack_react_query0.UseInfiniteQueryResult<{
|
|
22
22
|
pages: TPageData[];
|
|
23
23
|
pageParams: TPageParam[];
|
|
24
24
|
}, Response>;
|
|
@@ -47,15 +47,15 @@ declare class TypedQueryClient<Paths> {
|
|
|
47
47
|
setQueryClient(queryClient: QueryClient): void;
|
|
48
48
|
}
|
|
49
49
|
declare function createTypedQueryClient<Paths>(options?: TypedQueryClientOptions): TypedQueryClient<Paths>;
|
|
50
|
-
declare function useTypedQuery<Paths, T extends QueryEndpoint<Paths>>(client: TypedQueryClient<Paths>, endpoint: T, config?: FilteredRequestConfig<Paths, T>, options?: Omit<UseQueryOptions<ExtractEndpointResponse<Paths, T>, Response>, 'queryKey' | 'queryFn'>):
|
|
51
|
-
declare function useTypedMutation<Paths, T extends MutationEndpoint<Paths>>(client: TypedQueryClient<Paths>, endpoint: T, options?: Omit<UseMutationOptions<ExtractEndpointResponse<Paths, T>, Response, FilteredRequestConfig<Paths, T>>, 'mutationFn'>):
|
|
50
|
+
declare function useTypedQuery<Paths, T extends QueryEndpoint<Paths>>(client: TypedQueryClient<Paths>, endpoint: T, config?: FilteredRequestConfig<Paths, T>, options?: Omit<UseQueryOptions<ExtractEndpointResponse<Paths, T>, Response>, 'queryKey' | 'queryFn'>): _tanstack_react_query0.UseQueryResult<_tanstack_react_query0.NoInfer<ExtractEndpointResponse<Paths, T>>, Response>;
|
|
51
|
+
declare function useTypedMutation<Paths, T extends MutationEndpoint<Paths>>(client: TypedQueryClient<Paths>, endpoint: T, options?: Omit<UseMutationOptions<ExtractEndpointResponse<Paths, T>, Response, FilteredRequestConfig<Paths, T>>, 'mutationFn'>): _tanstack_react_query0.UseMutationResult<ExtractEndpointResponse<Paths, T>, Response, FilteredRequestConfig<Paths, T>, unknown>;
|
|
52
52
|
declare function useTypedInfiniteQuery<Paths, T extends QueryEndpoint<Paths>, TPageData = ExtractEndpointResponse<Paths, T>, TPageParam = unknown>(client: TypedQueryClient<Paths>, endpoint: T, options: Omit<UseInfiniteQueryOptions<TPageData, Response, {
|
|
53
53
|
pages: TPageData[];
|
|
54
54
|
pageParams: TPageParam[];
|
|
55
55
|
}, unknown[], TPageParam>, 'queryKey' | 'queryFn' | 'getNextPageParam' | 'initialPageParam'> & {
|
|
56
56
|
getNextPageParam: (lastPage: TPageData, allPages: TPageData[], lastPageParam: TPageParam, allPageParams: TPageParam[]) => TPageParam | undefined;
|
|
57
57
|
initialPageParam: TPageParam;
|
|
58
|
-
}, config?: FilteredRequestConfig<Paths, T>):
|
|
58
|
+
}, config?: FilteredRequestConfig<Paths, T>): _tanstack_react_query0.UseInfiniteQueryResult<{
|
|
59
59
|
pages: TPageData[];
|
|
60
60
|
pageParams: TPageParam[];
|
|
61
61
|
}, Response>;
|
package/dist/react-query.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ExtractEndpointResponse, FetcherOptions, FilteredRequestConfig, MutationEndpoint, QueryEndpoint, TypedEndpoint } from "./types-
|
|
1
|
+
import { ExtractEndpointResponse, FetcherOptions, FilteredRequestConfig, MutationEndpoint, QueryEndpoint, TypedEndpoint } from "./types-Cdv1XAWr.mjs";
|
|
2
2
|
import * as _tanstack_react_query3 from "@tanstack/react-query";
|
|
3
3
|
import { QueryClient, UseInfiniteQueryOptions, UseMutationOptions, UseQueryOptions } from "@tanstack/react-query";
|
|
4
4
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
//#region src/types.d.ts
|
|
2
2
|
type OpenAPIRoutes<Paths> = keyof Paths;
|
|
3
|
-
type
|
|
3
|
+
type HttpMethod = 'get' | 'post' | 'put' | 'patch' | 'delete' | 'head' | 'options';
|
|
4
|
+
type ExtractMethod<Paths, Route extends OpenAPIRoutes<Paths>> = Extract<keyof Paths[Route], HttpMethod>;
|
|
4
5
|
type ExtractPathParams<Paths, Route extends OpenAPIRoutes<Paths>> = Paths[Route] extends {
|
|
5
6
|
parameters?: {
|
|
6
7
|
path?: infer P;
|
|
@@ -42,8 +43,7 @@ type RequestConfig<Paths, Route extends OpenAPIRoutes<Paths>, Method extends Ext
|
|
|
42
43
|
headers?: Record<string, string>;
|
|
43
44
|
};
|
|
44
45
|
type EndpointString = `${Uppercase<string>} ${string}`;
|
|
45
|
-
type
|
|
46
|
-
type ValidEndpoint<Paths> = { [Route in keyof Paths]: { [Method in keyof FilterNeverMethods<Paths[Route]>]: `${Uppercase<string & Method>} ${string & Route}` }[keyof FilterNeverMethods<Paths[Route]>] }[keyof Paths];
|
|
46
|
+
type ValidEndpoint<Paths> = { [Route in keyof Paths]: { [Method in Extract<keyof Paths[Route], HttpMethod>]: `${Uppercase<string & Method>} ${string & Route}` }[Extract<keyof Paths[Route], HttpMethod>] }[keyof Paths];
|
|
47
47
|
type TypedEndpoint<Paths> = ValidEndpoint<Paths> extends infer E ? E extends string ? E : never : never;
|
|
48
48
|
type FilterEndpointByMethod<Paths, Method extends string> = ValidEndpoint<Paths> extends infer E ? E extends `${Method} ${string}` ? E : never : never;
|
|
49
49
|
type QueryEndpoint<Paths> = FilterEndpointByMethod<Paths, 'GET'>;
|
|
@@ -96,4 +96,4 @@ interface FetcherOptions {
|
|
|
96
96
|
}
|
|
97
97
|
//#endregion
|
|
98
98
|
export { EndpointString, ExtractEndpointConfig, ExtractEndpointResponse, ExtractMethod, ExtractPathParams, ExtractQueryParams, ExtractRequestBody, ExtractResponse, FetcherOptions, FilterEndpointByMethod, FilteredRequestConfig, IsConfigRequired, MutationEndpoint, OpenAPIRoutes, ParseEndpoint, QueryEndpoint, RequestConfig, TypedApiFunction, TypedEndpoint, ValidEndpoint };
|
|
99
|
-
//# sourceMappingURL=types-
|
|
99
|
+
//# sourceMappingURL=types-Cdv1XAWr.d.mts.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
//#region src/types.d.ts
|
|
2
2
|
type OpenAPIRoutes<Paths> = keyof Paths;
|
|
3
|
-
type
|
|
3
|
+
type HttpMethod = 'get' | 'post' | 'put' | 'patch' | 'delete' | 'head' | 'options';
|
|
4
|
+
type ExtractMethod<Paths, Route extends OpenAPIRoutes<Paths>> = Extract<keyof Paths[Route], HttpMethod>;
|
|
4
5
|
type ExtractPathParams<Paths, Route extends OpenAPIRoutes<Paths>> = Paths[Route] extends {
|
|
5
6
|
parameters?: {
|
|
6
7
|
path?: infer P;
|
|
@@ -42,8 +43,7 @@ type RequestConfig<Paths, Route extends OpenAPIRoutes<Paths>, Method extends Ext
|
|
|
42
43
|
headers?: Record<string, string>;
|
|
43
44
|
};
|
|
44
45
|
type EndpointString = `${Uppercase<string>} ${string}`;
|
|
45
|
-
type
|
|
46
|
-
type ValidEndpoint<Paths> = { [Route in keyof Paths]: { [Method in keyof FilterNeverMethods<Paths[Route]>]: `${Uppercase<string & Method>} ${string & Route}` }[keyof FilterNeverMethods<Paths[Route]>] }[keyof Paths];
|
|
46
|
+
type ValidEndpoint<Paths> = { [Route in keyof Paths]: { [Method in Extract<keyof Paths[Route], HttpMethod>]: `${Uppercase<string & Method>} ${string & Route}` }[Extract<keyof Paths[Route], HttpMethod>] }[keyof Paths];
|
|
47
47
|
type TypedEndpoint<Paths> = ValidEndpoint<Paths> extends infer E ? E extends string ? E : never : never;
|
|
48
48
|
type FilterEndpointByMethod<Paths, Method extends string> = ValidEndpoint<Paths> extends infer E ? E extends `${Method} ${string}` ? E : never : never;
|
|
49
49
|
type QueryEndpoint<Paths> = FilterEndpointByMethod<Paths, 'GET'>;
|
|
@@ -96,4 +96,4 @@ interface FetcherOptions {
|
|
|
96
96
|
}
|
|
97
97
|
//#endregion
|
|
98
98
|
export { EndpointString, ExtractEndpointConfig, ExtractEndpointResponse, ExtractMethod, ExtractPathParams, ExtractQueryParams, ExtractRequestBody, ExtractResponse, FetcherOptions, FilterEndpointByMethod, FilteredRequestConfig, IsConfigRequired, MutationEndpoint, OpenAPIRoutes, ParseEndpoint, QueryEndpoint, RequestConfig, TypedApiFunction, TypedEndpoint, ValidEndpoint };
|
|
99
|
-
//# sourceMappingURL=types-
|
|
99
|
+
//# sourceMappingURL=types-D4OSWveN.d.cts.map
|
package/dist/types.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { EndpointString, ExtractEndpointConfig, ExtractEndpointResponse, ExtractMethod, ExtractPathParams, ExtractQueryParams, ExtractRequestBody, ExtractResponse, FetcherOptions, FilterEndpointByMethod, FilteredRequestConfig, IsConfigRequired, MutationEndpoint, OpenAPIRoutes, ParseEndpoint, QueryEndpoint, RequestConfig, TypedApiFunction, TypedEndpoint, ValidEndpoint } from "./types-
|
|
1
|
+
import { EndpointString, ExtractEndpointConfig, ExtractEndpointResponse, ExtractMethod, ExtractPathParams, ExtractQueryParams, ExtractRequestBody, ExtractResponse, FetcherOptions, FilterEndpointByMethod, FilteredRequestConfig, IsConfigRequired, MutationEndpoint, OpenAPIRoutes, ParseEndpoint, QueryEndpoint, RequestConfig, TypedApiFunction, TypedEndpoint, ValidEndpoint } from "./types-D4OSWveN.cjs";
|
|
2
2
|
export { EndpointString, ExtractEndpointConfig, ExtractEndpointResponse, ExtractMethod, ExtractPathParams, ExtractQueryParams, ExtractRequestBody, ExtractResponse, FetcherOptions, FilterEndpointByMethod, FilteredRequestConfig, IsConfigRequired, MutationEndpoint, OpenAPIRoutes, ParseEndpoint, QueryEndpoint, RequestConfig, TypedApiFunction, TypedEndpoint, ValidEndpoint };
|
package/dist/types.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { EndpointString, ExtractEndpointConfig, ExtractEndpointResponse, ExtractMethod, ExtractPathParams, ExtractQueryParams, ExtractRequestBody, ExtractResponse, FetcherOptions, FilterEndpointByMethod, FilteredRequestConfig, IsConfigRequired, MutationEndpoint, OpenAPIRoutes, ParseEndpoint, QueryEndpoint, RequestConfig, TypedApiFunction, TypedEndpoint, ValidEndpoint } from "./types-
|
|
1
|
+
import { EndpointString, ExtractEndpointConfig, ExtractEndpointResponse, ExtractMethod, ExtractPathParams, ExtractQueryParams, ExtractRequestBody, ExtractResponse, FetcherOptions, FilterEndpointByMethod, FilteredRequestConfig, IsConfigRequired, MutationEndpoint, OpenAPIRoutes, ParseEndpoint, QueryEndpoint, RequestConfig, TypedApiFunction, TypedEndpoint, ValidEndpoint } from "./types-Cdv1XAWr.mjs";
|
|
2
2
|
export { EndpointString, ExtractEndpointConfig, ExtractEndpointResponse, ExtractMethod, ExtractPathParams, ExtractQueryParams, ExtractRequestBody, ExtractResponse, FetcherOptions, FilterEndpointByMethod, FilteredRequestConfig, IsConfigRequired, MutationEndpoint, OpenAPIRoutes, ParseEndpoint, QueryEndpoint, RequestConfig, TypedApiFunction, TypedEndpoint, ValidEndpoint };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geekmidas/client",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"@standard-schema/spec": "^1.0.0",
|
|
58
|
-
"@geekmidas/schema": "0.0.
|
|
58
|
+
"@geekmidas/schema": "0.0.3"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@testing-library/jest-dom": "~6.6.3",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"react": ">=18.0.0",
|
|
73
73
|
"react-dom": ">=18.0.0",
|
|
74
74
|
"zod": "~4.1.13",
|
|
75
|
-
"@geekmidas/constructs": "0.2.
|
|
75
|
+
"@geekmidas/constructs": "0.2.3"
|
|
76
76
|
},
|
|
77
77
|
"peerDependenciesMeta": {
|
|
78
78
|
"@geekmidas/constructs": {
|
package/src/types.ts
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
export type OpenAPIRoutes<Paths> = keyof Paths;
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
type HttpMethod =
|
|
4
|
+
| 'get'
|
|
5
|
+
| 'post'
|
|
6
|
+
| 'put'
|
|
7
|
+
| 'patch'
|
|
8
|
+
| 'delete'
|
|
9
|
+
| 'head'
|
|
10
|
+
| 'options';
|
|
11
|
+
|
|
12
|
+
export type ExtractMethod<Paths, Route extends OpenAPIRoutes<Paths>> = Extract<
|
|
13
|
+
keyof Paths[Route],
|
|
14
|
+
HttpMethod
|
|
15
|
+
>;
|
|
7
16
|
|
|
8
17
|
export type ExtractPathParams<
|
|
9
18
|
Paths,
|
|
@@ -59,21 +68,14 @@ export type RequestConfig<
|
|
|
59
68
|
|
|
60
69
|
export type EndpointString = `${Uppercase<string>} ${string}`;
|
|
61
70
|
|
|
62
|
-
// Filter out methods that are never to avoid showing them in autocomplete
|
|
63
|
-
// This handles both explicit never and optional never (?: never)
|
|
64
|
-
type FilterNeverMethods<T> = {
|
|
65
|
-
[K in keyof T as T[K] extends never | undefined
|
|
66
|
-
? never
|
|
67
|
-
: K]: T[K] extends undefined ? never : T[K];
|
|
68
|
-
};
|
|
69
|
-
|
|
70
71
|
// Generate all valid endpoint strings from OpenAPI paths
|
|
72
|
+
// Uses Extract with HttpMethod to filter out non-HTTP keys like 'parameters'
|
|
71
73
|
export type ValidEndpoint<Paths> = {
|
|
72
74
|
[Route in keyof Paths]: {
|
|
73
|
-
[Method in keyof
|
|
75
|
+
[Method in Extract<keyof Paths[Route], HttpMethod>]: `${Uppercase<
|
|
74
76
|
string & Method
|
|
75
77
|
>} ${string & Route}`;
|
|
76
|
-
}[keyof
|
|
78
|
+
}[Extract<keyof Paths[Route], HttpMethod>];
|
|
77
79
|
}[keyof Paths];
|
|
78
80
|
|
|
79
81
|
// Helper type to get autocomplete for endpoint strings
|