fork of hey-api/openapi-ts because I need some additional things

Merge pull request #2569 from hey-api/fix/tanstack-query-hooks

feat(tanstack-query): add hooks options

authored by

Lubos and committed by
GitHub
b907a3e4 32ed5482

+343 -80
+2 -10
.changeset/changelog.js
··· 23 23 24 24 return ['### Updated Dependencies:', ...list].join('\n'); 25 25 }, 26 - getReleaseLine: async (changeset, type, changelogOpts) => { 27 - console.warn('----🐍🐍🐍🐍🐍🐍🐍'); 28 - console.warn(changeset); 29 - console.warn(type); 30 - console.warn(changelogOpts); 31 - console.warn('----🐍🐍🐍🐍🐍🐍🐍'); 26 + getReleaseLine: async (changeset) => { 32 27 const repo = getRepo(); 33 28 34 29 /** @type number | undefined */ ··· 73 68 } 74 69 const commitToFetchFrom = commitFromSummary || changeset.commit; 75 70 if (commitToFetchFrom) { 76 - const { links } = await getInfo({ 77 - commit: commitToFetchFrom, 78 - repo, 79 - }); 71 + const { links } = await getInfo({ commit: commitToFetchFrom, repo }); 80 72 return links; 81 73 } 82 74 return {
+3 -1
packages/openapi-ts-tests/main/test/openapi-ts.config.ts
··· 81 81 // deprecated: false, 82 82 operations: { 83 83 include: [ 84 - 'GET /event', 84 + // 'GET /event', 85 85 // '/^[A-Z]+ /v1//', 86 86 ], 87 87 }, ··· 212 212 // queryKeys: { 213 213 // name: '{{name}}QK', 214 214 // }, 215 + queryOptions: false, 215 216 // queryOptions: { 216 217 // name: '{{name}}QO', 217 218 // }, 219 + useQuery: true, 218 220 '~hooks': { 219 221 operations: { 220 222 getKind: (op) => {
+3 -1
packages/openapi-ts/README.md
··· 205 205 206 206 ### Node.js 207 207 208 - You can also generate output programmatically by importing `@hey-api/openapi-ts` in a TypeScript file. 208 + You can also generate output programmatically by calling `createClient()` in a JavaScript/TypeScript file. 209 + 210 + #### `script.ts` 209 211 210 212 ```ts 211 213 import { createClient } from '@hey-api/openapi-ts';
+3 -1
packages/openapi-ts/src/plugins/@pinia/colada/queryOptions.ts
··· 5 5 import { tsc } from '../../../tsc'; 6 6 import { 7 7 createOperationComment, 8 + hasOperationSse, 8 9 isOperationOptionsRequired, 9 10 } from '../../shared/utils/operation'; 10 11 import { handleMeta } from './meta'; ··· 35 36 }): void => { 36 37 if ( 37 38 !plugin.config.queryOptions.enabled || 38 - !plugin.hooks.operation.isQuery(operation) 39 + !plugin.hooks.operation.isQuery(operation) || 40 + hasOperationSse({ operation }) 39 41 ) { 40 42 return; 41 43 }
+1
packages/openapi-ts/src/plugins/@tanstack/angular-query-experimental/config.ts
··· 77 77 defaultValue: { 78 78 case: plugin.config.case ?? 'camelCase', 79 79 enabled: true, 80 + exported: true, 80 81 name: '{{name}}Options', 81 82 }, 82 83 mappers: {
+12
packages/openapi-ts/src/plugins/@tanstack/angular-query-experimental/types.d.ts
··· 268 268 */ 269 269 enabled?: boolean; 270 270 /** 271 + * Whether to export generated symbols. 272 + * 273 + * @default true 274 + */ 275 + exported?: boolean; 276 + /** 271 277 * Custom function to generate metadata for the operation. 272 278 * Can return any valid meta object that will be included in the generated query options. 273 279 * @param operation - The operation object containing all available metadata ··· 510 516 * @default true 511 517 */ 512 518 enabled: boolean; 519 + /** 520 + * Whether to export generated symbols. 521 + * 522 + * @default true 523 + */ 524 + exported: boolean; 513 525 /** 514 526 * Custom function to generate metadata for the operation. 515 527 * Can return any valid meta object that will be included in the generated query options.
+2 -9
packages/openapi-ts/src/plugins/@tanstack/query-core/infiniteQueryOptions.ts
··· 234 234 plugin: PluginInstance; 235 235 queryFn: string; 236 236 state: PluginState; 237 - }) => { 238 - if ( 239 - !plugin.config.infiniteQueryOptions.enabled || 240 - !plugin.hooks.operation.isQuery(operation) 241 - ) { 242 - return state; 243 - } 244 - 237 + }): void => { 245 238 const pagination = operationPagination({ 246 239 context: plugin.context, 247 240 operation, 248 241 }); 249 242 250 243 if (!pagination) { 251 - return state; 244 + return; 252 245 } 253 246 254 247 const file = plugin.context.file({ id: plugin.name })!;
+1 -10
packages/openapi-ts/src/plugins/@tanstack/query-core/mutationOptions.ts
··· 19 19 plugin: PluginInstance; 20 20 queryFn: string; 21 21 state: PluginState; 22 - }) => { 23 - if ( 24 - !plugin.config.mutationOptions.enabled || 25 - !plugin.hooks.operation.isMutation(operation) 26 - ) { 27 - return state; 28 - } 29 - 22 + }): void => { 30 23 const mutationsType = 31 24 plugin.name === '@tanstack/angular-query-experimental' || 32 25 plugin.name === '@tanstack/svelte-query' || ··· 165 158 name: identifier.name || '', 166 159 }); 167 160 file.add(statement); 168 - 169 - return state; 170 161 };
+33 -18
packages/openapi-ts/src/plugins/@tanstack/query-core/plugin.ts
··· 8 8 import { createMutationOptions } from './mutationOptions'; 9 9 import { createQueryOptions } from './queryOptions'; 10 10 import type { PluginHandler, PluginState } from './types'; 11 + import { createUseQuery } from './useQuery'; 11 12 12 13 export const handler = ({ plugin }: Parameters<PluginHandler>[0]) => { 13 14 const file = plugin.createFile({ ··· 68 69 ] 69 70 ).join('.'); 70 71 71 - createQueryOptions({ 72 - operation, 73 - plugin, 74 - queryFn, 75 - state, 76 - }); 72 + if (plugin.hooks.operation.isQuery(operation)) { 73 + if (plugin.config.queryOptions.enabled) { 74 + createQueryOptions({ 75 + operation, 76 + plugin, 77 + queryFn, 78 + state, 79 + }); 80 + } 77 81 78 - createInfiniteQueryOptions({ 79 - operation, 80 - plugin, 81 - queryFn, 82 - state, 83 - }); 82 + if (plugin.config.infiniteQueryOptions.enabled) { 83 + createInfiniteQueryOptions({ 84 + operation, 85 + plugin, 86 + queryFn, 87 + state, 88 + }); 89 + } 84 90 85 - createMutationOptions({ 86 - operation, 87 - plugin, 88 - queryFn, 89 - state, 90 - }); 91 + if ('useQuery' in plugin.config && plugin.config.useQuery.enabled) { 92 + createUseQuery({ operation, plugin, state }); 93 + } 94 + } 95 + 96 + if (plugin.hooks.operation.isMutation(operation)) { 97 + if (plugin.config.mutationOptions.enabled) { 98 + createMutationOptions({ 99 + operation, 100 + plugin, 101 + queryFn, 102 + state, 103 + }); 104 + } 105 + } 91 106 92 107 if (state.hasUsedQueryFn) { 93 108 file.import({
+5 -9
packages/openapi-ts/src/plugins/@tanstack/query-core/queryOptions.ts
··· 4 4 import { tsc } from '../../../tsc'; 5 5 import { 6 6 createOperationComment, 7 + hasOperationSse, 7 8 isOperationOptionsRequired, 8 9 } from '../../shared/utils/operation'; 9 10 import { handleMeta } from './meta'; ··· 28 29 plugin: PluginInstance; 29 30 queryFn: string; 30 31 state: PluginState; 31 - }) => { 32 - if ( 33 - !plugin.config.queryOptions.enabled || 34 - !plugin.hooks.operation.isQuery(operation) 35 - ) { 36 - return state; 32 + }): void => { 33 + if (hasOperationSse({ operation })) { 34 + return; 37 35 } 38 36 39 37 const file = plugin.context.file({ id: plugin.name })!; ··· 179 177 comment: plugin.config.comments 180 178 ? createOperationComment({ operation }) 181 179 : undefined, 182 - exportConst: true, 180 + exportConst: plugin.config.queryOptions.exported, 183 181 expression: tsc.arrowFunction({ 184 182 parameters: [ 185 183 { ··· 200 198 // TODO: AxiosError<PutSubmissionMetaError> 201 199 }); 202 200 file.add(statement); 203 - 204 - return state; 205 201 };
+1
packages/openapi-ts/src/plugins/@tanstack/query-core/types.d.ts
··· 25 25 hasInfiniteQueries: boolean; 26 26 hasMutations: boolean; 27 27 hasQueries: boolean; 28 + hasUseQuery?: boolean; 28 29 hasUsedQueryFn: boolean; 29 30 typeInfiniteData: ImportExportItem; 30 31 }
+92
packages/openapi-ts/src/plugins/@tanstack/query-core/useQuery.ts
··· 1 + import type { IR } from '../../../ir/types'; 2 + import { tsc } from '../../../tsc'; 3 + import { 4 + createOperationComment, 5 + hasOperationSse, 6 + isOperationOptionsRequired, 7 + } from '../../shared/utils/operation'; 8 + import type { PluginInstance, PluginState } from './types'; 9 + import { useTypeData } from './useType'; 10 + 11 + const useQueryFn = 'useQuery'; 12 + const optionsParamName = 'options'; 13 + 14 + export const createUseQuery = ({ 15 + operation, 16 + plugin, 17 + state, 18 + }: { 19 + operation: IR.OperationObject; 20 + plugin: PluginInstance; 21 + state: PluginState; 22 + }): void => { 23 + if (hasOperationSse({ operation })) { 24 + return; 25 + } 26 + 27 + const file = plugin.context.file({ id: plugin.name })!; 28 + 29 + if (!state.hasUseQuery) { 30 + state.hasUseQuery = true; 31 + 32 + file.import({ 33 + module: plugin.name, 34 + name: useQueryFn, 35 + }); 36 + } 37 + 38 + const identifierUseQuery = file.identifier({ 39 + // TODO: refactor for better cross-plugin compatibility 40 + $ref: `#/tanstack-query-use-query/${operation.id}`, 41 + case: 'useQuery' in plugin.config ? plugin.config.useQuery.case : undefined, 42 + create: true, 43 + nameTransformer: 44 + 'useQuery' in plugin.config ? plugin.config.useQuery.name : undefined, 45 + namespace: 'value', 46 + }); 47 + 48 + const identifierQueryOptions = file.identifier({ 49 + // TODO: refactor for better cross-plugin compatibility 50 + $ref: `#/tanstack-query-query-options/${operation.id}`, 51 + case: plugin.config.queryOptions.case, 52 + nameTransformer: plugin.config.queryOptions.name, 53 + namespace: 'value', 54 + }); 55 + 56 + const isRequiredOptions = isOperationOptionsRequired({ 57 + context: plugin.context, 58 + operation, 59 + }); 60 + const typeData = useTypeData({ operation, plugin }); 61 + 62 + const statement = tsc.constVariable({ 63 + comment: plugin.config.comments 64 + ? createOperationComment({ operation }) 65 + : undefined, 66 + exportConst: true, 67 + expression: tsc.arrowFunction({ 68 + parameters: [ 69 + { 70 + isRequired: isRequiredOptions, 71 + name: optionsParamName, 72 + type: typeData, 73 + }, 74 + ], 75 + statements: [ 76 + tsc.returnStatement({ 77 + expression: tsc.callExpression({ 78 + functionName: useQueryFn, 79 + parameters: [ 80 + tsc.callExpression({ 81 + functionName: identifierQueryOptions.name || '', 82 + parameters: [optionsParamName], 83 + }), 84 + ], 85 + }), 86 + }), 87 + ], 88 + }), 89 + name: identifierUseQuery.name || '', 90 + }); 91 + file.add(statement); 92 + };
+24
packages/openapi-ts/src/plugins/@tanstack/react-query/config.ts
··· 77 77 defaultValue: { 78 78 case: plugin.config.case ?? 'camelCase', 79 79 enabled: true, 80 + exported: true, 80 81 name: '{{name}}Options', 81 82 }, 82 83 mappers: { ··· 86 87 }, 87 88 value: plugin.config.queryOptions, 88 89 }); 90 + 91 + plugin.config.useQuery = context.valueToObject({ 92 + defaultValue: { 93 + case: plugin.config.case ?? 'camelCase', 94 + enabled: false, 95 + name: 'use{{name}}Query', 96 + }, 97 + mappers: { 98 + boolean: (enabled) => ({ enabled }), 99 + function: (name) => ({ enabled: true, name }), 100 + object: (fields) => ({ enabled: true, ...fields }), 101 + string: (name) => ({ enabled: true, name }), 102 + }, 103 + value: plugin.config.useQuery, 104 + }); 105 + 106 + if (plugin.config.useQuery.enabled) { 107 + // useQuery hooks consume queryOptions 108 + if (!plugin.config.queryOptions.enabled) { 109 + plugin.config.queryOptions.enabled = true; 110 + plugin.config.queryOptions.exported = false; 111 + } 112 + } 89 113 }, 90 114 }; 91 115
+108 -21
packages/openapi-ts/src/plugins/@tanstack/react-query/types.d.ts
··· 31 31 /** 32 32 * Configuration for generated infinite query key helpers. 33 33 * 34 - * See {@link https://tanstack.com/query/v5/docs/framework/react/reference/infiniteQueryOptions TanStack Query: infiniteQueryOptions} 34 + * See {@link https://tanstack.com/query/v5/docs/framework/react/reference/infiniteQueryOptions infiniteQueryOptions} 35 35 * 36 36 * Can be: 37 37 * - `boolean`: Shorthand for `{ enabled: boolean }` ··· 60 60 * Custom naming pattern for generated infinite query key names. The name variable is 61 61 * obtained from the SDK function name. 62 62 * 63 + * See {@link https://tanstack.com/query/v5/docs/framework/react/reference/infiniteQueryOptions infiniteQueryOptions} 64 + * 63 65 * @default '{{name}}InfiniteQueryKey' 64 - * @see https://tanstack.com/query/v5/docs/framework/react/reference/infiniteQueryOptions 65 66 */ 66 67 name?: StringName; 67 68 /** ··· 75 76 /** 76 77 * Configuration for generated infinite query options helpers. 77 78 * 78 - * See {@link https://tanstack.com/query/v5/docs/framework/react/reference/infiniteQueryOptions TanStack Query: infiniteQueryOptions} 79 + * See {@link https://tanstack.com/query/v5/docs/framework/react/reference/infiniteQueryOptions infiniteQueryOptions} 79 80 * 80 81 * Can be: 81 82 * - `boolean`: Shorthand for `{ enabled: boolean }` ··· 126 127 /** 127 128 * Custom naming pattern for generated infinite query options names. The name variable is 128 129 * obtained from the SDK function name. 130 + * 131 + * See {@link https://tanstack.com/query/v5/docs/framework/react/reference/infiniteQueryOptions infiniteQueryOptions} 129 132 * 130 133 * @default '{{name}}InfiniteOptions' 131 - * @see https://tanstack.com/query/v5/docs/framework/react/reference/infiniteQueryOptions 132 134 */ 133 135 name?: StringName; 134 136 }; 135 137 /** 136 138 * Configuration for generated mutation options helpers. 137 139 * 138 - * See {@link https://tanstack.com/query/v5/docs/framework/react/reference/useMutation TanStack Query: useMutation} 140 + * See {@link https://tanstack.com/query/v5/docs/framework/react/reference/useMutation useMutation} 139 141 * 140 142 * Can be: 141 143 * - `boolean`: Shorthand for `{ enabled: boolean }` ··· 187 189 * Custom naming pattern for generated mutation options names. The name variable is 188 190 * obtained from the SDK function name. 189 191 * 192 + * See {@link https://tanstack.com/query/v5/docs/framework/react/reference/useMutation useMutation} 193 + * 190 194 * @default '{{name}}Mutation' 191 - * @see https://tanstack.com/query/v5/docs/framework/react/reference/useMutation 192 195 */ 193 196 name?: StringName; 194 197 }; ··· 201 204 /** 202 205 * Configuration for generated query keys. 203 206 * 204 - * See {@link https://tanstack.com/query/v5/docs/framework/react/reference/queryKey TanStack Query: queryKey} 207 + * See {@link https://tanstack.com/query/v5/docs/framework/react/reference/queryKey queryKey} 205 208 * 206 209 * Can be: 207 210 * - `boolean`: Shorthand for `{ enabled: boolean }` ··· 230 233 * Custom naming pattern for generated query key names. The name variable is 231 234 * obtained from the SDK function name. 232 235 * 236 + * See {@link https://tanstack.com/query/v5/docs/framework/react/guides/query-keys Query Keys} 237 + * 233 238 * @default '{{name}}QueryKey' 234 - * @see https://tanstack.com/query/v5/docs/framework/react/reference/queryKey 235 239 */ 236 240 name?: StringName; 237 241 /** ··· 245 249 /** 246 250 * Configuration for generated query options helpers. 247 251 * 248 - * See {@link https://tanstack.com/query/v5/docs/framework/react/reference/queryOptions TanStack Query: queryOptions} 252 + * See {@link https://tanstack.com/query/v5/docs/framework/react/reference/queryOptions queryOptions} 249 253 * 250 254 * Can be: 251 255 * - `boolean`: Shorthand for `{ enabled: boolean }` ··· 271 275 */ 272 276 enabled?: boolean; 273 277 /** 278 + * Whether to export generated symbols. 279 + * 280 + * @default true 281 + */ 282 + exported?: boolean; 283 + /** 274 284 * Custom function to generate metadata for the operation. 275 285 * Can return any valid meta object that will be included in the generated query options. 276 286 * ··· 293 303 * @default undefined 294 304 */ 295 305 meta?: (operation: IR.OperationObject) => Record<string, unknown>; 296 - 297 306 /** 298 307 * Custom naming pattern for generated query options names. The name variable is 299 308 * obtained from the SDK function name. 309 + * 310 + * See {@link https://tanstack.com/query/v5/docs/framework/react/reference/queryOptions queryOptions} 300 311 * 301 312 * @default '{{name}}Options' 302 - * @see https://tanstack.com/query/v5/docs/framework/react/reference/queryOptions 313 + */ 314 + name?: StringName; 315 + }; 316 + /** 317 + * Configuration for generated `useQuery()` function helpers. 318 + * 319 + * See {@link https://tanstack.com/query/v5/docs/framework/react/reference/useQuery useQuery} 320 + * 321 + * Can be: 322 + * - `boolean`: Shorthand for `{ enabled: boolean }` 323 + * - `string` or `function`: Shorthand for `{ name: string | function }` 324 + * - `object`: Full configuration object 325 + * 326 + * @default false 327 + */ 328 + useQuery?: 329 + | boolean 330 + | StringName 331 + | { 332 + /** 333 + * The casing convention to use for generated names. 334 + * 335 + * @default 'camelCase' 336 + */ 337 + case?: StringCase; 338 + /** 339 + * Whether to generate `useQuery()` function helpers. 340 + * 341 + * @default true 342 + */ 343 + enabled?: boolean; 344 + /** 345 + * Custom naming pattern for generated `useQuery()` function names. The name variable is 346 + * obtained from the SDK function name. 347 + * 348 + * See {@link https://tanstack.com/query/v5/docs/framework/react/reference/useQuery useQuery} 349 + * 350 + * @default 'use{{name}}Query' 303 351 */ 304 352 name?: StringName; 305 353 }; ··· 328 376 /** 329 377 * Resolved configuration for generated infinite query key helpers. 330 378 * 331 - * @see https://tanstack.com/query/v5/docs/framework/react/reference/infiniteQueryOptions 379 + * See {@link https://tanstack.com/query/v5/docs/framework/react/reference/infiniteQueryOptions infiniteQueryOptions} 332 380 */ 333 381 infiniteQueryKeys: { 334 382 /** ··· 346 394 /** 347 395 * Custom naming pattern for generated infinite query key names. The name variable is obtained from the SDK function name. 348 396 * 397 + * See {@link https://tanstack.com/query/v5/docs/framework/react/reference/infiniteQueryOptions infiniteQueryOptions} 398 + * 349 399 * @default '{{name}}InfiniteQueryKey' 350 - * @see https://tanstack.com/query/v5/docs/framework/react/reference/infiniteQueryOptions 351 400 */ 352 401 name: StringName; 353 402 /** ··· 361 410 /** 362 411 * Resolved configuration for generated infinite query options helpers. 363 412 * 364 - * @see https://tanstack.com/query/v5/docs/framework/react/reference/infiniteQueryOptions 413 + * See {@link https://tanstack.com/query/v5/docs/framework/react/reference/infiniteQueryOptions infiniteQueryOptions} 365 414 */ 366 415 infiniteQueryOptions: { 367 416 /** ··· 402 451 /** 403 452 * Custom naming pattern for generated infinite query options names. The name variable is obtained from the SDK function name. 404 453 * 454 + * See {@link https://tanstack.com/query/v5/docs/framework/react/reference/infiniteQueryOptions infiniteQueryOptions} 455 + * 405 456 * @default '{{name}}InfiniteOptions' 406 - * @see https://tanstack.com/query/v5/docs/framework/react/reference/infiniteQueryOptions 407 457 */ 408 458 name: StringName; 409 459 }; 410 460 /** 411 461 * Resolved configuration for generated mutation options helpers. 412 462 * 413 - * @see https://tanstack.com/query/v5/docs/framework/react/reference/useMutation 463 + * See {@link https://tanstack.com/query/v5/docs/framework/react/reference/useMutation useMutation} 414 464 */ 415 465 mutationOptions: { 416 466 /** ··· 451 501 /** 452 502 * Custom naming pattern for generated mutation options names. The name variable is obtained from the SDK function name. 453 503 * 504 + * See {@link https://tanstack.com/query/v5/docs/framework/react/reference/useMutation useMutation} 505 + * 454 506 * @default '{{name}}Mutation' 455 - * @see https://tanstack.com/query/v5/docs/framework/react/reference/useMutation 456 507 */ 457 508 name: StringName; 458 509 }; ··· 465 516 /** 466 517 * Resolved configuration for generated query keys. 467 518 * 468 - * @see https://tanstack.com/query/v5/docs/framework/react/reference/queryKey 519 + * See {@link https://tanstack.com/query/v5/docs/framework/react/guides/query-keys Query Keys} 469 520 */ 470 521 queryKeys: { 471 522 /** ··· 482 533 enabled: boolean; 483 534 /** 484 535 * Custom naming pattern for generated query key names. The name variable is obtained from the SDK function name. 536 + * 537 + * See {@link https://tanstack.com/query/v5/docs/framework/react/guides/query-keys Query Keys} 485 538 * 486 539 * @default '{{name}}QueryKey' 487 - * @see https://tanstack.com/query/v5/docs/framework/react/reference/queryKey 488 540 */ 489 541 name: StringName; 490 542 /** ··· 498 550 /** 499 551 * Resolved configuration for generated query options helpers. 500 552 * 501 - * See {@link https://tanstack.com/query/v5/docs/framework/react/reference/queryOptions TanStack Query: queryOptions} 553 + * See {@link https://tanstack.com/query/v5/docs/framework/react/reference/queryOptions queryOptions} 502 554 */ 503 555 queryOptions: { 504 556 /** ··· 514 566 */ 515 567 enabled: boolean; 516 568 /** 569 + * Whether to export generated symbols. 570 + * 571 + * @default true 572 + */ 573 + exported: boolean; 574 + /** 517 575 * Custom function to generate metadata for the operation. 518 576 * Can return any valid meta object that will be included in the generated query options. 519 577 * ··· 539 597 /** 540 598 * Custom naming pattern for generated query options names. The name variable is obtained from the SDK function name. 541 599 * 600 + * See {@link https://tanstack.com/query/v5/docs/framework/react/reference/queryOptions queryOptions} 601 + * 542 602 * @default '{{name}}Options' 543 - * @see https://tanstack.com/query/v5/docs/framework/react/reference/queryOptions 603 + */ 604 + name: StringName; 605 + }; 606 + /** 607 + * Configuration for generated `useQuery()` function helpers. 608 + * 609 + * See {@link https://tanstack.com/query/v5/docs/framework/react/reference/useQuery useQuery} 610 + */ 611 + useQuery: { 612 + /** 613 + * The casing convention to use for generated names. 614 + * 615 + * @default 'camelCase' 616 + */ 617 + case: StringCase; 618 + /** 619 + * Whether to generate `useQuery()` function helpers. 620 + * 621 + * @default true 622 + */ 623 + enabled: boolean; 624 + /** 625 + * Custom naming pattern for generated `useQuery()` function names. The name variable is 626 + * obtained from the SDK function name. 627 + * 628 + * See {@link https://tanstack.com/query/v5/docs/framework/react/reference/useQuery useQuery} 629 + * 630 + * @default 'use{{name}}Query' 544 631 */ 545 632 name: StringName; 546 633 };
+1
packages/openapi-ts/src/plugins/@tanstack/solid-query/config.ts
··· 77 77 defaultValue: { 78 78 case: plugin.config.case ?? 'camelCase', 79 79 enabled: true, 80 + exported: true, 80 81 name: '{{name}}Options', 81 82 }, 82 83 mappers: {
+12
packages/openapi-ts/src/plugins/@tanstack/solid-query/types.d.ts
··· 269 269 */ 270 270 enabled?: boolean; 271 271 /** 272 + * Whether to export generated symbols. 273 + * 274 + * @default true 275 + */ 276 + exported?: boolean; 277 + /** 272 278 * Custom function to generate metadata for the operation. 273 279 * Can return any valid meta object that will be included in the generated query options. 274 280 * @param operation - The operation object containing all available metadata ··· 511 517 * @default true 512 518 */ 513 519 enabled: boolean; 520 + /** 521 + * Whether to export generated symbols. 522 + * 523 + * @default true 524 + */ 525 + exported: boolean; 514 526 /** 515 527 * Custom function to generate metadata for the operation. 516 528 * Can return any valid meta object that will be included in the generated query options.
+1
packages/openapi-ts/src/plugins/@tanstack/svelte-query/config.ts
··· 77 77 defaultValue: { 78 78 case: plugin.config.case ?? 'camelCase', 79 79 enabled: true, 80 + exported: true, 80 81 name: '{{name}}Options', 81 82 }, 82 83 mappers: {
+12
packages/openapi-ts/src/plugins/@tanstack/svelte-query/types.d.ts
··· 268 268 */ 269 269 enabled?: boolean; 270 270 /** 271 + * Whether to export generated symbols. 272 + * 273 + * @default true 274 + */ 275 + exported?: boolean; 276 + /** 271 277 * Custom function to generate metadata for the operation. 272 278 * Can return any valid meta object that will be included in the generated query options. 273 279 * @param operation - The operation object containing all available metadata ··· 510 516 * @default true 511 517 */ 512 518 enabled: boolean; 519 + /** 520 + * Whether to export generated symbols. 521 + * 522 + * @default true 523 + */ 524 + exported: boolean; 513 525 /** 514 526 * Custom function to generate metadata for the operation. 515 527 * Can return any valid meta object that will be included in the generated query options.
+1
packages/openapi-ts/src/plugins/@tanstack/vue-query/config.ts
··· 77 77 defaultValue: { 78 78 case: plugin.config.case ?? 'camelCase', 79 79 enabled: true, 80 + exported: true, 80 81 name: '{{name}}Options', 81 82 }, 82 83 mappers: {
+12
packages/openapi-ts/src/plugins/@tanstack/vue-query/types.d.ts
··· 270 270 */ 271 271 enabled?: boolean; 272 272 /** 273 + * Whether to export generated symbols. 274 + * 275 + * @default true 276 + */ 277 + exported?: boolean; 278 + /** 273 279 * Custom function to generate metadata for the operation. 274 280 * Can return any valid meta object that will be included in the generated query options. 275 281 * ··· 515 521 * @default true 516 522 */ 517 523 enabled: boolean; 524 + /** 525 + * Whether to export generated symbols. 526 + * 527 + * @default true 528 + */ 529 + exported: boolean; 518 530 /** 519 531 * Custom function to generate metadata for the operation. 520 532 * Can return any valid meta object that will be included in the generated query options.
+14
packages/openapi-ts/src/plugins/shared/utils/operation.ts
··· 42 42 hasOperationDataRequired(operation) 43 43 ); 44 44 }; 45 + 46 + export const hasOperationSse = ({ 47 + operation, 48 + }: { 49 + operation: IR.OperationObject; 50 + }): boolean => { 51 + for (const statusCode in operation.responses) { 52 + const response = operation.responses[statusCode]!; 53 + if (response.mediaType === 'text/event-stream') { 54 + return true; 55 + } 56 + } 57 + return false; 58 + };