File tree Expand file tree Collapse file tree 3 files changed +23
-12
lines changed Expand file tree Collapse file tree 3 files changed +23
-12
lines changed Original file line number Diff line number Diff line change 1+ import type { QueryClient } from "react-query" ;
12import {
2- Opts ,
33 DeepAsyncFnRecord ,
44 DoFetch ,
55 getTypedSDKInstance ,
@@ -8,7 +8,12 @@ import {
88} from "./internal" ;
99
1010export function createTypedSDK < T extends DeepAsyncFnRecord < any > > (
11- opts : Opts
11+ opts :
12+ | { url : string ; queryClient ?: QueryClient }
13+ | {
14+ queryClient ?: QueryClient ;
15+ doFetch : DoFetch ;
16+ }
1217) : TypedSDK < T > {
1318 let doFetch : DoFetch ;
1419 if ( "doFetch" in opts ) {
Original file line number Diff line number Diff line change @@ -19,13 +19,6 @@ export type DoFetch = <TPageParam = any>(
1919 } & Partial < QueryFunctionContext < readonly string [ ] , TPageParam > >
2020) => Promise < any > ;
2121
22- export type Opts =
23- | { url : string ; queryClient ?: QueryClient }
24- | {
25- queryClient ?: QueryClient ;
26- doFetch : DoFetch ;
27- } ;
28-
2922export type AsyncFn = ( ...args : any [ ] ) => Promise < any > ;
3023
3124export type DeepAsyncFnRecord < T extends { } > = {
Original file line number Diff line number Diff line change 11import {
22 DeepAsyncFnRecord ,
33 TypedGetSDKQueryKey ,
4- Opts ,
54 TypedSDK as TypedSDK ,
65 TypedUseInfiniteQuery as TypedUseInfiniteSDK ,
76 TypedUseQuery as TypedUseSDK ,
@@ -28,15 +27,29 @@ export { QueryClient } from "react-query";
2827
2928export function createTypedReactSDK <
3029 Endpoints extends DeepAsyncFnRecord < Endpoints >
31- > ( opts : Opts ) : SDK < Endpoints > {
30+ > (
31+ opts :
32+ | { url : string ; queryClient : QueryClient }
33+ | {
34+ queryClient : QueryClient ;
35+ doFetch : DoFetch ;
36+ }
37+ ) : SDK < Endpoints > {
3238 return new SDK ( opts ) ;
3339}
3440
3541class SDK < Endpoints extends DeepAsyncFnRecord < Endpoints > > {
3642 private queryClient ?: QueryClient ;
3743 private doFetch : DoFetch ;
3844
39- constructor ( opts : Opts ) {
45+ constructor (
46+ opts :
47+ | { url : string ; queryClient : QueryClient }
48+ | {
49+ queryClient : QueryClient ;
50+ doFetch : DoFetch ;
51+ }
52+ ) {
4053 this . queryClient = opts . queryClient ;
4154 if ( "doFetch" in opts ) {
4255 this . doFetch = getFetchFn ( { userSuppliedDoFetch : opts . doFetch } ) ;
You can’t perform that action at this time.
0 commit comments