diff --git a/.changeset/blue-carrots-juggle.md b/.changeset/blue-carrots-juggle.md new file mode 100644 index 000000000..7ffdd90dd --- /dev/null +++ b/.changeset/blue-carrots-juggle.md @@ -0,0 +1,5 @@ +--- +'@hey-api/openapi-ts': patch +--- + +fix: rename infinite key in query key to \_infinite diff --git a/packages/openapi-ts/src/plugins/@tanstack/query-core/plugin.ts b/packages/openapi-ts/src/plugins/@tanstack/query-core/plugin.ts index fa76f250b..6f3399de7 100644 --- a/packages/openapi-ts/src/plugins/@tanstack/query-core/plugin.ts +++ b/packages/openapi-ts/src/plugins/@tanstack/query-core/plugin.ts @@ -77,6 +77,8 @@ const createQueryKeyFunction = ({ file }: { file: Files[keyof Files] }) => { ]), }); + const infiniteIdentifier = compiler.identifier({ text: 'infinite' }); + const fn = compiler.constVariable({ expression: compiler.arrowFunction({ multiLine: true, @@ -119,16 +121,16 @@ const createQueryKeyFunction = ({ file }: { file: Files[keyof Files] }) => { typeName: returnType, }), compiler.ifStatement({ - expression: compiler.identifier({ text: 'infinite' }), + expression: infiniteIdentifier, thenStatement: ts.factory.createBlock( [ compiler.expressionToStatement({ expression: compiler.binaryExpression({ left: compiler.propertyAccessExpression({ expression: 'params', - name: 'infinite', + name: '_infinite', }), - right: compiler.identifier({ text: 'infinite' }), + right: infiniteIdentifier, }), }), ], @@ -261,7 +263,7 @@ const createQueryKeyType = ({ file }: { file: Files[keyof Files] }) => { }, { isRequired: false, - name: 'infinite', + name: '_infinite', type: compiler.keywordTypeNode({ keyword: 'boolean', }), @@ -795,6 +797,9 @@ export const handler: PluginDefinition['handler'] = ({ { spread: 'options', }, + { + spread: 'queryKey[0]', + }, { key: 'body', value: compiler.objectExpression({ @@ -853,12 +858,6 @@ export const handler: PluginDefinition['handler'] = ({ ], }), }, - { - key: getClientBaseUrlKey(), - value: compiler.identifier({ - text: `client.getConfig().${getClientBaseUrlKey()}`, - }), - }, { key: 'throwOnError', value: true, diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-axios-plugin-tanstack-react-query/@tanstack/react-query.gen.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-axios-plugin-tanstack-react-query/@tanstack/react-query.gen.ts.snap index 9b65c358d..eb0696597 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-axios-plugin-tanstack-react-query/@tanstack/react-query.gen.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-axios-plugin-tanstack-react-query/@tanstack/react-query.gen.ts.snap @@ -9,14 +9,14 @@ import type { AxiosError } from 'axios'; type QueryKey = [ Pick & { _id: string; - infinite?: boolean; + _infinite?: boolean; } ]; const createQueryKey = (id: string, options?: TOptions, infinite?: boolean): QueryKey[0] => { const params: QueryKey[0] = { _id: id, baseURL: client.getConfig().baseURL } as QueryKey[0]; if (infinite) { - params.infinite = infinite; + params._infinite = infinite; } if (options?.body) { params.body = options.body; @@ -237,6 +237,7 @@ export const callWithParametersInfiniteOptions = (options: Options = [ Pick & { _id: string; - infinite?: boolean; + _infinite?: boolean; } ]; const createQueryKey = (id: string, options?: TOptions, infinite?: boolean): QueryKey[0] => { const params: QueryKey[0] = { _id: id, baseURL: client.getConfig().baseURL } as QueryKey[0]; if (infinite) { - params.infinite = infinite; + params._infinite = infinite; } if (options?.body) { params.body = options.body; diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-axios-plugin-tanstack-solid-query/@tanstack/solid-query.gen.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-axios-plugin-tanstack-solid-query/@tanstack/solid-query.gen.ts.snap index 70c63bccc..eb7e8863a 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-axios-plugin-tanstack-solid-query/@tanstack/solid-query.gen.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-axios-plugin-tanstack-solid-query/@tanstack/solid-query.gen.ts.snap @@ -9,14 +9,14 @@ import type { AxiosError } from 'axios'; type QueryKey = [ Pick & { _id: string; - infinite?: boolean; + _infinite?: boolean; } ]; const createQueryKey = (id: string, options?: TOptions, infinite?: boolean): QueryKey[0] => { const params: QueryKey[0] = { _id: id, baseURL: client.getConfig().baseURL } as QueryKey[0]; if (infinite) { - params.infinite = infinite; + params._infinite = infinite; } if (options?.body) { params.body = options.body; @@ -237,6 +237,7 @@ export const callWithParametersInfiniteOptions = (options: Options = [ Pick & { _id: string; - infinite?: boolean; + _infinite?: boolean; } ]; const createQueryKey = (id: string, options?: TOptions, infinite?: boolean): QueryKey[0] => { const params: QueryKey[0] = { _id: id, baseURL: client.getConfig().baseURL } as QueryKey[0]; if (infinite) { - params.infinite = infinite; + params._infinite = infinite; } if (options?.body) { params.body = options.body; diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-axios-plugin-tanstack-svelte-query/@tanstack/svelte-query.gen.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-axios-plugin-tanstack-svelte-query/@tanstack/svelte-query.gen.ts.snap index 807676597..c1bfd9bc2 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-axios-plugin-tanstack-svelte-query/@tanstack/svelte-query.gen.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-axios-plugin-tanstack-svelte-query/@tanstack/svelte-query.gen.ts.snap @@ -9,14 +9,14 @@ import type { AxiosError } from 'axios'; type QueryKey = [ Pick & { _id: string; - infinite?: boolean; + _infinite?: boolean; } ]; const createQueryKey = (id: string, options?: TOptions, infinite?: boolean): QueryKey[0] => { const params: QueryKey[0] = { _id: id, baseURL: client.getConfig().baseURL } as QueryKey[0]; if (infinite) { - params.infinite = infinite; + params._infinite = infinite; } if (options?.body) { params.body = options.body; @@ -237,6 +237,7 @@ export const callWithParametersInfiniteOptions = (options: Options = [ Pick & { _id: string; - infinite?: boolean; + _infinite?: boolean; } ]; const createQueryKey = (id: string, options?: TOptions, infinite?: boolean): QueryKey[0] => { const params: QueryKey[0] = { _id: id, baseURL: client.getConfig().baseURL } as QueryKey[0]; if (infinite) { - params.infinite = infinite; + params._infinite = infinite; } if (options?.body) { params.body = options.body; diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-axios-plugin-tanstack-vue-query/@tanstack/vue-query.gen.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-axios-plugin-tanstack-vue-query/@tanstack/vue-query.gen.ts.snap index ac608082f..99376efb0 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-axios-plugin-tanstack-vue-query/@tanstack/vue-query.gen.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-axios-plugin-tanstack-vue-query/@tanstack/vue-query.gen.ts.snap @@ -9,14 +9,14 @@ import type { AxiosError } from 'axios'; type QueryKey = [ Pick & { _id: string; - infinite?: boolean; + _infinite?: boolean; } ]; const createQueryKey = (id: string, options?: TOptions, infinite?: boolean): QueryKey[0] => { const params: QueryKey[0] = { _id: id, baseURL: client.getConfig().baseURL } as QueryKey[0]; if (infinite) { - params.infinite = infinite; + params._infinite = infinite; } if (options?.body) { params.body = options.body; @@ -237,6 +237,7 @@ export const callWithParametersInfiniteOptions = (options: Options = [ Pick & { _id: string; - infinite?: boolean; + _infinite?: boolean; } ]; const createQueryKey = (id: string, options?: TOptions, infinite?: boolean): QueryKey[0] => { const params: QueryKey[0] = { _id: id, baseURL: client.getConfig().baseURL } as QueryKey[0]; if (infinite) { - params.infinite = infinite; + params._infinite = infinite; } if (options?.body) { params.body = options.body; diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-fetch-plugin-tanstack-react-query/@tanstack/react-query.gen.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-fetch-plugin-tanstack-react-query/@tanstack/react-query.gen.ts.snap index eb4937625..f8f054081 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-fetch-plugin-tanstack-react-query/@tanstack/react-query.gen.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-fetch-plugin-tanstack-react-query/@tanstack/react-query.gen.ts.snap @@ -8,14 +8,14 @@ import type { ImportData, ImportError, ImportResponse, DeleteFooData3, CallWithD type QueryKey = [ Pick & { _id: string; - infinite?: boolean; + _infinite?: boolean; } ]; const createQueryKey = (id: string, options?: TOptions, infinite?: boolean): QueryKey[0] => { const params: QueryKey[0] = { _id: id, baseUrl: client.getConfig().baseUrl } as QueryKey[0]; if (infinite) { - params.infinite = infinite; + params._infinite = infinite; } if (options?.body) { params.body = options.body; @@ -236,6 +236,7 @@ export const callWithParametersInfiniteOptions = (options: Options = [ Pick & { _id: string; - infinite?: boolean; + _infinite?: boolean; } ]; const createQueryKey = (id: string, options?: TOptions, infinite?: boolean): QueryKey[0] => { const params: QueryKey[0] = { _id: id, baseUrl: client.getConfig().baseUrl } as QueryKey[0]; if (infinite) { - params.infinite = infinite; + params._infinite = infinite; } if (options?.body) { params.body = options.body; diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-fetch-plugin-tanstack-solid-query/@tanstack/solid-query.gen.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-fetch-plugin-tanstack-solid-query/@tanstack/solid-query.gen.ts.snap index 08d97fb52..ad9ce357b 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-fetch-plugin-tanstack-solid-query/@tanstack/solid-query.gen.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-fetch-plugin-tanstack-solid-query/@tanstack/solid-query.gen.ts.snap @@ -8,14 +8,14 @@ import type { ImportData, ImportError, ImportResponse, DeleteFooData3, CallWithD type QueryKey = [ Pick & { _id: string; - infinite?: boolean; + _infinite?: boolean; } ]; const createQueryKey = (id: string, options?: TOptions, infinite?: boolean): QueryKey[0] => { const params: QueryKey[0] = { _id: id, baseUrl: client.getConfig().baseUrl } as QueryKey[0]; if (infinite) { - params.infinite = infinite; + params._infinite = infinite; } if (options?.body) { params.body = options.body; @@ -236,6 +236,7 @@ export const callWithParametersInfiniteOptions = (options: Options = [ Pick & { _id: string; - infinite?: boolean; + _infinite?: boolean; } ]; const createQueryKey = (id: string, options?: TOptions, infinite?: boolean): QueryKey[0] => { const params: QueryKey[0] = { _id: id, baseUrl: client.getConfig().baseUrl } as QueryKey[0]; if (infinite) { - params.infinite = infinite; + params._infinite = infinite; } if (options?.body) { params.body = options.body; diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-fetch-plugin-tanstack-svelte-query/@tanstack/svelte-query.gen.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-fetch-plugin-tanstack-svelte-query/@tanstack/svelte-query.gen.ts.snap index 2dc43a73f..841f82420 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-fetch-plugin-tanstack-svelte-query/@tanstack/svelte-query.gen.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-fetch-plugin-tanstack-svelte-query/@tanstack/svelte-query.gen.ts.snap @@ -8,14 +8,14 @@ import type { ImportData, ImportError, ImportResponse, DeleteFooData3, CallWithD type QueryKey = [ Pick & { _id: string; - infinite?: boolean; + _infinite?: boolean; } ]; const createQueryKey = (id: string, options?: TOptions, infinite?: boolean): QueryKey[0] => { const params: QueryKey[0] = { _id: id, baseUrl: client.getConfig().baseUrl } as QueryKey[0]; if (infinite) { - params.infinite = infinite; + params._infinite = infinite; } if (options?.body) { params.body = options.body; @@ -236,6 +236,7 @@ export const callWithParametersInfiniteOptions = (options: Options = [ Pick & { _id: string; - infinite?: boolean; + _infinite?: boolean; } ]; const createQueryKey = (id: string, options?: TOptions, infinite?: boolean): QueryKey[0] => { const params: QueryKey[0] = { _id: id, baseUrl: client.getConfig().baseUrl } as QueryKey[0]; if (infinite) { - params.infinite = infinite; + params._infinite = infinite; } if (options?.body) { params.body = options.body; diff --git a/packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-fetch-plugin-tanstack-vue-query/@tanstack/vue-query.gen.ts.snap b/packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-fetch-plugin-tanstack-vue-query/@tanstack/vue-query.gen.ts.snap index 615ce418b..06fe6f04b 100644 --- a/packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-fetch-plugin-tanstack-vue-query/@tanstack/vue-query.gen.ts.snap +++ b/packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-fetch-plugin-tanstack-vue-query/@tanstack/vue-query.gen.ts.snap @@ -8,14 +8,14 @@ import type { ImportData, ImportError, ImportResponse, DeleteFooData3, CallWithD type QueryKey = [ Pick & { _id: string; - infinite?: boolean; + _infinite?: boolean; } ]; const createQueryKey = (id: string, options?: TOptions, infinite?: boolean): QueryKey[0] => { const params: QueryKey[0] = { _id: id, baseUrl: client.getConfig().baseUrl } as QueryKey[0]; if (infinite) { - params.infinite = infinite; + params._infinite = infinite; } if (options?.body) { params.body = options.body; @@ -236,6 +236,7 @@ export const callWithParametersInfiniteOptions = (options: Options = [ Pick & { _id: string; - infinite?: boolean; + _infinite?: boolean; } ]; const createQueryKey = (id: string, options?: TOptions, infinite?: boolean): QueryKey[0] => { const params: QueryKey[0] = { _id: id, baseUrl: client.getConfig().baseUrl } as QueryKey[0]; if (infinite) { - params.infinite = infinite; + params._infinite = infinite; } if (options?.body) { params.body = options.body; diff --git a/packages/openapi-ts/test/sample.cjs b/packages/openapi-ts/test/sample.cjs index bf82eb989..df4aef134 100644 --- a/packages/openapi-ts/test/sample.cjs +++ b/packages/openapi-ts/test/sample.cjs @@ -17,19 +17,19 @@ const main = async () => { output: { path: './test/generated/sample/', }, - // plugins: [ - // { - // // infiniteQueryOptions: false, - // // mutationOptions: false, - // name: '@tanstack/react-query', - // // queryOptions: false, - // }, - // ], + plugins: [ + { + // infiniteQueryOptions: false, + // mutationOptions: false, + name: '@tanstack/react-query', + // queryOptions: false, + }, + ], schemas: { export: false, }, services: { - export: false, + // export: false, // asClass: true, // filter: '^POST /api/v{api-version}/upload$', // export: false,