File tree Expand file tree Collapse file tree
packages/openapi-ts/src/plugins/@tanstack/query-core/v5 Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ import { handleMeta } from '../shared/meta';
1212import { useTypeData , useTypeError , useTypeResponse } from '../shared/useType' ;
1313import type { PluginInstance } from '../types' ;
1414
15- const createInfiniteParamsFunction = ( { plugin } : { plugin : PluginInstance } ) => {
15+ function createInfiniteParamsFunction ( { plugin } : { plugin : PluginInstance } ) : void {
1616 const symbolCreateInfiniteParams = plugin . symbol (
1717 applyNaming ( 'createInfiniteParams' , {
1818 case : plugin . config . case ,
@@ -89,15 +89,15 @@ const createInfiniteParamsFunction = ({ plugin }: { plugin: PluginInstance }) =>
8989 ) ,
9090 ) ;
9191 plugin . node ( fn ) ;
92- } ;
92+ }
9393
94- export const createInfiniteQueryOptions = ( {
94+ export function createInfiniteQueryOptions ( {
9595 operation,
9696 plugin,
9797} : {
9898 operation : IR . OperationObject ;
9999 plugin : PluginInstance ;
100- } ) : void => {
100+ } ) : void {
101101 const pagination = operationPagination ( {
102102 context : plugin . context ,
103103 operation,
@@ -255,4 +255,4 @@ export const createInfiniteQueryOptions = ({
255255 ) ,
256256 ) ;
257257 plugin . node ( statement ) ;
258- } ;
258+ }
Original file line number Diff line number Diff line change @@ -11,16 +11,14 @@ import { handleMeta } from '../shared/meta';
1111import { useTypeData , useTypeError , useTypeResponse } from '../shared/useType' ;
1212import type { PluginInstance } from '../types' ;
1313
14- export const createMutationOptions = ( {
14+ export function createMutationOptions ( {
1515 operation,
1616 plugin,
1717} : {
1818 operation : IR . OperationObject ;
1919 plugin : PluginInstance ;
20- } ) : void => {
21- if ( hasOperationSse ( { operation } ) ) {
22- return ;
23- }
20+ } ) : void {
21+ if ( hasOperationSse ( { operation } ) ) return ;
2422
2523 const symbolMutationOptionsType = plugin . external ( `${ plugin . name } .MutationOptions` ) ;
2624
@@ -91,4 +89,4 @@ export const createMutationOptions = ({
9189 ) ,
9290 ) ;
9391 plugin . node ( statement ) ;
94- } ;
92+ }
Original file line number Diff line number Diff line change @@ -68,17 +68,17 @@ export const handlerV5: PluginHandler = ({ plugin }) => {
6868 createInfiniteQueryOptions ( { operation, plugin } ) ;
6969 }
7070
71- if ( 'setQueryData' in plugin . config && plugin . config . setQueryData . enabled ) {
71+ if ( plugin . config . setQueryData . enabled ) {
7272 createSetQueryData ( { operation, plugin } ) ;
7373 }
7474
75- if ( 'useSetQueryData' in plugin . config && plugin . config . useSetQueryData . enabled ) {
76- createUseSetQueryData ( { operation, plugin } ) ;
77- }
78-
7975 if ( 'useQuery' in plugin . config && plugin . config . useQuery . enabled ) {
8076 createUseQuery ( { operation, plugin } ) ;
8177 }
78+
79+ if ( 'useSetQueryData' in plugin . config && plugin . config . useSetQueryData . enabled ) {
80+ createUseSetQueryData ( { operation, plugin } ) ;
81+ }
8282 }
8383
8484 if ( plugin . hooks . operation . isMutation ( operation ) ) {
Original file line number Diff line number Diff line change @@ -15,16 +15,14 @@ import type { PluginInstance } from '../types';
1515
1616const optionsParamName = 'options' ;
1717
18- export const createQueryOptions = ( {
18+ export function createQueryOptions ( {
1919 operation,
2020 plugin,
2121} : {
2222 operation : IR . OperationObject ;
2323 plugin : PluginInstance ;
24- } ) : void => {
25- if ( hasOperationSse ( { operation } ) ) {
26- return ;
27- }
24+ } ) : void {
25+ if ( hasOperationSse ( { operation } ) ) return ;
2826
2927 const isRequiredOptions = isOperationOptionsRequired ( {
3028 context : plugin . context ,
@@ -128,4 +126,4 @@ export const createQueryOptions = ({
128126 ) ,
129127 ) ;
130128 plugin . node ( statement ) ;
131- } ;
129+ }
Original file line number Diff line number Diff line change @@ -9,20 +9,14 @@ import { $ } from '../../../../ts-dsl';
99import { useTypeData , useTypeResponse } from '../shared/useType' ;
1010import type { PluginInstance } from '../types' ;
1111
12- export const createSetQueryData = ( {
12+ export function createSetQueryData ( {
1313 operation,
1414 plugin,
1515} : {
1616 operation : IR . OperationObject ;
1717 plugin : PluginInstance ;
18- } ) : void => {
19- if ( hasOperationSse ( { operation } ) ) {
20- return ;
21- }
22-
23- if ( ! ( 'setQueryData' in plugin . config ) ) {
24- return ;
25- }
18+ } ) : void {
19+ if ( hasOperationSse ( { operation } ) ) return ;
2620
2721 // setQueryData reuses the queryOptions function to get the queryKey,
2822 // mirroring how useQuery wraps queryOptions. This requires queryOptions
@@ -82,4 +76,4 @@ export const createSetQueryData = ({
8276 ) ,
8377 ) ;
8478 plugin . node ( statement ) ;
85- } ;
79+ }
Original file line number Diff line number Diff line change @@ -8,16 +8,14 @@ import type { PluginInstance } from '../types';
88
99const mutationOptionsParamName = 'mutationOptions' ;
1010
11- export const createUseMutation = ( {
11+ export function createUseMutation ( {
1212 operation,
1313 plugin,
1414} : {
1515 operation : IR . OperationObject ;
1616 plugin : PluginInstance ;
17- } ) : void => {
18- if ( ! ( 'useMutation' in plugin . config ) ) {
19- return ;
20- }
17+ } ) : void {
18+ if ( ! ( 'useMutation' in plugin . config ) ) return ;
2119
2220 const symbolUseMutationFn = plugin . symbol ( applyNaming ( operation . id , plugin . config . useMutation ) ) ;
2321
@@ -60,4 +58,4 @@ export const createUseMutation = ({
6058 . $if ( plugin . config . comments && createOperationComment ( operation ) , ( c , v ) => c . doc ( v ) )
6159 . assign ( func ) ;
6260 plugin . node ( statement ) ;
63- } ;
61+ }
Original file line number Diff line number Diff line change @@ -12,20 +12,16 @@ import type { PluginInstance } from '../types';
1212
1313const optionsParamName = 'options' ;
1414
15- export const createUseQuery = ( {
15+ export function createUseQuery ( {
1616 operation,
1717 plugin,
1818} : {
1919 operation : IR . OperationObject ;
2020 plugin : PluginInstance ;
21- } ) : void => {
22- if ( hasOperationSse ( { operation } ) ) {
23- return ;
24- }
21+ } ) : void {
22+ if ( hasOperationSse ( { operation } ) ) return ;
2523
26- if ( ! ( 'useQuery' in plugin . config ) ) {
27- return ;
28- }
24+ if ( ! ( 'useQuery' in plugin . config ) ) return ;
2925
3026 const symbolUseQueryFn = plugin . symbol ( applyNaming ( operation . id , plugin . config . useQuery ) ) ;
3127
@@ -53,4 +49,4 @@ export const createUseQuery = ({
5349 . do ( $ ( symbolUseQuery ) . call ( $ ( symbolQueryOptionsFn ) . call ( optionsParamName ) ) . return ( ) ) ,
5450 ) ;
5551 plugin . node ( statement ) ;
56- } ;
52+ }
Original file line number Diff line number Diff line change @@ -9,20 +9,16 @@ import { $ } from '../../../../ts-dsl';
99import { useTypeData , useTypeResponse } from '../shared/useType' ;
1010import type { PluginInstance } from '../types' ;
1111
12- export const createUseSetQueryData = ( {
12+ export function createUseSetQueryData ( {
1313 operation,
1414 plugin,
1515} : {
1616 operation : IR . OperationObject ;
1717 plugin : PluginInstance ;
18- } ) : void => {
19- if ( hasOperationSse ( { operation } ) ) {
20- return ;
21- }
18+ } ) : void {
19+ if ( hasOperationSse ( { operation } ) ) return ;
2220
23- if ( ! ( 'useSetQueryData' in plugin . config ) ) {
24- return ;
25- }
21+ if ( ! ( 'useSetQueryData' in plugin . config ) ) return ;
2622
2723 const symbolUseQueryClient = plugin . external ( `${ plugin . name } .useQueryClient` ) ;
2824 const symbolQueryOptionsFn = plugin . referenceSymbol ( {
@@ -84,4 +80,4 @@ export const createUseSetQueryData = ({
8480 ) ,
8581 ) ;
8682 plugin . node ( statement ) ;
87- } ;
83+ }
You can’t perform that action at this time.
0 commit comments