Skip to content

Commit ed672c5

Browse files
ci: apply automated fixes
1 parent 083b7d0 commit ed672c5

File tree

4 files changed

+178
-154
lines changed

4 files changed

+178
-154
lines changed

integrations/react-next-15/app/authors/page.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
2-
import { HydrationBoundary, dehydrate } from "@tanstack/react-query";
3-
import { makeQueryClient } from "../make-query-client";
4-
import { getApiV1AuthorsOptions } from "../query";
5-
import { Authors } from "../client-component";
1+
import { HydrationBoundary, dehydrate } from '@tanstack/react-query'
2+
import { makeQueryClient } from '../make-query-client'
3+
import { getApiV1AuthorsOptions } from '../query'
4+
import { Authors } from '../client-component'
65

76
export default async function Page() {
8-
const queryClient = makeQueryClient()
9-
10-
const data = await queryClient.fetchQuery({...getApiV1AuthorsOptions()})
7+
const queryClient = makeQueryClient()
118

9+
const data = await queryClient.fetchQuery({ ...getApiV1AuthorsOptions() })
1210

1311
return (
1412
<HydrationBoundary state={dehydrate(queryClient)}>

integrations/react-next-15/app/client-component.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use client'
2-
import { useQuery, useSuspenseQuery } from "@tanstack/react-query"
3-
import Link from "next/link"
2+
import { useQuery, useSuspenseQuery } from '@tanstack/react-query'
3+
import Link from 'next/link'
44
import React from 'react'
55
import { Temporal } from '@js-temporal/polyfill'
66
import { getApiV1ActivitiesOptions, getApiV1AuthorsOptions } from './query'
@@ -36,10 +36,6 @@ export function ClientComponent() {
3636
)
3737
}
3838

39-
40-
41-
42-
4339
export const Activities = () => {
4440
const { data: activities } = useSuspenseQuery({
4541
...getApiV1ActivitiesOptions(),
@@ -64,4 +60,4 @@ export const Authors = () => {
6460
<pre>{JSON.stringify(authors, null, 2)}</pre>
6561
</div>
6662
)
67-
}
63+
}

integrations/react-next-15/app/page.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,8 @@ export default function Home() {
2727
},
2828
})
2929

30-
3130
void queryClient.prefetchQuery({ ...getApiV1ActivitiesOptions() })
3231

33-
3432
const state = dehydrate(queryClient)
3533

3634
return (
@@ -44,7 +42,6 @@ export default function Home() {
4442
<Activities />
4543
</Suspense>
4644
</HydrationBoundary>
47-
4845
</main>
4946
)
5047
}
Lines changed: 169 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -1,157 +1,190 @@
1-
import { createClient, createConfig } from "@hey-api/client-next";
2-
import { queryOptions } from "@tanstack/react-query";
3-
4-
import type { Client, ClientOptions, CreateClientConfig, Options as HeyApiOptions, TDataShape } from "@hey-api/client-next";
5-
6-
export type Options<TData extends TDataShape = TDataShape, TThrowOnError extends boolean = boolean> = HeyApiOptions<TData, TThrowOnError> & {
7-
/**
8-
* You can provide a client instance returned by `createClient()` instead of
9-
* individual options. This might be also useful if you want to implement a
10-
* custom client.
11-
*/
12-
client?: Client;
13-
/**
14-
* You can pass arbitrary values through the `meta` object. This can be
15-
* used to access values that aren't defined as part of the SDK function.
16-
*/
17-
meta?: Record<string, unknown>;
18-
};
19-
1+
import { createClient, createConfig } from '@hey-api/client-next'
2+
import { queryOptions } from '@tanstack/react-query'
3+
4+
import type {
5+
Client,
6+
ClientOptions,
7+
CreateClientConfig,
8+
Options as HeyApiOptions,
9+
TDataShape,
10+
} from '@hey-api/client-next'
11+
12+
export type Options<
13+
TData extends TDataShape = TDataShape,
14+
TThrowOnError extends boolean = boolean,
15+
> = HeyApiOptions<TData, TThrowOnError> & {
16+
/**
17+
* You can provide a client instance returned by `createClient()` instead of
18+
* individual options. This might be also useful if you want to implement a
19+
* custom client.
20+
*/
21+
client?: Client
22+
/**
23+
* You can pass arbitrary values through the `meta` object. This can be
24+
* used to access values that aren't defined as part of the SDK function.
25+
*/
26+
meta?: Record<string, unknown>
27+
}
2028

2129
export const createClientConfig: CreateClientConfig = (config) => ({
2230
...config,
2331
baseUrl: 'https://fakerestapi.azurewebsites.net/',
2432
})
2533

26-
27-
export const _heyApiClient = createClient(createClientConfig(createConfig<ClientOptions>({
28-
baseUrl: 'https://fakerestapi.azurewebsites.net'
29-
})));
34+
export const _heyApiClient = createClient(
35+
createClientConfig(
36+
createConfig<ClientOptions>({
37+
baseUrl: 'https://fakerestapi.azurewebsites.net',
38+
}),
39+
),
40+
)
3041

3142
export type GetApiV1ActivitiesData = {
32-
body?: never;
33-
path?: never;
34-
query?: never;
35-
url: '/api/v1/Activities';
36-
};
43+
body?: never
44+
path?: never
45+
query?: never
46+
url: '/api/v1/Activities'
47+
}
3748

3849
export type Activity = {
39-
id?: number;
40-
title?: string | null;
41-
dueDate?: string;
42-
completed?: boolean;
43-
};
50+
id?: number
51+
title?: string | null
52+
dueDate?: string
53+
completed?: boolean
54+
}
4455

4556
export type Author = {
46-
id?: number;
47-
idBook?: number;
48-
firstName?: string | null;
49-
lastName?: string | null;
50-
};
57+
id?: number
58+
idBook?: number
59+
firstName?: string | null
60+
lastName?: string | null
61+
}
5162

5263
export type GetApiV1ActivitiesResponses = {
53-
/**
54-
* Success
55-
*/
56-
200: Array<Activity>;
57-
};
64+
/**
65+
* Success
66+
*/
67+
200: Array<Activity>
68+
}
5869

5970
export type GetApiV1AuthorsData = {
60-
body?: never;
61-
path?: never;
62-
query?: never;
63-
url: '/api/v1/Authors';
64-
};
71+
body?: never
72+
path?: never
73+
query?: never
74+
url: '/api/v1/Authors'
75+
}
6576

66-
export type GetApiV1ActivitiesResponse = GetApiV1ActivitiesResponses[keyof GetApiV1ActivitiesResponses];
77+
export type GetApiV1ActivitiesResponse =
78+
GetApiV1ActivitiesResponses[keyof GetApiV1ActivitiesResponses]
6779

6880
export type QueryKey<TOptions extends Options> = [
69-
Pick<TOptions, 'baseUrl' | 'body' | 'headers' | 'path' | 'query'> & {
70-
_id: string;
71-
_infinite?: boolean;
72-
}
73-
];
74-
75-
76-
const createQueryKey = <TOptions extends Options>(id: string, options?: TOptions, infinite?: boolean): [
77-
QueryKey<TOptions>[0]
78-
] => {
79-
const params: QueryKey<TOptions>[0] = { _id: id, baseUrl: (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey<TOptions>[0];
80-
if (infinite) {
81-
params._infinite = infinite;
82-
}
83-
if (options?.body) {
84-
params.body = options.body;
85-
}
86-
if (options?.headers) {
87-
params.headers = options.headers;
88-
}
89-
if (options?.path) {
90-
params.path = options.path;
91-
}
92-
if (options?.query) {
93-
params.query = options.query;
94-
}
95-
return [
96-
params
97-
];
98-
};
99-
100-
export const getApiV1Activities = <TThrowOnError extends boolean = false>(options?: Options<GetApiV1ActivitiesData,TThrowOnError>) => {
101-
return (options?.client ?? _heyApiClient).get<GetApiV1ActivitiesResponse, unknown, TThrowOnError>({
102-
url: '/api/v1/Activities',
103-
...options
104-
});
105-
};
106-
107-
export const getApiV1ActivitiesQueryKey = (options?: Options<GetApiV1ActivitiesData>) => createQueryKey('getApiV1Activities', options);
108-
109-
110-
export const getApiV1ActivitiesOptions = (options?: Options<GetApiV1ActivitiesData>) => {
111-
return queryOptions({
112-
queryFn: async ({ queryKey, signal }) => {
113-
const { data } = await getApiV1Activities({
114-
...options,
115-
...queryKey[0],
116-
signal,
117-
throwOnError: true
118-
});
119-
return data;
120-
},
121-
queryKey: getApiV1ActivitiesQueryKey(options)
122-
});
123-
};
81+
Pick<TOptions, 'baseUrl' | 'body' | 'headers' | 'path' | 'query'> & {
82+
_id: string
83+
_infinite?: boolean
84+
},
85+
]
86+
87+
const createQueryKey = <TOptions extends Options>(
88+
id: string,
89+
options?: TOptions,
90+
infinite?: boolean,
91+
): [QueryKey<TOptions>[0]] => {
92+
const params: QueryKey<TOptions>[0] = {
93+
_id: id,
94+
baseUrl: (options?.client ?? _heyApiClient).getConfig().baseUrl,
95+
} as QueryKey<TOptions>[0]
96+
if (infinite) {
97+
params._infinite = infinite
98+
}
99+
if (options?.body) {
100+
params.body = options.body
101+
}
102+
if (options?.headers) {
103+
params.headers = options.headers
104+
}
105+
if (options?.path) {
106+
params.path = options.path
107+
}
108+
if (options?.query) {
109+
params.query = options.query
110+
}
111+
return [params]
112+
}
113+
114+
export const getApiV1Activities = <TThrowOnError extends boolean = false>(
115+
options?: Options<GetApiV1ActivitiesData, TThrowOnError>,
116+
) => {
117+
return (options?.client ?? _heyApiClient).get<
118+
GetApiV1ActivitiesResponse,
119+
unknown,
120+
TThrowOnError
121+
>({
122+
url: '/api/v1/Activities',
123+
...options,
124+
})
125+
}
126+
127+
export const getApiV1ActivitiesQueryKey = (
128+
options?: Options<GetApiV1ActivitiesData>,
129+
) => createQueryKey('getApiV1Activities', options)
130+
131+
export const getApiV1ActivitiesOptions = (
132+
options?: Options<GetApiV1ActivitiesData>,
133+
) => {
134+
return queryOptions({
135+
queryFn: async ({ queryKey, signal }) => {
136+
const { data } = await getApiV1Activities({
137+
...options,
138+
...queryKey[0],
139+
signal,
140+
throwOnError: true,
141+
})
142+
return data
143+
},
144+
queryKey: getApiV1ActivitiesQueryKey(options),
145+
})
146+
}
124147

125148
export type GetApiV1AuthorsResponses = {
126-
/**
127-
* Success
128-
*/
129-
200: Array<Author>;
130-
};
131-
132-
export type GetApiV1AuthorsResponse = GetApiV1AuthorsResponses[keyof GetApiV1AuthorsResponses];
133-
134-
135-
export const getApiV1Authors = <TThrowOnError extends boolean = false>(options?: Options<GetApiV1AuthorsData,TThrowOnError>) => {
136-
return (options?.client ?? _heyApiClient).get<GetApiV1AuthorsResponse, unknown, TThrowOnError>({
137-
url: '/api/v1/Authors',
138-
...options
139-
});
140-
};
141-
142-
export const getApiV1AuthorsQueryKey = (options?: Options<GetApiV1AuthorsData>) => createQueryKey('getApiV1Authors', options);
143-
144-
export const getApiV1AuthorsOptions = (options?: Options<GetApiV1AuthorsData>) => {
145-
return queryOptions({
146-
queryFn: async ({ queryKey, signal }) => {
147-
const { data } = await getApiV1Authors({
148-
...options,
149-
...queryKey[0],
150-
signal,
151-
throwOnError: true
152-
});
153-
return data;
154-
},
155-
queryKey: getApiV1AuthorsQueryKey(options)
156-
});
157-
};
149+
/**
150+
* Success
151+
*/
152+
200: Array<Author>
153+
}
154+
155+
export type GetApiV1AuthorsResponse =
156+
GetApiV1AuthorsResponses[keyof GetApiV1AuthorsResponses]
157+
158+
export const getApiV1Authors = <TThrowOnError extends boolean = false>(
159+
options?: Options<GetApiV1AuthorsData, TThrowOnError>,
160+
) => {
161+
return (options?.client ?? _heyApiClient).get<
162+
GetApiV1AuthorsResponse,
163+
unknown,
164+
TThrowOnError
165+
>({
166+
url: '/api/v1/Authors',
167+
...options,
168+
})
169+
}
170+
171+
export const getApiV1AuthorsQueryKey = (
172+
options?: Options<GetApiV1AuthorsData>,
173+
) => createQueryKey('getApiV1Authors', options)
174+
175+
export const getApiV1AuthorsOptions = (
176+
options?: Options<GetApiV1AuthorsData>,
177+
) => {
178+
return queryOptions({
179+
queryFn: async ({ queryKey, signal }) => {
180+
const { data } = await getApiV1Authors({
181+
...options,
182+
...queryKey[0],
183+
signal,
184+
throwOnError: true,
185+
})
186+
return data
187+
},
188+
queryKey: getApiV1AuthorsQueryKey(options),
189+
})
190+
}

0 commit comments

Comments
 (0)