Skip to content

Commit bb8fd95

Browse files
committed
feat: unify types TanStack Query types to include IR.OperationObject in meta function signatures
1 parent 5868ac0 commit bb8fd95

File tree

5 files changed

+29
-18
lines changed

5 files changed

+29
-18
lines changed

packages/openapi-ts-tests/main/test/plugins/@tanstack/meta-function.test.ts

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -53,19 +53,6 @@ describe('TanStack Query Meta Function Customization', () => {
5353
},
5454
] as const;
5555

56-
// Custom meta function that returns the expected field names
57-
const customMetaFunction = (operation: any) => ({
58-
id: operation.id,
59-
method: operation.method,
60-
path: operation.path,
61-
});
62-
63-
const metaConfig = {
64-
infiniteQueryOptions: { meta: customMetaFunction },
65-
mutationOptions: { meta: customMetaFunction },
66-
queryOptions: { meta: customMetaFunction },
67-
};
68-
6956
// Generate scenarios for each framework
7057
const scenarios = frameworks.map((framework) => ({
7158
config: createConfig({
@@ -79,8 +66,28 @@ describe('TanStack Query Meta Function Customization', () => {
7966
),
8067
plugins: [
8168
{
69+
infiniteQueryOptions: {
70+
meta: (operation) => ({
71+
id: operation.id,
72+
method: operation.method,
73+
path: operation.path,
74+
}),
75+
},
76+
mutationOptions: {
77+
meta: (operation) => ({
78+
id: operation.id,
79+
method: operation.method,
80+
path: operation.path,
81+
}),
82+
},
8283
name: framework.name,
83-
...metaConfig,
84+
queryOptions: {
85+
meta: (operation) => ({
86+
id: operation.id,
87+
method: operation.method,
88+
path: operation.path,
89+
}),
90+
},
8491
},
8592
'@hey-api/client-fetch',
8693
],

packages/openapi-ts/src/plugins/@tanstack/react-query/types.d.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { IR } from '../../../ir/types';
12
import type { StringCase, StringName } from '../../../types/case';
23
import type { DefinePlugin, Plugin } from '../../types';
34

@@ -386,7 +387,7 @@ export type Config = Plugin.Name<'@tanstack/react-query'> & {
386387
* })
387388
* ```
388389
*/
389-
meta?: (operation: any) => Record<string, any>;
390+
meta?: false | ((operation: IR.OperationObject) => Record<string, any>);
390391
/**
391392
* Custom naming pattern for generated infinite query options names. The name variable is obtained from the SDK function name.
392393
*
@@ -433,7 +434,7 @@ export type Config = Plugin.Name<'@tanstack/react-query'> & {
433434
* })
434435
* ```
435436
*/
436-
meta?: (operation: any) => Record<string, any>;
437+
meta?: false | ((operation: IR.OperationObject) => Record<string, any>);
437438
/**
438439
* Custom naming pattern for generated mutation options names. The name variable is obtained from the SDK function name.
439440
*
@@ -519,7 +520,7 @@ export type Config = Plugin.Name<'@tanstack/react-query'> & {
519520
* })
520521
* ```
521522
*/
522-
meta?: (operation: any) => Record<string, any>;
523+
meta?: false | ((operation: IR.OperationObject) => Record<string, any>);
523524
/**
524525
* Custom naming pattern for generated query options names. The name variable is obtained from the SDK function name.
525526
*

packages/openapi-ts/src/plugins/@tanstack/solid-query/types.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { IR } from '../../../ir/types';
12
import type { StringCase, StringName } from '../../../types/case';
23
import type { DefinePlugin, Plugin } from '../../types';
34

packages/openapi-ts/src/plugins/@tanstack/svelte-query/types.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { IR } from '../../../ir/types';
12
import type { StringCase, StringName } from '../../../types/case';
23
import type { DefinePlugin, Plugin } from '../../types';
34

packages/openapi-ts/src/plugins/@tanstack/vue-query/types.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { IR } from '../../../ir/types';
12
import type { StringCase, StringName } from '../../../types/case';
23
import type { DefinePlugin, Plugin } from '../../types';
34

@@ -381,7 +382,7 @@ export type Config = Plugin.Name<'@tanstack/vue-query'> & {
381382
* })
382383
* ```
383384
*/
384-
meta?: (operation: any) => Record<string, any>;
385+
meta?: false | ((operation: IR.OperationObject) => Record<string, any>);
385386
/**
386387
* Custom naming pattern for generated infinite query options names. The name variable is
387388
* obtained from the SDK function name.

0 commit comments

Comments
 (0)