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

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #927 from hey-api/chore/tanstack-query-wip-9

chore: progress on TanStack Query plugin

authored by

Lubos and committed by
GitHub
76228dae fa65218c

+2517 -3197
+5
.changeset/tall-deers-shout.md
··· 1 + --- 2 + '@hey-api/openapi-ts': patch 3 + --- 4 + 5 + fix: update TanStack Query key to contain base URL
+5
.changeset/wild-toys-yawn.md
··· 1 + --- 2 + '@hey-api/openapi-ts': patch 3 + --- 4 + 5 + fix: change TanStack Query mutation helpers to functions for consistent API
+8 -6
packages/openapi-ts/src/compiler/module.ts
··· 36 36 types, 37 37 }: { 38 38 functionName: string | ts.PropertyAccessExpression; 39 - parameters?: Array<string | ts.Expression>; 39 + parameters?: Array<string | ts.Expression | undefined>; 40 40 types?: ReadonlyArray<ts.TypeNode>; 41 41 }) => { 42 42 const expression = 43 43 typeof functionName === 'string' 44 44 ? createIdentifier({ text: functionName }) 45 45 : functionName; 46 - const argumentsArray = parameters.map((parameter) => 47 - typeof parameter === 'string' 48 - ? createIdentifier({ text: parameter }) 49 - : parameter, 50 - ); 46 + const argumentsArray = parameters 47 + .filter((parameter) => parameter !== undefined) 48 + .map((parameter) => 49 + typeof parameter === 'string' 50 + ? createIdentifier({ text: parameter }) 51 + : parameter, 52 + ); 51 53 const callExpression = ts.factory.createCallExpression( 52 54 expression, 53 55 types,
+7 -4
packages/openapi-ts/src/compiler/typedef.ts
··· 98 98 * @param isNullable - if the whole type can be null 99 99 * @returns ts.IntersectionTypeNode | ts.UnionTypeNode 100 100 */ 101 - export const createTypeIntersectNode = ( 102 - types: (any | ts.TypeNode)[], 103 - isNullable: boolean = false, 104 - ) => { 101 + export const createTypeIntersectNode = ({ 102 + isNullable, 103 + types, 104 + }: { 105 + isNullable?: boolean; 106 + types: (any | ts.TypeNode)[]; 107 + }) => { 105 108 const nodes = types.map((type) => createTypeNode(type)); 106 109 const node = ts.factory.createIntersectionTypeNode(nodes); 107 110 return maybeNullable({ isNullable, node });
+6 -3
packages/openapi-ts/src/compiler/types.ts
··· 338 338 comments?: Comments; 339 339 isValueAccess?: boolean; 340 340 key: string; 341 + shorthand?: boolean; 341 342 value: any; 342 343 }; 343 344 ··· 363 364 identifiers = [], 364 365 multiLine = true, 365 366 obj, 366 - shorthand = false, 367 + shorthand, 367 368 unescape = false, 368 369 }: { 369 370 comments?: Comments; ··· 399 400 } 400 401 let assignment: ObjectAssignment; 401 402 if ('spread' in value) { 402 - const nameIdentifier = createIdentifier({ text: value.spread }); 403 + const nameIdentifier = isTsNode(value.spread) 404 + ? value.spread 405 + : createIdentifier({ text: value.spread }); 403 406 assignment = ts.factory.createSpreadAssignment( 404 407 value.assertion 405 408 ? ts.factory.createAsExpression( ··· 408 411 ) 409 412 : nameIdentifier, 410 413 ); 411 - } else if (shorthand && canShorthand) { 414 + } else if (value.shorthand || (shorthand && canShorthand)) { 412 415 assignment = ts.factory.createShorthandPropertyAssignment( 413 416 value.value, 414 417 );
+9 -916
packages/openapi-ts/src/generate/plugins.ts
··· 1 1 import path from 'node:path'; 2 2 3 - import ts from 'typescript'; 4 - 5 - import { compiler, Property, TypeScriptFile } from '../compiler'; 6 - import type { ImportExportItem } from '../compiler/module'; 7 - import { ImportExportItemObject } from '../compiler/utils'; 8 - import type { Operation } from '../openApi'; 9 - import type { 10 - Method, 11 - Model, 12 - OperationParameter, 13 - } from '../openApi/common/interfaces/client'; 14 - import { isOperationParameterRequired } from '../openApi/common/parser/operation'; 3 + import { TypeScriptFile } from '../compiler'; 15 4 import type { Client } from '../types/client'; 16 5 import type { Files } from '../types/utils'; 17 6 import { getConfig, isStandaloneClient } from '../utils/config'; 18 - import { clientModulePath, clientOptionsTypeName } from './client'; 19 - import { 20 - generateImport, 21 - operationDataTypeName, 22 - operationErrorTypeName, 23 - operationOptionsType, 24 - operationResponseTypeName, 25 - toOperationName, 26 - } from './services'; 27 - 28 - const toInfiniteQueryOptionsName = (operation: Operation) => 29 - `${toOperationName(operation, false)}InfiniteOptions`; 30 - 31 - const toMutationOptionsName = (operation: Operation) => 32 - `${toOperationName(operation, false)}Mutation`; 33 - 34 - const toQueryOptionsName = (operation: Operation) => 35 - `${toOperationName(operation, false)}Options`; 36 7 37 8 export const generatePlugins = async ({ 38 9 client, ··· 50 21 return; 51 22 } 52 23 53 - config.plugins.forEach((plugin) => { 24 + for (const plugin of config.plugins) { 54 25 const outputParts = plugin.output.split('/'); 55 26 const outputDir = path.resolve( 56 27 config.output.path, ··· 60 31 dir: outputDir, 61 32 name: `${outputParts[outputParts.length - 1]}.ts`, 62 33 }); 63 - const file = files[plugin.name]; 64 - 65 - if ( 66 - plugin.name === '@tanstack/react-query' || 67 - plugin.name === '@tanstack/solid-query' || 68 - plugin.name === '@tanstack/svelte-query' || 69 - plugin.name === '@tanstack/vue-query' 70 - ) { 71 - const checkPrerequisites = ({ files }: { files: Files }) => { 72 - if (!files.services) { 73 - throw new Error( 74 - '🚫 services need to be exported to use TanStack Query plugin - enable service generation', 75 - ); 76 - } 77 - }; 78 - 79 - checkPrerequisites({ files }); 80 - 81 - const paginationWordsRegExp = /^(cursor|offset|page|start)/; 82 - 83 - file.import({ 84 - asType: true, 85 - module: clientModulePath(), 86 - name: clientOptionsTypeName(), 87 - }); 88 - 89 - const relativePath = 90 - new Array(outputParts.length).fill('').join('../') || './'; 91 - const servicesModulePath = relativePath + files.services.getName(false); 92 - const typesModulePath = relativePath + files.types.getName(false); 93 - 94 - const createQueryKeyParamsFn = 'createQueryKeyParams'; 95 - const infiniteQueryOptionsFn = 'infiniteQueryOptions'; 96 - const mutationsType = 97 - plugin.name === '@tanstack/svelte-query' || 98 - plugin.name === '@tanstack/solid-query' 99 - ? 'MutationOptions' 100 - : 'UseMutationOptions'; 101 - const queryKeyName = 'QueryKey'; 102 - const queryOptionsFn = 'queryOptions'; 103 - const TOptionsType = 'TOptions'; 104 - 105 - const getPaginationIn = (parameter: OperationParameter) => { 106 - switch (parameter.in) { 107 - case 'formData': 108 - return 'body'; 109 - case 'header': 110 - return 'headers'; 111 - default: 112 - return parameter.in; 113 - } 114 - }; 115 - 116 - let hasCreateQueryKeyParamsFunction = false; 117 - const createQueryKeyParamsFunction = () => { 118 - hasCreateQueryKeyParamsFunction = true; 119 - 120 - const returnType = compiler.indexedAccessTypeNode({ 121 - indexType: ts.factory.createLiteralTypeNode( 122 - compiler.stringLiteral({ text: 'params' }), 123 - ), 124 - objectType: compiler.indexedAccessTypeNode({ 125 - indexType: compiler.typeNode(0), 126 - objectType: compiler.typeNode(queryKeyName, [ 127 - compiler.typeNode(TOptionsType), 128 - ]), 129 - }), 130 - }); 131 - 132 - const queryKeyParamsFunction = compiler.constVariable({ 133 - expression: compiler.arrowFunction({ 134 - multiLine: true, 135 - parameters: [ 136 - { 137 - isRequired: false, 138 - name: 'options', 139 - type: compiler.typeNode(TOptionsType), 140 - }, 141 - ], 142 - returnType, 143 - statements: [ 144 - compiler.constVariable({ 145 - assertion: returnType, 146 - expression: compiler.objectExpression({ 147 - multiLine: false, 148 - obj: [], 149 - }), 150 - name: 'params', 151 - typeName: returnType, 152 - }), 153 - compiler.ifStatement({ 154 - expression: compiler.propertyAccessExpression({ 155 - expression: compiler.identifier({ text: 'options' }), 156 - isOptional: true, 157 - name: compiler.identifier({ text: 'body' }), 158 - }), 159 - thenStatement: ts.factory.createBlock( 160 - [ 161 - compiler.expressionToStatement({ 162 - expression: compiler.binaryExpression({ 163 - left: compiler.propertyAccessExpression({ 164 - expression: 'params', 165 - name: 'body', 166 - }), 167 - right: compiler.propertyAccessExpression({ 168 - expression: 'options', 169 - name: 'body', 170 - }), 171 - }), 172 - }), 173 - ], 174 - true, 175 - ), 176 - }), 177 - compiler.ifStatement({ 178 - expression: compiler.propertyAccessExpression({ 179 - expression: compiler.identifier({ text: 'options' }), 180 - isOptional: true, 181 - name: compiler.identifier({ text: 'headers' }), 182 - }), 183 - thenStatement: ts.factory.createBlock( 184 - [ 185 - compiler.expressionToStatement({ 186 - expression: compiler.binaryExpression({ 187 - left: compiler.propertyAccessExpression({ 188 - expression: 'params', 189 - name: 'headers', 190 - }), 191 - right: compiler.propertyAccessExpression({ 192 - expression: 'options', 193 - name: 'headers', 194 - }), 195 - }), 196 - }), 197 - ], 198 - true, 199 - ), 200 - }), 201 - compiler.ifStatement({ 202 - expression: compiler.propertyAccessExpression({ 203 - expression: compiler.identifier({ text: 'options' }), 204 - isOptional: true, 205 - name: compiler.identifier({ text: 'path' }), 206 - }), 207 - thenStatement: ts.factory.createBlock( 208 - [ 209 - compiler.expressionToStatement({ 210 - expression: compiler.binaryExpression({ 211 - left: compiler.propertyAccessExpression({ 212 - expression: 'params', 213 - name: 'path', 214 - }), 215 - right: compiler.propertyAccessExpression({ 216 - expression: 'options', 217 - name: 'path', 218 - }), 219 - }), 220 - }), 221 - ], 222 - true, 223 - ), 224 - }), 225 - compiler.ifStatement({ 226 - expression: compiler.propertyAccessExpression({ 227 - expression: compiler.identifier({ text: 'options' }), 228 - isOptional: true, 229 - name: compiler.identifier({ text: 'query' }), 230 - }), 231 - thenStatement: ts.factory.createBlock( 232 - [ 233 - compiler.expressionToStatement({ 234 - expression: compiler.binaryExpression({ 235 - left: compiler.propertyAccessExpression({ 236 - expression: 'params', 237 - name: 'query', 238 - }), 239 - right: compiler.propertyAccessExpression({ 240 - expression: 'options', 241 - name: 'query', 242 - }), 243 - }), 244 - }), 245 - ], 246 - true, 247 - ), 248 - }), 249 - compiler.returnVariable({ 250 - name: 'params', 251 - }), 252 - ], 253 - types: [ 254 - { 255 - extends: compiler.typeReferenceNode({ 256 - typeName: compiler.identifier({ 257 - text: clientOptionsTypeName(), 258 - }), 259 - }), 260 - name: TOptionsType, 261 - }, 262 - ], 263 - }), 264 - name: createQueryKeyParamsFn, 265 - }); 266 - file.add(queryKeyParamsFunction); 267 - }; 268 - 269 - const createQueryKeyLiteral = ({ 270 - isInfinite, 271 - operation, 272 - }: { 273 - isInfinite?: boolean; 274 - operation: Operation; 275 - }) => { 276 - const queryKeyLiteral = compiler.arrayLiteralExpression({ 277 - elements: [ 278 - compiler.objectExpression({ 279 - obj: [ 280 - isInfinite && { 281 - key: 'infinite', 282 - value: true, 283 - }, 284 - { 285 - key: 'params', 286 - value: compiler.callExpression({ 287 - functionName: createQueryKeyParamsFn, 288 - parameters: ['options'], 289 - }), 290 - }, 291 - { 292 - key: 'scope', 293 - value: operation.name, 294 - }, 295 - ].filter(Boolean), 296 - }), 297 - ], 298 - }); 299 - return queryKeyLiteral; 300 - }; 301 - 302 - const createQueryKeyType = () => { 303 - const properties: Property[] = [ 304 - { 305 - isRequired: false, 306 - name: 'infinite', 307 - type: compiler.keywordTypeNode({ 308 - keyword: 'boolean', 309 - }), 310 - }, 311 - { 312 - name: 'params', 313 - type: compiler.typeReferenceNode({ 314 - typeArguments: [ 315 - compiler.typeReferenceNode({ 316 - typeName: compiler.identifier({ text: TOptionsType }), 317 - }), 318 - compiler.typeUnionNode( 319 - ['body', 'headers', 'path', 'query'].map((key) => 320 - ts.factory.createLiteralTypeNode( 321 - compiler.stringLiteral({ text: key }), 322 - ), 323 - ), 324 - ), 325 - ], 326 - typeName: compiler.identifier({ text: 'Pick' }), 327 - }), 328 - }, 329 - { 330 - name: 'scope', 331 - type: compiler.keywordTypeNode({ 332 - keyword: 'string', 333 - }), 334 - }, 335 - ]; 336 - 337 - const queryKeyType = compiler.typeAliasDeclaration({ 338 - name: queryKeyName, 339 - type: compiler.typeTupleNode({ 340 - types: [compiler.typeInterfaceNode({ properties })], 341 - }), 342 - typeParameters: [ 343 - { 344 - extends: compiler.typeReferenceNode({ 345 - typeName: compiler.identifier({ 346 - text: clientOptionsTypeName(), 347 - }), 348 - }), 349 - name: TOptionsType, 350 - }, 351 - ], 352 - }); 353 - file.add(queryKeyType); 354 - }; 355 - 356 - const createTypeData = ({ operation }: { operation: Operation }) => { 357 - const { name: nameTypeData } = generateImport({ 358 - client, 359 - meta: operation.parameters.length 360 - ? { 361 - // TODO: this should be exact ref to operation for consistency, 362 - // but name should work too as operation ID is unique 363 - $ref: operation.name, 364 - name: operation.name, 365 - } 366 - : undefined, 367 - nameTransformer: operationDataTypeName, 368 - onImport: (name) => { 369 - file.import({ 370 - asType: true, 371 - module: typesModulePath, 372 - name, 373 - }); 374 - }, 375 - }); 376 - 377 - const typeData = operationOptionsType(nameTypeData); 378 - 379 - return { typeData }; 380 - }; 381 - 382 - const createTypeError = ({ operation }: { operation: Operation }) => { 383 - const { name: nameTypeError } = generateImport({ 384 - client, 385 - meta: { 386 - // TODO: this should be exact ref to operation for consistency, 387 - // but name should work too as operation ID is unique 388 - $ref: operation.name, 389 - name: operation.name, 390 - }, 391 - nameTransformer: operationErrorTypeName, 392 - onImport: (name) => { 393 - file.import({ 394 - asType: true, 395 - module: typesModulePath, 396 - name, 397 - }); 398 - }, 399 - }); 400 - 401 - let typeError: ImportExportItemObject = { 402 - asType: true, 403 - name: nameTypeError, 404 - }; 405 - if (!typeError.name) { 406 - typeError = file.import({ 407 - asType: true, 408 - module: plugin.name, 409 - name: 'DefaultError', 410 - }); 411 - } 412 - 413 - if (config.client.name === '@hey-api/client-axios') { 414 - const axiosError = file.import({ 415 - asType: true, 416 - module: 'axios', 417 - name: 'AxiosError', 418 - }); 419 - typeError = { 420 - ...axiosError, 421 - name: `${axiosError.name}<${typeError.name}>`, 422 - }; 423 - } 424 - 425 - return { typeError }; 426 - }; 427 - 428 - const createTypeResponse = ({ operation }: { operation: Operation }) => { 429 - const { name: nameTypeResponse } = generateImport({ 430 - client, 431 - meta: { 432 - // TODO: this should be exact ref to operation for consistency, 433 - // but name should work too as operation ID is unique 434 - $ref: operation.name, 435 - name: operation.name, 436 - }, 437 - nameTransformer: operationResponseTypeName, 438 - onImport: (imported) => { 439 - file.import({ 440 - asType: true, 441 - module: typesModulePath, 442 - name: imported, 443 - }); 444 - }, 445 - }); 446 - 447 - const typeResponse = nameTypeResponse || 'void'; 448 - 449 - return { typeResponse }; 450 - }; 451 - 452 - let typeInfiniteData!: ImportExportItem; 453 - let hasInfiniteQueries = false; 454 - let hasMutations = false; 455 - let hasQueries = false; 456 - 457 - for (const service of client.services) { 458 - for (const operation of service.operations) { 459 - const queryFn = toOperationName(operation, true); 460 - let hasUsedQueryFn = false; 461 - 462 - // queries 463 - if ( 464 - plugin.queryOptions && 465 - (['GET', 'POST'] as ReadonlyArray<Method>).includes( 466 - operation.method, 467 - ) 468 - ) { 469 - if (!hasQueries) { 470 - hasQueries = true; 471 - 472 - if (!hasCreateQueryKeyParamsFunction) { 473 - createQueryKeyType(); 474 - createQueryKeyParamsFunction(); 475 - } 476 - 477 - file.import({ 478 - module: plugin.name, 479 - name: queryOptionsFn, 480 - }); 481 - } 482 - 483 - hasUsedQueryFn = true; 484 - 485 - const { typeData } = createTypeData({ operation }); 486 - 487 - const isRequired = isOperationParameterRequired( 488 - operation.parameters, 489 - ); 490 - 491 - const expression = compiler.arrowFunction({ 492 - parameters: [ 493 - { 494 - isRequired, 495 - name: 'options', 496 - type: typeData, 497 - }, 498 - ], 499 - statements: [ 500 - compiler.returnFunctionCall({ 501 - args: [ 502 - compiler.objectExpression({ 503 - obj: [ 504 - { 505 - key: 'queryFn', 506 - value: compiler.arrowFunction({ 507 - async: true, 508 - multiLine: true, 509 - parameters: [ 510 - { 511 - destructure: [ 512 - { 513 - name: 'queryKey', 514 - }, 515 - ], 516 - }, 517 - ], 518 - statements: [ 519 - compiler.constVariable({ 520 - destructure: true, 521 - expression: compiler.awaitExpression({ 522 - expression: compiler.callExpression({ 523 - functionName: queryFn, 524 - parameters: [ 525 - compiler.objectExpression({ 526 - multiLine: true, 527 - obj: [ 528 - { 529 - spread: 'options', 530 - }, 531 - { 532 - spread: 'queryKey[0].params', 533 - }, 534 - { 535 - key: 'throwOnError', 536 - value: true, 537 - }, 538 - ], 539 - }), 540 - ], 541 - }), 542 - }), 543 - name: 'data', 544 - }), 545 - compiler.returnVariable({ 546 - name: 'data', 547 - }), 548 - ], 549 - }), 550 - }, 551 - { 552 - key: 'queryKey', 553 - value: createQueryKeyLiteral({ 554 - operation, 555 - }), 556 - }, 557 - ], 558 - }), 559 - ], 560 - name: queryOptionsFn, 561 - }), 562 - ], 563 - }); 564 - const statement = compiler.constVariable({ 565 - // TODO: describe options, same as the actual function call 566 - comment: [], 567 - exportConst: true, 568 - expression, 569 - name: toQueryOptionsName(operation), 570 - // TODO: add type error 571 - // TODO: AxiosError<PutSubmissionMetaError> 572 - }); 573 - file.add(statement); 574 - } 575 - 576 - // infinite queries 577 - if ( 578 - plugin.infiniteQueryOptions && 579 - (['GET', 'POST'] as ReadonlyArray<Method>).includes( 580 - operation.method, 581 - ) 582 - ) { 583 - // the actual pagination field might be nested inside parameter, e.g. body 584 - let paginationField!: Model | OperationParameter; 585 - 586 - const paginationParameter = operation.parameters.find( 587 - (parameter) => { 588 - if (paginationWordsRegExp.test(parameter.name)) { 589 - paginationField = parameter; 590 - return true; 591 - } 592 - 593 - if (parameter.in !== 'body') { 594 - return; 595 - } 596 - 597 - if (parameter.export === 'reference') { 598 - const ref = parameter.$refs[0]; 599 - const refModel = client.models.find( 600 - (model) => model.meta?.$ref === ref, 601 - ); 602 - return refModel?.properties.find((property) => { 603 - if (paginationWordsRegExp.test(property.name)) { 604 - paginationField = property; 605 - return true; 606 - } 607 - }); 608 - } 609 - 610 - return parameter.properties.find((property) => { 611 - if (paginationWordsRegExp.test(property.name)) { 612 - paginationField = property; 613 - return true; 614 - } 615 - }); 616 - }, 617 - ); 618 - 619 - if (paginationParameter && paginationField) { 620 - if (!hasInfiniteQueries) { 621 - hasInfiniteQueries = true; 622 - 623 - if (!hasCreateQueryKeyParamsFunction) { 624 - createQueryKeyType(); 625 - createQueryKeyParamsFunction(); 626 - } 627 - 628 - file.import({ 629 - module: plugin.name, 630 - name: infiniteQueryOptionsFn, 631 - }); 632 - 633 - typeInfiniteData = file.import({ 634 - asType: true, 635 - module: plugin.name, 636 - name: 'InfiniteData', 637 - }); 638 - } 639 - 640 - hasUsedQueryFn = true; 641 - 642 - const { typeData } = createTypeData({ operation }); 643 - const { typeError } = createTypeError({ operation }); 644 - const { typeResponse } = createTypeResponse({ operation }); 645 - 646 - const isRequired = isOperationParameterRequired( 647 - operation.parameters, 648 - ); 649 - 650 - const typeQueryKey = `${queryKeyName}<${typeData}>`; 651 - const typePageObjectParam = `${typeQueryKey}[0]['params']`; 652 - const typePageParam = `${paginationField.base} | ${typePageObjectParam}`; 653 - 654 - const expression = compiler.arrowFunction({ 655 - parameters: [ 656 - { 657 - isRequired, 658 - name: 'options', 659 - type: typeData, 660 - }, 661 - ], 662 - statements: [ 663 - compiler.returnFunctionCall({ 664 - args: [ 665 - compiler.objectExpression({ 666 - comments: [ 667 - { 668 - jsdoc: false, 669 - lines: ['@ts-ignore'], 670 - }, 671 - ], 672 - obj: [ 673 - { 674 - key: 'queryFn', 675 - value: compiler.arrowFunction({ 676 - async: true, 677 - multiLine: true, 678 - parameters: [ 679 - { 680 - destructure: [ 681 - { 682 - name: 'pageParam', 683 - }, 684 - { 685 - name: 'queryKey', 686 - }, 687 - ], 688 - }, 689 - ], 690 - statements: [ 691 - compiler.constVariable({ 692 - comment: [ 693 - { 694 - jsdoc: false, 695 - lines: ['@ts-ignore'], 696 - }, 697 - ], 698 - expression: compiler.conditionalExpression({ 699 - condition: compiler.binaryExpression({ 700 - left: compiler.typeOfExpression({ 701 - text: 'pageParam', 702 - }), 703 - operator: '===', 704 - right: compiler.stringLiteral({ 705 - text: 'object', 706 - }), 707 - }), 708 - whenFalse: compiler.objectExpression({ 709 - multiLine: true, 710 - obj: [ 711 - { 712 - key: getPaginationIn( 713 - paginationParameter, 714 - ), 715 - value: compiler.objectExpression({ 716 - multiLine: true, 717 - obj: [ 718 - { 719 - key: paginationField.name, 720 - value: compiler.identifier({ 721 - text: 'pageParam', 722 - }), 723 - }, 724 - ], 725 - }), 726 - }, 727 - ], 728 - }), 729 - whenTrue: compiler.identifier({ 730 - text: 'pageParam', 731 - }), 732 - }), 733 - name: 'page', 734 - typeName: typePageObjectParam, 735 - }), 736 - compiler.constVariable({ 737 - destructure: true, 738 - expression: compiler.awaitExpression({ 739 - expression: compiler.callExpression({ 740 - functionName: queryFn, 741 - parameters: [ 742 - compiler.objectExpression({ 743 - multiLine: true, 744 - obj: [ 745 - { 746 - spread: 'options', 747 - }, 748 - { 749 - key: 'body', 750 - value: compiler.objectExpression({ 751 - multiLine: true, 752 - obj: [ 753 - { 754 - assertion: 'any', 755 - spread: 756 - 'queryKey[0].params.body', 757 - }, 758 - { 759 - assertion: 'any', 760 - spread: 'page.body', 761 - }, 762 - ], 763 - }), 764 - }, 765 - { 766 - key: 'headers', 767 - value: compiler.objectExpression({ 768 - multiLine: true, 769 - obj: [ 770 - { 771 - spread: 772 - 'queryKey[0].params.headers', 773 - }, 774 - { 775 - spread: 'page.headers', 776 - }, 777 - ], 778 - }), 779 - }, 780 - { 781 - key: 'path', 782 - value: compiler.objectExpression({ 783 - multiLine: true, 784 - obj: [ 785 - { 786 - spread: 787 - 'queryKey[0].params.path', 788 - }, 789 - { 790 - spread: 'page.path', 791 - }, 792 - ], 793 - }), 794 - }, 795 - { 796 - key: 'query', 797 - value: compiler.objectExpression({ 798 - multiLine: true, 799 - obj: [ 800 - { 801 - spread: 802 - 'queryKey[0].params.query', 803 - }, 804 - { 805 - spread: 'page.query', 806 - }, 807 - ], 808 - }), 809 - }, 810 - { 811 - key: 'throwOnError', 812 - value: true, 813 - }, 814 - ], 815 - }), 816 - ], 817 - }), 818 - }), 819 - name: 'data', 820 - }), 821 - compiler.returnVariable({ 822 - name: 'data', 823 - }), 824 - ], 825 - }), 826 - }, 827 - { 828 - key: 'queryKey', 829 - value: createQueryKeyLiteral({ 830 - isInfinite: true, 831 - operation, 832 - }), 833 - }, 834 - ], 835 - }), 836 - ], 837 - name: infiniteQueryOptionsFn, 838 - // TODO: better types syntax 839 - types: [ 840 - typeResponse, 841 - typeError.name, 842 - `${typeof typeInfiniteData === 'string' ? typeInfiniteData : typeInfiniteData.name}<${typeResponse}>`, 843 - typeQueryKey, 844 - typePageParam, 845 - ], 846 - }), 847 - ], 848 - }); 849 - const statement = compiler.constVariable({ 850 - // TODO: describe options, same as the actual function call 851 - comment: [], 852 - exportConst: true, 853 - expression, 854 - name: toInfiniteQueryOptionsName(operation), 855 - }); 856 - file.add(statement); 857 - } 858 - } 859 - 860 - // mutations 861 - if ( 862 - plugin.mutationOptions && 863 - ( 864 - ['DELETE', 'PATCH', 'POST', 'PUT'] as ReadonlyArray<Method> 865 - ).includes(operation.method) 866 - ) { 867 - if (!hasMutations) { 868 - hasMutations = true; 869 - 870 - file.import({ 871 - asType: true, 872 - module: plugin.name, 873 - name: mutationsType, 874 - }); 875 - } 876 - 877 - hasUsedQueryFn = true; 878 - 879 - const { typeData } = createTypeData({ operation }); 880 - const { typeError } = createTypeError({ operation }); 881 - const { typeResponse } = createTypeResponse({ operation }); 882 - 883 - const statement = compiler.constVariable({ 884 - // TODO: describe options, same as the actual function call 885 - comment: [], 886 - exportConst: true, 887 - expression: compiler.objectExpression({ 888 - obj: [ 889 - { 890 - key: 'mutationFn', 891 - value: compiler.arrowFunction({ 892 - async: true, 893 - multiLine: true, 894 - parameters: [ 895 - { 896 - name: 'options', 897 - }, 898 - ], 899 - statements: [ 900 - compiler.constVariable({ 901 - destructure: true, 902 - expression: compiler.awaitExpression({ 903 - expression: compiler.callExpression({ 904 - functionName: queryFn, 905 - parameters: [ 906 - compiler.objectExpression({ 907 - multiLine: true, 908 - obj: [ 909 - { 910 - spread: 'options', 911 - }, 912 - { 913 - key: 'throwOnError', 914 - value: true, 915 - }, 916 - ], 917 - }), 918 - ], 919 - }), 920 - }), 921 - name: 'data', 922 - }), 923 - compiler.returnVariable({ 924 - name: 'data', 925 - }), 926 - ], 927 - }), 928 - }, 929 - ], 930 - }), 931 - name: toMutationOptionsName(operation), 932 - // TODO: better types syntax 933 - typeName: `${mutationsType}<${typeResponse}, ${typeError.name}, ${typeData}>`, 934 - }); 935 - file.add(statement); 936 - } 937 - 938 - if (hasUsedQueryFn) { 939 - file.import({ 940 - module: servicesModulePath, 941 - name: queryFn, 942 - }); 943 - } 944 - } 945 - } 946 - } 947 - }); 34 + plugin.handler({ 35 + client, 36 + files, 37 + outputParts, 38 + plugin, 39 + }); 40 + } 948 41 };
+1031
packages/openapi-ts/src/plugins/@tanstack/query-core/plugin.ts
··· 1 + import ts from 'typescript'; 2 + 3 + import { compiler, type Property } from '../../../compiler'; 4 + import type { ImportExportItem } from '../../../compiler/module'; 5 + import { ImportExportItemObject } from '../../../compiler/utils'; 6 + import { 7 + clientModulePath, 8 + clientOptionsTypeName, 9 + } from '../../../generate/client'; 10 + import { 11 + generateImport, 12 + operationDataTypeName, 13 + operationErrorTypeName, 14 + operationOptionsType, 15 + operationResponseTypeName, 16 + toOperationName, 17 + } from '../../../generate/services'; 18 + import type { Operation } from '../../../openApi'; 19 + import type { 20 + Method, 21 + Model, 22 + OperationParameter, 23 + } from '../../../openApi/common/interfaces/client'; 24 + import { isOperationParameterRequired } from '../../../openApi/common/parser/operation'; 25 + import type { Client } from '../../../types/client'; 26 + import type { Files } from '../../../types/utils'; 27 + import { getConfig } from '../../../utils/config'; 28 + import type { PluginDefinition } from '../../types'; 29 + 30 + const toInfiniteQueryOptionsName = (operation: Operation) => 31 + `${toOperationName(operation, false)}InfiniteOptions`; 32 + 33 + const toMutationOptionsName = (operation: Operation) => 34 + `${toOperationName(operation, false)}Mutation`; 35 + 36 + const toQueryOptionsName = (operation: Operation) => 37 + `${toOperationName(operation, false)}Options`; 38 + 39 + const checkPrerequisites = ({ files }: { files: Files }) => { 40 + if (!files.services) { 41 + throw new Error( 42 + '🚫 services need to be exported to use TanStack Query plugin - enable service generation', 43 + ); 44 + } 45 + }; 46 + 47 + const getPaginationIn = (parameter: OperationParameter) => { 48 + switch (parameter.in) { 49 + case 'formData': 50 + return 'body'; 51 + case 'header': 52 + return 'headers'; 53 + default: 54 + return parameter.in; 55 + } 56 + }; 57 + 58 + const paginationWordsRegExp = /^(cursor|offset|page|start)/; 59 + 60 + const createQueryKeyFn = 'createQueryKey'; 61 + const infiniteQueryOptionsFn = 'infiniteQueryOptions'; 62 + const mutationOptionsFn = 'mutationOptions'; 63 + const queryKeyName = 'QueryKey'; 64 + const queryOptionsFn = 'queryOptions'; 65 + const TOptionsType = 'TOptions'; 66 + 67 + const getClientBaseUrlKey = () => { 68 + const config = getConfig(); 69 + return config.client.name === '@hey-api/client-axios' ? 'baseURL' : 'baseUrl'; 70 + }; 71 + 72 + const createQueryKeyFunction = ({ file }: { file: Files[keyof Files] }) => { 73 + const returnType = compiler.indexedAccessTypeNode({ 74 + indexType: compiler.typeNode(0), 75 + objectType: compiler.typeNode(queryKeyName, [ 76 + compiler.typeNode(TOptionsType), 77 + ]), 78 + }); 79 + 80 + const fn = compiler.constVariable({ 81 + expression: compiler.arrowFunction({ 82 + multiLine: true, 83 + parameters: [ 84 + { 85 + name: 'id', 86 + type: compiler.typeNode('string'), 87 + }, 88 + { 89 + isRequired: false, 90 + name: 'options', 91 + type: compiler.typeNode(TOptionsType), 92 + }, 93 + { 94 + isRequired: false, 95 + name: 'infinite', 96 + type: compiler.typeNode('boolean'), 97 + }, 98 + ], 99 + returnType, 100 + statements: [ 101 + compiler.constVariable({ 102 + assertion: returnType, 103 + expression: compiler.objectExpression({ 104 + multiLine: false, 105 + obj: [ 106 + { 107 + key: '_id', 108 + value: compiler.identifier({ text: 'id' }), 109 + }, 110 + { 111 + key: getClientBaseUrlKey(), 112 + value: compiler.identifier({ 113 + text: `client.getConfig().${getClientBaseUrlKey()}`, 114 + }), 115 + }, 116 + ], 117 + }), 118 + name: 'params', 119 + typeName: returnType, 120 + }), 121 + compiler.ifStatement({ 122 + expression: compiler.identifier({ text: 'infinite' }), 123 + thenStatement: ts.factory.createBlock( 124 + [ 125 + compiler.expressionToStatement({ 126 + expression: compiler.binaryExpression({ 127 + left: compiler.propertyAccessExpression({ 128 + expression: 'params', 129 + name: 'infinite', 130 + }), 131 + right: compiler.identifier({ text: 'infinite' }), 132 + }), 133 + }), 134 + ], 135 + true, 136 + ), 137 + }), 138 + compiler.ifStatement({ 139 + expression: compiler.propertyAccessExpression({ 140 + expression: compiler.identifier({ text: 'options' }), 141 + isOptional: true, 142 + name: compiler.identifier({ text: 'body' }), 143 + }), 144 + thenStatement: ts.factory.createBlock( 145 + [ 146 + compiler.expressionToStatement({ 147 + expression: compiler.binaryExpression({ 148 + left: compiler.propertyAccessExpression({ 149 + expression: 'params', 150 + name: 'body', 151 + }), 152 + right: compiler.propertyAccessExpression({ 153 + expression: 'options', 154 + name: 'body', 155 + }), 156 + }), 157 + }), 158 + ], 159 + true, 160 + ), 161 + }), 162 + compiler.ifStatement({ 163 + expression: compiler.propertyAccessExpression({ 164 + expression: compiler.identifier({ text: 'options' }), 165 + isOptional: true, 166 + name: compiler.identifier({ text: 'headers' }), 167 + }), 168 + thenStatement: ts.factory.createBlock( 169 + [ 170 + compiler.expressionToStatement({ 171 + expression: compiler.binaryExpression({ 172 + left: compiler.propertyAccessExpression({ 173 + expression: 'params', 174 + name: 'headers', 175 + }), 176 + right: compiler.propertyAccessExpression({ 177 + expression: 'options', 178 + name: 'headers', 179 + }), 180 + }), 181 + }), 182 + ], 183 + true, 184 + ), 185 + }), 186 + compiler.ifStatement({ 187 + expression: compiler.propertyAccessExpression({ 188 + expression: compiler.identifier({ text: 'options' }), 189 + isOptional: true, 190 + name: compiler.identifier({ text: 'path' }), 191 + }), 192 + thenStatement: ts.factory.createBlock( 193 + [ 194 + compiler.expressionToStatement({ 195 + expression: compiler.binaryExpression({ 196 + left: compiler.propertyAccessExpression({ 197 + expression: 'params', 198 + name: 'path', 199 + }), 200 + right: compiler.propertyAccessExpression({ 201 + expression: 'options', 202 + name: 'path', 203 + }), 204 + }), 205 + }), 206 + ], 207 + true, 208 + ), 209 + }), 210 + compiler.ifStatement({ 211 + expression: compiler.propertyAccessExpression({ 212 + expression: compiler.identifier({ text: 'options' }), 213 + isOptional: true, 214 + name: compiler.identifier({ text: 'query' }), 215 + }), 216 + thenStatement: ts.factory.createBlock( 217 + [ 218 + compiler.expressionToStatement({ 219 + expression: compiler.binaryExpression({ 220 + left: compiler.propertyAccessExpression({ 221 + expression: 'params', 222 + name: 'query', 223 + }), 224 + right: compiler.propertyAccessExpression({ 225 + expression: 'options', 226 + name: 'query', 227 + }), 228 + }), 229 + }), 230 + ], 231 + true, 232 + ), 233 + }), 234 + compiler.returnVariable({ 235 + name: 'params', 236 + }), 237 + ], 238 + types: [ 239 + { 240 + extends: compiler.typeReferenceNode({ 241 + typeName: compiler.identifier({ 242 + text: clientOptionsTypeName(), 243 + }), 244 + }), 245 + name: TOptionsType, 246 + }, 247 + ], 248 + }), 249 + name: createQueryKeyFn, 250 + }); 251 + file.add(fn); 252 + }; 253 + 254 + const createQueryKeyType = ({ file }: { file: Files[keyof Files] }) => { 255 + const properties: Property[] = [ 256 + { 257 + name: '_id', 258 + type: compiler.keywordTypeNode({ 259 + keyword: 'string', 260 + }), 261 + }, 262 + { 263 + isRequired: false, 264 + name: 'infinite', 265 + type: compiler.keywordTypeNode({ 266 + keyword: 'boolean', 267 + }), 268 + }, 269 + ]; 270 + 271 + const queryKeyType = compiler.typeAliasDeclaration({ 272 + name: queryKeyName, 273 + type: compiler.typeTupleNode({ 274 + types: [ 275 + compiler.typeIntersectNode({ 276 + types: [ 277 + compiler.typeReferenceNode({ 278 + typeName: `Pick<TOptions, '${getClientBaseUrlKey()}' | 'body' | 'headers' | 'path' | 'query'>`, 279 + }), 280 + compiler.typeInterfaceNode({ properties }), 281 + ], 282 + }), 283 + ], 284 + }), 285 + typeParameters: [ 286 + { 287 + extends: compiler.typeReferenceNode({ 288 + typeName: compiler.identifier({ 289 + text: clientOptionsTypeName(), 290 + }), 291 + }), 292 + name: TOptionsType, 293 + }, 294 + ], 295 + }); 296 + file.add(queryKeyType); 297 + }; 298 + 299 + const createTypeData = ({ 300 + client, 301 + file, 302 + operation, 303 + typesModulePath, 304 + }: { 305 + client: Client; 306 + file: Files[keyof Files]; 307 + operation: Operation; 308 + typesModulePath: string; 309 + }) => { 310 + const { name: nameTypeData } = generateImport({ 311 + client, 312 + meta: operation.parameters.length 313 + ? { 314 + // TODO: this should be exact ref to operation for consistency, 315 + // but name should work too as operation ID is unique 316 + $ref: operation.name, 317 + name: operation.name, 318 + } 319 + : undefined, 320 + nameTransformer: operationDataTypeName, 321 + onImport: (name) => { 322 + file.import({ 323 + asType: true, 324 + module: typesModulePath, 325 + name, 326 + }); 327 + }, 328 + }); 329 + 330 + const typeData = operationOptionsType(nameTypeData); 331 + 332 + return { typeData }; 333 + }; 334 + 335 + const createTypeError = ({ 336 + client, 337 + file, 338 + operation, 339 + pluginName, 340 + typesModulePath, 341 + }: { 342 + client: Client; 343 + file: Files[keyof Files]; 344 + operation: Operation; 345 + pluginName: string; 346 + typesModulePath: string; 347 + }) => { 348 + const config = getConfig(); 349 + 350 + const { name: nameTypeError } = generateImport({ 351 + client, 352 + meta: { 353 + // TODO: this should be exact ref to operation for consistency, 354 + // but name should work too as operation ID is unique 355 + $ref: operation.name, 356 + name: operation.name, 357 + }, 358 + nameTransformer: operationErrorTypeName, 359 + onImport: (name) => { 360 + file.import({ 361 + asType: true, 362 + module: typesModulePath, 363 + name, 364 + }); 365 + }, 366 + }); 367 + 368 + let typeError: ImportExportItemObject = { 369 + asType: true, 370 + name: nameTypeError, 371 + }; 372 + if (!typeError.name) { 373 + typeError = file.import({ 374 + asType: true, 375 + module: pluginName, 376 + name: 'DefaultError', 377 + }); 378 + } 379 + 380 + if (config.client.name === '@hey-api/client-axios') { 381 + const axiosError = file.import({ 382 + asType: true, 383 + module: 'axios', 384 + name: 'AxiosError', 385 + }); 386 + typeError = { 387 + ...axiosError, 388 + name: `${axiosError.name}<${typeError.name}>`, 389 + }; 390 + } 391 + 392 + return { typeError }; 393 + }; 394 + 395 + const createTypeResponse = ({ 396 + client, 397 + file, 398 + operation, 399 + typesModulePath, 400 + }: { 401 + client: Client; 402 + file: Files[keyof Files]; 403 + operation: Operation; 404 + typesModulePath: string; 405 + }) => { 406 + const { name: nameTypeResponse } = generateImport({ 407 + client, 408 + meta: { 409 + // TODO: this should be exact ref to operation for consistency, 410 + // but name should work too as operation ID is unique 411 + $ref: operation.name, 412 + name: operation.name, 413 + }, 414 + nameTransformer: operationResponseTypeName, 415 + onImport: (imported) => { 416 + file.import({ 417 + asType: true, 418 + module: typesModulePath, 419 + name: imported, 420 + }); 421 + }, 422 + }); 423 + 424 + const typeResponse = nameTypeResponse || 'void'; 425 + 426 + return { typeResponse }; 427 + }; 428 + 429 + const createQueryKeyLiteral = ({ 430 + isInfinite, 431 + operation, 432 + }: { 433 + isInfinite?: boolean; 434 + operation: Operation; 435 + }) => { 436 + const queryKeyLiteral = compiler.arrayLiteralExpression({ 437 + elements: [ 438 + compiler.callExpression({ 439 + functionName: createQueryKeyFn, 440 + parameters: [ 441 + compiler.stringLiteral({ text: operation.name }), 442 + 'options', 443 + isInfinite ? compiler.ots.boolean(true) : undefined, 444 + ], 445 + }), 446 + ], 447 + multiLine: false, 448 + }); 449 + return queryKeyLiteral; 450 + }; 451 + 452 + export const handler: PluginDefinition['handler'] = ({ 453 + client, 454 + files, 455 + outputParts, 456 + plugin, 457 + }) => { 458 + if ( 459 + plugin.name !== '@tanstack/react-query' && 460 + plugin.name !== '@tanstack/solid-query' && 461 + plugin.name !== '@tanstack/svelte-query' && 462 + plugin.name !== '@tanstack/vue-query' 463 + ) { 464 + return; 465 + } 466 + 467 + checkPrerequisites({ files }); 468 + 469 + const file = files[plugin.name]; 470 + 471 + file.import({ 472 + asType: true, 473 + module: clientModulePath(), 474 + name: clientOptionsTypeName(), 475 + }); 476 + 477 + const relativePath = 478 + new Array(outputParts.length).fill('').join('../') || './'; 479 + const typesModulePath = relativePath + files.types.getName(false); 480 + 481 + const mutationsType = 482 + plugin.name === '@tanstack/svelte-query' || 483 + plugin.name === '@tanstack/solid-query' 484 + ? 'MutationOptions' 485 + : 'UseMutationOptions'; 486 + 487 + let typeInfiniteData!: ImportExportItem; 488 + let hasCreateQueryKeyParamsFunction = false; 489 + let hasInfiniteQueries = false; 490 + let hasMutations = false; 491 + let hasQueries = false; 492 + 493 + for (const service of client.services) { 494 + for (const operation of service.operations) { 495 + const queryFn = toOperationName(operation, true); 496 + let hasUsedQueryFn = false; 497 + 498 + // queries 499 + if ( 500 + plugin.queryOptions && 501 + (['GET', 'POST'] as ReadonlyArray<Method>).includes(operation.method) 502 + ) { 503 + if (!hasQueries) { 504 + hasQueries = true; 505 + 506 + if (!hasCreateQueryKeyParamsFunction) { 507 + createQueryKeyType({ file }); 508 + createQueryKeyFunction({ file }); 509 + hasCreateQueryKeyParamsFunction = true; 510 + } 511 + 512 + file.import({ 513 + module: plugin.name, 514 + name: queryOptionsFn, 515 + }); 516 + } 517 + 518 + hasUsedQueryFn = true; 519 + 520 + const { typeData } = createTypeData({ 521 + client, 522 + file, 523 + operation, 524 + typesModulePath, 525 + }); 526 + 527 + const isRequired = isOperationParameterRequired(operation.parameters); 528 + 529 + const expression = compiler.arrowFunction({ 530 + parameters: [ 531 + { 532 + isRequired, 533 + name: 'options', 534 + type: typeData, 535 + }, 536 + ], 537 + statements: [ 538 + compiler.returnFunctionCall({ 539 + args: [ 540 + compiler.objectExpression({ 541 + obj: [ 542 + { 543 + key: 'queryFn', 544 + value: compiler.arrowFunction({ 545 + async: true, 546 + multiLine: true, 547 + parameters: [ 548 + { 549 + destructure: [ 550 + { 551 + name: 'queryKey', 552 + }, 553 + ], 554 + }, 555 + ], 556 + statements: [ 557 + compiler.constVariable({ 558 + destructure: true, 559 + expression: compiler.awaitExpression({ 560 + expression: compiler.callExpression({ 561 + functionName: queryFn, 562 + parameters: [ 563 + compiler.objectExpression({ 564 + multiLine: true, 565 + obj: [ 566 + { 567 + spread: 'options', 568 + }, 569 + { 570 + spread: 'queryKey[0]', 571 + }, 572 + { 573 + key: 'throwOnError', 574 + value: true, 575 + }, 576 + ], 577 + }), 578 + ], 579 + }), 580 + }), 581 + name: 'data', 582 + }), 583 + compiler.returnVariable({ 584 + name: 'data', 585 + }), 586 + ], 587 + }), 588 + }, 589 + { 590 + key: 'queryKey', 591 + value: createQueryKeyLiteral({ 592 + operation, 593 + }), 594 + }, 595 + ], 596 + }), 597 + ], 598 + name: queryOptionsFn, 599 + }), 600 + ], 601 + }); 602 + const statement = compiler.constVariable({ 603 + // TODO: describe options, same as the actual function call 604 + comment: [], 605 + exportConst: true, 606 + expression, 607 + name: toQueryOptionsName(operation), 608 + // TODO: add type error 609 + // TODO: AxiosError<PutSubmissionMetaError> 610 + }); 611 + file.add(statement); 612 + } 613 + 614 + // infinite queries 615 + if ( 616 + plugin.infiniteQueryOptions && 617 + (['GET', 'POST'] as ReadonlyArray<Method>).includes(operation.method) 618 + ) { 619 + // the actual pagination field might be nested inside parameter, e.g. body 620 + let paginationField!: Model | OperationParameter; 621 + 622 + const paginationParameter = operation.parameters.find((parameter) => { 623 + if (paginationWordsRegExp.test(parameter.name)) { 624 + paginationField = parameter; 625 + return true; 626 + } 627 + 628 + if (parameter.in !== 'body') { 629 + return; 630 + } 631 + 632 + if (parameter.export === 'reference') { 633 + const ref = parameter.$refs[0]; 634 + const refModel = client.models.find( 635 + (model) => model.meta?.$ref === ref, 636 + ); 637 + return refModel?.properties.find((property) => { 638 + if (paginationWordsRegExp.test(property.name)) { 639 + paginationField = property; 640 + return true; 641 + } 642 + }); 643 + } 644 + 645 + return parameter.properties.find((property) => { 646 + if (paginationWordsRegExp.test(property.name)) { 647 + paginationField = property; 648 + return true; 649 + } 650 + }); 651 + }); 652 + 653 + if (paginationParameter && paginationField) { 654 + if (!hasInfiniteQueries) { 655 + hasInfiniteQueries = true; 656 + 657 + if (!hasCreateQueryKeyParamsFunction) { 658 + createQueryKeyType({ file }); 659 + createQueryKeyFunction({ file }); 660 + hasCreateQueryKeyParamsFunction = true; 661 + } 662 + 663 + file.import({ 664 + module: plugin.name, 665 + name: infiniteQueryOptionsFn, 666 + }); 667 + 668 + typeInfiniteData = file.import({ 669 + asType: true, 670 + module: plugin.name, 671 + name: 'InfiniteData', 672 + }); 673 + } 674 + 675 + hasUsedQueryFn = true; 676 + 677 + const { typeData } = createTypeData({ 678 + client, 679 + file, 680 + operation, 681 + typesModulePath, 682 + }); 683 + const { typeError } = createTypeError({ 684 + client, 685 + file, 686 + operation, 687 + pluginName: plugin.name, 688 + typesModulePath, 689 + }); 690 + const { typeResponse } = createTypeResponse({ 691 + client, 692 + file, 693 + operation, 694 + typesModulePath, 695 + }); 696 + 697 + const isRequired = isOperationParameterRequired(operation.parameters); 698 + 699 + const typeQueryKey = `${queryKeyName}<${typeData}>`; 700 + const typePageObjectParam = `${typeQueryKey}[0]`; 701 + const typePageParam = `${paginationField.base} | ${typePageObjectParam}`; 702 + 703 + const expression = compiler.arrowFunction({ 704 + parameters: [ 705 + { 706 + isRequired, 707 + name: 'options', 708 + type: typeData, 709 + }, 710 + ], 711 + statements: [ 712 + compiler.returnFunctionCall({ 713 + args: [ 714 + compiler.objectExpression({ 715 + comments: [ 716 + { 717 + jsdoc: false, 718 + lines: ['@ts-ignore'], 719 + }, 720 + ], 721 + obj: [ 722 + { 723 + key: 'queryFn', 724 + value: compiler.arrowFunction({ 725 + async: true, 726 + multiLine: true, 727 + parameters: [ 728 + { 729 + destructure: [ 730 + { 731 + name: 'pageParam', 732 + }, 733 + { 734 + name: 'queryKey', 735 + }, 736 + ], 737 + }, 738 + ], 739 + statements: [ 740 + compiler.constVariable({ 741 + comment: [ 742 + { 743 + jsdoc: false, 744 + lines: ['@ts-ignore'], 745 + }, 746 + ], 747 + expression: compiler.conditionalExpression({ 748 + condition: compiler.binaryExpression({ 749 + left: compiler.typeOfExpression({ 750 + text: 'pageParam', 751 + }), 752 + operator: '===', 753 + right: compiler.stringLiteral({ 754 + text: 'object', 755 + }), 756 + }), 757 + whenFalse: compiler.objectExpression({ 758 + multiLine: true, 759 + obj: [ 760 + { 761 + key: getPaginationIn(paginationParameter), 762 + value: compiler.objectExpression({ 763 + multiLine: true, 764 + obj: [ 765 + { 766 + key: paginationField.name, 767 + value: compiler.identifier({ 768 + text: 'pageParam', 769 + }), 770 + }, 771 + ], 772 + }), 773 + }, 774 + ], 775 + }), 776 + whenTrue: compiler.identifier({ 777 + text: 'pageParam', 778 + }), 779 + }), 780 + name: 'page', 781 + typeName: typePageObjectParam, 782 + }), 783 + compiler.constVariable({ 784 + destructure: true, 785 + expression: compiler.awaitExpression({ 786 + expression: compiler.callExpression({ 787 + functionName: queryFn, 788 + parameters: [ 789 + compiler.objectExpression({ 790 + multiLine: true, 791 + obj: [ 792 + { 793 + spread: 'options', 794 + }, 795 + { 796 + key: 'body', 797 + value: compiler.objectExpression({ 798 + multiLine: true, 799 + obj: [ 800 + { 801 + assertion: 'any', 802 + spread: 'queryKey[0].body', 803 + }, 804 + { 805 + assertion: 'any', 806 + spread: 'page.body', 807 + }, 808 + ], 809 + }), 810 + }, 811 + { 812 + key: 'headers', 813 + value: compiler.objectExpression({ 814 + multiLine: true, 815 + obj: [ 816 + { 817 + spread: 'queryKey[0].headers', 818 + }, 819 + { 820 + spread: 'page.headers', 821 + }, 822 + ], 823 + }), 824 + }, 825 + { 826 + key: 'path', 827 + value: compiler.objectExpression({ 828 + multiLine: true, 829 + obj: [ 830 + { 831 + spread: 'queryKey[0].path', 832 + }, 833 + { 834 + spread: 'page.path', 835 + }, 836 + ], 837 + }), 838 + }, 839 + { 840 + key: 'query', 841 + value: compiler.objectExpression({ 842 + multiLine: true, 843 + obj: [ 844 + { 845 + spread: 'queryKey[0].query', 846 + }, 847 + { 848 + spread: 'page.query', 849 + }, 850 + ], 851 + }), 852 + }, 853 + { 854 + key: getClientBaseUrlKey(), 855 + value: compiler.identifier({ 856 + text: `client.getConfig().${getClientBaseUrlKey()}`, 857 + }), 858 + }, 859 + { 860 + key: 'throwOnError', 861 + value: true, 862 + }, 863 + ], 864 + }), 865 + ], 866 + }), 867 + }), 868 + name: 'data', 869 + }), 870 + compiler.returnVariable({ 871 + name: 'data', 872 + }), 873 + ], 874 + }), 875 + }, 876 + { 877 + key: 'queryKey', 878 + value: createQueryKeyLiteral({ 879 + isInfinite: true, 880 + operation, 881 + }), 882 + }, 883 + ], 884 + }), 885 + ], 886 + name: infiniteQueryOptionsFn, 887 + // TODO: better types syntax 888 + types: [ 889 + typeResponse, 890 + typeError.name, 891 + `${typeof typeInfiniteData === 'string' ? typeInfiniteData : typeInfiniteData.name}<${typeResponse}>`, 892 + typeQueryKey, 893 + typePageParam, 894 + ], 895 + }), 896 + ], 897 + }); 898 + const statement = compiler.constVariable({ 899 + // TODO: describe options, same as the actual function call 900 + comment: [], 901 + exportConst: true, 902 + expression, 903 + name: toInfiniteQueryOptionsName(operation), 904 + }); 905 + file.add(statement); 906 + } 907 + } 908 + 909 + // mutations 910 + if ( 911 + plugin.mutationOptions && 912 + (['DELETE', 'PATCH', 'POST', 'PUT'] as ReadonlyArray<Method>).includes( 913 + operation.method, 914 + ) 915 + ) { 916 + if (!hasMutations) { 917 + hasMutations = true; 918 + 919 + file.import({ 920 + asType: true, 921 + module: plugin.name, 922 + name: mutationsType, 923 + }); 924 + } 925 + 926 + hasUsedQueryFn = true; 927 + 928 + const { typeData } = createTypeData({ 929 + client, 930 + file, 931 + operation, 932 + typesModulePath, 933 + }); 934 + const { typeError } = createTypeError({ 935 + client, 936 + file, 937 + operation, 938 + pluginName: plugin.name, 939 + typesModulePath, 940 + }); 941 + const { typeResponse } = createTypeResponse({ 942 + client, 943 + file, 944 + operation, 945 + typesModulePath, 946 + }); 947 + 948 + const expression = compiler.arrowFunction({ 949 + statements: [ 950 + compiler.constVariable({ 951 + expression: compiler.objectExpression({ 952 + obj: [ 953 + { 954 + key: 'mutationFn', 955 + value: compiler.arrowFunction({ 956 + async: true, 957 + multiLine: true, 958 + parameters: [ 959 + { 960 + name: 'options', 961 + }, 962 + ], 963 + statements: [ 964 + compiler.constVariable({ 965 + destructure: true, 966 + expression: compiler.awaitExpression({ 967 + expression: compiler.callExpression({ 968 + functionName: queryFn, 969 + parameters: [ 970 + compiler.objectExpression({ 971 + multiLine: true, 972 + obj: [ 973 + { 974 + spread: 'options', 975 + }, 976 + { 977 + key: 'throwOnError', 978 + value: true, 979 + }, 980 + ], 981 + }), 982 + ], 983 + }), 984 + }), 985 + name: 'data', 986 + }), 987 + compiler.returnVariable({ 988 + name: 'data', 989 + }), 990 + ], 991 + }), 992 + }, 993 + ], 994 + }), 995 + name: mutationOptionsFn, 996 + // TODO: better types syntax 997 + typeName: `${mutationsType}<${typeResponse}, ${typeError.name}, ${typeData}>`, 998 + }), 999 + compiler.returnVariable({ 1000 + name: mutationOptionsFn, 1001 + }), 1002 + ], 1003 + }); 1004 + const statement = compiler.constVariable({ 1005 + // TODO: describe options, same as the actual function call 1006 + comment: [], 1007 + exportConst: true, 1008 + expression, 1009 + name: toMutationOptionsName(operation), 1010 + }); 1011 + file.add(statement); 1012 + } 1013 + 1014 + const servicesModulePath = relativePath + files.services.getName(false); 1015 + 1016 + if (hasQueries || hasInfiniteQueries) { 1017 + file.import({ 1018 + module: servicesModulePath, 1019 + name: 'client', 1020 + }); 1021 + } 1022 + 1023 + if (hasUsedQueryFn) { 1024 + file.import({ 1025 + module: servicesModulePath, 1026 + name: queryFn, 1027 + }); 1028 + } 1029 + } 1030 + } 1031 + };
+5 -1
packages/openapi-ts/src/plugins/@tanstack/react-query/config.ts
··· 1 - export interface PluginTanStackReactQuery { 1 + import type { PluginDefinition } from '../../types'; 2 + import { handler } from '../query-core/plugin'; 3 + 4 + export interface PluginTanStackReactQuery extends PluginDefinition { 2 5 /** 3 6 * Generate {@link https://tanstack.com/query/v5/docs/framework/react/reference/infiniteQueryOptions `infiniteQueryOptions()`} helpers? These will be generated from GET and POST requests where a pagination parameter is detected. 4 7 * @default true ··· 28 31 29 32 export const pluginTanStackReactQueryDefaultConfig: Required<PluginTanStackReactQuery> = 30 33 { 34 + handler, 31 35 infiniteQueryOptions: true, 32 36 mutationOptions: true, 33 37 name: '@tanstack/react-query',
+5 -1
packages/openapi-ts/src/plugins/@tanstack/solid-query/config.ts
··· 1 - export interface PluginTanStackSolidQuery { 1 + import type { PluginDefinition } from '../../types'; 2 + import { handler } from '../query-core/plugin'; 3 + 4 + export interface PluginTanStackSolidQuery extends PluginDefinition { 2 5 /** 3 6 * Generate `createInfiniteQuery()` helpers? These will be generated from GET and POST requests where a pagination parameter is detected. 4 7 * @default true ··· 28 31 29 32 export const pluginTanStackSolidQueryDefaultConfig: Required<PluginTanStackSolidQuery> = 30 33 { 34 + handler, 31 35 infiniteQueryOptions: true, 32 36 mutationOptions: true, 33 37 name: '@tanstack/solid-query',
+5 -1
packages/openapi-ts/src/plugins/@tanstack/svelte-query/config.ts
··· 1 - export interface PluginTanStackSvelteQuery { 1 + import type { PluginDefinition } from '../../types'; 2 + import { handler } from '../query-core/plugin'; 3 + 4 + export interface PluginTanStackSvelteQuery extends PluginDefinition { 2 5 /** 3 6 * Generate `createInfiniteQuery()` helpers? These will be generated from GET and POST requests where a pagination parameter is detected. 4 7 * @default true ··· 28 31 29 32 export const pluginTanStackSvelteQueryDefaultConfig: Required<PluginTanStackSvelteQuery> = 30 33 { 34 + handler, 31 35 infiniteQueryOptions: true, 32 36 mutationOptions: true, 33 37 name: '@tanstack/svelte-query',
+5 -1
packages/openapi-ts/src/plugins/@tanstack/vue-query/config.ts
··· 1 - export interface PluginTanStackVueQuery { 1 + import type { PluginDefinition } from '../../types'; 2 + import { handler } from '../query-core/plugin'; 3 + 4 + export interface PluginTanStackVueQuery extends PluginDefinition { 2 5 /** 3 6 * Generate {@link https://tanstack.com/query/v5/docs/framework/vue/reference/infiniteQueryOptions `infiniteQueryOptions()`} helpers? These will be generated from GET and POST requests where a pagination parameter is detected. 4 7 * @default true ··· 28 31 29 32 export const pluginTanStackVueQueryDefaultConfig: Required<PluginTanStackVueQuery> = 30 33 { 34 + handler, 31 35 infiniteQueryOptions: true, 32 36 mutationOptions: true, 33 37 name: '@tanstack/vue-query',
+1 -15
packages/openapi-ts/src/plugins/index.ts
··· 14 14 type PluginTanStackVueQuery, 15 15 pluginTanStackVueQueryDefaultConfig, 16 16 } from './@tanstack/vue-query/config'; 17 + import type { DefaultPluginConfigsMap } from './types'; 17 18 18 19 export type Plugins = 19 20 | PluginTanStackReactQuery 20 21 | PluginTanStackSolidQuery 21 22 | PluginTanStackSvelteQuery 22 23 | PluginTanStackVueQuery; 23 - 24 - type KeyTypes = string | number | symbol; 25 - 26 - type ExtractFromPluginConfig<T> = T extends { name: infer U } 27 - ? U extends KeyTypes 28 - ? U 29 - : never 30 - : never; 31 - 32 - type DefaultPluginConfigsMap< 33 - T, 34 - U extends KeyTypes = ExtractFromPluginConfig<T>, 35 - > = { 36 - [K in U]: Required<Extract<T, { name: K }>>; 37 - }; 38 24 39 25 export const defaultPluginConfigs: DefaultPluginConfigsMap<Plugins> = { 40 26 '@tanstack/react-query': pluginTanStackReactQueryDefaultConfig,
+29
packages/openapi-ts/src/plugins/types.ts
··· 1 + import type { Client } from '../types/client'; 2 + import type { Config } from '../types/config'; 3 + import type { Files } from '../types/utils'; 4 + 5 + export interface PluginDefinition { 6 + handler: (args: { 7 + client: Client; 8 + files: Files; 9 + outputParts: string[]; 10 + plugin: Config['plugins'][number]; 11 + }) => void; 12 + name: string; 13 + output?: string; 14 + } 15 + 16 + type KeyTypes = string | number | symbol; 17 + 18 + type ExtractFromPluginConfig<T> = T extends { name: infer U } 19 + ? U extends KeyTypes 20 + ? U 21 + : never 22 + : never; 23 + 24 + export type DefaultPluginConfigsMap< 25 + T, 26 + U extends KeyTypes = ExtractFromPluginConfig<T>, 27 + > = { 28 + [K in U]: Required<Extract<T, { name: K }>> & PluginDefinition; 29 + };
+4 -1
packages/openapi-ts/src/utils/type.ts
··· 105 105 const types = model.properties 106 106 .map((m) => compiler.nodeToString({ node: toType(m), unescape: true })) 107 107 .filter(unique); 108 - return compiler.typeIntersectNode(types, model.isNullable); 108 + return compiler.typeIntersectNode({ 109 + isNullable: model.isNullable, 110 + types, 111 + }); 109 112 }; 110 113 111 114 const typeInterface = (model: Model) => {
+152 -258
packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-axios-plugin-tanstack-react-query/@tanstack/react-query.gen.ts.snap
··· 2 2 3 3 import type { Options } from '@hey-api/client-axios'; 4 4 import { queryOptions, type UseMutationOptions, type DefaultError, infiniteQueryOptions, type InfiniteData } from '@tanstack/react-query'; 5 - import { export_, import_, apiVVersionOdataControllerCount, getCallWithoutParametersAndResponse, putCallWithoutParametersAndResponse, postCallWithoutParametersAndResponse, deleteCallWithoutParametersAndResponse, patchCallWithoutParametersAndResponse, deleteFoo, callWithDescriptions, deprecatedCall, callWithParameters, callWithWeirdParameterNames, getCallWithOptionalParam, postCallWithOptionalParam, postApiVbyApiVersionRequestBody, postApiVbyApiVersionFormData, callWithDefaultParameters, callWithDefaultOptionalParameters, callToTestOrderOfParams, duplicateName, duplicateName1, duplicateName2, duplicateName3, callWithNoContentResponse, callWithResponseAndNoContentResponse, dummyA, dummyB, callWithResponse, callWithDuplicateResponses, callWithResponses, collectionFormat, types, uploadFile, fileResponse, complexTypes, multipartRequest, multipartResponse, complexParams, callWithResultFromHeader, testErrorCode, nonAsciiæøåÆøÅöôêÊ字符串, putWithFormUrlEncoded } from '../services.gen'; 5 + import { client, export_, import_, apiVVersionOdataControllerCount, getCallWithoutParametersAndResponse, putCallWithoutParametersAndResponse, postCallWithoutParametersAndResponse, deleteCallWithoutParametersAndResponse, patchCallWithoutParametersAndResponse, deleteFoo, callWithDescriptions, deprecatedCall, callWithParameters, callWithWeirdParameterNames, getCallWithOptionalParam, postCallWithOptionalParam, postApiVbyApiVersionRequestBody, postApiVbyApiVersionFormData, callWithDefaultParameters, callWithDefaultOptionalParameters, callToTestOrderOfParams, duplicateName, duplicateName1, duplicateName2, duplicateName3, callWithNoContentResponse, callWithResponseAndNoContentResponse, dummyA, dummyB, callWithResponse, callWithDuplicateResponses, callWithResponses, collectionFormat, types, uploadFile, fileResponse, complexTypes, multipartRequest, multipartResponse, complexParams, callWithResultFromHeader, testErrorCode, nonAsciiæøåÆøÅöôêÊ字符串, putWithFormUrlEncoded } from '../services.gen'; 6 6 import type { ImportData, ImportError, ImportResponse, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamError, PostCallWithOptionalParamResponse, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, UploadFileData, UploadFileError, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartRequestData, ComplexParamsData, ComplexParamsError, ComplexParamsResponse, CallWithResultFromHeaderError, CallWithResultFromHeaderResponse, TestErrorCodeData, TestErrorCodeError, TestErrorCodeResponse, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Error, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; 7 7 import type { AxiosError } from 'axios'; 8 8 9 9 type QueryKey<TOptions extends Options> = [ 10 - { 10 + Pick<TOptions, 'baseURL' | 'body' | 'headers' | 'path' | 'query'> & { 11 + _id: string; 11 12 infinite?: boolean; 12 - params: Pick<TOptions, "body" | "headers" | "path" | "query">; 13 - scope: string; 14 13 } 15 14 ]; 16 15 17 - const createQueryKeyParams = <TOptions extends Options>(options?: TOptions): QueryKey<TOptions>[0]["params"] => { 18 - const params: QueryKey<TOptions>[0]["params"] = {} as QueryKey<TOptions>[0]["params"]; 16 + const createQueryKey = <TOptions extends Options>(id: string, options?: TOptions, infinite?: boolean): QueryKey<TOptions>[0] => { 17 + const params: QueryKey<TOptions>[0] = { _id: id, baseURL: client.getConfig().baseURL } as QueryKey<TOptions>[0]; 18 + if (infinite) { 19 + params.infinite = infinite; 20 + } 19 21 if (options?.body) { 20 22 params.body = options.body; 21 23 } ··· 35 37 queryFn: async ({ queryKey }) => { 36 38 const { data } = await export_({ 37 39 ...options, 38 - ...queryKey[0].params, 40 + ...queryKey[0], 39 41 throwOnError: true 40 42 }); 41 43 return data; 42 44 }, 43 45 queryKey: [ 44 - { 45 - params: createQueryKeyParams(options), 46 - scope: 'export' 47 - } 46 + createQueryKey("export", options) 48 47 ] 49 48 }); }; 50 49 ··· 52 51 queryFn: async ({ queryKey }) => { 53 52 const { data } = await import_({ 54 53 ...options, 55 - ...queryKey[0].params, 54 + ...queryKey[0], 56 55 throwOnError: true 57 56 }); 58 57 return data; 59 58 }, 60 59 queryKey: [ 61 - { 62 - params: createQueryKeyParams(options), 63 - scope: 'import' 64 - } 60 + createQueryKey("import", options) 65 61 ] 66 62 }); }; 67 63 68 - export const importMutation: UseMutationOptions<ImportResponse, AxiosError<ImportError>, Options<ImportData>> = { 64 + export const importMutation = () => { const mutationOptions: UseMutationOptions<ImportResponse, AxiosError<ImportError>, Options<ImportData>> = { 69 65 mutationFn: async (options) => { 70 66 const { data } = await import_({ 71 67 ...options, ··· 73 69 }); 74 70 return data; 75 71 } 76 - }; 72 + }; return mutationOptions; }; 77 73 78 74 export const apiVVersionOdataControllerCountOptions = (options?: Options) => { return queryOptions({ 79 75 queryFn: async ({ queryKey }) => { 80 76 const { data } = await apiVVersionOdataControllerCount({ 81 77 ...options, 82 - ...queryKey[0].params, 78 + ...queryKey[0], 83 79 throwOnError: true 84 80 }); 85 81 return data; 86 82 }, 87 83 queryKey: [ 88 - { 89 - params: createQueryKeyParams(options), 90 - scope: 'apiVVersionOdataControllerCount' 91 - } 84 + createQueryKey("apiVVersionOdataControllerCount", options) 92 85 ] 93 86 }); }; 94 87 ··· 96 89 queryFn: async ({ queryKey }) => { 97 90 const { data } = await getCallWithoutParametersAndResponse({ 98 91 ...options, 99 - ...queryKey[0].params, 92 + ...queryKey[0], 100 93 throwOnError: true 101 94 }); 102 95 return data; 103 96 }, 104 97 queryKey: [ 105 - { 106 - params: createQueryKeyParams(options), 107 - scope: 'getCallWithoutParametersAndResponse' 108 - } 98 + createQueryKey("getCallWithoutParametersAndResponse", options) 109 99 ] 110 100 }); }; 111 101 112 - export const putCallWithoutParametersAndResponseMutation: UseMutationOptions<void, AxiosError<DefaultError>, Options> = { 102 + export const putCallWithoutParametersAndResponseMutation = () => { const mutationOptions: UseMutationOptions<void, AxiosError<DefaultError>, Options> = { 113 103 mutationFn: async (options) => { 114 104 const { data } = await putCallWithoutParametersAndResponse({ 115 105 ...options, ··· 117 107 }); 118 108 return data; 119 109 } 120 - }; 110 + }; return mutationOptions; }; 121 111 122 112 export const postCallWithoutParametersAndResponseOptions = (options?: Options) => { return queryOptions({ 123 113 queryFn: async ({ queryKey }) => { 124 114 const { data } = await postCallWithoutParametersAndResponse({ 125 115 ...options, 126 - ...queryKey[0].params, 116 + ...queryKey[0], 127 117 throwOnError: true 128 118 }); 129 119 return data; 130 120 }, 131 121 queryKey: [ 132 - { 133 - params: createQueryKeyParams(options), 134 - scope: 'postCallWithoutParametersAndResponse' 135 - } 122 + createQueryKey("postCallWithoutParametersAndResponse", options) 136 123 ] 137 124 }); }; 138 125 139 - export const postCallWithoutParametersAndResponseMutation: UseMutationOptions<void, AxiosError<DefaultError>, Options> = { 126 + export const postCallWithoutParametersAndResponseMutation = () => { const mutationOptions: UseMutationOptions<void, AxiosError<DefaultError>, Options> = { 140 127 mutationFn: async (options) => { 141 128 const { data } = await postCallWithoutParametersAndResponse({ 142 129 ...options, ··· 144 131 }); 145 132 return data; 146 133 } 147 - }; 134 + }; return mutationOptions; }; 148 135 149 - export const deleteCallWithoutParametersAndResponseMutation: UseMutationOptions<void, AxiosError<DefaultError>, Options> = { 136 + export const deleteCallWithoutParametersAndResponseMutation = () => { const mutationOptions: UseMutationOptions<void, AxiosError<DefaultError>, Options> = { 150 137 mutationFn: async (options) => { 151 138 const { data } = await deleteCallWithoutParametersAndResponse({ 152 139 ...options, ··· 154 141 }); 155 142 return data; 156 143 } 157 - }; 144 + }; return mutationOptions; }; 158 145 159 - export const patchCallWithoutParametersAndResponseMutation: UseMutationOptions<void, AxiosError<DefaultError>, Options> = { 146 + export const patchCallWithoutParametersAndResponseMutation = () => { const mutationOptions: UseMutationOptions<void, AxiosError<DefaultError>, Options> = { 160 147 mutationFn: async (options) => { 161 148 const { data } = await patchCallWithoutParametersAndResponse({ 162 149 ...options, ··· 164 151 }); 165 152 return data; 166 153 } 167 - }; 154 + }; return mutationOptions; }; 168 155 169 - export const deleteFooMutation: UseMutationOptions<void, AxiosError<DefaultError>, Options<DeleteFooData3>> = { 156 + export const deleteFooMutation = () => { const mutationOptions: UseMutationOptions<void, AxiosError<DefaultError>, Options<DeleteFooData3>> = { 170 157 mutationFn: async (options) => { 171 158 const { data } = await deleteFoo({ 172 159 ...options, ··· 174 161 }); 175 162 return data; 176 163 } 177 - }; 164 + }; return mutationOptions; }; 178 165 179 166 export const callWithDescriptionsOptions = (options?: Options<CallWithDescriptionsData>) => { return queryOptions({ 180 167 queryFn: async ({ queryKey }) => { 181 168 const { data } = await callWithDescriptions({ 182 169 ...options, 183 - ...queryKey[0].params, 170 + ...queryKey[0], 184 171 throwOnError: true 185 172 }); 186 173 return data; 187 174 }, 188 175 queryKey: [ 189 - { 190 - params: createQueryKeyParams(options), 191 - scope: 'callWithDescriptions' 192 - } 176 + createQueryKey("callWithDescriptions", options) 193 177 ] 194 178 }); }; 195 179 196 - export const callWithDescriptionsMutation: UseMutationOptions<void, AxiosError<DefaultError>, Options<CallWithDescriptionsData>> = { 180 + export const callWithDescriptionsMutation = () => { const mutationOptions: UseMutationOptions<void, AxiosError<DefaultError>, Options<CallWithDescriptionsData>> = { 197 181 mutationFn: async (options) => { 198 182 const { data } = await callWithDescriptions({ 199 183 ...options, ··· 201 185 }); 202 186 return data; 203 187 } 204 - }; 188 + }; return mutationOptions; }; 205 189 206 190 export const deprecatedCallOptions = (options: Options<DeprecatedCallData>) => { return queryOptions({ 207 191 queryFn: async ({ queryKey }) => { 208 192 const { data } = await deprecatedCall({ 209 193 ...options, 210 - ...queryKey[0].params, 194 + ...queryKey[0], 211 195 throwOnError: true 212 196 }); 213 197 return data; 214 198 }, 215 199 queryKey: [ 216 - { 217 - params: createQueryKeyParams(options), 218 - scope: 'deprecatedCall' 219 - } 200 + createQueryKey("deprecatedCall", options) 220 201 ] 221 202 }); }; 222 203 223 - export const deprecatedCallMutation: UseMutationOptions<void, AxiosError<DefaultError>, Options<DeprecatedCallData>> = { 204 + export const deprecatedCallMutation = () => { const mutationOptions: UseMutationOptions<void, AxiosError<DefaultError>, Options<DeprecatedCallData>> = { 224 205 mutationFn: async (options) => { 225 206 const { data } = await deprecatedCall({ 226 207 ...options, ··· 228 209 }); 229 210 return data; 230 211 } 231 - }; 212 + }; return mutationOptions; }; 232 213 233 214 export const callWithParametersOptions = (options: Options<CallWithParametersData>) => { return queryOptions({ 234 215 queryFn: async ({ queryKey }) => { 235 216 const { data } = await callWithParameters({ 236 217 ...options, 237 - ...queryKey[0].params, 218 + ...queryKey[0], 238 219 throwOnError: true 239 220 }); 240 221 return data; 241 222 }, 242 223 queryKey: [ 243 - { 244 - params: createQueryKeyParams(options), 245 - scope: 'callWithParameters' 246 - } 224 + createQueryKey("callWithParameters", options) 247 225 ] 248 226 }); }; 249 227 250 - export const callWithParametersInfiniteOptions = (options: Options<CallWithParametersData>) => { return infiniteQueryOptions<void, AxiosError<DefaultError>, InfiniteData<void>, QueryKey<Options<CallWithParametersData>>, string | QueryKey<Options<CallWithParametersData>>[0]['params']>( 228 + export const callWithParametersInfiniteOptions = (options: Options<CallWithParametersData>) => { return infiniteQueryOptions<void, AxiosError<DefaultError>, InfiniteData<void>, QueryKey<Options<CallWithParametersData>>, string | QueryKey<Options<CallWithParametersData>>[0]>( 251 229 // @ts-ignore 252 230 { 253 231 queryFn: async ({ pageParam, queryKey }) => { 254 232 // @ts-ignore 255 - const page: QueryKey<Options<CallWithParametersData>>[0]['params'] = typeof pageParam === "object" ? pageParam : { 233 + const page: QueryKey<Options<CallWithParametersData>>[0] = typeof pageParam === "object" ? pageParam : { 256 234 query: { 257 235 cursor: pageParam 258 236 } ··· 260 238 const { data } = await callWithParameters({ 261 239 ...options, 262 240 body: { 263 - ...queryKey[0].params.body as any, 241 + ...queryKey[0].body as any, 264 242 ...page.body as any 265 243 }, 266 244 headers: { 267 - ...queryKey[0].params.headers, 245 + ...queryKey[0].headers, 268 246 ...page.headers 269 247 }, 270 248 path: { 271 - ...queryKey[0].params.path, 249 + ...queryKey[0].path, 272 250 ...page.path 273 251 }, 274 252 query: { 275 - ...queryKey[0].params.query, 253 + ...queryKey[0].query, 276 254 ...page.query 277 255 }, 256 + baseURL: client.getConfig().baseURL, 278 257 throwOnError: true 279 258 }); 280 259 return data; 281 260 }, 282 261 queryKey: [ 283 - { 284 - infinite: true, 285 - params: createQueryKeyParams(options), 286 - scope: 'callWithParameters' 287 - } 262 + createQueryKey("callWithParameters", options, true) 288 263 ] 289 264 }); }; 290 265 291 - export const callWithParametersMutation: UseMutationOptions<void, AxiosError<DefaultError>, Options<CallWithParametersData>> = { 266 + export const callWithParametersMutation = () => { const mutationOptions: UseMutationOptions<void, AxiosError<DefaultError>, Options<CallWithParametersData>> = { 292 267 mutationFn: async (options) => { 293 268 const { data } = await callWithParameters({ 294 269 ...options, ··· 296 271 }); 297 272 return data; 298 273 } 299 - }; 274 + }; return mutationOptions; }; 300 275 301 276 export const callWithWeirdParameterNamesOptions = (options: Options<CallWithWeirdParameterNamesData>) => { return queryOptions({ 302 277 queryFn: async ({ queryKey }) => { 303 278 const { data } = await callWithWeirdParameterNames({ 304 279 ...options, 305 - ...queryKey[0].params, 280 + ...queryKey[0], 306 281 throwOnError: true 307 282 }); 308 283 return data; 309 284 }, 310 285 queryKey: [ 311 - { 312 - params: createQueryKeyParams(options), 313 - scope: 'callWithWeirdParameterNames' 314 - } 286 + createQueryKey("callWithWeirdParameterNames", options) 315 287 ] 316 288 }); }; 317 289 318 - export const callWithWeirdParameterNamesMutation: UseMutationOptions<void, AxiosError<DefaultError>, Options<CallWithWeirdParameterNamesData>> = { 290 + export const callWithWeirdParameterNamesMutation = () => { const mutationOptions: UseMutationOptions<void, AxiosError<DefaultError>, Options<CallWithWeirdParameterNamesData>> = { 319 291 mutationFn: async (options) => { 320 292 const { data } = await callWithWeirdParameterNames({ 321 293 ...options, ··· 323 295 }); 324 296 return data; 325 297 } 326 - }; 298 + }; return mutationOptions; }; 327 299 328 300 export const getCallWithOptionalParamOptions = (options: Options<GetCallWithOptionalParamData>) => { return queryOptions({ 329 301 queryFn: async ({ queryKey }) => { 330 302 const { data } = await getCallWithOptionalParam({ 331 303 ...options, 332 - ...queryKey[0].params, 304 + ...queryKey[0], 333 305 throwOnError: true 334 306 }); 335 307 return data; 336 308 }, 337 309 queryKey: [ 338 - { 339 - params: createQueryKeyParams(options), 340 - scope: 'getCallWithOptionalParam' 341 - } 310 + createQueryKey("getCallWithOptionalParam", options) 342 311 ] 343 312 }); }; 344 313 345 - export const getCallWithOptionalParamInfiniteOptions = (options: Options<GetCallWithOptionalParamData>) => { return infiniteQueryOptions<void, AxiosError<DefaultError>, InfiniteData<void>, QueryKey<Options<GetCallWithOptionalParamData>>, number | QueryKey<Options<GetCallWithOptionalParamData>>[0]['params']>( 314 + export const getCallWithOptionalParamInfiniteOptions = (options: Options<GetCallWithOptionalParamData>) => { return infiniteQueryOptions<void, AxiosError<DefaultError>, InfiniteData<void>, QueryKey<Options<GetCallWithOptionalParamData>>, number | QueryKey<Options<GetCallWithOptionalParamData>>[0]>( 346 315 // @ts-ignore 347 316 { 348 317 queryFn: async ({ pageParam, queryKey }) => { 349 318 // @ts-ignore 350 - const page: QueryKey<Options<GetCallWithOptionalParamData>>[0]['params'] = typeof pageParam === "object" ? pageParam : { 319 + const page: QueryKey<Options<GetCallWithOptionalParamData>>[0] = typeof pageParam === "object" ? pageParam : { 351 320 query: { 352 321 page: pageParam 353 322 } ··· 355 324 const { data } = await getCallWithOptionalParam({ 356 325 ...options, 357 326 body: { 358 - ...queryKey[0].params.body as any, 327 + ...queryKey[0].body as any, 359 328 ...page.body as any 360 329 }, 361 330 headers: { 362 - ...queryKey[0].params.headers, 331 + ...queryKey[0].headers, 363 332 ...page.headers 364 333 }, 365 334 path: { 366 - ...queryKey[0].params.path, 335 + ...queryKey[0].path, 367 336 ...page.path 368 337 }, 369 338 query: { 370 - ...queryKey[0].params.query, 339 + ...queryKey[0].query, 371 340 ...page.query 372 341 }, 342 + baseURL: client.getConfig().baseURL, 373 343 throwOnError: true 374 344 }); 375 345 return data; 376 346 }, 377 347 queryKey: [ 378 - { 379 - infinite: true, 380 - params: createQueryKeyParams(options), 381 - scope: 'getCallWithOptionalParam' 382 - } 348 + createQueryKey("getCallWithOptionalParam", options, true) 383 349 ] 384 350 }); }; 385 351 ··· 387 353 queryFn: async ({ queryKey }) => { 388 354 const { data } = await postCallWithOptionalParam({ 389 355 ...options, 390 - ...queryKey[0].params, 356 + ...queryKey[0], 391 357 throwOnError: true 392 358 }); 393 359 return data; 394 360 }, 395 361 queryKey: [ 396 - { 397 - params: createQueryKeyParams(options), 398 - scope: 'postCallWithOptionalParam' 399 - } 362 + createQueryKey("postCallWithOptionalParam", options) 400 363 ] 401 364 }); }; 402 365 403 - export const postCallWithOptionalParamInfiniteOptions = (options: Options<PostCallWithOptionalParamData>) => { return infiniteQueryOptions<PostCallWithOptionalParamResponse, AxiosError<PostCallWithOptionalParamError>, InfiniteData<PostCallWithOptionalParamResponse>, QueryKey<Options<PostCallWithOptionalParamData>>, number | QueryKey<Options<PostCallWithOptionalParamData>>[0]['params']>( 366 + export const postCallWithOptionalParamInfiniteOptions = (options: Options<PostCallWithOptionalParamData>) => { return infiniteQueryOptions<PostCallWithOptionalParamResponse, AxiosError<PostCallWithOptionalParamError>, InfiniteData<PostCallWithOptionalParamResponse>, QueryKey<Options<PostCallWithOptionalParamData>>, number | QueryKey<Options<PostCallWithOptionalParamData>>[0]>( 404 367 // @ts-ignore 405 368 { 406 369 queryFn: async ({ pageParam, queryKey }) => { 407 370 // @ts-ignore 408 - const page: QueryKey<Options<PostCallWithOptionalParamData>>[0]['params'] = typeof pageParam === "object" ? pageParam : { 371 + const page: QueryKey<Options<PostCallWithOptionalParamData>>[0] = typeof pageParam === "object" ? pageParam : { 409 372 body: { 410 373 offset: pageParam 411 374 } ··· 413 376 const { data } = await postCallWithOptionalParam({ 414 377 ...options, 415 378 body: { 416 - ...queryKey[0].params.body as any, 379 + ...queryKey[0].body as any, 417 380 ...page.body as any 418 381 }, 419 382 headers: { 420 - ...queryKey[0].params.headers, 383 + ...queryKey[0].headers, 421 384 ...page.headers 422 385 }, 423 386 path: { 424 - ...queryKey[0].params.path, 387 + ...queryKey[0].path, 425 388 ...page.path 426 389 }, 427 390 query: { 428 - ...queryKey[0].params.query, 391 + ...queryKey[0].query, 429 392 ...page.query 430 393 }, 394 + baseURL: client.getConfig().baseURL, 431 395 throwOnError: true 432 396 }); 433 397 return data; 434 398 }, 435 399 queryKey: [ 436 - { 437 - infinite: true, 438 - params: createQueryKeyParams(options), 439 - scope: 'postCallWithOptionalParam' 440 - } 400 + createQueryKey("postCallWithOptionalParam", options, true) 441 401 ] 442 402 }); }; 443 403 444 - export const postCallWithOptionalParamMutation: UseMutationOptions<PostCallWithOptionalParamResponse, AxiosError<PostCallWithOptionalParamError>, Options<PostCallWithOptionalParamData>> = { 404 + export const postCallWithOptionalParamMutation = () => { const mutationOptions: UseMutationOptions<PostCallWithOptionalParamResponse, AxiosError<PostCallWithOptionalParamError>, Options<PostCallWithOptionalParamData>> = { 445 405 mutationFn: async (options) => { 446 406 const { data } = await postCallWithOptionalParam({ 447 407 ...options, ··· 449 409 }); 450 410 return data; 451 411 } 452 - }; 412 + }; return mutationOptions; }; 453 413 454 414 export const postApiVbyApiVersionRequestBodyOptions = (options?: Options<PostApiVbyApiVersionRequestBodyData>) => { return queryOptions({ 455 415 queryFn: async ({ queryKey }) => { 456 416 const { data } = await postApiVbyApiVersionRequestBody({ 457 417 ...options, 458 - ...queryKey[0].params, 418 + ...queryKey[0], 459 419 throwOnError: true 460 420 }); 461 421 return data; 462 422 }, 463 423 queryKey: [ 464 - { 465 - params: createQueryKeyParams(options), 466 - scope: 'postApiVbyApiVersionRequestBody' 467 - } 424 + createQueryKey("postApiVbyApiVersionRequestBody", options) 468 425 ] 469 426 }); }; 470 427 471 - export const postApiVbyApiVersionRequestBodyMutation: UseMutationOptions<void, AxiosError<DefaultError>, Options<PostApiVbyApiVersionRequestBodyData>> = { 428 + export const postApiVbyApiVersionRequestBodyMutation = () => { const mutationOptions: UseMutationOptions<void, AxiosError<DefaultError>, Options<PostApiVbyApiVersionRequestBodyData>> = { 472 429 mutationFn: async (options) => { 473 430 const { data } = await postApiVbyApiVersionRequestBody({ 474 431 ...options, ··· 476 433 }); 477 434 return data; 478 435 } 479 - }; 436 + }; return mutationOptions; }; 480 437 481 438 export const postApiVbyApiVersionFormDataOptions = (options?: Options<PostApiVbyApiVersionFormDataData>) => { return queryOptions({ 482 439 queryFn: async ({ queryKey }) => { 483 440 const { data } = await postApiVbyApiVersionFormData({ 484 441 ...options, 485 - ...queryKey[0].params, 442 + ...queryKey[0], 486 443 throwOnError: true 487 444 }); 488 445 return data; 489 446 }, 490 447 queryKey: [ 491 - { 492 - params: createQueryKeyParams(options), 493 - scope: 'postApiVbyApiVersionFormData' 494 - } 448 + createQueryKey("postApiVbyApiVersionFormData", options) 495 449 ] 496 450 }); }; 497 451 498 - export const postApiVbyApiVersionFormDataMutation: UseMutationOptions<void, AxiosError<DefaultError>, Options<PostApiVbyApiVersionFormDataData>> = { 452 + export const postApiVbyApiVersionFormDataMutation = () => { const mutationOptions: UseMutationOptions<void, AxiosError<DefaultError>, Options<PostApiVbyApiVersionFormDataData>> = { 499 453 mutationFn: async (options) => { 500 454 const { data } = await postApiVbyApiVersionFormData({ 501 455 ...options, ··· 503 457 }); 504 458 return data; 505 459 } 506 - }; 460 + }; return mutationOptions; }; 507 461 508 462 export const callWithDefaultParametersOptions = (options?: Options<CallWithDefaultParametersData>) => { return queryOptions({ 509 463 queryFn: async ({ queryKey }) => { 510 464 const { data } = await callWithDefaultParameters({ 511 465 ...options, 512 - ...queryKey[0].params, 466 + ...queryKey[0], 513 467 throwOnError: true 514 468 }); 515 469 return data; 516 470 }, 517 471 queryKey: [ 518 - { 519 - params: createQueryKeyParams(options), 520 - scope: 'callWithDefaultParameters' 521 - } 472 + createQueryKey("callWithDefaultParameters", options) 522 473 ] 523 474 }); }; 524 475 ··· 526 477 queryFn: async ({ queryKey }) => { 527 478 const { data } = await callWithDefaultOptionalParameters({ 528 479 ...options, 529 - ...queryKey[0].params, 480 + ...queryKey[0], 530 481 throwOnError: true 531 482 }); 532 483 return data; 533 484 }, 534 485 queryKey: [ 535 - { 536 - params: createQueryKeyParams(options), 537 - scope: 'callWithDefaultOptionalParameters' 538 - } 486 + createQueryKey("callWithDefaultOptionalParameters", options) 539 487 ] 540 488 }); }; 541 489 542 - export const callWithDefaultOptionalParametersMutation: UseMutationOptions<void, AxiosError<DefaultError>, Options<CallWithDefaultOptionalParametersData>> = { 490 + export const callWithDefaultOptionalParametersMutation = () => { const mutationOptions: UseMutationOptions<void, AxiosError<DefaultError>, Options<CallWithDefaultOptionalParametersData>> = { 543 491 mutationFn: async (options) => { 544 492 const { data } = await callWithDefaultOptionalParameters({ 545 493 ...options, ··· 547 495 }); 548 496 return data; 549 497 } 550 - }; 498 + }; return mutationOptions; }; 551 499 552 - export const callToTestOrderOfParamsMutation: UseMutationOptions<void, AxiosError<DefaultError>, Options<CallToTestOrderOfParamsData>> = { 500 + export const callToTestOrderOfParamsMutation = () => { const mutationOptions: UseMutationOptions<void, AxiosError<DefaultError>, Options<CallToTestOrderOfParamsData>> = { 553 501 mutationFn: async (options) => { 554 502 const { data } = await callToTestOrderOfParams({ 555 503 ...options, ··· 557 505 }); 558 506 return data; 559 507 } 560 - }; 508 + }; return mutationOptions; }; 561 509 562 510 export const duplicateNameOptions = (options?: Options) => { return queryOptions({ 563 511 queryFn: async ({ queryKey }) => { 564 512 const { data } = await duplicateName({ 565 513 ...options, 566 - ...queryKey[0].params, 514 + ...queryKey[0], 567 515 throwOnError: true 568 516 }); 569 517 return data; 570 518 }, 571 519 queryKey: [ 572 - { 573 - params: createQueryKeyParams(options), 574 - scope: 'duplicateName' 575 - } 520 + createQueryKey("duplicateName", options) 576 521 ] 577 522 }); }; 578 523 ··· 580 525 queryFn: async ({ queryKey }) => { 581 526 const { data } = await duplicateName1({ 582 527 ...options, 583 - ...queryKey[0].params, 528 + ...queryKey[0], 584 529 throwOnError: true 585 530 }); 586 531 return data; 587 532 }, 588 533 queryKey: [ 589 - { 590 - params: createQueryKeyParams(options), 591 - scope: 'duplicateName1' 592 - } 534 + createQueryKey("duplicateName1", options) 593 535 ] 594 536 }); }; 595 537 596 - export const duplicateName1Mutation: UseMutationOptions<void, AxiosError<DefaultError>, Options> = { 538 + export const duplicateName1Mutation = () => { const mutationOptions: UseMutationOptions<void, AxiosError<DefaultError>, Options> = { 597 539 mutationFn: async (options) => { 598 540 const { data } = await duplicateName1({ 599 541 ...options, ··· 601 543 }); 602 544 return data; 603 545 } 604 - }; 546 + }; return mutationOptions; }; 605 547 606 - export const duplicateName2Mutation: UseMutationOptions<void, AxiosError<DefaultError>, Options> = { 548 + export const duplicateName2Mutation = () => { const mutationOptions: UseMutationOptions<void, AxiosError<DefaultError>, Options> = { 607 549 mutationFn: async (options) => { 608 550 const { data } = await duplicateName2({ 609 551 ...options, ··· 611 553 }); 612 554 return data; 613 555 } 614 - }; 556 + }; return mutationOptions; }; 615 557 616 - export const duplicateName3Mutation: UseMutationOptions<void, AxiosError<DefaultError>, Options> = { 558 + export const duplicateName3Mutation = () => { const mutationOptions: UseMutationOptions<void, AxiosError<DefaultError>, Options> = { 617 559 mutationFn: async (options) => { 618 560 const { data } = await duplicateName3({ 619 561 ...options, ··· 621 563 }); 622 564 return data; 623 565 } 624 - }; 566 + }; return mutationOptions; }; 625 567 626 568 export const callWithNoContentResponseOptions = (options?: Options) => { return queryOptions({ 627 569 queryFn: async ({ queryKey }) => { 628 570 const { data } = await callWithNoContentResponse({ 629 571 ...options, 630 - ...queryKey[0].params, 572 + ...queryKey[0], 631 573 throwOnError: true 632 574 }); 633 575 return data; 634 576 }, 635 577 queryKey: [ 636 - { 637 - params: createQueryKeyParams(options), 638 - scope: 'callWithNoContentResponse' 639 - } 578 + createQueryKey("callWithNoContentResponse", options) 640 579 ] 641 580 }); }; 642 581 ··· 644 583 queryFn: async ({ queryKey }) => { 645 584 const { data } = await callWithResponseAndNoContentResponse({ 646 585 ...options, 647 - ...queryKey[0].params, 586 + ...queryKey[0], 648 587 throwOnError: true 649 588 }); 650 589 return data; 651 590 }, 652 591 queryKey: [ 653 - { 654 - params: createQueryKeyParams(options), 655 - scope: 'callWithResponseAndNoContentResponse' 656 - } 592 + createQueryKey("callWithResponseAndNoContentResponse", options) 657 593 ] 658 594 }); }; 659 595 ··· 661 597 queryFn: async ({ queryKey }) => { 662 598 const { data } = await dummyA({ 663 599 ...options, 664 - ...queryKey[0].params, 600 + ...queryKey[0], 665 601 throwOnError: true 666 602 }); 667 603 return data; 668 604 }, 669 605 queryKey: [ 670 - { 671 - params: createQueryKeyParams(options), 672 - scope: 'dummyA' 673 - } 606 + createQueryKey("dummyA", options) 674 607 ] 675 608 }); }; 676 609 ··· 678 611 queryFn: async ({ queryKey }) => { 679 612 const { data } = await dummyB({ 680 613 ...options, 681 - ...queryKey[0].params, 614 + ...queryKey[0], 682 615 throwOnError: true 683 616 }); 684 617 return data; 685 618 }, 686 619 queryKey: [ 687 - { 688 - params: createQueryKeyParams(options), 689 - scope: 'dummyB' 690 - } 620 + createQueryKey("dummyB", options) 691 621 ] 692 622 }); }; 693 623 ··· 695 625 queryFn: async ({ queryKey }) => { 696 626 const { data } = await callWithResponse({ 697 627 ...options, 698 - ...queryKey[0].params, 628 + ...queryKey[0], 699 629 throwOnError: true 700 630 }); 701 631 return data; 702 632 }, 703 633 queryKey: [ 704 - { 705 - params: createQueryKeyParams(options), 706 - scope: 'callWithResponse' 707 - } 634 + createQueryKey("callWithResponse", options) 708 635 ] 709 636 }); }; 710 637 ··· 712 639 queryFn: async ({ queryKey }) => { 713 640 const { data } = await callWithDuplicateResponses({ 714 641 ...options, 715 - ...queryKey[0].params, 642 + ...queryKey[0], 716 643 throwOnError: true 717 644 }); 718 645 return data; 719 646 }, 720 647 queryKey: [ 721 - { 722 - params: createQueryKeyParams(options), 723 - scope: 'callWithDuplicateResponses' 724 - } 648 + createQueryKey("callWithDuplicateResponses", options) 725 649 ] 726 650 }); }; 727 651 728 - export const callWithDuplicateResponsesMutation: UseMutationOptions<CallWithDuplicateResponsesResponse, AxiosError<CallWithDuplicateResponsesError>, Options> = { 652 + export const callWithDuplicateResponsesMutation = () => { const mutationOptions: UseMutationOptions<CallWithDuplicateResponsesResponse, AxiosError<CallWithDuplicateResponsesError>, Options> = { 729 653 mutationFn: async (options) => { 730 654 const { data } = await callWithDuplicateResponses({ 731 655 ...options, ··· 733 657 }); 734 658 return data; 735 659 } 736 - }; 660 + }; return mutationOptions; }; 737 661 738 - export const callWithResponsesMutation: UseMutationOptions<CallWithResponsesResponse, AxiosError<CallWithResponsesError>, Options> = { 662 + export const callWithResponsesMutation = () => { const mutationOptions: UseMutationOptions<CallWithResponsesResponse, AxiosError<CallWithResponsesError>, Options> = { 739 663 mutationFn: async (options) => { 740 664 const { data } = await callWithResponses({ 741 665 ...options, ··· 743 667 }); 744 668 return data; 745 669 } 746 - }; 670 + }; return mutationOptions; }; 747 671 748 672 export const collectionFormatOptions = (options: Options<CollectionFormatData>) => { return queryOptions({ 749 673 queryFn: async ({ queryKey }) => { 750 674 const { data } = await collectionFormat({ 751 675 ...options, 752 - ...queryKey[0].params, 676 + ...queryKey[0], 753 677 throwOnError: true 754 678 }); 755 679 return data; 756 680 }, 757 681 queryKey: [ 758 - { 759 - params: createQueryKeyParams(options), 760 - scope: 'collectionFormat' 761 - } 682 + createQueryKey("collectionFormat", options) 762 683 ] 763 684 }); }; 764 685 ··· 766 687 queryFn: async ({ queryKey }) => { 767 688 const { data } = await types({ 768 689 ...options, 769 - ...queryKey[0].params, 690 + ...queryKey[0], 770 691 throwOnError: true 771 692 }); 772 693 return data; 773 694 }, 774 695 queryKey: [ 775 - { 776 - params: createQueryKeyParams(options), 777 - scope: 'types' 778 - } 696 + createQueryKey("types", options) 779 697 ] 780 698 }); }; 781 699 ··· 783 701 queryFn: async ({ queryKey }) => { 784 702 const { data } = await uploadFile({ 785 703 ...options, 786 - ...queryKey[0].params, 704 + ...queryKey[0], 787 705 throwOnError: true 788 706 }); 789 707 return data; 790 708 }, 791 709 queryKey: [ 792 - { 793 - params: createQueryKeyParams(options), 794 - scope: 'uploadFile' 795 - } 710 + createQueryKey("uploadFile", options) 796 711 ] 797 712 }); }; 798 713 799 - export const uploadFileMutation: UseMutationOptions<UploadFileResponse, AxiosError<UploadFileError>, Options<UploadFileData>> = { 714 + export const uploadFileMutation = () => { const mutationOptions: UseMutationOptions<UploadFileResponse, AxiosError<UploadFileError>, Options<UploadFileData>> = { 800 715 mutationFn: async (options) => { 801 716 const { data } = await uploadFile({ 802 717 ...options, ··· 804 719 }); 805 720 return data; 806 721 } 807 - }; 722 + }; return mutationOptions; }; 808 723 809 724 export const fileResponseOptions = (options: Options<FileResponseData>) => { return queryOptions({ 810 725 queryFn: async ({ queryKey }) => { 811 726 const { data } = await fileResponse({ 812 727 ...options, 813 - ...queryKey[0].params, 728 + ...queryKey[0], 814 729 throwOnError: true 815 730 }); 816 731 return data; 817 732 }, 818 733 queryKey: [ 819 - { 820 - params: createQueryKeyParams(options), 821 - scope: 'fileResponse' 822 - } 734 + createQueryKey("fileResponse", options) 823 735 ] 824 736 }); }; 825 737 ··· 827 739 queryFn: async ({ queryKey }) => { 828 740 const { data } = await complexTypes({ 829 741 ...options, 830 - ...queryKey[0].params, 742 + ...queryKey[0], 831 743 throwOnError: true 832 744 }); 833 745 return data; 834 746 }, 835 747 queryKey: [ 836 - { 837 - params: createQueryKeyParams(options), 838 - scope: 'complexTypes' 839 - } 748 + createQueryKey("complexTypes", options) 840 749 ] 841 750 }); }; 842 751 ··· 844 753 queryFn: async ({ queryKey }) => { 845 754 const { data } = await multipartRequest({ 846 755 ...options, 847 - ...queryKey[0].params, 756 + ...queryKey[0], 848 757 throwOnError: true 849 758 }); 850 759 return data; 851 760 }, 852 761 queryKey: [ 853 - { 854 - params: createQueryKeyParams(options), 855 - scope: 'multipartRequest' 856 - } 762 + createQueryKey("multipartRequest", options) 857 763 ] 858 764 }); }; 859 765 860 - export const multipartRequestMutation: UseMutationOptions<void, AxiosError<DefaultError>, Options<MultipartRequestData>> = { 766 + export const multipartRequestMutation = () => { const mutationOptions: UseMutationOptions<void, AxiosError<DefaultError>, Options<MultipartRequestData>> = { 861 767 mutationFn: async (options) => { 862 768 const { data } = await multipartRequest({ 863 769 ...options, ··· 865 771 }); 866 772 return data; 867 773 } 868 - }; 774 + }; return mutationOptions; }; 869 775 870 776 export const multipartResponseOptions = (options?: Options) => { return queryOptions({ 871 777 queryFn: async ({ queryKey }) => { 872 778 const { data } = await multipartResponse({ 873 779 ...options, 874 - ...queryKey[0].params, 780 + ...queryKey[0], 875 781 throwOnError: true 876 782 }); 877 783 return data; 878 784 }, 879 785 queryKey: [ 880 - { 881 - params: createQueryKeyParams(options), 882 - scope: 'multipartResponse' 883 - } 786 + createQueryKey("multipartResponse", options) 884 787 ] 885 788 }); }; 886 789 887 - export const complexParamsMutation: UseMutationOptions<ComplexParamsResponse, AxiosError<ComplexParamsError>, Options<ComplexParamsData>> = { 790 + export const complexParamsMutation = () => { const mutationOptions: UseMutationOptions<ComplexParamsResponse, AxiosError<ComplexParamsError>, Options<ComplexParamsData>> = { 888 791 mutationFn: async (options) => { 889 792 const { data } = await complexParams({ 890 793 ...options, ··· 892 795 }); 893 796 return data; 894 797 } 895 - }; 798 + }; return mutationOptions; }; 896 799 897 800 export const callWithResultFromHeaderOptions = (options?: Options) => { return queryOptions({ 898 801 queryFn: async ({ queryKey }) => { 899 802 const { data } = await callWithResultFromHeader({ 900 803 ...options, 901 - ...queryKey[0].params, 804 + ...queryKey[0], 902 805 throwOnError: true 903 806 }); 904 807 return data; 905 808 }, 906 809 queryKey: [ 907 - { 908 - params: createQueryKeyParams(options), 909 - scope: 'callWithResultFromHeader' 910 - } 810 + createQueryKey("callWithResultFromHeader", options) 911 811 ] 912 812 }); }; 913 813 914 - export const callWithResultFromHeaderMutation: UseMutationOptions<CallWithResultFromHeaderResponse, AxiosError<CallWithResultFromHeaderError>, Options> = { 814 + export const callWithResultFromHeaderMutation = () => { const mutationOptions: UseMutationOptions<CallWithResultFromHeaderResponse, AxiosError<CallWithResultFromHeaderError>, Options> = { 915 815 mutationFn: async (options) => { 916 816 const { data } = await callWithResultFromHeader({ 917 817 ...options, ··· 919 819 }); 920 820 return data; 921 821 } 922 - }; 822 + }; return mutationOptions; }; 923 823 924 824 export const testErrorCodeOptions = (options: Options<TestErrorCodeData>) => { return queryOptions({ 925 825 queryFn: async ({ queryKey }) => { 926 826 const { data } = await testErrorCode({ 927 827 ...options, 928 - ...queryKey[0].params, 828 + ...queryKey[0], 929 829 throwOnError: true 930 830 }); 931 831 return data; 932 832 }, 933 833 queryKey: [ 934 - { 935 - params: createQueryKeyParams(options), 936 - scope: 'testErrorCode' 937 - } 834 + createQueryKey("testErrorCode", options) 938 835 ] 939 836 }); }; 940 837 941 - export const testErrorCodeMutation: UseMutationOptions<TestErrorCodeResponse, AxiosError<TestErrorCodeError>, Options<TestErrorCodeData>> = { 838 + export const testErrorCodeMutation = () => { const mutationOptions: UseMutationOptions<TestErrorCodeResponse, AxiosError<TestErrorCodeError>, Options<TestErrorCodeData>> = { 942 839 mutationFn: async (options) => { 943 840 const { data } = await testErrorCode({ 944 841 ...options, ··· 946 843 }); 947 844 return data; 948 845 } 949 - }; 846 + }; return mutationOptions; }; 950 847 951 848 export const nonAsciiæøåÆøÅöôêÊ字符串Options = (options: Options<NonAsciiæøåÆøÅöôêÊ字符串Data>) => { return queryOptions({ 952 849 queryFn: async ({ queryKey }) => { 953 850 const { data } = await nonAsciiæøåÆøÅöôêÊ字符串({ 954 851 ...options, 955 - ...queryKey[0].params, 852 + ...queryKey[0], 956 853 throwOnError: true 957 854 }); 958 855 return data; 959 856 }, 960 857 queryKey: [ 961 - { 962 - params: createQueryKeyParams(options), 963 - scope: 'nonAsciiæøåÆøÅöôêÊ字符串' 964 - } 858 + createQueryKey("nonAsciiæøåÆøÅöôêÊ字符串", options) 965 859 ] 966 860 }); }; 967 861 968 - export const nonAsciiæøåÆøÅöôêÊ字符串Mutation: UseMutationOptions<NonAsciiæøåÆøÅöôêÊ字符串Response, AxiosError<NonAsciiæøåÆøÅöôêÊ字符串Error>, Options<NonAsciiæøåÆøÅöôêÊ字符串Data>> = { 862 + export const nonAsciiæøåÆøÅöôêÊ字符串Mutation = () => { const mutationOptions: UseMutationOptions<NonAsciiæøåÆøÅöôêÊ字符串Response, AxiosError<NonAsciiæøåÆøÅöôêÊ字符串Error>, Options<NonAsciiæøåÆøÅöôêÊ字符串Data>> = { 969 863 mutationFn: async (options) => { 970 864 const { data } = await nonAsciiæøåÆøÅöôêÊ字符串({ 971 865 ...options, ··· 973 867 }); 974 868 return data; 975 869 } 976 - }; 870 + }; return mutationOptions; }; 977 871 978 - export const putWithFormUrlEncodedMutation: UseMutationOptions<void, AxiosError<DefaultError>, Options<PutWithFormUrlEncodedData>> = { 872 + export const putWithFormUrlEncodedMutation = () => { const mutationOptions: UseMutationOptions<void, AxiosError<DefaultError>, Options<PutWithFormUrlEncodedData>> = { 979 873 mutationFn: async (options) => { 980 874 const { data } = await putWithFormUrlEncoded({ 981 875 ...options, ··· 983 877 }); 984 878 return data; 985 879 } 986 - }; 880 + }; return mutationOptions; };
+22 -23
packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-axios-plugin-tanstack-react-query_transform/@tanstack/react-query.gen.ts.snap
··· 4 4 import { queryOptions, type UseMutationOptions } from '@tanstack/react-query'; 5 5 import type { ParentModelWithDatesError, ParentModelWithDatesResponse, ModelWithDatesError, ModelWithDatesResponse, ModelWithDatesArrayError, ModelWithDatesArrayResponse, ArrayOfDatesError, ArrayOfDatesResponse, DateError, DateResponse, MultipleResponsesError, MultipleResponsesResponse } from '../types.gen'; 6 6 import type { AxiosError } from 'axios'; 7 - import { parentModelWithDates, modelWithDates, modelWithDatesArray, arrayOfDates, date, multipleResponses } from '../services.gen'; 7 + import { client, parentModelWithDates, modelWithDates, modelWithDatesArray, arrayOfDates, date, multipleResponses } from '../services.gen'; 8 8 9 9 type QueryKey<TOptions extends Options> = [ 10 - { 10 + Pick<TOptions, 'baseURL' | 'body' | 'headers' | 'path' | 'query'> & { 11 + _id: string; 11 12 infinite?: boolean; 12 - params: Pick<TOptions, "body" | "headers" | "path" | "query">; 13 - scope: string; 14 13 } 15 14 ]; 16 15 17 - const createQueryKeyParams = <TOptions extends Options>(options?: TOptions): QueryKey<TOptions>[0]["params"] => { 18 - const params: QueryKey<TOptions>[0]["params"] = {} as QueryKey<TOptions>[0]["params"]; 16 + const createQueryKey = <TOptions extends Options>(id: string, options?: TOptions, infinite?: boolean): QueryKey<TOptions>[0] => { 17 + const params: QueryKey<TOptions>[0] = { _id: id, baseURL: client.getConfig().baseURL } as QueryKey<TOptions>[0]; 18 + if (infinite) { 19 + params.infinite = infinite; 20 + } 19 21 if (options?.body) { 20 22 params.body = options.body; 21 23 } ··· 35 37 queryFn: async ({ queryKey }) => { 36 38 const { data } = await parentModelWithDates({ 37 39 ...options, 38 - ...queryKey[0].params, 40 + ...queryKey[0], 39 41 throwOnError: true 40 42 }); 41 43 return data; 42 44 }, 43 45 queryKey: [ 44 - { 45 - params: createQueryKeyParams(options), 46 - scope: 'parentModelWithDates' 47 - } 46 + createQueryKey("parentModelWithDates", options) 48 47 ] 49 48 }); }; 50 49 51 - export const parentModelWithDatesMutation: UseMutationOptions<ParentModelWithDatesResponse, AxiosError<ParentModelWithDatesError>, Options> = { 50 + export const parentModelWithDatesMutation = () => { const mutationOptions: UseMutationOptions<ParentModelWithDatesResponse, AxiosError<ParentModelWithDatesError>, Options> = { 52 51 mutationFn: async (options) => { 53 52 const { data } = await parentModelWithDates({ 54 53 ...options, ··· 56 55 }); 57 56 return data; 58 57 } 59 - }; 58 + }; return mutationOptions; }; 60 59 61 - export const modelWithDatesMutation: UseMutationOptions<ModelWithDatesResponse, AxiosError<ModelWithDatesError>, Options> = { 60 + export const modelWithDatesMutation = () => { const mutationOptions: UseMutationOptions<ModelWithDatesResponse, AxiosError<ModelWithDatesError>, Options> = { 62 61 mutationFn: async (options) => { 63 62 const { data } = await modelWithDates({ 64 63 ...options, ··· 66 65 }); 67 66 return data; 68 67 } 69 - }; 68 + }; return mutationOptions; }; 70 69 71 - export const modelWithDatesArrayMutation: UseMutationOptions<ModelWithDatesArrayResponse, AxiosError<ModelWithDatesArrayError>, Options> = { 70 + export const modelWithDatesArrayMutation = () => { const mutationOptions: UseMutationOptions<ModelWithDatesArrayResponse, AxiosError<ModelWithDatesArrayError>, Options> = { 72 71 mutationFn: async (options) => { 73 72 const { data } = await modelWithDatesArray({ 74 73 ...options, ··· 76 75 }); 77 76 return data; 78 77 } 79 - }; 78 + }; return mutationOptions; }; 80 79 81 - export const arrayOfDatesMutation: UseMutationOptions<ArrayOfDatesResponse, AxiosError<ArrayOfDatesError>, Options> = { 80 + export const arrayOfDatesMutation = () => { const mutationOptions: UseMutationOptions<ArrayOfDatesResponse, AxiosError<ArrayOfDatesError>, Options> = { 82 81 mutationFn: async (options) => { 83 82 const { data } = await arrayOfDates({ 84 83 ...options, ··· 86 85 }); 87 86 return data; 88 87 } 89 - }; 88 + }; return mutationOptions; }; 90 89 91 - export const dateMutation: UseMutationOptions<DateResponse, AxiosError<DateError>, Options> = { 90 + export const dateMutation = () => { const mutationOptions: UseMutationOptions<DateResponse, AxiosError<DateError>, Options> = { 92 91 mutationFn: async (options) => { 93 92 const { data } = await date({ 94 93 ...options, ··· 96 95 }); 97 96 return data; 98 97 } 99 - }; 98 + }; return mutationOptions; }; 100 99 101 - export const multipleResponsesMutation: UseMutationOptions<MultipleResponsesResponse, AxiosError<MultipleResponsesError>, Options> = { 100 + export const multipleResponsesMutation = () => { const mutationOptions: UseMutationOptions<MultipleResponsesResponse, AxiosError<MultipleResponsesError>, Options> = { 102 101 mutationFn: async (options) => { 103 102 const { data } = await multipleResponses({ 104 103 ...options, ··· 106 105 }); 107 106 return data; 108 107 } 109 - }; 108 + }; return mutationOptions; };
+152 -258
packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-axios-plugin-tanstack-solid-query/@tanstack/solid-query.gen.ts.snap
··· 2 2 3 3 import type { Options } from '@hey-api/client-axios'; 4 4 import { queryOptions, type MutationOptions, type DefaultError, infiniteQueryOptions, type InfiniteData } from '@tanstack/solid-query'; 5 - import { export_, import_, apiVVersionOdataControllerCount, getCallWithoutParametersAndResponse, putCallWithoutParametersAndResponse, postCallWithoutParametersAndResponse, deleteCallWithoutParametersAndResponse, patchCallWithoutParametersAndResponse, deleteFoo, callWithDescriptions, deprecatedCall, callWithParameters, callWithWeirdParameterNames, getCallWithOptionalParam, postCallWithOptionalParam, postApiVbyApiVersionRequestBody, postApiVbyApiVersionFormData, callWithDefaultParameters, callWithDefaultOptionalParameters, callToTestOrderOfParams, duplicateName, duplicateName1, duplicateName2, duplicateName3, callWithNoContentResponse, callWithResponseAndNoContentResponse, dummyA, dummyB, callWithResponse, callWithDuplicateResponses, callWithResponses, collectionFormat, types, uploadFile, fileResponse, complexTypes, multipartRequest, multipartResponse, complexParams, callWithResultFromHeader, testErrorCode, nonAsciiæøåÆøÅöôêÊ字符串, putWithFormUrlEncoded } from '../services.gen'; 5 + import { client, export_, import_, apiVVersionOdataControllerCount, getCallWithoutParametersAndResponse, putCallWithoutParametersAndResponse, postCallWithoutParametersAndResponse, deleteCallWithoutParametersAndResponse, patchCallWithoutParametersAndResponse, deleteFoo, callWithDescriptions, deprecatedCall, callWithParameters, callWithWeirdParameterNames, getCallWithOptionalParam, postCallWithOptionalParam, postApiVbyApiVersionRequestBody, postApiVbyApiVersionFormData, callWithDefaultParameters, callWithDefaultOptionalParameters, callToTestOrderOfParams, duplicateName, duplicateName1, duplicateName2, duplicateName3, callWithNoContentResponse, callWithResponseAndNoContentResponse, dummyA, dummyB, callWithResponse, callWithDuplicateResponses, callWithResponses, collectionFormat, types, uploadFile, fileResponse, complexTypes, multipartRequest, multipartResponse, complexParams, callWithResultFromHeader, testErrorCode, nonAsciiæøåÆøÅöôêÊ字符串, putWithFormUrlEncoded } from '../services.gen'; 6 6 import type { ImportData, ImportError, ImportResponse, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamError, PostCallWithOptionalParamResponse, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, UploadFileData, UploadFileError, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartRequestData, ComplexParamsData, ComplexParamsError, ComplexParamsResponse, CallWithResultFromHeaderError, CallWithResultFromHeaderResponse, TestErrorCodeData, TestErrorCodeError, TestErrorCodeResponse, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Error, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; 7 7 import type { AxiosError } from 'axios'; 8 8 9 9 type QueryKey<TOptions extends Options> = [ 10 - { 10 + Pick<TOptions, 'baseURL' | 'body' | 'headers' | 'path' | 'query'> & { 11 + _id: string; 11 12 infinite?: boolean; 12 - params: Pick<TOptions, "body" | "headers" | "path" | "query">; 13 - scope: string; 14 13 } 15 14 ]; 16 15 17 - const createQueryKeyParams = <TOptions extends Options>(options?: TOptions): QueryKey<TOptions>[0]["params"] => { 18 - const params: QueryKey<TOptions>[0]["params"] = {} as QueryKey<TOptions>[0]["params"]; 16 + const createQueryKey = <TOptions extends Options>(id: string, options?: TOptions, infinite?: boolean): QueryKey<TOptions>[0] => { 17 + const params: QueryKey<TOptions>[0] = { _id: id, baseURL: client.getConfig().baseURL } as QueryKey<TOptions>[0]; 18 + if (infinite) { 19 + params.infinite = infinite; 20 + } 19 21 if (options?.body) { 20 22 params.body = options.body; 21 23 } ··· 35 37 queryFn: async ({ queryKey }) => { 36 38 const { data } = await export_({ 37 39 ...options, 38 - ...queryKey[0].params, 40 + ...queryKey[0], 39 41 throwOnError: true 40 42 }); 41 43 return data; 42 44 }, 43 45 queryKey: [ 44 - { 45 - params: createQueryKeyParams(options), 46 - scope: 'export' 47 - } 46 + createQueryKey("export", options) 48 47 ] 49 48 }); }; 50 49 ··· 52 51 queryFn: async ({ queryKey }) => { 53 52 const { data } = await import_({ 54 53 ...options, 55 - ...queryKey[0].params, 54 + ...queryKey[0], 56 55 throwOnError: true 57 56 }); 58 57 return data; 59 58 }, 60 59 queryKey: [ 61 - { 62 - params: createQueryKeyParams(options), 63 - scope: 'import' 64 - } 60 + createQueryKey("import", options) 65 61 ] 66 62 }); }; 67 63 68 - export const importMutation: MutationOptions<ImportResponse, AxiosError<ImportError>, Options<ImportData>> = { 64 + export const importMutation = () => { const mutationOptions: MutationOptions<ImportResponse, AxiosError<ImportError>, Options<ImportData>> = { 69 65 mutationFn: async (options) => { 70 66 const { data } = await import_({ 71 67 ...options, ··· 73 69 }); 74 70 return data; 75 71 } 76 - }; 72 + }; return mutationOptions; }; 77 73 78 74 export const apiVVersionOdataControllerCountOptions = (options?: Options) => { return queryOptions({ 79 75 queryFn: async ({ queryKey }) => { 80 76 const { data } = await apiVVersionOdataControllerCount({ 81 77 ...options, 82 - ...queryKey[0].params, 78 + ...queryKey[0], 83 79 throwOnError: true 84 80 }); 85 81 return data; 86 82 }, 87 83 queryKey: [ 88 - { 89 - params: createQueryKeyParams(options), 90 - scope: 'apiVVersionOdataControllerCount' 91 - } 84 + createQueryKey("apiVVersionOdataControllerCount", options) 92 85 ] 93 86 }); }; 94 87 ··· 96 89 queryFn: async ({ queryKey }) => { 97 90 const { data } = await getCallWithoutParametersAndResponse({ 98 91 ...options, 99 - ...queryKey[0].params, 92 + ...queryKey[0], 100 93 throwOnError: true 101 94 }); 102 95 return data; 103 96 }, 104 97 queryKey: [ 105 - { 106 - params: createQueryKeyParams(options), 107 - scope: 'getCallWithoutParametersAndResponse' 108 - } 98 + createQueryKey("getCallWithoutParametersAndResponse", options) 109 99 ] 110 100 }); }; 111 101 112 - export const putCallWithoutParametersAndResponseMutation: MutationOptions<void, AxiosError<DefaultError>, Options> = { 102 + export const putCallWithoutParametersAndResponseMutation = () => { const mutationOptions: MutationOptions<void, AxiosError<DefaultError>, Options> = { 113 103 mutationFn: async (options) => { 114 104 const { data } = await putCallWithoutParametersAndResponse({ 115 105 ...options, ··· 117 107 }); 118 108 return data; 119 109 } 120 - }; 110 + }; return mutationOptions; }; 121 111 122 112 export const postCallWithoutParametersAndResponseOptions = (options?: Options) => { return queryOptions({ 123 113 queryFn: async ({ queryKey }) => { 124 114 const { data } = await postCallWithoutParametersAndResponse({ 125 115 ...options, 126 - ...queryKey[0].params, 116 + ...queryKey[0], 127 117 throwOnError: true 128 118 }); 129 119 return data; 130 120 }, 131 121 queryKey: [ 132 - { 133 - params: createQueryKeyParams(options), 134 - scope: 'postCallWithoutParametersAndResponse' 135 - } 122 + createQueryKey("postCallWithoutParametersAndResponse", options) 136 123 ] 137 124 }); }; 138 125 139 - export const postCallWithoutParametersAndResponseMutation: MutationOptions<void, AxiosError<DefaultError>, Options> = { 126 + export const postCallWithoutParametersAndResponseMutation = () => { const mutationOptions: MutationOptions<void, AxiosError<DefaultError>, Options> = { 140 127 mutationFn: async (options) => { 141 128 const { data } = await postCallWithoutParametersAndResponse({ 142 129 ...options, ··· 144 131 }); 145 132 return data; 146 133 } 147 - }; 134 + }; return mutationOptions; }; 148 135 149 - export const deleteCallWithoutParametersAndResponseMutation: MutationOptions<void, AxiosError<DefaultError>, Options> = { 136 + export const deleteCallWithoutParametersAndResponseMutation = () => { const mutationOptions: MutationOptions<void, AxiosError<DefaultError>, Options> = { 150 137 mutationFn: async (options) => { 151 138 const { data } = await deleteCallWithoutParametersAndResponse({ 152 139 ...options, ··· 154 141 }); 155 142 return data; 156 143 } 157 - }; 144 + }; return mutationOptions; }; 158 145 159 - export const patchCallWithoutParametersAndResponseMutation: MutationOptions<void, AxiosError<DefaultError>, Options> = { 146 + export const patchCallWithoutParametersAndResponseMutation = () => { const mutationOptions: MutationOptions<void, AxiosError<DefaultError>, Options> = { 160 147 mutationFn: async (options) => { 161 148 const { data } = await patchCallWithoutParametersAndResponse({ 162 149 ...options, ··· 164 151 }); 165 152 return data; 166 153 } 167 - }; 154 + }; return mutationOptions; }; 168 155 169 - export const deleteFooMutation: MutationOptions<void, AxiosError<DefaultError>, Options<DeleteFooData3>> = { 156 + export const deleteFooMutation = () => { const mutationOptions: MutationOptions<void, AxiosError<DefaultError>, Options<DeleteFooData3>> = { 170 157 mutationFn: async (options) => { 171 158 const { data } = await deleteFoo({ 172 159 ...options, ··· 174 161 }); 175 162 return data; 176 163 } 177 - }; 164 + }; return mutationOptions; }; 178 165 179 166 export const callWithDescriptionsOptions = (options?: Options<CallWithDescriptionsData>) => { return queryOptions({ 180 167 queryFn: async ({ queryKey }) => { 181 168 const { data } = await callWithDescriptions({ 182 169 ...options, 183 - ...queryKey[0].params, 170 + ...queryKey[0], 184 171 throwOnError: true 185 172 }); 186 173 return data; 187 174 }, 188 175 queryKey: [ 189 - { 190 - params: createQueryKeyParams(options), 191 - scope: 'callWithDescriptions' 192 - } 176 + createQueryKey("callWithDescriptions", options) 193 177 ] 194 178 }); }; 195 179 196 - export const callWithDescriptionsMutation: MutationOptions<void, AxiosError<DefaultError>, Options<CallWithDescriptionsData>> = { 180 + export const callWithDescriptionsMutation = () => { const mutationOptions: MutationOptions<void, AxiosError<DefaultError>, Options<CallWithDescriptionsData>> = { 197 181 mutationFn: async (options) => { 198 182 const { data } = await callWithDescriptions({ 199 183 ...options, ··· 201 185 }); 202 186 return data; 203 187 } 204 - }; 188 + }; return mutationOptions; }; 205 189 206 190 export const deprecatedCallOptions = (options: Options<DeprecatedCallData>) => { return queryOptions({ 207 191 queryFn: async ({ queryKey }) => { 208 192 const { data } = await deprecatedCall({ 209 193 ...options, 210 - ...queryKey[0].params, 194 + ...queryKey[0], 211 195 throwOnError: true 212 196 }); 213 197 return data; 214 198 }, 215 199 queryKey: [ 216 - { 217 - params: createQueryKeyParams(options), 218 - scope: 'deprecatedCall' 219 - } 200 + createQueryKey("deprecatedCall", options) 220 201 ] 221 202 }); }; 222 203 223 - export const deprecatedCallMutation: MutationOptions<void, AxiosError<DefaultError>, Options<DeprecatedCallData>> = { 204 + export const deprecatedCallMutation = () => { const mutationOptions: MutationOptions<void, AxiosError<DefaultError>, Options<DeprecatedCallData>> = { 224 205 mutationFn: async (options) => { 225 206 const { data } = await deprecatedCall({ 226 207 ...options, ··· 228 209 }); 229 210 return data; 230 211 } 231 - }; 212 + }; return mutationOptions; }; 232 213 233 214 export const callWithParametersOptions = (options: Options<CallWithParametersData>) => { return queryOptions({ 234 215 queryFn: async ({ queryKey }) => { 235 216 const { data } = await callWithParameters({ 236 217 ...options, 237 - ...queryKey[0].params, 218 + ...queryKey[0], 238 219 throwOnError: true 239 220 }); 240 221 return data; 241 222 }, 242 223 queryKey: [ 243 - { 244 - params: createQueryKeyParams(options), 245 - scope: 'callWithParameters' 246 - } 224 + createQueryKey("callWithParameters", options) 247 225 ] 248 226 }); }; 249 227 250 - export const callWithParametersInfiniteOptions = (options: Options<CallWithParametersData>) => { return infiniteQueryOptions<void, AxiosError<DefaultError>, InfiniteData<void>, QueryKey<Options<CallWithParametersData>>, string | QueryKey<Options<CallWithParametersData>>[0]['params']>( 228 + export const callWithParametersInfiniteOptions = (options: Options<CallWithParametersData>) => { return infiniteQueryOptions<void, AxiosError<DefaultError>, InfiniteData<void>, QueryKey<Options<CallWithParametersData>>, string | QueryKey<Options<CallWithParametersData>>[0]>( 251 229 // @ts-ignore 252 230 { 253 231 queryFn: async ({ pageParam, queryKey }) => { 254 232 // @ts-ignore 255 - const page: QueryKey<Options<CallWithParametersData>>[0]['params'] = typeof pageParam === "object" ? pageParam : { 233 + const page: QueryKey<Options<CallWithParametersData>>[0] = typeof pageParam === "object" ? pageParam : { 256 234 query: { 257 235 cursor: pageParam 258 236 } ··· 260 238 const { data } = await callWithParameters({ 261 239 ...options, 262 240 body: { 263 - ...queryKey[0].params.body as any, 241 + ...queryKey[0].body as any, 264 242 ...page.body as any 265 243 }, 266 244 headers: { 267 - ...queryKey[0].params.headers, 245 + ...queryKey[0].headers, 268 246 ...page.headers 269 247 }, 270 248 path: { 271 - ...queryKey[0].params.path, 249 + ...queryKey[0].path, 272 250 ...page.path 273 251 }, 274 252 query: { 275 - ...queryKey[0].params.query, 253 + ...queryKey[0].query, 276 254 ...page.query 277 255 }, 256 + baseURL: client.getConfig().baseURL, 278 257 throwOnError: true 279 258 }); 280 259 return data; 281 260 }, 282 261 queryKey: [ 283 - { 284 - infinite: true, 285 - params: createQueryKeyParams(options), 286 - scope: 'callWithParameters' 287 - } 262 + createQueryKey("callWithParameters", options, true) 288 263 ] 289 264 }); }; 290 265 291 - export const callWithParametersMutation: MutationOptions<void, AxiosError<DefaultError>, Options<CallWithParametersData>> = { 266 + export const callWithParametersMutation = () => { const mutationOptions: MutationOptions<void, AxiosError<DefaultError>, Options<CallWithParametersData>> = { 292 267 mutationFn: async (options) => { 293 268 const { data } = await callWithParameters({ 294 269 ...options, ··· 296 271 }); 297 272 return data; 298 273 } 299 - }; 274 + }; return mutationOptions; }; 300 275 301 276 export const callWithWeirdParameterNamesOptions = (options: Options<CallWithWeirdParameterNamesData>) => { return queryOptions({ 302 277 queryFn: async ({ queryKey }) => { 303 278 const { data } = await callWithWeirdParameterNames({ 304 279 ...options, 305 - ...queryKey[0].params, 280 + ...queryKey[0], 306 281 throwOnError: true 307 282 }); 308 283 return data; 309 284 }, 310 285 queryKey: [ 311 - { 312 - params: createQueryKeyParams(options), 313 - scope: 'callWithWeirdParameterNames' 314 - } 286 + createQueryKey("callWithWeirdParameterNames", options) 315 287 ] 316 288 }); }; 317 289 318 - export const callWithWeirdParameterNamesMutation: MutationOptions<void, AxiosError<DefaultError>, Options<CallWithWeirdParameterNamesData>> = { 290 + export const callWithWeirdParameterNamesMutation = () => { const mutationOptions: MutationOptions<void, AxiosError<DefaultError>, Options<CallWithWeirdParameterNamesData>> = { 319 291 mutationFn: async (options) => { 320 292 const { data } = await callWithWeirdParameterNames({ 321 293 ...options, ··· 323 295 }); 324 296 return data; 325 297 } 326 - }; 298 + }; return mutationOptions; }; 327 299 328 300 export const getCallWithOptionalParamOptions = (options: Options<GetCallWithOptionalParamData>) => { return queryOptions({ 329 301 queryFn: async ({ queryKey }) => { 330 302 const { data } = await getCallWithOptionalParam({ 331 303 ...options, 332 - ...queryKey[0].params, 304 + ...queryKey[0], 333 305 throwOnError: true 334 306 }); 335 307 return data; 336 308 }, 337 309 queryKey: [ 338 - { 339 - params: createQueryKeyParams(options), 340 - scope: 'getCallWithOptionalParam' 341 - } 310 + createQueryKey("getCallWithOptionalParam", options) 342 311 ] 343 312 }); }; 344 313 345 - export const getCallWithOptionalParamInfiniteOptions = (options: Options<GetCallWithOptionalParamData>) => { return infiniteQueryOptions<void, AxiosError<DefaultError>, InfiniteData<void>, QueryKey<Options<GetCallWithOptionalParamData>>, number | QueryKey<Options<GetCallWithOptionalParamData>>[0]['params']>( 314 + export const getCallWithOptionalParamInfiniteOptions = (options: Options<GetCallWithOptionalParamData>) => { return infiniteQueryOptions<void, AxiosError<DefaultError>, InfiniteData<void>, QueryKey<Options<GetCallWithOptionalParamData>>, number | QueryKey<Options<GetCallWithOptionalParamData>>[0]>( 346 315 // @ts-ignore 347 316 { 348 317 queryFn: async ({ pageParam, queryKey }) => { 349 318 // @ts-ignore 350 - const page: QueryKey<Options<GetCallWithOptionalParamData>>[0]['params'] = typeof pageParam === "object" ? pageParam : { 319 + const page: QueryKey<Options<GetCallWithOptionalParamData>>[0] = typeof pageParam === "object" ? pageParam : { 351 320 query: { 352 321 page: pageParam 353 322 } ··· 355 324 const { data } = await getCallWithOptionalParam({ 356 325 ...options, 357 326 body: { 358 - ...queryKey[0].params.body as any, 327 + ...queryKey[0].body as any, 359 328 ...page.body as any 360 329 }, 361 330 headers: { 362 - ...queryKey[0].params.headers, 331 + ...queryKey[0].headers, 363 332 ...page.headers 364 333 }, 365 334 path: { 366 - ...queryKey[0].params.path, 335 + ...queryKey[0].path, 367 336 ...page.path 368 337 }, 369 338 query: { 370 - ...queryKey[0].params.query, 339 + ...queryKey[0].query, 371 340 ...page.query 372 341 }, 342 + baseURL: client.getConfig().baseURL, 373 343 throwOnError: true 374 344 }); 375 345 return data; 376 346 }, 377 347 queryKey: [ 378 - { 379 - infinite: true, 380 - params: createQueryKeyParams(options), 381 - scope: 'getCallWithOptionalParam' 382 - } 348 + createQueryKey("getCallWithOptionalParam", options, true) 383 349 ] 384 350 }); }; 385 351 ··· 387 353 queryFn: async ({ queryKey }) => { 388 354 const { data } = await postCallWithOptionalParam({ 389 355 ...options, 390 - ...queryKey[0].params, 356 + ...queryKey[0], 391 357 throwOnError: true 392 358 }); 393 359 return data; 394 360 }, 395 361 queryKey: [ 396 - { 397 - params: createQueryKeyParams(options), 398 - scope: 'postCallWithOptionalParam' 399 - } 362 + createQueryKey("postCallWithOptionalParam", options) 400 363 ] 401 364 }); }; 402 365 403 - export const postCallWithOptionalParamInfiniteOptions = (options: Options<PostCallWithOptionalParamData>) => { return infiniteQueryOptions<PostCallWithOptionalParamResponse, AxiosError<PostCallWithOptionalParamError>, InfiniteData<PostCallWithOptionalParamResponse>, QueryKey<Options<PostCallWithOptionalParamData>>, number | QueryKey<Options<PostCallWithOptionalParamData>>[0]['params']>( 366 + export const postCallWithOptionalParamInfiniteOptions = (options: Options<PostCallWithOptionalParamData>) => { return infiniteQueryOptions<PostCallWithOptionalParamResponse, AxiosError<PostCallWithOptionalParamError>, InfiniteData<PostCallWithOptionalParamResponse>, QueryKey<Options<PostCallWithOptionalParamData>>, number | QueryKey<Options<PostCallWithOptionalParamData>>[0]>( 404 367 // @ts-ignore 405 368 { 406 369 queryFn: async ({ pageParam, queryKey }) => { 407 370 // @ts-ignore 408 - const page: QueryKey<Options<PostCallWithOptionalParamData>>[0]['params'] = typeof pageParam === "object" ? pageParam : { 371 + const page: QueryKey<Options<PostCallWithOptionalParamData>>[0] = typeof pageParam === "object" ? pageParam : { 409 372 body: { 410 373 offset: pageParam 411 374 } ··· 413 376 const { data } = await postCallWithOptionalParam({ 414 377 ...options, 415 378 body: { 416 - ...queryKey[0].params.body as any, 379 + ...queryKey[0].body as any, 417 380 ...page.body as any 418 381 }, 419 382 headers: { 420 - ...queryKey[0].params.headers, 383 + ...queryKey[0].headers, 421 384 ...page.headers 422 385 }, 423 386 path: { 424 - ...queryKey[0].params.path, 387 + ...queryKey[0].path, 425 388 ...page.path 426 389 }, 427 390 query: { 428 - ...queryKey[0].params.query, 391 + ...queryKey[0].query, 429 392 ...page.query 430 393 }, 394 + baseURL: client.getConfig().baseURL, 431 395 throwOnError: true 432 396 }); 433 397 return data; 434 398 }, 435 399 queryKey: [ 436 - { 437 - infinite: true, 438 - params: createQueryKeyParams(options), 439 - scope: 'postCallWithOptionalParam' 440 - } 400 + createQueryKey("postCallWithOptionalParam", options, true) 441 401 ] 442 402 }); }; 443 403 444 - export const postCallWithOptionalParamMutation: MutationOptions<PostCallWithOptionalParamResponse, AxiosError<PostCallWithOptionalParamError>, Options<PostCallWithOptionalParamData>> = { 404 + export const postCallWithOptionalParamMutation = () => { const mutationOptions: MutationOptions<PostCallWithOptionalParamResponse, AxiosError<PostCallWithOptionalParamError>, Options<PostCallWithOptionalParamData>> = { 445 405 mutationFn: async (options) => { 446 406 const { data } = await postCallWithOptionalParam({ 447 407 ...options, ··· 449 409 }); 450 410 return data; 451 411 } 452 - }; 412 + }; return mutationOptions; }; 453 413 454 414 export const postApiVbyApiVersionRequestBodyOptions = (options?: Options<PostApiVbyApiVersionRequestBodyData>) => { return queryOptions({ 455 415 queryFn: async ({ queryKey }) => { 456 416 const { data } = await postApiVbyApiVersionRequestBody({ 457 417 ...options, 458 - ...queryKey[0].params, 418 + ...queryKey[0], 459 419 throwOnError: true 460 420 }); 461 421 return data; 462 422 }, 463 423 queryKey: [ 464 - { 465 - params: createQueryKeyParams(options), 466 - scope: 'postApiVbyApiVersionRequestBody' 467 - } 424 + createQueryKey("postApiVbyApiVersionRequestBody", options) 468 425 ] 469 426 }); }; 470 427 471 - export const postApiVbyApiVersionRequestBodyMutation: MutationOptions<void, AxiosError<DefaultError>, Options<PostApiVbyApiVersionRequestBodyData>> = { 428 + export const postApiVbyApiVersionRequestBodyMutation = () => { const mutationOptions: MutationOptions<void, AxiosError<DefaultError>, Options<PostApiVbyApiVersionRequestBodyData>> = { 472 429 mutationFn: async (options) => { 473 430 const { data } = await postApiVbyApiVersionRequestBody({ 474 431 ...options, ··· 476 433 }); 477 434 return data; 478 435 } 479 - }; 436 + }; return mutationOptions; }; 480 437 481 438 export const postApiVbyApiVersionFormDataOptions = (options?: Options<PostApiVbyApiVersionFormDataData>) => { return queryOptions({ 482 439 queryFn: async ({ queryKey }) => { 483 440 const { data } = await postApiVbyApiVersionFormData({ 484 441 ...options, 485 - ...queryKey[0].params, 442 + ...queryKey[0], 486 443 throwOnError: true 487 444 }); 488 445 return data; 489 446 }, 490 447 queryKey: [ 491 - { 492 - params: createQueryKeyParams(options), 493 - scope: 'postApiVbyApiVersionFormData' 494 - } 448 + createQueryKey("postApiVbyApiVersionFormData", options) 495 449 ] 496 450 }); }; 497 451 498 - export const postApiVbyApiVersionFormDataMutation: MutationOptions<void, AxiosError<DefaultError>, Options<PostApiVbyApiVersionFormDataData>> = { 452 + export const postApiVbyApiVersionFormDataMutation = () => { const mutationOptions: MutationOptions<void, AxiosError<DefaultError>, Options<PostApiVbyApiVersionFormDataData>> = { 499 453 mutationFn: async (options) => { 500 454 const { data } = await postApiVbyApiVersionFormData({ 501 455 ...options, ··· 503 457 }); 504 458 return data; 505 459 } 506 - }; 460 + }; return mutationOptions; }; 507 461 508 462 export const callWithDefaultParametersOptions = (options?: Options<CallWithDefaultParametersData>) => { return queryOptions({ 509 463 queryFn: async ({ queryKey }) => { 510 464 const { data } = await callWithDefaultParameters({ 511 465 ...options, 512 - ...queryKey[0].params, 466 + ...queryKey[0], 513 467 throwOnError: true 514 468 }); 515 469 return data; 516 470 }, 517 471 queryKey: [ 518 - { 519 - params: createQueryKeyParams(options), 520 - scope: 'callWithDefaultParameters' 521 - } 472 + createQueryKey("callWithDefaultParameters", options) 522 473 ] 523 474 }); }; 524 475 ··· 526 477 queryFn: async ({ queryKey }) => { 527 478 const { data } = await callWithDefaultOptionalParameters({ 528 479 ...options, 529 - ...queryKey[0].params, 480 + ...queryKey[0], 530 481 throwOnError: true 531 482 }); 532 483 return data; 533 484 }, 534 485 queryKey: [ 535 - { 536 - params: createQueryKeyParams(options), 537 - scope: 'callWithDefaultOptionalParameters' 538 - } 486 + createQueryKey("callWithDefaultOptionalParameters", options) 539 487 ] 540 488 }); }; 541 489 542 - export const callWithDefaultOptionalParametersMutation: MutationOptions<void, AxiosError<DefaultError>, Options<CallWithDefaultOptionalParametersData>> = { 490 + export const callWithDefaultOptionalParametersMutation = () => { const mutationOptions: MutationOptions<void, AxiosError<DefaultError>, Options<CallWithDefaultOptionalParametersData>> = { 543 491 mutationFn: async (options) => { 544 492 const { data } = await callWithDefaultOptionalParameters({ 545 493 ...options, ··· 547 495 }); 548 496 return data; 549 497 } 550 - }; 498 + }; return mutationOptions; }; 551 499 552 - export const callToTestOrderOfParamsMutation: MutationOptions<void, AxiosError<DefaultError>, Options<CallToTestOrderOfParamsData>> = { 500 + export const callToTestOrderOfParamsMutation = () => { const mutationOptions: MutationOptions<void, AxiosError<DefaultError>, Options<CallToTestOrderOfParamsData>> = { 553 501 mutationFn: async (options) => { 554 502 const { data } = await callToTestOrderOfParams({ 555 503 ...options, ··· 557 505 }); 558 506 return data; 559 507 } 560 - }; 508 + }; return mutationOptions; }; 561 509 562 510 export const duplicateNameOptions = (options?: Options) => { return queryOptions({ 563 511 queryFn: async ({ queryKey }) => { 564 512 const { data } = await duplicateName({ 565 513 ...options, 566 - ...queryKey[0].params, 514 + ...queryKey[0], 567 515 throwOnError: true 568 516 }); 569 517 return data; 570 518 }, 571 519 queryKey: [ 572 - { 573 - params: createQueryKeyParams(options), 574 - scope: 'duplicateName' 575 - } 520 + createQueryKey("duplicateName", options) 576 521 ] 577 522 }); }; 578 523 ··· 580 525 queryFn: async ({ queryKey }) => { 581 526 const { data } = await duplicateName1({ 582 527 ...options, 583 - ...queryKey[0].params, 528 + ...queryKey[0], 584 529 throwOnError: true 585 530 }); 586 531 return data; 587 532 }, 588 533 queryKey: [ 589 - { 590 - params: createQueryKeyParams(options), 591 - scope: 'duplicateName1' 592 - } 534 + createQueryKey("duplicateName1", options) 593 535 ] 594 536 }); }; 595 537 596 - export const duplicateName1Mutation: MutationOptions<void, AxiosError<DefaultError>, Options> = { 538 + export const duplicateName1Mutation = () => { const mutationOptions: MutationOptions<void, AxiosError<DefaultError>, Options> = { 597 539 mutationFn: async (options) => { 598 540 const { data } = await duplicateName1({ 599 541 ...options, ··· 601 543 }); 602 544 return data; 603 545 } 604 - }; 546 + }; return mutationOptions; }; 605 547 606 - export const duplicateName2Mutation: MutationOptions<void, AxiosError<DefaultError>, Options> = { 548 + export const duplicateName2Mutation = () => { const mutationOptions: MutationOptions<void, AxiosError<DefaultError>, Options> = { 607 549 mutationFn: async (options) => { 608 550 const { data } = await duplicateName2({ 609 551 ...options, ··· 611 553 }); 612 554 return data; 613 555 } 614 - }; 556 + }; return mutationOptions; }; 615 557 616 - export const duplicateName3Mutation: MutationOptions<void, AxiosError<DefaultError>, Options> = { 558 + export const duplicateName3Mutation = () => { const mutationOptions: MutationOptions<void, AxiosError<DefaultError>, Options> = { 617 559 mutationFn: async (options) => { 618 560 const { data } = await duplicateName3({ 619 561 ...options, ··· 621 563 }); 622 564 return data; 623 565 } 624 - }; 566 + }; return mutationOptions; }; 625 567 626 568 export const callWithNoContentResponseOptions = (options?: Options) => { return queryOptions({ 627 569 queryFn: async ({ queryKey }) => { 628 570 const { data } = await callWithNoContentResponse({ 629 571 ...options, 630 - ...queryKey[0].params, 572 + ...queryKey[0], 631 573 throwOnError: true 632 574 }); 633 575 return data; 634 576 }, 635 577 queryKey: [ 636 - { 637 - params: createQueryKeyParams(options), 638 - scope: 'callWithNoContentResponse' 639 - } 578 + createQueryKey("callWithNoContentResponse", options) 640 579 ] 641 580 }); }; 642 581 ··· 644 583 queryFn: async ({ queryKey }) => { 645 584 const { data } = await callWithResponseAndNoContentResponse({ 646 585 ...options, 647 - ...queryKey[0].params, 586 + ...queryKey[0], 648 587 throwOnError: true 649 588 }); 650 589 return data; 651 590 }, 652 591 queryKey: [ 653 - { 654 - params: createQueryKeyParams(options), 655 - scope: 'callWithResponseAndNoContentResponse' 656 - } 592 + createQueryKey("callWithResponseAndNoContentResponse", options) 657 593 ] 658 594 }); }; 659 595 ··· 661 597 queryFn: async ({ queryKey }) => { 662 598 const { data } = await dummyA({ 663 599 ...options, 664 - ...queryKey[0].params, 600 + ...queryKey[0], 665 601 throwOnError: true 666 602 }); 667 603 return data; 668 604 }, 669 605 queryKey: [ 670 - { 671 - params: createQueryKeyParams(options), 672 - scope: 'dummyA' 673 - } 606 + createQueryKey("dummyA", options) 674 607 ] 675 608 }); }; 676 609 ··· 678 611 queryFn: async ({ queryKey }) => { 679 612 const { data } = await dummyB({ 680 613 ...options, 681 - ...queryKey[0].params, 614 + ...queryKey[0], 682 615 throwOnError: true 683 616 }); 684 617 return data; 685 618 }, 686 619 queryKey: [ 687 - { 688 - params: createQueryKeyParams(options), 689 - scope: 'dummyB' 690 - } 620 + createQueryKey("dummyB", options) 691 621 ] 692 622 }); }; 693 623 ··· 695 625 queryFn: async ({ queryKey }) => { 696 626 const { data } = await callWithResponse({ 697 627 ...options, 698 - ...queryKey[0].params, 628 + ...queryKey[0], 699 629 throwOnError: true 700 630 }); 701 631 return data; 702 632 }, 703 633 queryKey: [ 704 - { 705 - params: createQueryKeyParams(options), 706 - scope: 'callWithResponse' 707 - } 634 + createQueryKey("callWithResponse", options) 708 635 ] 709 636 }); }; 710 637 ··· 712 639 queryFn: async ({ queryKey }) => { 713 640 const { data } = await callWithDuplicateResponses({ 714 641 ...options, 715 - ...queryKey[0].params, 642 + ...queryKey[0], 716 643 throwOnError: true 717 644 }); 718 645 return data; 719 646 }, 720 647 queryKey: [ 721 - { 722 - params: createQueryKeyParams(options), 723 - scope: 'callWithDuplicateResponses' 724 - } 648 + createQueryKey("callWithDuplicateResponses", options) 725 649 ] 726 650 }); }; 727 651 728 - export const callWithDuplicateResponsesMutation: MutationOptions<CallWithDuplicateResponsesResponse, AxiosError<CallWithDuplicateResponsesError>, Options> = { 652 + export const callWithDuplicateResponsesMutation = () => { const mutationOptions: MutationOptions<CallWithDuplicateResponsesResponse, AxiosError<CallWithDuplicateResponsesError>, Options> = { 729 653 mutationFn: async (options) => { 730 654 const { data } = await callWithDuplicateResponses({ 731 655 ...options, ··· 733 657 }); 734 658 return data; 735 659 } 736 - }; 660 + }; return mutationOptions; }; 737 661 738 - export const callWithResponsesMutation: MutationOptions<CallWithResponsesResponse, AxiosError<CallWithResponsesError>, Options> = { 662 + export const callWithResponsesMutation = () => { const mutationOptions: MutationOptions<CallWithResponsesResponse, AxiosError<CallWithResponsesError>, Options> = { 739 663 mutationFn: async (options) => { 740 664 const { data } = await callWithResponses({ 741 665 ...options, ··· 743 667 }); 744 668 return data; 745 669 } 746 - }; 670 + }; return mutationOptions; }; 747 671 748 672 export const collectionFormatOptions = (options: Options<CollectionFormatData>) => { return queryOptions({ 749 673 queryFn: async ({ queryKey }) => { 750 674 const { data } = await collectionFormat({ 751 675 ...options, 752 - ...queryKey[0].params, 676 + ...queryKey[0], 753 677 throwOnError: true 754 678 }); 755 679 return data; 756 680 }, 757 681 queryKey: [ 758 - { 759 - params: createQueryKeyParams(options), 760 - scope: 'collectionFormat' 761 - } 682 + createQueryKey("collectionFormat", options) 762 683 ] 763 684 }); }; 764 685 ··· 766 687 queryFn: async ({ queryKey }) => { 767 688 const { data } = await types({ 768 689 ...options, 769 - ...queryKey[0].params, 690 + ...queryKey[0], 770 691 throwOnError: true 771 692 }); 772 693 return data; 773 694 }, 774 695 queryKey: [ 775 - { 776 - params: createQueryKeyParams(options), 777 - scope: 'types' 778 - } 696 + createQueryKey("types", options) 779 697 ] 780 698 }); }; 781 699 ··· 783 701 queryFn: async ({ queryKey }) => { 784 702 const { data } = await uploadFile({ 785 703 ...options, 786 - ...queryKey[0].params, 704 + ...queryKey[0], 787 705 throwOnError: true 788 706 }); 789 707 return data; 790 708 }, 791 709 queryKey: [ 792 - { 793 - params: createQueryKeyParams(options), 794 - scope: 'uploadFile' 795 - } 710 + createQueryKey("uploadFile", options) 796 711 ] 797 712 }); }; 798 713 799 - export const uploadFileMutation: MutationOptions<UploadFileResponse, AxiosError<UploadFileError>, Options<UploadFileData>> = { 714 + export const uploadFileMutation = () => { const mutationOptions: MutationOptions<UploadFileResponse, AxiosError<UploadFileError>, Options<UploadFileData>> = { 800 715 mutationFn: async (options) => { 801 716 const { data } = await uploadFile({ 802 717 ...options, ··· 804 719 }); 805 720 return data; 806 721 } 807 - }; 722 + }; return mutationOptions; }; 808 723 809 724 export const fileResponseOptions = (options: Options<FileResponseData>) => { return queryOptions({ 810 725 queryFn: async ({ queryKey }) => { 811 726 const { data } = await fileResponse({ 812 727 ...options, 813 - ...queryKey[0].params, 728 + ...queryKey[0], 814 729 throwOnError: true 815 730 }); 816 731 return data; 817 732 }, 818 733 queryKey: [ 819 - { 820 - params: createQueryKeyParams(options), 821 - scope: 'fileResponse' 822 - } 734 + createQueryKey("fileResponse", options) 823 735 ] 824 736 }); }; 825 737 ··· 827 739 queryFn: async ({ queryKey }) => { 828 740 const { data } = await complexTypes({ 829 741 ...options, 830 - ...queryKey[0].params, 742 + ...queryKey[0], 831 743 throwOnError: true 832 744 }); 833 745 return data; 834 746 }, 835 747 queryKey: [ 836 - { 837 - params: createQueryKeyParams(options), 838 - scope: 'complexTypes' 839 - } 748 + createQueryKey("complexTypes", options) 840 749 ] 841 750 }); }; 842 751 ··· 844 753 queryFn: async ({ queryKey }) => { 845 754 const { data } = await multipartRequest({ 846 755 ...options, 847 - ...queryKey[0].params, 756 + ...queryKey[0], 848 757 throwOnError: true 849 758 }); 850 759 return data; 851 760 }, 852 761 queryKey: [ 853 - { 854 - params: createQueryKeyParams(options), 855 - scope: 'multipartRequest' 856 - } 762 + createQueryKey("multipartRequest", options) 857 763 ] 858 764 }); }; 859 765 860 - export const multipartRequestMutation: MutationOptions<void, AxiosError<DefaultError>, Options<MultipartRequestData>> = { 766 + export const multipartRequestMutation = () => { const mutationOptions: MutationOptions<void, AxiosError<DefaultError>, Options<MultipartRequestData>> = { 861 767 mutationFn: async (options) => { 862 768 const { data } = await multipartRequest({ 863 769 ...options, ··· 865 771 }); 866 772 return data; 867 773 } 868 - }; 774 + }; return mutationOptions; }; 869 775 870 776 export const multipartResponseOptions = (options?: Options) => { return queryOptions({ 871 777 queryFn: async ({ queryKey }) => { 872 778 const { data } = await multipartResponse({ 873 779 ...options, 874 - ...queryKey[0].params, 780 + ...queryKey[0], 875 781 throwOnError: true 876 782 }); 877 783 return data; 878 784 }, 879 785 queryKey: [ 880 - { 881 - params: createQueryKeyParams(options), 882 - scope: 'multipartResponse' 883 - } 786 + createQueryKey("multipartResponse", options) 884 787 ] 885 788 }); }; 886 789 887 - export const complexParamsMutation: MutationOptions<ComplexParamsResponse, AxiosError<ComplexParamsError>, Options<ComplexParamsData>> = { 790 + export const complexParamsMutation = () => { const mutationOptions: MutationOptions<ComplexParamsResponse, AxiosError<ComplexParamsError>, Options<ComplexParamsData>> = { 888 791 mutationFn: async (options) => { 889 792 const { data } = await complexParams({ 890 793 ...options, ··· 892 795 }); 893 796 return data; 894 797 } 895 - }; 798 + }; return mutationOptions; }; 896 799 897 800 export const callWithResultFromHeaderOptions = (options?: Options) => { return queryOptions({ 898 801 queryFn: async ({ queryKey }) => { 899 802 const { data } = await callWithResultFromHeader({ 900 803 ...options, 901 - ...queryKey[0].params, 804 + ...queryKey[0], 902 805 throwOnError: true 903 806 }); 904 807 return data; 905 808 }, 906 809 queryKey: [ 907 - { 908 - params: createQueryKeyParams(options), 909 - scope: 'callWithResultFromHeader' 910 - } 810 + createQueryKey("callWithResultFromHeader", options) 911 811 ] 912 812 }); }; 913 813 914 - export const callWithResultFromHeaderMutation: MutationOptions<CallWithResultFromHeaderResponse, AxiosError<CallWithResultFromHeaderError>, Options> = { 814 + export const callWithResultFromHeaderMutation = () => { const mutationOptions: MutationOptions<CallWithResultFromHeaderResponse, AxiosError<CallWithResultFromHeaderError>, Options> = { 915 815 mutationFn: async (options) => { 916 816 const { data } = await callWithResultFromHeader({ 917 817 ...options, ··· 919 819 }); 920 820 return data; 921 821 } 922 - }; 822 + }; return mutationOptions; }; 923 823 924 824 export const testErrorCodeOptions = (options: Options<TestErrorCodeData>) => { return queryOptions({ 925 825 queryFn: async ({ queryKey }) => { 926 826 const { data } = await testErrorCode({ 927 827 ...options, 928 - ...queryKey[0].params, 828 + ...queryKey[0], 929 829 throwOnError: true 930 830 }); 931 831 return data; 932 832 }, 933 833 queryKey: [ 934 - { 935 - params: createQueryKeyParams(options), 936 - scope: 'testErrorCode' 937 - } 834 + createQueryKey("testErrorCode", options) 938 835 ] 939 836 }); }; 940 837 941 - export const testErrorCodeMutation: MutationOptions<TestErrorCodeResponse, AxiosError<TestErrorCodeError>, Options<TestErrorCodeData>> = { 838 + export const testErrorCodeMutation = () => { const mutationOptions: MutationOptions<TestErrorCodeResponse, AxiosError<TestErrorCodeError>, Options<TestErrorCodeData>> = { 942 839 mutationFn: async (options) => { 943 840 const { data } = await testErrorCode({ 944 841 ...options, ··· 946 843 }); 947 844 return data; 948 845 } 949 - }; 846 + }; return mutationOptions; }; 950 847 951 848 export const nonAsciiæøåÆøÅöôêÊ字符串Options = (options: Options<NonAsciiæøåÆøÅöôêÊ字符串Data>) => { return queryOptions({ 952 849 queryFn: async ({ queryKey }) => { 953 850 const { data } = await nonAsciiæøåÆøÅöôêÊ字符串({ 954 851 ...options, 955 - ...queryKey[0].params, 852 + ...queryKey[0], 956 853 throwOnError: true 957 854 }); 958 855 return data; 959 856 }, 960 857 queryKey: [ 961 - { 962 - params: createQueryKeyParams(options), 963 - scope: 'nonAsciiæøåÆøÅöôêÊ字符串' 964 - } 858 + createQueryKey("nonAsciiæøåÆøÅöôêÊ字符串", options) 965 859 ] 966 860 }); }; 967 861 968 - export const nonAsciiæøåÆøÅöôêÊ字符串Mutation: MutationOptions<NonAsciiæøåÆøÅöôêÊ字符串Response, AxiosError<NonAsciiæøåÆøÅöôêÊ字符串Error>, Options<NonAsciiæøåÆøÅöôêÊ字符串Data>> = { 862 + export const nonAsciiæøåÆøÅöôêÊ字符串Mutation = () => { const mutationOptions: MutationOptions<NonAsciiæøåÆøÅöôêÊ字符串Response, AxiosError<NonAsciiæøåÆøÅöôêÊ字符串Error>, Options<NonAsciiæøåÆøÅöôêÊ字符串Data>> = { 969 863 mutationFn: async (options) => { 970 864 const { data } = await nonAsciiæøåÆøÅöôêÊ字符串({ 971 865 ...options, ··· 973 867 }); 974 868 return data; 975 869 } 976 - }; 870 + }; return mutationOptions; }; 977 871 978 - export const putWithFormUrlEncodedMutation: MutationOptions<void, AxiosError<DefaultError>, Options<PutWithFormUrlEncodedData>> = { 872 + export const putWithFormUrlEncodedMutation = () => { const mutationOptions: MutationOptions<void, AxiosError<DefaultError>, Options<PutWithFormUrlEncodedData>> = { 979 873 mutationFn: async (options) => { 980 874 const { data } = await putWithFormUrlEncoded({ 981 875 ...options, ··· 983 877 }); 984 878 return data; 985 879 } 986 - }; 880 + }; return mutationOptions; };
+22 -23
packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-axios-plugin-tanstack-solid-query_transform/@tanstack/solid-query.gen.ts.snap
··· 4 4 import { queryOptions, type MutationOptions } from '@tanstack/solid-query'; 5 5 import type { ParentModelWithDatesError, ParentModelWithDatesResponse, ModelWithDatesError, ModelWithDatesResponse, ModelWithDatesArrayError, ModelWithDatesArrayResponse, ArrayOfDatesError, ArrayOfDatesResponse, DateError, DateResponse, MultipleResponsesError, MultipleResponsesResponse } from '../types.gen'; 6 6 import type { AxiosError } from 'axios'; 7 - import { parentModelWithDates, modelWithDates, modelWithDatesArray, arrayOfDates, date, multipleResponses } from '../services.gen'; 7 + import { client, parentModelWithDates, modelWithDates, modelWithDatesArray, arrayOfDates, date, multipleResponses } from '../services.gen'; 8 8 9 9 type QueryKey<TOptions extends Options> = [ 10 - { 10 + Pick<TOptions, 'baseURL' | 'body' | 'headers' | 'path' | 'query'> & { 11 + _id: string; 11 12 infinite?: boolean; 12 - params: Pick<TOptions, "body" | "headers" | "path" | "query">; 13 - scope: string; 14 13 } 15 14 ]; 16 15 17 - const createQueryKeyParams = <TOptions extends Options>(options?: TOptions): QueryKey<TOptions>[0]["params"] => { 18 - const params: QueryKey<TOptions>[0]["params"] = {} as QueryKey<TOptions>[0]["params"]; 16 + const createQueryKey = <TOptions extends Options>(id: string, options?: TOptions, infinite?: boolean): QueryKey<TOptions>[0] => { 17 + const params: QueryKey<TOptions>[0] = { _id: id, baseURL: client.getConfig().baseURL } as QueryKey<TOptions>[0]; 18 + if (infinite) { 19 + params.infinite = infinite; 20 + } 19 21 if (options?.body) { 20 22 params.body = options.body; 21 23 } ··· 35 37 queryFn: async ({ queryKey }) => { 36 38 const { data } = await parentModelWithDates({ 37 39 ...options, 38 - ...queryKey[0].params, 40 + ...queryKey[0], 39 41 throwOnError: true 40 42 }); 41 43 return data; 42 44 }, 43 45 queryKey: [ 44 - { 45 - params: createQueryKeyParams(options), 46 - scope: 'parentModelWithDates' 47 - } 46 + createQueryKey("parentModelWithDates", options) 48 47 ] 49 48 }); }; 50 49 51 - export const parentModelWithDatesMutation: MutationOptions<ParentModelWithDatesResponse, AxiosError<ParentModelWithDatesError>, Options> = { 50 + export const parentModelWithDatesMutation = () => { const mutationOptions: MutationOptions<ParentModelWithDatesResponse, AxiosError<ParentModelWithDatesError>, Options> = { 52 51 mutationFn: async (options) => { 53 52 const { data } = await parentModelWithDates({ 54 53 ...options, ··· 56 55 }); 57 56 return data; 58 57 } 59 - }; 58 + }; return mutationOptions; }; 60 59 61 - export const modelWithDatesMutation: MutationOptions<ModelWithDatesResponse, AxiosError<ModelWithDatesError>, Options> = { 60 + export const modelWithDatesMutation = () => { const mutationOptions: MutationOptions<ModelWithDatesResponse, AxiosError<ModelWithDatesError>, Options> = { 62 61 mutationFn: async (options) => { 63 62 const { data } = await modelWithDates({ 64 63 ...options, ··· 66 65 }); 67 66 return data; 68 67 } 69 - }; 68 + }; return mutationOptions; }; 70 69 71 - export const modelWithDatesArrayMutation: MutationOptions<ModelWithDatesArrayResponse, AxiosError<ModelWithDatesArrayError>, Options> = { 70 + export const modelWithDatesArrayMutation = () => { const mutationOptions: MutationOptions<ModelWithDatesArrayResponse, AxiosError<ModelWithDatesArrayError>, Options> = { 72 71 mutationFn: async (options) => { 73 72 const { data } = await modelWithDatesArray({ 74 73 ...options, ··· 76 75 }); 77 76 return data; 78 77 } 79 - }; 78 + }; return mutationOptions; }; 80 79 81 - export const arrayOfDatesMutation: MutationOptions<ArrayOfDatesResponse, AxiosError<ArrayOfDatesError>, Options> = { 80 + export const arrayOfDatesMutation = () => { const mutationOptions: MutationOptions<ArrayOfDatesResponse, AxiosError<ArrayOfDatesError>, Options> = { 82 81 mutationFn: async (options) => { 83 82 const { data } = await arrayOfDates({ 84 83 ...options, ··· 86 85 }); 87 86 return data; 88 87 } 89 - }; 88 + }; return mutationOptions; }; 90 89 91 - export const dateMutation: MutationOptions<DateResponse, AxiosError<DateError>, Options> = { 90 + export const dateMutation = () => { const mutationOptions: MutationOptions<DateResponse, AxiosError<DateError>, Options> = { 92 91 mutationFn: async (options) => { 93 92 const { data } = await date({ 94 93 ...options, ··· 96 95 }); 97 96 return data; 98 97 } 99 - }; 98 + }; return mutationOptions; }; 100 99 101 - export const multipleResponsesMutation: MutationOptions<MultipleResponsesResponse, AxiosError<MultipleResponsesError>, Options> = { 100 + export const multipleResponsesMutation = () => { const mutationOptions: MutationOptions<MultipleResponsesResponse, AxiosError<MultipleResponsesError>, Options> = { 102 101 mutationFn: async (options) => { 103 102 const { data } = await multipleResponses({ 104 103 ...options, ··· 106 105 }); 107 106 return data; 108 107 } 109 - }; 108 + }; return mutationOptions; };
+152 -258
packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-axios-plugin-tanstack-svelte-query/@tanstack/svelte-query.gen.ts.snap
··· 2 2 3 3 import type { Options } from '@hey-api/client-axios'; 4 4 import { queryOptions, type MutationOptions, type DefaultError, infiniteQueryOptions, type InfiniteData } from '@tanstack/svelte-query'; 5 - import { export_, import_, apiVVersionOdataControllerCount, getCallWithoutParametersAndResponse, putCallWithoutParametersAndResponse, postCallWithoutParametersAndResponse, deleteCallWithoutParametersAndResponse, patchCallWithoutParametersAndResponse, deleteFoo, callWithDescriptions, deprecatedCall, callWithParameters, callWithWeirdParameterNames, getCallWithOptionalParam, postCallWithOptionalParam, postApiVbyApiVersionRequestBody, postApiVbyApiVersionFormData, callWithDefaultParameters, callWithDefaultOptionalParameters, callToTestOrderOfParams, duplicateName, duplicateName1, duplicateName2, duplicateName3, callWithNoContentResponse, callWithResponseAndNoContentResponse, dummyA, dummyB, callWithResponse, callWithDuplicateResponses, callWithResponses, collectionFormat, types, uploadFile, fileResponse, complexTypes, multipartRequest, multipartResponse, complexParams, callWithResultFromHeader, testErrorCode, nonAsciiæøåÆøÅöôêÊ字符串, putWithFormUrlEncoded } from '../services.gen'; 5 + import { client, export_, import_, apiVVersionOdataControllerCount, getCallWithoutParametersAndResponse, putCallWithoutParametersAndResponse, postCallWithoutParametersAndResponse, deleteCallWithoutParametersAndResponse, patchCallWithoutParametersAndResponse, deleteFoo, callWithDescriptions, deprecatedCall, callWithParameters, callWithWeirdParameterNames, getCallWithOptionalParam, postCallWithOptionalParam, postApiVbyApiVersionRequestBody, postApiVbyApiVersionFormData, callWithDefaultParameters, callWithDefaultOptionalParameters, callToTestOrderOfParams, duplicateName, duplicateName1, duplicateName2, duplicateName3, callWithNoContentResponse, callWithResponseAndNoContentResponse, dummyA, dummyB, callWithResponse, callWithDuplicateResponses, callWithResponses, collectionFormat, types, uploadFile, fileResponse, complexTypes, multipartRequest, multipartResponse, complexParams, callWithResultFromHeader, testErrorCode, nonAsciiæøåÆøÅöôêÊ字符串, putWithFormUrlEncoded } from '../services.gen'; 6 6 import type { ImportData, ImportError, ImportResponse, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamError, PostCallWithOptionalParamResponse, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, UploadFileData, UploadFileError, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartRequestData, ComplexParamsData, ComplexParamsError, ComplexParamsResponse, CallWithResultFromHeaderError, CallWithResultFromHeaderResponse, TestErrorCodeData, TestErrorCodeError, TestErrorCodeResponse, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Error, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; 7 7 import type { AxiosError } from 'axios'; 8 8 9 9 type QueryKey<TOptions extends Options> = [ 10 - { 10 + Pick<TOptions, 'baseURL' | 'body' | 'headers' | 'path' | 'query'> & { 11 + _id: string; 11 12 infinite?: boolean; 12 - params: Pick<TOptions, "body" | "headers" | "path" | "query">; 13 - scope: string; 14 13 } 15 14 ]; 16 15 17 - const createQueryKeyParams = <TOptions extends Options>(options?: TOptions): QueryKey<TOptions>[0]["params"] => { 18 - const params: QueryKey<TOptions>[0]["params"] = {} as QueryKey<TOptions>[0]["params"]; 16 + const createQueryKey = <TOptions extends Options>(id: string, options?: TOptions, infinite?: boolean): QueryKey<TOptions>[0] => { 17 + const params: QueryKey<TOptions>[0] = { _id: id, baseURL: client.getConfig().baseURL } as QueryKey<TOptions>[0]; 18 + if (infinite) { 19 + params.infinite = infinite; 20 + } 19 21 if (options?.body) { 20 22 params.body = options.body; 21 23 } ··· 35 37 queryFn: async ({ queryKey }) => { 36 38 const { data } = await export_({ 37 39 ...options, 38 - ...queryKey[0].params, 40 + ...queryKey[0], 39 41 throwOnError: true 40 42 }); 41 43 return data; 42 44 }, 43 45 queryKey: [ 44 - { 45 - params: createQueryKeyParams(options), 46 - scope: 'export' 47 - } 46 + createQueryKey("export", options) 48 47 ] 49 48 }); }; 50 49 ··· 52 51 queryFn: async ({ queryKey }) => { 53 52 const { data } = await import_({ 54 53 ...options, 55 - ...queryKey[0].params, 54 + ...queryKey[0], 56 55 throwOnError: true 57 56 }); 58 57 return data; 59 58 }, 60 59 queryKey: [ 61 - { 62 - params: createQueryKeyParams(options), 63 - scope: 'import' 64 - } 60 + createQueryKey("import", options) 65 61 ] 66 62 }); }; 67 63 68 - export const importMutation: MutationOptions<ImportResponse, AxiosError<ImportError>, Options<ImportData>> = { 64 + export const importMutation = () => { const mutationOptions: MutationOptions<ImportResponse, AxiosError<ImportError>, Options<ImportData>> = { 69 65 mutationFn: async (options) => { 70 66 const { data } = await import_({ 71 67 ...options, ··· 73 69 }); 74 70 return data; 75 71 } 76 - }; 72 + }; return mutationOptions; }; 77 73 78 74 export const apiVVersionOdataControllerCountOptions = (options?: Options) => { return queryOptions({ 79 75 queryFn: async ({ queryKey }) => { 80 76 const { data } = await apiVVersionOdataControllerCount({ 81 77 ...options, 82 - ...queryKey[0].params, 78 + ...queryKey[0], 83 79 throwOnError: true 84 80 }); 85 81 return data; 86 82 }, 87 83 queryKey: [ 88 - { 89 - params: createQueryKeyParams(options), 90 - scope: 'apiVVersionOdataControllerCount' 91 - } 84 + createQueryKey("apiVVersionOdataControllerCount", options) 92 85 ] 93 86 }); }; 94 87 ··· 96 89 queryFn: async ({ queryKey }) => { 97 90 const { data } = await getCallWithoutParametersAndResponse({ 98 91 ...options, 99 - ...queryKey[0].params, 92 + ...queryKey[0], 100 93 throwOnError: true 101 94 }); 102 95 return data; 103 96 }, 104 97 queryKey: [ 105 - { 106 - params: createQueryKeyParams(options), 107 - scope: 'getCallWithoutParametersAndResponse' 108 - } 98 + createQueryKey("getCallWithoutParametersAndResponse", options) 109 99 ] 110 100 }); }; 111 101 112 - export const putCallWithoutParametersAndResponseMutation: MutationOptions<void, AxiosError<DefaultError>, Options> = { 102 + export const putCallWithoutParametersAndResponseMutation = () => { const mutationOptions: MutationOptions<void, AxiosError<DefaultError>, Options> = { 113 103 mutationFn: async (options) => { 114 104 const { data } = await putCallWithoutParametersAndResponse({ 115 105 ...options, ··· 117 107 }); 118 108 return data; 119 109 } 120 - }; 110 + }; return mutationOptions; }; 121 111 122 112 export const postCallWithoutParametersAndResponseOptions = (options?: Options) => { return queryOptions({ 123 113 queryFn: async ({ queryKey }) => { 124 114 const { data } = await postCallWithoutParametersAndResponse({ 125 115 ...options, 126 - ...queryKey[0].params, 116 + ...queryKey[0], 127 117 throwOnError: true 128 118 }); 129 119 return data; 130 120 }, 131 121 queryKey: [ 132 - { 133 - params: createQueryKeyParams(options), 134 - scope: 'postCallWithoutParametersAndResponse' 135 - } 122 + createQueryKey("postCallWithoutParametersAndResponse", options) 136 123 ] 137 124 }); }; 138 125 139 - export const postCallWithoutParametersAndResponseMutation: MutationOptions<void, AxiosError<DefaultError>, Options> = { 126 + export const postCallWithoutParametersAndResponseMutation = () => { const mutationOptions: MutationOptions<void, AxiosError<DefaultError>, Options> = { 140 127 mutationFn: async (options) => { 141 128 const { data } = await postCallWithoutParametersAndResponse({ 142 129 ...options, ··· 144 131 }); 145 132 return data; 146 133 } 147 - }; 134 + }; return mutationOptions; }; 148 135 149 - export const deleteCallWithoutParametersAndResponseMutation: MutationOptions<void, AxiosError<DefaultError>, Options> = { 136 + export const deleteCallWithoutParametersAndResponseMutation = () => { const mutationOptions: MutationOptions<void, AxiosError<DefaultError>, Options> = { 150 137 mutationFn: async (options) => { 151 138 const { data } = await deleteCallWithoutParametersAndResponse({ 152 139 ...options, ··· 154 141 }); 155 142 return data; 156 143 } 157 - }; 144 + }; return mutationOptions; }; 158 145 159 - export const patchCallWithoutParametersAndResponseMutation: MutationOptions<void, AxiosError<DefaultError>, Options> = { 146 + export const patchCallWithoutParametersAndResponseMutation = () => { const mutationOptions: MutationOptions<void, AxiosError<DefaultError>, Options> = { 160 147 mutationFn: async (options) => { 161 148 const { data } = await patchCallWithoutParametersAndResponse({ 162 149 ...options, ··· 164 151 }); 165 152 return data; 166 153 } 167 - }; 154 + }; return mutationOptions; }; 168 155 169 - export const deleteFooMutation: MutationOptions<void, AxiosError<DefaultError>, Options<DeleteFooData3>> = { 156 + export const deleteFooMutation = () => { const mutationOptions: MutationOptions<void, AxiosError<DefaultError>, Options<DeleteFooData3>> = { 170 157 mutationFn: async (options) => { 171 158 const { data } = await deleteFoo({ 172 159 ...options, ··· 174 161 }); 175 162 return data; 176 163 } 177 - }; 164 + }; return mutationOptions; }; 178 165 179 166 export const callWithDescriptionsOptions = (options?: Options<CallWithDescriptionsData>) => { return queryOptions({ 180 167 queryFn: async ({ queryKey }) => { 181 168 const { data } = await callWithDescriptions({ 182 169 ...options, 183 - ...queryKey[0].params, 170 + ...queryKey[0], 184 171 throwOnError: true 185 172 }); 186 173 return data; 187 174 }, 188 175 queryKey: [ 189 - { 190 - params: createQueryKeyParams(options), 191 - scope: 'callWithDescriptions' 192 - } 176 + createQueryKey("callWithDescriptions", options) 193 177 ] 194 178 }); }; 195 179 196 - export const callWithDescriptionsMutation: MutationOptions<void, AxiosError<DefaultError>, Options<CallWithDescriptionsData>> = { 180 + export const callWithDescriptionsMutation = () => { const mutationOptions: MutationOptions<void, AxiosError<DefaultError>, Options<CallWithDescriptionsData>> = { 197 181 mutationFn: async (options) => { 198 182 const { data } = await callWithDescriptions({ 199 183 ...options, ··· 201 185 }); 202 186 return data; 203 187 } 204 - }; 188 + }; return mutationOptions; }; 205 189 206 190 export const deprecatedCallOptions = (options: Options<DeprecatedCallData>) => { return queryOptions({ 207 191 queryFn: async ({ queryKey }) => { 208 192 const { data } = await deprecatedCall({ 209 193 ...options, 210 - ...queryKey[0].params, 194 + ...queryKey[0], 211 195 throwOnError: true 212 196 }); 213 197 return data; 214 198 }, 215 199 queryKey: [ 216 - { 217 - params: createQueryKeyParams(options), 218 - scope: 'deprecatedCall' 219 - } 200 + createQueryKey("deprecatedCall", options) 220 201 ] 221 202 }); }; 222 203 223 - export const deprecatedCallMutation: MutationOptions<void, AxiosError<DefaultError>, Options<DeprecatedCallData>> = { 204 + export const deprecatedCallMutation = () => { const mutationOptions: MutationOptions<void, AxiosError<DefaultError>, Options<DeprecatedCallData>> = { 224 205 mutationFn: async (options) => { 225 206 const { data } = await deprecatedCall({ 226 207 ...options, ··· 228 209 }); 229 210 return data; 230 211 } 231 - }; 212 + }; return mutationOptions; }; 232 213 233 214 export const callWithParametersOptions = (options: Options<CallWithParametersData>) => { return queryOptions({ 234 215 queryFn: async ({ queryKey }) => { 235 216 const { data } = await callWithParameters({ 236 217 ...options, 237 - ...queryKey[0].params, 218 + ...queryKey[0], 238 219 throwOnError: true 239 220 }); 240 221 return data; 241 222 }, 242 223 queryKey: [ 243 - { 244 - params: createQueryKeyParams(options), 245 - scope: 'callWithParameters' 246 - } 224 + createQueryKey("callWithParameters", options) 247 225 ] 248 226 }); }; 249 227 250 - export const callWithParametersInfiniteOptions = (options: Options<CallWithParametersData>) => { return infiniteQueryOptions<void, AxiosError<DefaultError>, InfiniteData<void>, QueryKey<Options<CallWithParametersData>>, string | QueryKey<Options<CallWithParametersData>>[0]['params']>( 228 + export const callWithParametersInfiniteOptions = (options: Options<CallWithParametersData>) => { return infiniteQueryOptions<void, AxiosError<DefaultError>, InfiniteData<void>, QueryKey<Options<CallWithParametersData>>, string | QueryKey<Options<CallWithParametersData>>[0]>( 251 229 // @ts-ignore 252 230 { 253 231 queryFn: async ({ pageParam, queryKey }) => { 254 232 // @ts-ignore 255 - const page: QueryKey<Options<CallWithParametersData>>[0]['params'] = typeof pageParam === "object" ? pageParam : { 233 + const page: QueryKey<Options<CallWithParametersData>>[0] = typeof pageParam === "object" ? pageParam : { 256 234 query: { 257 235 cursor: pageParam 258 236 } ··· 260 238 const { data } = await callWithParameters({ 261 239 ...options, 262 240 body: { 263 - ...queryKey[0].params.body as any, 241 + ...queryKey[0].body as any, 264 242 ...page.body as any 265 243 }, 266 244 headers: { 267 - ...queryKey[0].params.headers, 245 + ...queryKey[0].headers, 268 246 ...page.headers 269 247 }, 270 248 path: { 271 - ...queryKey[0].params.path, 249 + ...queryKey[0].path, 272 250 ...page.path 273 251 }, 274 252 query: { 275 - ...queryKey[0].params.query, 253 + ...queryKey[0].query, 276 254 ...page.query 277 255 }, 256 + baseURL: client.getConfig().baseURL, 278 257 throwOnError: true 279 258 }); 280 259 return data; 281 260 }, 282 261 queryKey: [ 283 - { 284 - infinite: true, 285 - params: createQueryKeyParams(options), 286 - scope: 'callWithParameters' 287 - } 262 + createQueryKey("callWithParameters", options, true) 288 263 ] 289 264 }); }; 290 265 291 - export const callWithParametersMutation: MutationOptions<void, AxiosError<DefaultError>, Options<CallWithParametersData>> = { 266 + export const callWithParametersMutation = () => { const mutationOptions: MutationOptions<void, AxiosError<DefaultError>, Options<CallWithParametersData>> = { 292 267 mutationFn: async (options) => { 293 268 const { data } = await callWithParameters({ 294 269 ...options, ··· 296 271 }); 297 272 return data; 298 273 } 299 - }; 274 + }; return mutationOptions; }; 300 275 301 276 export const callWithWeirdParameterNamesOptions = (options: Options<CallWithWeirdParameterNamesData>) => { return queryOptions({ 302 277 queryFn: async ({ queryKey }) => { 303 278 const { data } = await callWithWeirdParameterNames({ 304 279 ...options, 305 - ...queryKey[0].params, 280 + ...queryKey[0], 306 281 throwOnError: true 307 282 }); 308 283 return data; 309 284 }, 310 285 queryKey: [ 311 - { 312 - params: createQueryKeyParams(options), 313 - scope: 'callWithWeirdParameterNames' 314 - } 286 + createQueryKey("callWithWeirdParameterNames", options) 315 287 ] 316 288 }); }; 317 289 318 - export const callWithWeirdParameterNamesMutation: MutationOptions<void, AxiosError<DefaultError>, Options<CallWithWeirdParameterNamesData>> = { 290 + export const callWithWeirdParameterNamesMutation = () => { const mutationOptions: MutationOptions<void, AxiosError<DefaultError>, Options<CallWithWeirdParameterNamesData>> = { 319 291 mutationFn: async (options) => { 320 292 const { data } = await callWithWeirdParameterNames({ 321 293 ...options, ··· 323 295 }); 324 296 return data; 325 297 } 326 - }; 298 + }; return mutationOptions; }; 327 299 328 300 export const getCallWithOptionalParamOptions = (options: Options<GetCallWithOptionalParamData>) => { return queryOptions({ 329 301 queryFn: async ({ queryKey }) => { 330 302 const { data } = await getCallWithOptionalParam({ 331 303 ...options, 332 - ...queryKey[0].params, 304 + ...queryKey[0], 333 305 throwOnError: true 334 306 }); 335 307 return data; 336 308 }, 337 309 queryKey: [ 338 - { 339 - params: createQueryKeyParams(options), 340 - scope: 'getCallWithOptionalParam' 341 - } 310 + createQueryKey("getCallWithOptionalParam", options) 342 311 ] 343 312 }); }; 344 313 345 - export const getCallWithOptionalParamInfiniteOptions = (options: Options<GetCallWithOptionalParamData>) => { return infiniteQueryOptions<void, AxiosError<DefaultError>, InfiniteData<void>, QueryKey<Options<GetCallWithOptionalParamData>>, number | QueryKey<Options<GetCallWithOptionalParamData>>[0]['params']>( 314 + export const getCallWithOptionalParamInfiniteOptions = (options: Options<GetCallWithOptionalParamData>) => { return infiniteQueryOptions<void, AxiosError<DefaultError>, InfiniteData<void>, QueryKey<Options<GetCallWithOptionalParamData>>, number | QueryKey<Options<GetCallWithOptionalParamData>>[0]>( 346 315 // @ts-ignore 347 316 { 348 317 queryFn: async ({ pageParam, queryKey }) => { 349 318 // @ts-ignore 350 - const page: QueryKey<Options<GetCallWithOptionalParamData>>[0]['params'] = typeof pageParam === "object" ? pageParam : { 319 + const page: QueryKey<Options<GetCallWithOptionalParamData>>[0] = typeof pageParam === "object" ? pageParam : { 351 320 query: { 352 321 page: pageParam 353 322 } ··· 355 324 const { data } = await getCallWithOptionalParam({ 356 325 ...options, 357 326 body: { 358 - ...queryKey[0].params.body as any, 327 + ...queryKey[0].body as any, 359 328 ...page.body as any 360 329 }, 361 330 headers: { 362 - ...queryKey[0].params.headers, 331 + ...queryKey[0].headers, 363 332 ...page.headers 364 333 }, 365 334 path: { 366 - ...queryKey[0].params.path, 335 + ...queryKey[0].path, 367 336 ...page.path 368 337 }, 369 338 query: { 370 - ...queryKey[0].params.query, 339 + ...queryKey[0].query, 371 340 ...page.query 372 341 }, 342 + baseURL: client.getConfig().baseURL, 373 343 throwOnError: true 374 344 }); 375 345 return data; 376 346 }, 377 347 queryKey: [ 378 - { 379 - infinite: true, 380 - params: createQueryKeyParams(options), 381 - scope: 'getCallWithOptionalParam' 382 - } 348 + createQueryKey("getCallWithOptionalParam", options, true) 383 349 ] 384 350 }); }; 385 351 ··· 387 353 queryFn: async ({ queryKey }) => { 388 354 const { data } = await postCallWithOptionalParam({ 389 355 ...options, 390 - ...queryKey[0].params, 356 + ...queryKey[0], 391 357 throwOnError: true 392 358 }); 393 359 return data; 394 360 }, 395 361 queryKey: [ 396 - { 397 - params: createQueryKeyParams(options), 398 - scope: 'postCallWithOptionalParam' 399 - } 362 + createQueryKey("postCallWithOptionalParam", options) 400 363 ] 401 364 }); }; 402 365 403 - export const postCallWithOptionalParamInfiniteOptions = (options: Options<PostCallWithOptionalParamData>) => { return infiniteQueryOptions<PostCallWithOptionalParamResponse, AxiosError<PostCallWithOptionalParamError>, InfiniteData<PostCallWithOptionalParamResponse>, QueryKey<Options<PostCallWithOptionalParamData>>, number | QueryKey<Options<PostCallWithOptionalParamData>>[0]['params']>( 366 + export const postCallWithOptionalParamInfiniteOptions = (options: Options<PostCallWithOptionalParamData>) => { return infiniteQueryOptions<PostCallWithOptionalParamResponse, AxiosError<PostCallWithOptionalParamError>, InfiniteData<PostCallWithOptionalParamResponse>, QueryKey<Options<PostCallWithOptionalParamData>>, number | QueryKey<Options<PostCallWithOptionalParamData>>[0]>( 404 367 // @ts-ignore 405 368 { 406 369 queryFn: async ({ pageParam, queryKey }) => { 407 370 // @ts-ignore 408 - const page: QueryKey<Options<PostCallWithOptionalParamData>>[0]['params'] = typeof pageParam === "object" ? pageParam : { 371 + const page: QueryKey<Options<PostCallWithOptionalParamData>>[0] = typeof pageParam === "object" ? pageParam : { 409 372 body: { 410 373 offset: pageParam 411 374 } ··· 413 376 const { data } = await postCallWithOptionalParam({ 414 377 ...options, 415 378 body: { 416 - ...queryKey[0].params.body as any, 379 + ...queryKey[0].body as any, 417 380 ...page.body as any 418 381 }, 419 382 headers: { 420 - ...queryKey[0].params.headers, 383 + ...queryKey[0].headers, 421 384 ...page.headers 422 385 }, 423 386 path: { 424 - ...queryKey[0].params.path, 387 + ...queryKey[0].path, 425 388 ...page.path 426 389 }, 427 390 query: { 428 - ...queryKey[0].params.query, 391 + ...queryKey[0].query, 429 392 ...page.query 430 393 }, 394 + baseURL: client.getConfig().baseURL, 431 395 throwOnError: true 432 396 }); 433 397 return data; 434 398 }, 435 399 queryKey: [ 436 - { 437 - infinite: true, 438 - params: createQueryKeyParams(options), 439 - scope: 'postCallWithOptionalParam' 440 - } 400 + createQueryKey("postCallWithOptionalParam", options, true) 441 401 ] 442 402 }); }; 443 403 444 - export const postCallWithOptionalParamMutation: MutationOptions<PostCallWithOptionalParamResponse, AxiosError<PostCallWithOptionalParamError>, Options<PostCallWithOptionalParamData>> = { 404 + export const postCallWithOptionalParamMutation = () => { const mutationOptions: MutationOptions<PostCallWithOptionalParamResponse, AxiosError<PostCallWithOptionalParamError>, Options<PostCallWithOptionalParamData>> = { 445 405 mutationFn: async (options) => { 446 406 const { data } = await postCallWithOptionalParam({ 447 407 ...options, ··· 449 409 }); 450 410 return data; 451 411 } 452 - }; 412 + }; return mutationOptions; }; 453 413 454 414 export const postApiVbyApiVersionRequestBodyOptions = (options?: Options<PostApiVbyApiVersionRequestBodyData>) => { return queryOptions({ 455 415 queryFn: async ({ queryKey }) => { 456 416 const { data } = await postApiVbyApiVersionRequestBody({ 457 417 ...options, 458 - ...queryKey[0].params, 418 + ...queryKey[0], 459 419 throwOnError: true 460 420 }); 461 421 return data; 462 422 }, 463 423 queryKey: [ 464 - { 465 - params: createQueryKeyParams(options), 466 - scope: 'postApiVbyApiVersionRequestBody' 467 - } 424 + createQueryKey("postApiVbyApiVersionRequestBody", options) 468 425 ] 469 426 }); }; 470 427 471 - export const postApiVbyApiVersionRequestBodyMutation: MutationOptions<void, AxiosError<DefaultError>, Options<PostApiVbyApiVersionRequestBodyData>> = { 428 + export const postApiVbyApiVersionRequestBodyMutation = () => { const mutationOptions: MutationOptions<void, AxiosError<DefaultError>, Options<PostApiVbyApiVersionRequestBodyData>> = { 472 429 mutationFn: async (options) => { 473 430 const { data } = await postApiVbyApiVersionRequestBody({ 474 431 ...options, ··· 476 433 }); 477 434 return data; 478 435 } 479 - }; 436 + }; return mutationOptions; }; 480 437 481 438 export const postApiVbyApiVersionFormDataOptions = (options?: Options<PostApiVbyApiVersionFormDataData>) => { return queryOptions({ 482 439 queryFn: async ({ queryKey }) => { 483 440 const { data } = await postApiVbyApiVersionFormData({ 484 441 ...options, 485 - ...queryKey[0].params, 442 + ...queryKey[0], 486 443 throwOnError: true 487 444 }); 488 445 return data; 489 446 }, 490 447 queryKey: [ 491 - { 492 - params: createQueryKeyParams(options), 493 - scope: 'postApiVbyApiVersionFormData' 494 - } 448 + createQueryKey("postApiVbyApiVersionFormData", options) 495 449 ] 496 450 }); }; 497 451 498 - export const postApiVbyApiVersionFormDataMutation: MutationOptions<void, AxiosError<DefaultError>, Options<PostApiVbyApiVersionFormDataData>> = { 452 + export const postApiVbyApiVersionFormDataMutation = () => { const mutationOptions: MutationOptions<void, AxiosError<DefaultError>, Options<PostApiVbyApiVersionFormDataData>> = { 499 453 mutationFn: async (options) => { 500 454 const { data } = await postApiVbyApiVersionFormData({ 501 455 ...options, ··· 503 457 }); 504 458 return data; 505 459 } 506 - }; 460 + }; return mutationOptions; }; 507 461 508 462 export const callWithDefaultParametersOptions = (options?: Options<CallWithDefaultParametersData>) => { return queryOptions({ 509 463 queryFn: async ({ queryKey }) => { 510 464 const { data } = await callWithDefaultParameters({ 511 465 ...options, 512 - ...queryKey[0].params, 466 + ...queryKey[0], 513 467 throwOnError: true 514 468 }); 515 469 return data; 516 470 }, 517 471 queryKey: [ 518 - { 519 - params: createQueryKeyParams(options), 520 - scope: 'callWithDefaultParameters' 521 - } 472 + createQueryKey("callWithDefaultParameters", options) 522 473 ] 523 474 }); }; 524 475 ··· 526 477 queryFn: async ({ queryKey }) => { 527 478 const { data } = await callWithDefaultOptionalParameters({ 528 479 ...options, 529 - ...queryKey[0].params, 480 + ...queryKey[0], 530 481 throwOnError: true 531 482 }); 532 483 return data; 533 484 }, 534 485 queryKey: [ 535 - { 536 - params: createQueryKeyParams(options), 537 - scope: 'callWithDefaultOptionalParameters' 538 - } 486 + createQueryKey("callWithDefaultOptionalParameters", options) 539 487 ] 540 488 }); }; 541 489 542 - export const callWithDefaultOptionalParametersMutation: MutationOptions<void, AxiosError<DefaultError>, Options<CallWithDefaultOptionalParametersData>> = { 490 + export const callWithDefaultOptionalParametersMutation = () => { const mutationOptions: MutationOptions<void, AxiosError<DefaultError>, Options<CallWithDefaultOptionalParametersData>> = { 543 491 mutationFn: async (options) => { 544 492 const { data } = await callWithDefaultOptionalParameters({ 545 493 ...options, ··· 547 495 }); 548 496 return data; 549 497 } 550 - }; 498 + }; return mutationOptions; }; 551 499 552 - export const callToTestOrderOfParamsMutation: MutationOptions<void, AxiosError<DefaultError>, Options<CallToTestOrderOfParamsData>> = { 500 + export const callToTestOrderOfParamsMutation = () => { const mutationOptions: MutationOptions<void, AxiosError<DefaultError>, Options<CallToTestOrderOfParamsData>> = { 553 501 mutationFn: async (options) => { 554 502 const { data } = await callToTestOrderOfParams({ 555 503 ...options, ··· 557 505 }); 558 506 return data; 559 507 } 560 - }; 508 + }; return mutationOptions; }; 561 509 562 510 export const duplicateNameOptions = (options?: Options) => { return queryOptions({ 563 511 queryFn: async ({ queryKey }) => { 564 512 const { data } = await duplicateName({ 565 513 ...options, 566 - ...queryKey[0].params, 514 + ...queryKey[0], 567 515 throwOnError: true 568 516 }); 569 517 return data; 570 518 }, 571 519 queryKey: [ 572 - { 573 - params: createQueryKeyParams(options), 574 - scope: 'duplicateName' 575 - } 520 + createQueryKey("duplicateName", options) 576 521 ] 577 522 }); }; 578 523 ··· 580 525 queryFn: async ({ queryKey }) => { 581 526 const { data } = await duplicateName1({ 582 527 ...options, 583 - ...queryKey[0].params, 528 + ...queryKey[0], 584 529 throwOnError: true 585 530 }); 586 531 return data; 587 532 }, 588 533 queryKey: [ 589 - { 590 - params: createQueryKeyParams(options), 591 - scope: 'duplicateName1' 592 - } 534 + createQueryKey("duplicateName1", options) 593 535 ] 594 536 }); }; 595 537 596 - export const duplicateName1Mutation: MutationOptions<void, AxiosError<DefaultError>, Options> = { 538 + export const duplicateName1Mutation = () => { const mutationOptions: MutationOptions<void, AxiosError<DefaultError>, Options> = { 597 539 mutationFn: async (options) => { 598 540 const { data } = await duplicateName1({ 599 541 ...options, ··· 601 543 }); 602 544 return data; 603 545 } 604 - }; 546 + }; return mutationOptions; }; 605 547 606 - export const duplicateName2Mutation: MutationOptions<void, AxiosError<DefaultError>, Options> = { 548 + export const duplicateName2Mutation = () => { const mutationOptions: MutationOptions<void, AxiosError<DefaultError>, Options> = { 607 549 mutationFn: async (options) => { 608 550 const { data } = await duplicateName2({ 609 551 ...options, ··· 611 553 }); 612 554 return data; 613 555 } 614 - }; 556 + }; return mutationOptions; }; 615 557 616 - export const duplicateName3Mutation: MutationOptions<void, AxiosError<DefaultError>, Options> = { 558 + export const duplicateName3Mutation = () => { const mutationOptions: MutationOptions<void, AxiosError<DefaultError>, Options> = { 617 559 mutationFn: async (options) => { 618 560 const { data } = await duplicateName3({ 619 561 ...options, ··· 621 563 }); 622 564 return data; 623 565 } 624 - }; 566 + }; return mutationOptions; }; 625 567 626 568 export const callWithNoContentResponseOptions = (options?: Options) => { return queryOptions({ 627 569 queryFn: async ({ queryKey }) => { 628 570 const { data } = await callWithNoContentResponse({ 629 571 ...options, 630 - ...queryKey[0].params, 572 + ...queryKey[0], 631 573 throwOnError: true 632 574 }); 633 575 return data; 634 576 }, 635 577 queryKey: [ 636 - { 637 - params: createQueryKeyParams(options), 638 - scope: 'callWithNoContentResponse' 639 - } 578 + createQueryKey("callWithNoContentResponse", options) 640 579 ] 641 580 }); }; 642 581 ··· 644 583 queryFn: async ({ queryKey }) => { 645 584 const { data } = await callWithResponseAndNoContentResponse({ 646 585 ...options, 647 - ...queryKey[0].params, 586 + ...queryKey[0], 648 587 throwOnError: true 649 588 }); 650 589 return data; 651 590 }, 652 591 queryKey: [ 653 - { 654 - params: createQueryKeyParams(options), 655 - scope: 'callWithResponseAndNoContentResponse' 656 - } 592 + createQueryKey("callWithResponseAndNoContentResponse", options) 657 593 ] 658 594 }); }; 659 595 ··· 661 597 queryFn: async ({ queryKey }) => { 662 598 const { data } = await dummyA({ 663 599 ...options, 664 - ...queryKey[0].params, 600 + ...queryKey[0], 665 601 throwOnError: true 666 602 }); 667 603 return data; 668 604 }, 669 605 queryKey: [ 670 - { 671 - params: createQueryKeyParams(options), 672 - scope: 'dummyA' 673 - } 606 + createQueryKey("dummyA", options) 674 607 ] 675 608 }); }; 676 609 ··· 678 611 queryFn: async ({ queryKey }) => { 679 612 const { data } = await dummyB({ 680 613 ...options, 681 - ...queryKey[0].params, 614 + ...queryKey[0], 682 615 throwOnError: true 683 616 }); 684 617 return data; 685 618 }, 686 619 queryKey: [ 687 - { 688 - params: createQueryKeyParams(options), 689 - scope: 'dummyB' 690 - } 620 + createQueryKey("dummyB", options) 691 621 ] 692 622 }); }; 693 623 ··· 695 625 queryFn: async ({ queryKey }) => { 696 626 const { data } = await callWithResponse({ 697 627 ...options, 698 - ...queryKey[0].params, 628 + ...queryKey[0], 699 629 throwOnError: true 700 630 }); 701 631 return data; 702 632 }, 703 633 queryKey: [ 704 - { 705 - params: createQueryKeyParams(options), 706 - scope: 'callWithResponse' 707 - } 634 + createQueryKey("callWithResponse", options) 708 635 ] 709 636 }); }; 710 637 ··· 712 639 queryFn: async ({ queryKey }) => { 713 640 const { data } = await callWithDuplicateResponses({ 714 641 ...options, 715 - ...queryKey[0].params, 642 + ...queryKey[0], 716 643 throwOnError: true 717 644 }); 718 645 return data; 719 646 }, 720 647 queryKey: [ 721 - { 722 - params: createQueryKeyParams(options), 723 - scope: 'callWithDuplicateResponses' 724 - } 648 + createQueryKey("callWithDuplicateResponses", options) 725 649 ] 726 650 }); }; 727 651 728 - export const callWithDuplicateResponsesMutation: MutationOptions<CallWithDuplicateResponsesResponse, AxiosError<CallWithDuplicateResponsesError>, Options> = { 652 + export const callWithDuplicateResponsesMutation = () => { const mutationOptions: MutationOptions<CallWithDuplicateResponsesResponse, AxiosError<CallWithDuplicateResponsesError>, Options> = { 729 653 mutationFn: async (options) => { 730 654 const { data } = await callWithDuplicateResponses({ 731 655 ...options, ··· 733 657 }); 734 658 return data; 735 659 } 736 - }; 660 + }; return mutationOptions; }; 737 661 738 - export const callWithResponsesMutation: MutationOptions<CallWithResponsesResponse, AxiosError<CallWithResponsesError>, Options> = { 662 + export const callWithResponsesMutation = () => { const mutationOptions: MutationOptions<CallWithResponsesResponse, AxiosError<CallWithResponsesError>, Options> = { 739 663 mutationFn: async (options) => { 740 664 const { data } = await callWithResponses({ 741 665 ...options, ··· 743 667 }); 744 668 return data; 745 669 } 746 - }; 670 + }; return mutationOptions; }; 747 671 748 672 export const collectionFormatOptions = (options: Options<CollectionFormatData>) => { return queryOptions({ 749 673 queryFn: async ({ queryKey }) => { 750 674 const { data } = await collectionFormat({ 751 675 ...options, 752 - ...queryKey[0].params, 676 + ...queryKey[0], 753 677 throwOnError: true 754 678 }); 755 679 return data; 756 680 }, 757 681 queryKey: [ 758 - { 759 - params: createQueryKeyParams(options), 760 - scope: 'collectionFormat' 761 - } 682 + createQueryKey("collectionFormat", options) 762 683 ] 763 684 }); }; 764 685 ··· 766 687 queryFn: async ({ queryKey }) => { 767 688 const { data } = await types({ 768 689 ...options, 769 - ...queryKey[0].params, 690 + ...queryKey[0], 770 691 throwOnError: true 771 692 }); 772 693 return data; 773 694 }, 774 695 queryKey: [ 775 - { 776 - params: createQueryKeyParams(options), 777 - scope: 'types' 778 - } 696 + createQueryKey("types", options) 779 697 ] 780 698 }); }; 781 699 ··· 783 701 queryFn: async ({ queryKey }) => { 784 702 const { data } = await uploadFile({ 785 703 ...options, 786 - ...queryKey[0].params, 704 + ...queryKey[0], 787 705 throwOnError: true 788 706 }); 789 707 return data; 790 708 }, 791 709 queryKey: [ 792 - { 793 - params: createQueryKeyParams(options), 794 - scope: 'uploadFile' 795 - } 710 + createQueryKey("uploadFile", options) 796 711 ] 797 712 }); }; 798 713 799 - export const uploadFileMutation: MutationOptions<UploadFileResponse, AxiosError<UploadFileError>, Options<UploadFileData>> = { 714 + export const uploadFileMutation = () => { const mutationOptions: MutationOptions<UploadFileResponse, AxiosError<UploadFileError>, Options<UploadFileData>> = { 800 715 mutationFn: async (options) => { 801 716 const { data } = await uploadFile({ 802 717 ...options, ··· 804 719 }); 805 720 return data; 806 721 } 807 - }; 722 + }; return mutationOptions; }; 808 723 809 724 export const fileResponseOptions = (options: Options<FileResponseData>) => { return queryOptions({ 810 725 queryFn: async ({ queryKey }) => { 811 726 const { data } = await fileResponse({ 812 727 ...options, 813 - ...queryKey[0].params, 728 + ...queryKey[0], 814 729 throwOnError: true 815 730 }); 816 731 return data; 817 732 }, 818 733 queryKey: [ 819 - { 820 - params: createQueryKeyParams(options), 821 - scope: 'fileResponse' 822 - } 734 + createQueryKey("fileResponse", options) 823 735 ] 824 736 }); }; 825 737 ··· 827 739 queryFn: async ({ queryKey }) => { 828 740 const { data } = await complexTypes({ 829 741 ...options, 830 - ...queryKey[0].params, 742 + ...queryKey[0], 831 743 throwOnError: true 832 744 }); 833 745 return data; 834 746 }, 835 747 queryKey: [ 836 - { 837 - params: createQueryKeyParams(options), 838 - scope: 'complexTypes' 839 - } 748 + createQueryKey("complexTypes", options) 840 749 ] 841 750 }); }; 842 751 ··· 844 753 queryFn: async ({ queryKey }) => { 845 754 const { data } = await multipartRequest({ 846 755 ...options, 847 - ...queryKey[0].params, 756 + ...queryKey[0], 848 757 throwOnError: true 849 758 }); 850 759 return data; 851 760 }, 852 761 queryKey: [ 853 - { 854 - params: createQueryKeyParams(options), 855 - scope: 'multipartRequest' 856 - } 762 + createQueryKey("multipartRequest", options) 857 763 ] 858 764 }); }; 859 765 860 - export const multipartRequestMutation: MutationOptions<void, AxiosError<DefaultError>, Options<MultipartRequestData>> = { 766 + export const multipartRequestMutation = () => { const mutationOptions: MutationOptions<void, AxiosError<DefaultError>, Options<MultipartRequestData>> = { 861 767 mutationFn: async (options) => { 862 768 const { data } = await multipartRequest({ 863 769 ...options, ··· 865 771 }); 866 772 return data; 867 773 } 868 - }; 774 + }; return mutationOptions; }; 869 775 870 776 export const multipartResponseOptions = (options?: Options) => { return queryOptions({ 871 777 queryFn: async ({ queryKey }) => { 872 778 const { data } = await multipartResponse({ 873 779 ...options, 874 - ...queryKey[0].params, 780 + ...queryKey[0], 875 781 throwOnError: true 876 782 }); 877 783 return data; 878 784 }, 879 785 queryKey: [ 880 - { 881 - params: createQueryKeyParams(options), 882 - scope: 'multipartResponse' 883 - } 786 + createQueryKey("multipartResponse", options) 884 787 ] 885 788 }); }; 886 789 887 - export const complexParamsMutation: MutationOptions<ComplexParamsResponse, AxiosError<ComplexParamsError>, Options<ComplexParamsData>> = { 790 + export const complexParamsMutation = () => { const mutationOptions: MutationOptions<ComplexParamsResponse, AxiosError<ComplexParamsError>, Options<ComplexParamsData>> = { 888 791 mutationFn: async (options) => { 889 792 const { data } = await complexParams({ 890 793 ...options, ··· 892 795 }); 893 796 return data; 894 797 } 895 - }; 798 + }; return mutationOptions; }; 896 799 897 800 export const callWithResultFromHeaderOptions = (options?: Options) => { return queryOptions({ 898 801 queryFn: async ({ queryKey }) => { 899 802 const { data } = await callWithResultFromHeader({ 900 803 ...options, 901 - ...queryKey[0].params, 804 + ...queryKey[0], 902 805 throwOnError: true 903 806 }); 904 807 return data; 905 808 }, 906 809 queryKey: [ 907 - { 908 - params: createQueryKeyParams(options), 909 - scope: 'callWithResultFromHeader' 910 - } 810 + createQueryKey("callWithResultFromHeader", options) 911 811 ] 912 812 }); }; 913 813 914 - export const callWithResultFromHeaderMutation: MutationOptions<CallWithResultFromHeaderResponse, AxiosError<CallWithResultFromHeaderError>, Options> = { 814 + export const callWithResultFromHeaderMutation = () => { const mutationOptions: MutationOptions<CallWithResultFromHeaderResponse, AxiosError<CallWithResultFromHeaderError>, Options> = { 915 815 mutationFn: async (options) => { 916 816 const { data } = await callWithResultFromHeader({ 917 817 ...options, ··· 919 819 }); 920 820 return data; 921 821 } 922 - }; 822 + }; return mutationOptions; }; 923 823 924 824 export const testErrorCodeOptions = (options: Options<TestErrorCodeData>) => { return queryOptions({ 925 825 queryFn: async ({ queryKey }) => { 926 826 const { data } = await testErrorCode({ 927 827 ...options, 928 - ...queryKey[0].params, 828 + ...queryKey[0], 929 829 throwOnError: true 930 830 }); 931 831 return data; 932 832 }, 933 833 queryKey: [ 934 - { 935 - params: createQueryKeyParams(options), 936 - scope: 'testErrorCode' 937 - } 834 + createQueryKey("testErrorCode", options) 938 835 ] 939 836 }); }; 940 837 941 - export const testErrorCodeMutation: MutationOptions<TestErrorCodeResponse, AxiosError<TestErrorCodeError>, Options<TestErrorCodeData>> = { 838 + export const testErrorCodeMutation = () => { const mutationOptions: MutationOptions<TestErrorCodeResponse, AxiosError<TestErrorCodeError>, Options<TestErrorCodeData>> = { 942 839 mutationFn: async (options) => { 943 840 const { data } = await testErrorCode({ 944 841 ...options, ··· 946 843 }); 947 844 return data; 948 845 } 949 - }; 846 + }; return mutationOptions; }; 950 847 951 848 export const nonAsciiæøåÆøÅöôêÊ字符串Options = (options: Options<NonAsciiæøåÆøÅöôêÊ字符串Data>) => { return queryOptions({ 952 849 queryFn: async ({ queryKey }) => { 953 850 const { data } = await nonAsciiæøåÆøÅöôêÊ字符串({ 954 851 ...options, 955 - ...queryKey[0].params, 852 + ...queryKey[0], 956 853 throwOnError: true 957 854 }); 958 855 return data; 959 856 }, 960 857 queryKey: [ 961 - { 962 - params: createQueryKeyParams(options), 963 - scope: 'nonAsciiæøåÆøÅöôêÊ字符串' 964 - } 858 + createQueryKey("nonAsciiæøåÆøÅöôêÊ字符串", options) 965 859 ] 966 860 }); }; 967 861 968 - export const nonAsciiæøåÆøÅöôêÊ字符串Mutation: MutationOptions<NonAsciiæøåÆøÅöôêÊ字符串Response, AxiosError<NonAsciiæøåÆøÅöôêÊ字符串Error>, Options<NonAsciiæøåÆøÅöôêÊ字符串Data>> = { 862 + export const nonAsciiæøåÆøÅöôêÊ字符串Mutation = () => { const mutationOptions: MutationOptions<NonAsciiæøåÆøÅöôêÊ字符串Response, AxiosError<NonAsciiæøåÆøÅöôêÊ字符串Error>, Options<NonAsciiæøåÆøÅöôêÊ字符串Data>> = { 969 863 mutationFn: async (options) => { 970 864 const { data } = await nonAsciiæøåÆøÅöôêÊ字符串({ 971 865 ...options, ··· 973 867 }); 974 868 return data; 975 869 } 976 - }; 870 + }; return mutationOptions; }; 977 871 978 - export const putWithFormUrlEncodedMutation: MutationOptions<void, AxiosError<DefaultError>, Options<PutWithFormUrlEncodedData>> = { 872 + export const putWithFormUrlEncodedMutation = () => { const mutationOptions: MutationOptions<void, AxiosError<DefaultError>, Options<PutWithFormUrlEncodedData>> = { 979 873 mutationFn: async (options) => { 980 874 const { data } = await putWithFormUrlEncoded({ 981 875 ...options, ··· 983 877 }); 984 878 return data; 985 879 } 986 - }; 880 + }; return mutationOptions; };
+22 -23
packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-axios-plugin-tanstack-svelte-query_transform/@tanstack/svelte-query.gen.ts.snap
··· 4 4 import { queryOptions, type MutationOptions } from '@tanstack/svelte-query'; 5 5 import type { ParentModelWithDatesError, ParentModelWithDatesResponse, ModelWithDatesError, ModelWithDatesResponse, ModelWithDatesArrayError, ModelWithDatesArrayResponse, ArrayOfDatesError, ArrayOfDatesResponse, DateError, DateResponse, MultipleResponsesError, MultipleResponsesResponse } from '../types.gen'; 6 6 import type { AxiosError } from 'axios'; 7 - import { parentModelWithDates, modelWithDates, modelWithDatesArray, arrayOfDates, date, multipleResponses } from '../services.gen'; 7 + import { client, parentModelWithDates, modelWithDates, modelWithDatesArray, arrayOfDates, date, multipleResponses } from '../services.gen'; 8 8 9 9 type QueryKey<TOptions extends Options> = [ 10 - { 10 + Pick<TOptions, 'baseURL' | 'body' | 'headers' | 'path' | 'query'> & { 11 + _id: string; 11 12 infinite?: boolean; 12 - params: Pick<TOptions, "body" | "headers" | "path" | "query">; 13 - scope: string; 14 13 } 15 14 ]; 16 15 17 - const createQueryKeyParams = <TOptions extends Options>(options?: TOptions): QueryKey<TOptions>[0]["params"] => { 18 - const params: QueryKey<TOptions>[0]["params"] = {} as QueryKey<TOptions>[0]["params"]; 16 + const createQueryKey = <TOptions extends Options>(id: string, options?: TOptions, infinite?: boolean): QueryKey<TOptions>[0] => { 17 + const params: QueryKey<TOptions>[0] = { _id: id, baseURL: client.getConfig().baseURL } as QueryKey<TOptions>[0]; 18 + if (infinite) { 19 + params.infinite = infinite; 20 + } 19 21 if (options?.body) { 20 22 params.body = options.body; 21 23 } ··· 35 37 queryFn: async ({ queryKey }) => { 36 38 const { data } = await parentModelWithDates({ 37 39 ...options, 38 - ...queryKey[0].params, 40 + ...queryKey[0], 39 41 throwOnError: true 40 42 }); 41 43 return data; 42 44 }, 43 45 queryKey: [ 44 - { 45 - params: createQueryKeyParams(options), 46 - scope: 'parentModelWithDates' 47 - } 46 + createQueryKey("parentModelWithDates", options) 48 47 ] 49 48 }); }; 50 49 51 - export const parentModelWithDatesMutation: MutationOptions<ParentModelWithDatesResponse, AxiosError<ParentModelWithDatesError>, Options> = { 50 + export const parentModelWithDatesMutation = () => { const mutationOptions: MutationOptions<ParentModelWithDatesResponse, AxiosError<ParentModelWithDatesError>, Options> = { 52 51 mutationFn: async (options) => { 53 52 const { data } = await parentModelWithDates({ 54 53 ...options, ··· 56 55 }); 57 56 return data; 58 57 } 59 - }; 58 + }; return mutationOptions; }; 60 59 61 - export const modelWithDatesMutation: MutationOptions<ModelWithDatesResponse, AxiosError<ModelWithDatesError>, Options> = { 60 + export const modelWithDatesMutation = () => { const mutationOptions: MutationOptions<ModelWithDatesResponse, AxiosError<ModelWithDatesError>, Options> = { 62 61 mutationFn: async (options) => { 63 62 const { data } = await modelWithDates({ 64 63 ...options, ··· 66 65 }); 67 66 return data; 68 67 } 69 - }; 68 + }; return mutationOptions; }; 70 69 71 - export const modelWithDatesArrayMutation: MutationOptions<ModelWithDatesArrayResponse, AxiosError<ModelWithDatesArrayError>, Options> = { 70 + export const modelWithDatesArrayMutation = () => { const mutationOptions: MutationOptions<ModelWithDatesArrayResponse, AxiosError<ModelWithDatesArrayError>, Options> = { 72 71 mutationFn: async (options) => { 73 72 const { data } = await modelWithDatesArray({ 74 73 ...options, ··· 76 75 }); 77 76 return data; 78 77 } 79 - }; 78 + }; return mutationOptions; }; 80 79 81 - export const arrayOfDatesMutation: MutationOptions<ArrayOfDatesResponse, AxiosError<ArrayOfDatesError>, Options> = { 80 + export const arrayOfDatesMutation = () => { const mutationOptions: MutationOptions<ArrayOfDatesResponse, AxiosError<ArrayOfDatesError>, Options> = { 82 81 mutationFn: async (options) => { 83 82 const { data } = await arrayOfDates({ 84 83 ...options, ··· 86 85 }); 87 86 return data; 88 87 } 89 - }; 88 + }; return mutationOptions; }; 90 89 91 - export const dateMutation: MutationOptions<DateResponse, AxiosError<DateError>, Options> = { 90 + export const dateMutation = () => { const mutationOptions: MutationOptions<DateResponse, AxiosError<DateError>, Options> = { 92 91 mutationFn: async (options) => { 93 92 const { data } = await date({ 94 93 ...options, ··· 96 95 }); 97 96 return data; 98 97 } 99 - }; 98 + }; return mutationOptions; }; 100 99 101 - export const multipleResponsesMutation: MutationOptions<MultipleResponsesResponse, AxiosError<MultipleResponsesError>, Options> = { 100 + export const multipleResponsesMutation = () => { const mutationOptions: MutationOptions<MultipleResponsesResponse, AxiosError<MultipleResponsesError>, Options> = { 102 101 mutationFn: async (options) => { 103 102 const { data } = await multipleResponses({ 104 103 ...options, ··· 106 105 }); 107 106 return data; 108 107 } 109 - }; 108 + }; return mutationOptions; };
+152 -258
packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-axios-plugin-tanstack-vue-query/@tanstack/vue-query.gen.ts.snap
··· 2 2 3 3 import type { Options } from '@hey-api/client-axios'; 4 4 import { queryOptions, type UseMutationOptions, type DefaultError, infiniteQueryOptions, type InfiniteData } from '@tanstack/vue-query'; 5 - import { export_, import_, apiVVersionOdataControllerCount, getCallWithoutParametersAndResponse, putCallWithoutParametersAndResponse, postCallWithoutParametersAndResponse, deleteCallWithoutParametersAndResponse, patchCallWithoutParametersAndResponse, deleteFoo, callWithDescriptions, deprecatedCall, callWithParameters, callWithWeirdParameterNames, getCallWithOptionalParam, postCallWithOptionalParam, postApiVbyApiVersionRequestBody, postApiVbyApiVersionFormData, callWithDefaultParameters, callWithDefaultOptionalParameters, callToTestOrderOfParams, duplicateName, duplicateName1, duplicateName2, duplicateName3, callWithNoContentResponse, callWithResponseAndNoContentResponse, dummyA, dummyB, callWithResponse, callWithDuplicateResponses, callWithResponses, collectionFormat, types, uploadFile, fileResponse, complexTypes, multipartRequest, multipartResponse, complexParams, callWithResultFromHeader, testErrorCode, nonAsciiæøåÆøÅöôêÊ字符串, putWithFormUrlEncoded } from '../services.gen'; 5 + import { client, export_, import_, apiVVersionOdataControllerCount, getCallWithoutParametersAndResponse, putCallWithoutParametersAndResponse, postCallWithoutParametersAndResponse, deleteCallWithoutParametersAndResponse, patchCallWithoutParametersAndResponse, deleteFoo, callWithDescriptions, deprecatedCall, callWithParameters, callWithWeirdParameterNames, getCallWithOptionalParam, postCallWithOptionalParam, postApiVbyApiVersionRequestBody, postApiVbyApiVersionFormData, callWithDefaultParameters, callWithDefaultOptionalParameters, callToTestOrderOfParams, duplicateName, duplicateName1, duplicateName2, duplicateName3, callWithNoContentResponse, callWithResponseAndNoContentResponse, dummyA, dummyB, callWithResponse, callWithDuplicateResponses, callWithResponses, collectionFormat, types, uploadFile, fileResponse, complexTypes, multipartRequest, multipartResponse, complexParams, callWithResultFromHeader, testErrorCode, nonAsciiæøåÆøÅöôêÊ字符串, putWithFormUrlEncoded } from '../services.gen'; 6 6 import type { ImportData, ImportError, ImportResponse, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamError, PostCallWithOptionalParamResponse, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, UploadFileData, UploadFileError, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartRequestData, ComplexParamsData, ComplexParamsError, ComplexParamsResponse, CallWithResultFromHeaderError, CallWithResultFromHeaderResponse, TestErrorCodeData, TestErrorCodeError, TestErrorCodeResponse, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Error, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; 7 7 import type { AxiosError } from 'axios'; 8 8 9 9 type QueryKey<TOptions extends Options> = [ 10 - { 10 + Pick<TOptions, 'baseURL' | 'body' | 'headers' | 'path' | 'query'> & { 11 + _id: string; 11 12 infinite?: boolean; 12 - params: Pick<TOptions, "body" | "headers" | "path" | "query">; 13 - scope: string; 14 13 } 15 14 ]; 16 15 17 - const createQueryKeyParams = <TOptions extends Options>(options?: TOptions): QueryKey<TOptions>[0]["params"] => { 18 - const params: QueryKey<TOptions>[0]["params"] = {} as QueryKey<TOptions>[0]["params"]; 16 + const createQueryKey = <TOptions extends Options>(id: string, options?: TOptions, infinite?: boolean): QueryKey<TOptions>[0] => { 17 + const params: QueryKey<TOptions>[0] = { _id: id, baseURL: client.getConfig().baseURL } as QueryKey<TOptions>[0]; 18 + if (infinite) { 19 + params.infinite = infinite; 20 + } 19 21 if (options?.body) { 20 22 params.body = options.body; 21 23 } ··· 35 37 queryFn: async ({ queryKey }) => { 36 38 const { data } = await export_({ 37 39 ...options, 38 - ...queryKey[0].params, 40 + ...queryKey[0], 39 41 throwOnError: true 40 42 }); 41 43 return data; 42 44 }, 43 45 queryKey: [ 44 - { 45 - params: createQueryKeyParams(options), 46 - scope: 'export' 47 - } 46 + createQueryKey("export", options) 48 47 ] 49 48 }); }; 50 49 ··· 52 51 queryFn: async ({ queryKey }) => { 53 52 const { data } = await import_({ 54 53 ...options, 55 - ...queryKey[0].params, 54 + ...queryKey[0], 56 55 throwOnError: true 57 56 }); 58 57 return data; 59 58 }, 60 59 queryKey: [ 61 - { 62 - params: createQueryKeyParams(options), 63 - scope: 'import' 64 - } 60 + createQueryKey("import", options) 65 61 ] 66 62 }); }; 67 63 68 - export const importMutation: UseMutationOptions<ImportResponse, AxiosError<ImportError>, Options<ImportData>> = { 64 + export const importMutation = () => { const mutationOptions: UseMutationOptions<ImportResponse, AxiosError<ImportError>, Options<ImportData>> = { 69 65 mutationFn: async (options) => { 70 66 const { data } = await import_({ 71 67 ...options, ··· 73 69 }); 74 70 return data; 75 71 } 76 - }; 72 + }; return mutationOptions; }; 77 73 78 74 export const apiVVersionOdataControllerCountOptions = (options?: Options) => { return queryOptions({ 79 75 queryFn: async ({ queryKey }) => { 80 76 const { data } = await apiVVersionOdataControllerCount({ 81 77 ...options, 82 - ...queryKey[0].params, 78 + ...queryKey[0], 83 79 throwOnError: true 84 80 }); 85 81 return data; 86 82 }, 87 83 queryKey: [ 88 - { 89 - params: createQueryKeyParams(options), 90 - scope: 'apiVVersionOdataControllerCount' 91 - } 84 + createQueryKey("apiVVersionOdataControllerCount", options) 92 85 ] 93 86 }); }; 94 87 ··· 96 89 queryFn: async ({ queryKey }) => { 97 90 const { data } = await getCallWithoutParametersAndResponse({ 98 91 ...options, 99 - ...queryKey[0].params, 92 + ...queryKey[0], 100 93 throwOnError: true 101 94 }); 102 95 return data; 103 96 }, 104 97 queryKey: [ 105 - { 106 - params: createQueryKeyParams(options), 107 - scope: 'getCallWithoutParametersAndResponse' 108 - } 98 + createQueryKey("getCallWithoutParametersAndResponse", options) 109 99 ] 110 100 }); }; 111 101 112 - export const putCallWithoutParametersAndResponseMutation: UseMutationOptions<void, AxiosError<DefaultError>, Options> = { 102 + export const putCallWithoutParametersAndResponseMutation = () => { const mutationOptions: UseMutationOptions<void, AxiosError<DefaultError>, Options> = { 113 103 mutationFn: async (options) => { 114 104 const { data } = await putCallWithoutParametersAndResponse({ 115 105 ...options, ··· 117 107 }); 118 108 return data; 119 109 } 120 - }; 110 + }; return mutationOptions; }; 121 111 122 112 export const postCallWithoutParametersAndResponseOptions = (options?: Options) => { return queryOptions({ 123 113 queryFn: async ({ queryKey }) => { 124 114 const { data } = await postCallWithoutParametersAndResponse({ 125 115 ...options, 126 - ...queryKey[0].params, 116 + ...queryKey[0], 127 117 throwOnError: true 128 118 }); 129 119 return data; 130 120 }, 131 121 queryKey: [ 132 - { 133 - params: createQueryKeyParams(options), 134 - scope: 'postCallWithoutParametersAndResponse' 135 - } 122 + createQueryKey("postCallWithoutParametersAndResponse", options) 136 123 ] 137 124 }); }; 138 125 139 - export const postCallWithoutParametersAndResponseMutation: UseMutationOptions<void, AxiosError<DefaultError>, Options> = { 126 + export const postCallWithoutParametersAndResponseMutation = () => { const mutationOptions: UseMutationOptions<void, AxiosError<DefaultError>, Options> = { 140 127 mutationFn: async (options) => { 141 128 const { data } = await postCallWithoutParametersAndResponse({ 142 129 ...options, ··· 144 131 }); 145 132 return data; 146 133 } 147 - }; 134 + }; return mutationOptions; }; 148 135 149 - export const deleteCallWithoutParametersAndResponseMutation: UseMutationOptions<void, AxiosError<DefaultError>, Options> = { 136 + export const deleteCallWithoutParametersAndResponseMutation = () => { const mutationOptions: UseMutationOptions<void, AxiosError<DefaultError>, Options> = { 150 137 mutationFn: async (options) => { 151 138 const { data } = await deleteCallWithoutParametersAndResponse({ 152 139 ...options, ··· 154 141 }); 155 142 return data; 156 143 } 157 - }; 144 + }; return mutationOptions; }; 158 145 159 - export const patchCallWithoutParametersAndResponseMutation: UseMutationOptions<void, AxiosError<DefaultError>, Options> = { 146 + export const patchCallWithoutParametersAndResponseMutation = () => { const mutationOptions: UseMutationOptions<void, AxiosError<DefaultError>, Options> = { 160 147 mutationFn: async (options) => { 161 148 const { data } = await patchCallWithoutParametersAndResponse({ 162 149 ...options, ··· 164 151 }); 165 152 return data; 166 153 } 167 - }; 154 + }; return mutationOptions; }; 168 155 169 - export const deleteFooMutation: UseMutationOptions<void, AxiosError<DefaultError>, Options<DeleteFooData3>> = { 156 + export const deleteFooMutation = () => { const mutationOptions: UseMutationOptions<void, AxiosError<DefaultError>, Options<DeleteFooData3>> = { 170 157 mutationFn: async (options) => { 171 158 const { data } = await deleteFoo({ 172 159 ...options, ··· 174 161 }); 175 162 return data; 176 163 } 177 - }; 164 + }; return mutationOptions; }; 178 165 179 166 export const callWithDescriptionsOptions = (options?: Options<CallWithDescriptionsData>) => { return queryOptions({ 180 167 queryFn: async ({ queryKey }) => { 181 168 const { data } = await callWithDescriptions({ 182 169 ...options, 183 - ...queryKey[0].params, 170 + ...queryKey[0], 184 171 throwOnError: true 185 172 }); 186 173 return data; 187 174 }, 188 175 queryKey: [ 189 - { 190 - params: createQueryKeyParams(options), 191 - scope: 'callWithDescriptions' 192 - } 176 + createQueryKey("callWithDescriptions", options) 193 177 ] 194 178 }); }; 195 179 196 - export const callWithDescriptionsMutation: UseMutationOptions<void, AxiosError<DefaultError>, Options<CallWithDescriptionsData>> = { 180 + export const callWithDescriptionsMutation = () => { const mutationOptions: UseMutationOptions<void, AxiosError<DefaultError>, Options<CallWithDescriptionsData>> = { 197 181 mutationFn: async (options) => { 198 182 const { data } = await callWithDescriptions({ 199 183 ...options, ··· 201 185 }); 202 186 return data; 203 187 } 204 - }; 188 + }; return mutationOptions; }; 205 189 206 190 export const deprecatedCallOptions = (options: Options<DeprecatedCallData>) => { return queryOptions({ 207 191 queryFn: async ({ queryKey }) => { 208 192 const { data } = await deprecatedCall({ 209 193 ...options, 210 - ...queryKey[0].params, 194 + ...queryKey[0], 211 195 throwOnError: true 212 196 }); 213 197 return data; 214 198 }, 215 199 queryKey: [ 216 - { 217 - params: createQueryKeyParams(options), 218 - scope: 'deprecatedCall' 219 - } 200 + createQueryKey("deprecatedCall", options) 220 201 ] 221 202 }); }; 222 203 223 - export const deprecatedCallMutation: UseMutationOptions<void, AxiosError<DefaultError>, Options<DeprecatedCallData>> = { 204 + export const deprecatedCallMutation = () => { const mutationOptions: UseMutationOptions<void, AxiosError<DefaultError>, Options<DeprecatedCallData>> = { 224 205 mutationFn: async (options) => { 225 206 const { data } = await deprecatedCall({ 226 207 ...options, ··· 228 209 }); 229 210 return data; 230 211 } 231 - }; 212 + }; return mutationOptions; }; 232 213 233 214 export const callWithParametersOptions = (options: Options<CallWithParametersData>) => { return queryOptions({ 234 215 queryFn: async ({ queryKey }) => { 235 216 const { data } = await callWithParameters({ 236 217 ...options, 237 - ...queryKey[0].params, 218 + ...queryKey[0], 238 219 throwOnError: true 239 220 }); 240 221 return data; 241 222 }, 242 223 queryKey: [ 243 - { 244 - params: createQueryKeyParams(options), 245 - scope: 'callWithParameters' 246 - } 224 + createQueryKey("callWithParameters", options) 247 225 ] 248 226 }); }; 249 227 250 - export const callWithParametersInfiniteOptions = (options: Options<CallWithParametersData>) => { return infiniteQueryOptions<void, AxiosError<DefaultError>, InfiniteData<void>, QueryKey<Options<CallWithParametersData>>, string | QueryKey<Options<CallWithParametersData>>[0]['params']>( 228 + export const callWithParametersInfiniteOptions = (options: Options<CallWithParametersData>) => { return infiniteQueryOptions<void, AxiosError<DefaultError>, InfiniteData<void>, QueryKey<Options<CallWithParametersData>>, string | QueryKey<Options<CallWithParametersData>>[0]>( 251 229 // @ts-ignore 252 230 { 253 231 queryFn: async ({ pageParam, queryKey }) => { 254 232 // @ts-ignore 255 - const page: QueryKey<Options<CallWithParametersData>>[0]['params'] = typeof pageParam === "object" ? pageParam : { 233 + const page: QueryKey<Options<CallWithParametersData>>[0] = typeof pageParam === "object" ? pageParam : { 256 234 query: { 257 235 cursor: pageParam 258 236 } ··· 260 238 const { data } = await callWithParameters({ 261 239 ...options, 262 240 body: { 263 - ...queryKey[0].params.body as any, 241 + ...queryKey[0].body as any, 264 242 ...page.body as any 265 243 }, 266 244 headers: { 267 - ...queryKey[0].params.headers, 245 + ...queryKey[0].headers, 268 246 ...page.headers 269 247 }, 270 248 path: { 271 - ...queryKey[0].params.path, 249 + ...queryKey[0].path, 272 250 ...page.path 273 251 }, 274 252 query: { 275 - ...queryKey[0].params.query, 253 + ...queryKey[0].query, 276 254 ...page.query 277 255 }, 256 + baseURL: client.getConfig().baseURL, 278 257 throwOnError: true 279 258 }); 280 259 return data; 281 260 }, 282 261 queryKey: [ 283 - { 284 - infinite: true, 285 - params: createQueryKeyParams(options), 286 - scope: 'callWithParameters' 287 - } 262 + createQueryKey("callWithParameters", options, true) 288 263 ] 289 264 }); }; 290 265 291 - export const callWithParametersMutation: UseMutationOptions<void, AxiosError<DefaultError>, Options<CallWithParametersData>> = { 266 + export const callWithParametersMutation = () => { const mutationOptions: UseMutationOptions<void, AxiosError<DefaultError>, Options<CallWithParametersData>> = { 292 267 mutationFn: async (options) => { 293 268 const { data } = await callWithParameters({ 294 269 ...options, ··· 296 271 }); 297 272 return data; 298 273 } 299 - }; 274 + }; return mutationOptions; }; 300 275 301 276 export const callWithWeirdParameterNamesOptions = (options: Options<CallWithWeirdParameterNamesData>) => { return queryOptions({ 302 277 queryFn: async ({ queryKey }) => { 303 278 const { data } = await callWithWeirdParameterNames({ 304 279 ...options, 305 - ...queryKey[0].params, 280 + ...queryKey[0], 306 281 throwOnError: true 307 282 }); 308 283 return data; 309 284 }, 310 285 queryKey: [ 311 - { 312 - params: createQueryKeyParams(options), 313 - scope: 'callWithWeirdParameterNames' 314 - } 286 + createQueryKey("callWithWeirdParameterNames", options) 315 287 ] 316 288 }); }; 317 289 318 - export const callWithWeirdParameterNamesMutation: UseMutationOptions<void, AxiosError<DefaultError>, Options<CallWithWeirdParameterNamesData>> = { 290 + export const callWithWeirdParameterNamesMutation = () => { const mutationOptions: UseMutationOptions<void, AxiosError<DefaultError>, Options<CallWithWeirdParameterNamesData>> = { 319 291 mutationFn: async (options) => { 320 292 const { data } = await callWithWeirdParameterNames({ 321 293 ...options, ··· 323 295 }); 324 296 return data; 325 297 } 326 - }; 298 + }; return mutationOptions; }; 327 299 328 300 export const getCallWithOptionalParamOptions = (options: Options<GetCallWithOptionalParamData>) => { return queryOptions({ 329 301 queryFn: async ({ queryKey }) => { 330 302 const { data } = await getCallWithOptionalParam({ 331 303 ...options, 332 - ...queryKey[0].params, 304 + ...queryKey[0], 333 305 throwOnError: true 334 306 }); 335 307 return data; 336 308 }, 337 309 queryKey: [ 338 - { 339 - params: createQueryKeyParams(options), 340 - scope: 'getCallWithOptionalParam' 341 - } 310 + createQueryKey("getCallWithOptionalParam", options) 342 311 ] 343 312 }); }; 344 313 345 - export const getCallWithOptionalParamInfiniteOptions = (options: Options<GetCallWithOptionalParamData>) => { return infiniteQueryOptions<void, AxiosError<DefaultError>, InfiniteData<void>, QueryKey<Options<GetCallWithOptionalParamData>>, number | QueryKey<Options<GetCallWithOptionalParamData>>[0]['params']>( 314 + export const getCallWithOptionalParamInfiniteOptions = (options: Options<GetCallWithOptionalParamData>) => { return infiniteQueryOptions<void, AxiosError<DefaultError>, InfiniteData<void>, QueryKey<Options<GetCallWithOptionalParamData>>, number | QueryKey<Options<GetCallWithOptionalParamData>>[0]>( 346 315 // @ts-ignore 347 316 { 348 317 queryFn: async ({ pageParam, queryKey }) => { 349 318 // @ts-ignore 350 - const page: QueryKey<Options<GetCallWithOptionalParamData>>[0]['params'] = typeof pageParam === "object" ? pageParam : { 319 + const page: QueryKey<Options<GetCallWithOptionalParamData>>[0] = typeof pageParam === "object" ? pageParam : { 351 320 query: { 352 321 page: pageParam 353 322 } ··· 355 324 const { data } = await getCallWithOptionalParam({ 356 325 ...options, 357 326 body: { 358 - ...queryKey[0].params.body as any, 327 + ...queryKey[0].body as any, 359 328 ...page.body as any 360 329 }, 361 330 headers: { 362 - ...queryKey[0].params.headers, 331 + ...queryKey[0].headers, 363 332 ...page.headers 364 333 }, 365 334 path: { 366 - ...queryKey[0].params.path, 335 + ...queryKey[0].path, 367 336 ...page.path 368 337 }, 369 338 query: { 370 - ...queryKey[0].params.query, 339 + ...queryKey[0].query, 371 340 ...page.query 372 341 }, 342 + baseURL: client.getConfig().baseURL, 373 343 throwOnError: true 374 344 }); 375 345 return data; 376 346 }, 377 347 queryKey: [ 378 - { 379 - infinite: true, 380 - params: createQueryKeyParams(options), 381 - scope: 'getCallWithOptionalParam' 382 - } 348 + createQueryKey("getCallWithOptionalParam", options, true) 383 349 ] 384 350 }); }; 385 351 ··· 387 353 queryFn: async ({ queryKey }) => { 388 354 const { data } = await postCallWithOptionalParam({ 389 355 ...options, 390 - ...queryKey[0].params, 356 + ...queryKey[0], 391 357 throwOnError: true 392 358 }); 393 359 return data; 394 360 }, 395 361 queryKey: [ 396 - { 397 - params: createQueryKeyParams(options), 398 - scope: 'postCallWithOptionalParam' 399 - } 362 + createQueryKey("postCallWithOptionalParam", options) 400 363 ] 401 364 }); }; 402 365 403 - export const postCallWithOptionalParamInfiniteOptions = (options: Options<PostCallWithOptionalParamData>) => { return infiniteQueryOptions<PostCallWithOptionalParamResponse, AxiosError<PostCallWithOptionalParamError>, InfiniteData<PostCallWithOptionalParamResponse>, QueryKey<Options<PostCallWithOptionalParamData>>, number | QueryKey<Options<PostCallWithOptionalParamData>>[0]['params']>( 366 + export const postCallWithOptionalParamInfiniteOptions = (options: Options<PostCallWithOptionalParamData>) => { return infiniteQueryOptions<PostCallWithOptionalParamResponse, AxiosError<PostCallWithOptionalParamError>, InfiniteData<PostCallWithOptionalParamResponse>, QueryKey<Options<PostCallWithOptionalParamData>>, number | QueryKey<Options<PostCallWithOptionalParamData>>[0]>( 404 367 // @ts-ignore 405 368 { 406 369 queryFn: async ({ pageParam, queryKey }) => { 407 370 // @ts-ignore 408 - const page: QueryKey<Options<PostCallWithOptionalParamData>>[0]['params'] = typeof pageParam === "object" ? pageParam : { 371 + const page: QueryKey<Options<PostCallWithOptionalParamData>>[0] = typeof pageParam === "object" ? pageParam : { 409 372 body: { 410 373 offset: pageParam 411 374 } ··· 413 376 const { data } = await postCallWithOptionalParam({ 414 377 ...options, 415 378 body: { 416 - ...queryKey[0].params.body as any, 379 + ...queryKey[0].body as any, 417 380 ...page.body as any 418 381 }, 419 382 headers: { 420 - ...queryKey[0].params.headers, 383 + ...queryKey[0].headers, 421 384 ...page.headers 422 385 }, 423 386 path: { 424 - ...queryKey[0].params.path, 387 + ...queryKey[0].path, 425 388 ...page.path 426 389 }, 427 390 query: { 428 - ...queryKey[0].params.query, 391 + ...queryKey[0].query, 429 392 ...page.query 430 393 }, 394 + baseURL: client.getConfig().baseURL, 431 395 throwOnError: true 432 396 }); 433 397 return data; 434 398 }, 435 399 queryKey: [ 436 - { 437 - infinite: true, 438 - params: createQueryKeyParams(options), 439 - scope: 'postCallWithOptionalParam' 440 - } 400 + createQueryKey("postCallWithOptionalParam", options, true) 441 401 ] 442 402 }); }; 443 403 444 - export const postCallWithOptionalParamMutation: UseMutationOptions<PostCallWithOptionalParamResponse, AxiosError<PostCallWithOptionalParamError>, Options<PostCallWithOptionalParamData>> = { 404 + export const postCallWithOptionalParamMutation = () => { const mutationOptions: UseMutationOptions<PostCallWithOptionalParamResponse, AxiosError<PostCallWithOptionalParamError>, Options<PostCallWithOptionalParamData>> = { 445 405 mutationFn: async (options) => { 446 406 const { data } = await postCallWithOptionalParam({ 447 407 ...options, ··· 449 409 }); 450 410 return data; 451 411 } 452 - }; 412 + }; return mutationOptions; }; 453 413 454 414 export const postApiVbyApiVersionRequestBodyOptions = (options?: Options<PostApiVbyApiVersionRequestBodyData>) => { return queryOptions({ 455 415 queryFn: async ({ queryKey }) => { 456 416 const { data } = await postApiVbyApiVersionRequestBody({ 457 417 ...options, 458 - ...queryKey[0].params, 418 + ...queryKey[0], 459 419 throwOnError: true 460 420 }); 461 421 return data; 462 422 }, 463 423 queryKey: [ 464 - { 465 - params: createQueryKeyParams(options), 466 - scope: 'postApiVbyApiVersionRequestBody' 467 - } 424 + createQueryKey("postApiVbyApiVersionRequestBody", options) 468 425 ] 469 426 }); }; 470 427 471 - export const postApiVbyApiVersionRequestBodyMutation: UseMutationOptions<void, AxiosError<DefaultError>, Options<PostApiVbyApiVersionRequestBodyData>> = { 428 + export const postApiVbyApiVersionRequestBodyMutation = () => { const mutationOptions: UseMutationOptions<void, AxiosError<DefaultError>, Options<PostApiVbyApiVersionRequestBodyData>> = { 472 429 mutationFn: async (options) => { 473 430 const { data } = await postApiVbyApiVersionRequestBody({ 474 431 ...options, ··· 476 433 }); 477 434 return data; 478 435 } 479 - }; 436 + }; return mutationOptions; }; 480 437 481 438 export const postApiVbyApiVersionFormDataOptions = (options?: Options<PostApiVbyApiVersionFormDataData>) => { return queryOptions({ 482 439 queryFn: async ({ queryKey }) => { 483 440 const { data } = await postApiVbyApiVersionFormData({ 484 441 ...options, 485 - ...queryKey[0].params, 442 + ...queryKey[0], 486 443 throwOnError: true 487 444 }); 488 445 return data; 489 446 }, 490 447 queryKey: [ 491 - { 492 - params: createQueryKeyParams(options), 493 - scope: 'postApiVbyApiVersionFormData' 494 - } 448 + createQueryKey("postApiVbyApiVersionFormData", options) 495 449 ] 496 450 }); }; 497 451 498 - export const postApiVbyApiVersionFormDataMutation: UseMutationOptions<void, AxiosError<DefaultError>, Options<PostApiVbyApiVersionFormDataData>> = { 452 + export const postApiVbyApiVersionFormDataMutation = () => { const mutationOptions: UseMutationOptions<void, AxiosError<DefaultError>, Options<PostApiVbyApiVersionFormDataData>> = { 499 453 mutationFn: async (options) => { 500 454 const { data } = await postApiVbyApiVersionFormData({ 501 455 ...options, ··· 503 457 }); 504 458 return data; 505 459 } 506 - }; 460 + }; return mutationOptions; }; 507 461 508 462 export const callWithDefaultParametersOptions = (options?: Options<CallWithDefaultParametersData>) => { return queryOptions({ 509 463 queryFn: async ({ queryKey }) => { 510 464 const { data } = await callWithDefaultParameters({ 511 465 ...options, 512 - ...queryKey[0].params, 466 + ...queryKey[0], 513 467 throwOnError: true 514 468 }); 515 469 return data; 516 470 }, 517 471 queryKey: [ 518 - { 519 - params: createQueryKeyParams(options), 520 - scope: 'callWithDefaultParameters' 521 - } 472 + createQueryKey("callWithDefaultParameters", options) 522 473 ] 523 474 }); }; 524 475 ··· 526 477 queryFn: async ({ queryKey }) => { 527 478 const { data } = await callWithDefaultOptionalParameters({ 528 479 ...options, 529 - ...queryKey[0].params, 480 + ...queryKey[0], 530 481 throwOnError: true 531 482 }); 532 483 return data; 533 484 }, 534 485 queryKey: [ 535 - { 536 - params: createQueryKeyParams(options), 537 - scope: 'callWithDefaultOptionalParameters' 538 - } 486 + createQueryKey("callWithDefaultOptionalParameters", options) 539 487 ] 540 488 }); }; 541 489 542 - export const callWithDefaultOptionalParametersMutation: UseMutationOptions<void, AxiosError<DefaultError>, Options<CallWithDefaultOptionalParametersData>> = { 490 + export const callWithDefaultOptionalParametersMutation = () => { const mutationOptions: UseMutationOptions<void, AxiosError<DefaultError>, Options<CallWithDefaultOptionalParametersData>> = { 543 491 mutationFn: async (options) => { 544 492 const { data } = await callWithDefaultOptionalParameters({ 545 493 ...options, ··· 547 495 }); 548 496 return data; 549 497 } 550 - }; 498 + }; return mutationOptions; }; 551 499 552 - export const callToTestOrderOfParamsMutation: UseMutationOptions<void, AxiosError<DefaultError>, Options<CallToTestOrderOfParamsData>> = { 500 + export const callToTestOrderOfParamsMutation = () => { const mutationOptions: UseMutationOptions<void, AxiosError<DefaultError>, Options<CallToTestOrderOfParamsData>> = { 553 501 mutationFn: async (options) => { 554 502 const { data } = await callToTestOrderOfParams({ 555 503 ...options, ··· 557 505 }); 558 506 return data; 559 507 } 560 - }; 508 + }; return mutationOptions; }; 561 509 562 510 export const duplicateNameOptions = (options?: Options) => { return queryOptions({ 563 511 queryFn: async ({ queryKey }) => { 564 512 const { data } = await duplicateName({ 565 513 ...options, 566 - ...queryKey[0].params, 514 + ...queryKey[0], 567 515 throwOnError: true 568 516 }); 569 517 return data; 570 518 }, 571 519 queryKey: [ 572 - { 573 - params: createQueryKeyParams(options), 574 - scope: 'duplicateName' 575 - } 520 + createQueryKey("duplicateName", options) 576 521 ] 577 522 }); }; 578 523 ··· 580 525 queryFn: async ({ queryKey }) => { 581 526 const { data } = await duplicateName1({ 582 527 ...options, 583 - ...queryKey[0].params, 528 + ...queryKey[0], 584 529 throwOnError: true 585 530 }); 586 531 return data; 587 532 }, 588 533 queryKey: [ 589 - { 590 - params: createQueryKeyParams(options), 591 - scope: 'duplicateName1' 592 - } 534 + createQueryKey("duplicateName1", options) 593 535 ] 594 536 }); }; 595 537 596 - export const duplicateName1Mutation: UseMutationOptions<void, AxiosError<DefaultError>, Options> = { 538 + export const duplicateName1Mutation = () => { const mutationOptions: UseMutationOptions<void, AxiosError<DefaultError>, Options> = { 597 539 mutationFn: async (options) => { 598 540 const { data } = await duplicateName1({ 599 541 ...options, ··· 601 543 }); 602 544 return data; 603 545 } 604 - }; 546 + }; return mutationOptions; }; 605 547 606 - export const duplicateName2Mutation: UseMutationOptions<void, AxiosError<DefaultError>, Options> = { 548 + export const duplicateName2Mutation = () => { const mutationOptions: UseMutationOptions<void, AxiosError<DefaultError>, Options> = { 607 549 mutationFn: async (options) => { 608 550 const { data } = await duplicateName2({ 609 551 ...options, ··· 611 553 }); 612 554 return data; 613 555 } 614 - }; 556 + }; return mutationOptions; }; 615 557 616 - export const duplicateName3Mutation: UseMutationOptions<void, AxiosError<DefaultError>, Options> = { 558 + export const duplicateName3Mutation = () => { const mutationOptions: UseMutationOptions<void, AxiosError<DefaultError>, Options> = { 617 559 mutationFn: async (options) => { 618 560 const { data } = await duplicateName3({ 619 561 ...options, ··· 621 563 }); 622 564 return data; 623 565 } 624 - }; 566 + }; return mutationOptions; }; 625 567 626 568 export const callWithNoContentResponseOptions = (options?: Options) => { return queryOptions({ 627 569 queryFn: async ({ queryKey }) => { 628 570 const { data } = await callWithNoContentResponse({ 629 571 ...options, 630 - ...queryKey[0].params, 572 + ...queryKey[0], 631 573 throwOnError: true 632 574 }); 633 575 return data; 634 576 }, 635 577 queryKey: [ 636 - { 637 - params: createQueryKeyParams(options), 638 - scope: 'callWithNoContentResponse' 639 - } 578 + createQueryKey("callWithNoContentResponse", options) 640 579 ] 641 580 }); }; 642 581 ··· 644 583 queryFn: async ({ queryKey }) => { 645 584 const { data } = await callWithResponseAndNoContentResponse({ 646 585 ...options, 647 - ...queryKey[0].params, 586 + ...queryKey[0], 648 587 throwOnError: true 649 588 }); 650 589 return data; 651 590 }, 652 591 queryKey: [ 653 - { 654 - params: createQueryKeyParams(options), 655 - scope: 'callWithResponseAndNoContentResponse' 656 - } 592 + createQueryKey("callWithResponseAndNoContentResponse", options) 657 593 ] 658 594 }); }; 659 595 ··· 661 597 queryFn: async ({ queryKey }) => { 662 598 const { data } = await dummyA({ 663 599 ...options, 664 - ...queryKey[0].params, 600 + ...queryKey[0], 665 601 throwOnError: true 666 602 }); 667 603 return data; 668 604 }, 669 605 queryKey: [ 670 - { 671 - params: createQueryKeyParams(options), 672 - scope: 'dummyA' 673 - } 606 + createQueryKey("dummyA", options) 674 607 ] 675 608 }); }; 676 609 ··· 678 611 queryFn: async ({ queryKey }) => { 679 612 const { data } = await dummyB({ 680 613 ...options, 681 - ...queryKey[0].params, 614 + ...queryKey[0], 682 615 throwOnError: true 683 616 }); 684 617 return data; 685 618 }, 686 619 queryKey: [ 687 - { 688 - params: createQueryKeyParams(options), 689 - scope: 'dummyB' 690 - } 620 + createQueryKey("dummyB", options) 691 621 ] 692 622 }); }; 693 623 ··· 695 625 queryFn: async ({ queryKey }) => { 696 626 const { data } = await callWithResponse({ 697 627 ...options, 698 - ...queryKey[0].params, 628 + ...queryKey[0], 699 629 throwOnError: true 700 630 }); 701 631 return data; 702 632 }, 703 633 queryKey: [ 704 - { 705 - params: createQueryKeyParams(options), 706 - scope: 'callWithResponse' 707 - } 634 + createQueryKey("callWithResponse", options) 708 635 ] 709 636 }); }; 710 637 ··· 712 639 queryFn: async ({ queryKey }) => { 713 640 const { data } = await callWithDuplicateResponses({ 714 641 ...options, 715 - ...queryKey[0].params, 642 + ...queryKey[0], 716 643 throwOnError: true 717 644 }); 718 645 return data; 719 646 }, 720 647 queryKey: [ 721 - { 722 - params: createQueryKeyParams(options), 723 - scope: 'callWithDuplicateResponses' 724 - } 648 + createQueryKey("callWithDuplicateResponses", options) 725 649 ] 726 650 }); }; 727 651 728 - export const callWithDuplicateResponsesMutation: UseMutationOptions<CallWithDuplicateResponsesResponse, AxiosError<CallWithDuplicateResponsesError>, Options> = { 652 + export const callWithDuplicateResponsesMutation = () => { const mutationOptions: UseMutationOptions<CallWithDuplicateResponsesResponse, AxiosError<CallWithDuplicateResponsesError>, Options> = { 729 653 mutationFn: async (options) => { 730 654 const { data } = await callWithDuplicateResponses({ 731 655 ...options, ··· 733 657 }); 734 658 return data; 735 659 } 736 - }; 660 + }; return mutationOptions; }; 737 661 738 - export const callWithResponsesMutation: UseMutationOptions<CallWithResponsesResponse, AxiosError<CallWithResponsesError>, Options> = { 662 + export const callWithResponsesMutation = () => { const mutationOptions: UseMutationOptions<CallWithResponsesResponse, AxiosError<CallWithResponsesError>, Options> = { 739 663 mutationFn: async (options) => { 740 664 const { data } = await callWithResponses({ 741 665 ...options, ··· 743 667 }); 744 668 return data; 745 669 } 746 - }; 670 + }; return mutationOptions; }; 747 671 748 672 export const collectionFormatOptions = (options: Options<CollectionFormatData>) => { return queryOptions({ 749 673 queryFn: async ({ queryKey }) => { 750 674 const { data } = await collectionFormat({ 751 675 ...options, 752 - ...queryKey[0].params, 676 + ...queryKey[0], 753 677 throwOnError: true 754 678 }); 755 679 return data; 756 680 }, 757 681 queryKey: [ 758 - { 759 - params: createQueryKeyParams(options), 760 - scope: 'collectionFormat' 761 - } 682 + createQueryKey("collectionFormat", options) 762 683 ] 763 684 }); }; 764 685 ··· 766 687 queryFn: async ({ queryKey }) => { 767 688 const { data } = await types({ 768 689 ...options, 769 - ...queryKey[0].params, 690 + ...queryKey[0], 770 691 throwOnError: true 771 692 }); 772 693 return data; 773 694 }, 774 695 queryKey: [ 775 - { 776 - params: createQueryKeyParams(options), 777 - scope: 'types' 778 - } 696 + createQueryKey("types", options) 779 697 ] 780 698 }); }; 781 699 ··· 783 701 queryFn: async ({ queryKey }) => { 784 702 const { data } = await uploadFile({ 785 703 ...options, 786 - ...queryKey[0].params, 704 + ...queryKey[0], 787 705 throwOnError: true 788 706 }); 789 707 return data; 790 708 }, 791 709 queryKey: [ 792 - { 793 - params: createQueryKeyParams(options), 794 - scope: 'uploadFile' 795 - } 710 + createQueryKey("uploadFile", options) 796 711 ] 797 712 }); }; 798 713 799 - export const uploadFileMutation: UseMutationOptions<UploadFileResponse, AxiosError<UploadFileError>, Options<UploadFileData>> = { 714 + export const uploadFileMutation = () => { const mutationOptions: UseMutationOptions<UploadFileResponse, AxiosError<UploadFileError>, Options<UploadFileData>> = { 800 715 mutationFn: async (options) => { 801 716 const { data } = await uploadFile({ 802 717 ...options, ··· 804 719 }); 805 720 return data; 806 721 } 807 - }; 722 + }; return mutationOptions; }; 808 723 809 724 export const fileResponseOptions = (options: Options<FileResponseData>) => { return queryOptions({ 810 725 queryFn: async ({ queryKey }) => { 811 726 const { data } = await fileResponse({ 812 727 ...options, 813 - ...queryKey[0].params, 728 + ...queryKey[0], 814 729 throwOnError: true 815 730 }); 816 731 return data; 817 732 }, 818 733 queryKey: [ 819 - { 820 - params: createQueryKeyParams(options), 821 - scope: 'fileResponse' 822 - } 734 + createQueryKey("fileResponse", options) 823 735 ] 824 736 }); }; 825 737 ··· 827 739 queryFn: async ({ queryKey }) => { 828 740 const { data } = await complexTypes({ 829 741 ...options, 830 - ...queryKey[0].params, 742 + ...queryKey[0], 831 743 throwOnError: true 832 744 }); 833 745 return data; 834 746 }, 835 747 queryKey: [ 836 - { 837 - params: createQueryKeyParams(options), 838 - scope: 'complexTypes' 839 - } 748 + createQueryKey("complexTypes", options) 840 749 ] 841 750 }); }; 842 751 ··· 844 753 queryFn: async ({ queryKey }) => { 845 754 const { data } = await multipartRequest({ 846 755 ...options, 847 - ...queryKey[0].params, 756 + ...queryKey[0], 848 757 throwOnError: true 849 758 }); 850 759 return data; 851 760 }, 852 761 queryKey: [ 853 - { 854 - params: createQueryKeyParams(options), 855 - scope: 'multipartRequest' 856 - } 762 + createQueryKey("multipartRequest", options) 857 763 ] 858 764 }); }; 859 765 860 - export const multipartRequestMutation: UseMutationOptions<void, AxiosError<DefaultError>, Options<MultipartRequestData>> = { 766 + export const multipartRequestMutation = () => { const mutationOptions: UseMutationOptions<void, AxiosError<DefaultError>, Options<MultipartRequestData>> = { 861 767 mutationFn: async (options) => { 862 768 const { data } = await multipartRequest({ 863 769 ...options, ··· 865 771 }); 866 772 return data; 867 773 } 868 - }; 774 + }; return mutationOptions; }; 869 775 870 776 export const multipartResponseOptions = (options?: Options) => { return queryOptions({ 871 777 queryFn: async ({ queryKey }) => { 872 778 const { data } = await multipartResponse({ 873 779 ...options, 874 - ...queryKey[0].params, 780 + ...queryKey[0], 875 781 throwOnError: true 876 782 }); 877 783 return data; 878 784 }, 879 785 queryKey: [ 880 - { 881 - params: createQueryKeyParams(options), 882 - scope: 'multipartResponse' 883 - } 786 + createQueryKey("multipartResponse", options) 884 787 ] 885 788 }); }; 886 789 887 - export const complexParamsMutation: UseMutationOptions<ComplexParamsResponse, AxiosError<ComplexParamsError>, Options<ComplexParamsData>> = { 790 + export const complexParamsMutation = () => { const mutationOptions: UseMutationOptions<ComplexParamsResponse, AxiosError<ComplexParamsError>, Options<ComplexParamsData>> = { 888 791 mutationFn: async (options) => { 889 792 const { data } = await complexParams({ 890 793 ...options, ··· 892 795 }); 893 796 return data; 894 797 } 895 - }; 798 + }; return mutationOptions; }; 896 799 897 800 export const callWithResultFromHeaderOptions = (options?: Options) => { return queryOptions({ 898 801 queryFn: async ({ queryKey }) => { 899 802 const { data } = await callWithResultFromHeader({ 900 803 ...options, 901 - ...queryKey[0].params, 804 + ...queryKey[0], 902 805 throwOnError: true 903 806 }); 904 807 return data; 905 808 }, 906 809 queryKey: [ 907 - { 908 - params: createQueryKeyParams(options), 909 - scope: 'callWithResultFromHeader' 910 - } 810 + createQueryKey("callWithResultFromHeader", options) 911 811 ] 912 812 }); }; 913 813 914 - export const callWithResultFromHeaderMutation: UseMutationOptions<CallWithResultFromHeaderResponse, AxiosError<CallWithResultFromHeaderError>, Options> = { 814 + export const callWithResultFromHeaderMutation = () => { const mutationOptions: UseMutationOptions<CallWithResultFromHeaderResponse, AxiosError<CallWithResultFromHeaderError>, Options> = { 915 815 mutationFn: async (options) => { 916 816 const { data } = await callWithResultFromHeader({ 917 817 ...options, ··· 919 819 }); 920 820 return data; 921 821 } 922 - }; 822 + }; return mutationOptions; }; 923 823 924 824 export const testErrorCodeOptions = (options: Options<TestErrorCodeData>) => { return queryOptions({ 925 825 queryFn: async ({ queryKey }) => { 926 826 const { data } = await testErrorCode({ 927 827 ...options, 928 - ...queryKey[0].params, 828 + ...queryKey[0], 929 829 throwOnError: true 930 830 }); 931 831 return data; 932 832 }, 933 833 queryKey: [ 934 - { 935 - params: createQueryKeyParams(options), 936 - scope: 'testErrorCode' 937 - } 834 + createQueryKey("testErrorCode", options) 938 835 ] 939 836 }); }; 940 837 941 - export const testErrorCodeMutation: UseMutationOptions<TestErrorCodeResponse, AxiosError<TestErrorCodeError>, Options<TestErrorCodeData>> = { 838 + export const testErrorCodeMutation = () => { const mutationOptions: UseMutationOptions<TestErrorCodeResponse, AxiosError<TestErrorCodeError>, Options<TestErrorCodeData>> = { 942 839 mutationFn: async (options) => { 943 840 const { data } = await testErrorCode({ 944 841 ...options, ··· 946 843 }); 947 844 return data; 948 845 } 949 - }; 846 + }; return mutationOptions; }; 950 847 951 848 export const nonAsciiæøåÆøÅöôêÊ字符串Options = (options: Options<NonAsciiæøåÆøÅöôêÊ字符串Data>) => { return queryOptions({ 952 849 queryFn: async ({ queryKey }) => { 953 850 const { data } = await nonAsciiæøåÆøÅöôêÊ字符串({ 954 851 ...options, 955 - ...queryKey[0].params, 852 + ...queryKey[0], 956 853 throwOnError: true 957 854 }); 958 855 return data; 959 856 }, 960 857 queryKey: [ 961 - { 962 - params: createQueryKeyParams(options), 963 - scope: 'nonAsciiæøåÆøÅöôêÊ字符串' 964 - } 858 + createQueryKey("nonAsciiæøåÆøÅöôêÊ字符串", options) 965 859 ] 966 860 }); }; 967 861 968 - export const nonAsciiæøåÆøÅöôêÊ字符串Mutation: UseMutationOptions<NonAsciiæøåÆøÅöôêÊ字符串Response, AxiosError<NonAsciiæøåÆøÅöôêÊ字符串Error>, Options<NonAsciiæøåÆøÅöôêÊ字符串Data>> = { 862 + export const nonAsciiæøåÆøÅöôêÊ字符串Mutation = () => { const mutationOptions: UseMutationOptions<NonAsciiæøåÆøÅöôêÊ字符串Response, AxiosError<NonAsciiæøåÆøÅöôêÊ字符串Error>, Options<NonAsciiæøåÆøÅöôêÊ字符串Data>> = { 969 863 mutationFn: async (options) => { 970 864 const { data } = await nonAsciiæøåÆøÅöôêÊ字符串({ 971 865 ...options, ··· 973 867 }); 974 868 return data; 975 869 } 976 - }; 870 + }; return mutationOptions; }; 977 871 978 - export const putWithFormUrlEncodedMutation: UseMutationOptions<void, AxiosError<DefaultError>, Options<PutWithFormUrlEncodedData>> = { 872 + export const putWithFormUrlEncodedMutation = () => { const mutationOptions: UseMutationOptions<void, AxiosError<DefaultError>, Options<PutWithFormUrlEncodedData>> = { 979 873 mutationFn: async (options) => { 980 874 const { data } = await putWithFormUrlEncoded({ 981 875 ...options, ··· 983 877 }); 984 878 return data; 985 879 } 986 - }; 880 + }; return mutationOptions; };
+22 -23
packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-axios-plugin-tanstack-vue-query_transform/@tanstack/vue-query.gen.ts.snap
··· 4 4 import { queryOptions, type UseMutationOptions } from '@tanstack/vue-query'; 5 5 import type { ParentModelWithDatesError, ParentModelWithDatesResponse, ModelWithDatesError, ModelWithDatesResponse, ModelWithDatesArrayError, ModelWithDatesArrayResponse, ArrayOfDatesError, ArrayOfDatesResponse, DateError, DateResponse, MultipleResponsesError, MultipleResponsesResponse } from '../types.gen'; 6 6 import type { AxiosError } from 'axios'; 7 - import { parentModelWithDates, modelWithDates, modelWithDatesArray, arrayOfDates, date, multipleResponses } from '../services.gen'; 7 + import { client, parentModelWithDates, modelWithDates, modelWithDatesArray, arrayOfDates, date, multipleResponses } from '../services.gen'; 8 8 9 9 type QueryKey<TOptions extends Options> = [ 10 - { 10 + Pick<TOptions, 'baseURL' | 'body' | 'headers' | 'path' | 'query'> & { 11 + _id: string; 11 12 infinite?: boolean; 12 - params: Pick<TOptions, "body" | "headers" | "path" | "query">; 13 - scope: string; 14 13 } 15 14 ]; 16 15 17 - const createQueryKeyParams = <TOptions extends Options>(options?: TOptions): QueryKey<TOptions>[0]["params"] => { 18 - const params: QueryKey<TOptions>[0]["params"] = {} as QueryKey<TOptions>[0]["params"]; 16 + const createQueryKey = <TOptions extends Options>(id: string, options?: TOptions, infinite?: boolean): QueryKey<TOptions>[0] => { 17 + const params: QueryKey<TOptions>[0] = { _id: id, baseURL: client.getConfig().baseURL } as QueryKey<TOptions>[0]; 18 + if (infinite) { 19 + params.infinite = infinite; 20 + } 19 21 if (options?.body) { 20 22 params.body = options.body; 21 23 } ··· 35 37 queryFn: async ({ queryKey }) => { 36 38 const { data } = await parentModelWithDates({ 37 39 ...options, 38 - ...queryKey[0].params, 40 + ...queryKey[0], 39 41 throwOnError: true 40 42 }); 41 43 return data; 42 44 }, 43 45 queryKey: [ 44 - { 45 - params: createQueryKeyParams(options), 46 - scope: 'parentModelWithDates' 47 - } 46 + createQueryKey("parentModelWithDates", options) 48 47 ] 49 48 }); }; 50 49 51 - export const parentModelWithDatesMutation: UseMutationOptions<ParentModelWithDatesResponse, AxiosError<ParentModelWithDatesError>, Options> = { 50 + export const parentModelWithDatesMutation = () => { const mutationOptions: UseMutationOptions<ParentModelWithDatesResponse, AxiosError<ParentModelWithDatesError>, Options> = { 52 51 mutationFn: async (options) => { 53 52 const { data } = await parentModelWithDates({ 54 53 ...options, ··· 56 55 }); 57 56 return data; 58 57 } 59 - }; 58 + }; return mutationOptions; }; 60 59 61 - export const modelWithDatesMutation: UseMutationOptions<ModelWithDatesResponse, AxiosError<ModelWithDatesError>, Options> = { 60 + export const modelWithDatesMutation = () => { const mutationOptions: UseMutationOptions<ModelWithDatesResponse, AxiosError<ModelWithDatesError>, Options> = { 62 61 mutationFn: async (options) => { 63 62 const { data } = await modelWithDates({ 64 63 ...options, ··· 66 65 }); 67 66 return data; 68 67 } 69 - }; 68 + }; return mutationOptions; }; 70 69 71 - export const modelWithDatesArrayMutation: UseMutationOptions<ModelWithDatesArrayResponse, AxiosError<ModelWithDatesArrayError>, Options> = { 70 + export const modelWithDatesArrayMutation = () => { const mutationOptions: UseMutationOptions<ModelWithDatesArrayResponse, AxiosError<ModelWithDatesArrayError>, Options> = { 72 71 mutationFn: async (options) => { 73 72 const { data } = await modelWithDatesArray({ 74 73 ...options, ··· 76 75 }); 77 76 return data; 78 77 } 79 - }; 78 + }; return mutationOptions; }; 80 79 81 - export const arrayOfDatesMutation: UseMutationOptions<ArrayOfDatesResponse, AxiosError<ArrayOfDatesError>, Options> = { 80 + export const arrayOfDatesMutation = () => { const mutationOptions: UseMutationOptions<ArrayOfDatesResponse, AxiosError<ArrayOfDatesError>, Options> = { 82 81 mutationFn: async (options) => { 83 82 const { data } = await arrayOfDates({ 84 83 ...options, ··· 86 85 }); 87 86 return data; 88 87 } 89 - }; 88 + }; return mutationOptions; }; 90 89 91 - export const dateMutation: UseMutationOptions<DateResponse, AxiosError<DateError>, Options> = { 90 + export const dateMutation = () => { const mutationOptions: UseMutationOptions<DateResponse, AxiosError<DateError>, Options> = { 92 91 mutationFn: async (options) => { 93 92 const { data } = await date({ 94 93 ...options, ··· 96 95 }); 97 96 return data; 98 97 } 99 - }; 98 + }; return mutationOptions; }; 100 99 101 - export const multipleResponsesMutation: UseMutationOptions<MultipleResponsesResponse, AxiosError<MultipleResponsesError>, Options> = { 100 + export const multipleResponsesMutation = () => { const mutationOptions: UseMutationOptions<MultipleResponsesResponse, AxiosError<MultipleResponsesError>, Options> = { 102 101 mutationFn: async (options) => { 103 102 const { data } = await multipleResponses({ 104 103 ...options, ··· 106 105 }); 107 106 return data; 108 107 } 109 - }; 108 + }; return mutationOptions; };
+152 -258
packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-fetch-plugin-tanstack-react-query/@tanstack/react-query.gen.ts.snap
··· 2 2 3 3 import type { Options } from '@hey-api/client-fetch'; 4 4 import { queryOptions, type UseMutationOptions, type DefaultError, infiniteQueryOptions, type InfiniteData } from '@tanstack/react-query'; 5 - import { export_, import_, apiVVersionOdataControllerCount, getCallWithoutParametersAndResponse, putCallWithoutParametersAndResponse, postCallWithoutParametersAndResponse, deleteCallWithoutParametersAndResponse, patchCallWithoutParametersAndResponse, deleteFoo, callWithDescriptions, deprecatedCall, callWithParameters, callWithWeirdParameterNames, getCallWithOptionalParam, postCallWithOptionalParam, postApiVbyApiVersionRequestBody, postApiVbyApiVersionFormData, callWithDefaultParameters, callWithDefaultOptionalParameters, callToTestOrderOfParams, duplicateName, duplicateName1, duplicateName2, duplicateName3, callWithNoContentResponse, callWithResponseAndNoContentResponse, dummyA, dummyB, callWithResponse, callWithDuplicateResponses, callWithResponses, collectionFormat, types, uploadFile, fileResponse, complexTypes, multipartRequest, multipartResponse, complexParams, callWithResultFromHeader, testErrorCode, nonAsciiæøåÆøÅöôêÊ字符串, putWithFormUrlEncoded } from '../services.gen'; 5 + import { client, export_, import_, apiVVersionOdataControllerCount, getCallWithoutParametersAndResponse, putCallWithoutParametersAndResponse, postCallWithoutParametersAndResponse, deleteCallWithoutParametersAndResponse, patchCallWithoutParametersAndResponse, deleteFoo, callWithDescriptions, deprecatedCall, callWithParameters, callWithWeirdParameterNames, getCallWithOptionalParam, postCallWithOptionalParam, postApiVbyApiVersionRequestBody, postApiVbyApiVersionFormData, callWithDefaultParameters, callWithDefaultOptionalParameters, callToTestOrderOfParams, duplicateName, duplicateName1, duplicateName2, duplicateName3, callWithNoContentResponse, callWithResponseAndNoContentResponse, dummyA, dummyB, callWithResponse, callWithDuplicateResponses, callWithResponses, collectionFormat, types, uploadFile, fileResponse, complexTypes, multipartRequest, multipartResponse, complexParams, callWithResultFromHeader, testErrorCode, nonAsciiæøåÆøÅöôêÊ字符串, putWithFormUrlEncoded } from '../services.gen'; 6 6 import type { ImportData, ImportError, ImportResponse, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamError, PostCallWithOptionalParamResponse, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, UploadFileData, UploadFileError, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartRequestData, ComplexParamsData, ComplexParamsError, ComplexParamsResponse, CallWithResultFromHeaderError, CallWithResultFromHeaderResponse, TestErrorCodeData, TestErrorCodeError, TestErrorCodeResponse, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Error, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; 7 7 8 8 type QueryKey<TOptions extends Options> = [ 9 - { 9 + Pick<TOptions, 'baseUrl' | 'body' | 'headers' | 'path' | 'query'> & { 10 + _id: string; 10 11 infinite?: boolean; 11 - params: Pick<TOptions, "body" | "headers" | "path" | "query">; 12 - scope: string; 13 12 } 14 13 ]; 15 14 16 - const createQueryKeyParams = <TOptions extends Options>(options?: TOptions): QueryKey<TOptions>[0]["params"] => { 17 - const params: QueryKey<TOptions>[0]["params"] = {} as QueryKey<TOptions>[0]["params"]; 15 + const createQueryKey = <TOptions extends Options>(id: string, options?: TOptions, infinite?: boolean): QueryKey<TOptions>[0] => { 16 + const params: QueryKey<TOptions>[0] = { _id: id, baseUrl: client.getConfig().baseUrl } as QueryKey<TOptions>[0]; 17 + if (infinite) { 18 + params.infinite = infinite; 19 + } 18 20 if (options?.body) { 19 21 params.body = options.body; 20 22 } ··· 34 36 queryFn: async ({ queryKey }) => { 35 37 const { data } = await export_({ 36 38 ...options, 37 - ...queryKey[0].params, 39 + ...queryKey[0], 38 40 throwOnError: true 39 41 }); 40 42 return data; 41 43 }, 42 44 queryKey: [ 43 - { 44 - params: createQueryKeyParams(options), 45 - scope: 'export' 46 - } 45 + createQueryKey("export", options) 47 46 ] 48 47 }); }; 49 48 ··· 51 50 queryFn: async ({ queryKey }) => { 52 51 const { data } = await import_({ 53 52 ...options, 54 - ...queryKey[0].params, 53 + ...queryKey[0], 55 54 throwOnError: true 56 55 }); 57 56 return data; 58 57 }, 59 58 queryKey: [ 60 - { 61 - params: createQueryKeyParams(options), 62 - scope: 'import' 63 - } 59 + createQueryKey("import", options) 64 60 ] 65 61 }); }; 66 62 67 - export const importMutation: UseMutationOptions<ImportResponse, ImportError, Options<ImportData>> = { 63 + export const importMutation = () => { const mutationOptions: UseMutationOptions<ImportResponse, ImportError, Options<ImportData>> = { 68 64 mutationFn: async (options) => { 69 65 const { data } = await import_({ 70 66 ...options, ··· 72 68 }); 73 69 return data; 74 70 } 75 - }; 71 + }; return mutationOptions; }; 76 72 77 73 export const apiVVersionOdataControllerCountOptions = (options?: Options) => { return queryOptions({ 78 74 queryFn: async ({ queryKey }) => { 79 75 const { data } = await apiVVersionOdataControllerCount({ 80 76 ...options, 81 - ...queryKey[0].params, 77 + ...queryKey[0], 82 78 throwOnError: true 83 79 }); 84 80 return data; 85 81 }, 86 82 queryKey: [ 87 - { 88 - params: createQueryKeyParams(options), 89 - scope: 'apiVVersionOdataControllerCount' 90 - } 83 + createQueryKey("apiVVersionOdataControllerCount", options) 91 84 ] 92 85 }); }; 93 86 ··· 95 88 queryFn: async ({ queryKey }) => { 96 89 const { data } = await getCallWithoutParametersAndResponse({ 97 90 ...options, 98 - ...queryKey[0].params, 91 + ...queryKey[0], 99 92 throwOnError: true 100 93 }); 101 94 return data; 102 95 }, 103 96 queryKey: [ 104 - { 105 - params: createQueryKeyParams(options), 106 - scope: 'getCallWithoutParametersAndResponse' 107 - } 97 + createQueryKey("getCallWithoutParametersAndResponse", options) 108 98 ] 109 99 }); }; 110 100 111 - export const putCallWithoutParametersAndResponseMutation: UseMutationOptions<void, DefaultError, Options> = { 101 + export const putCallWithoutParametersAndResponseMutation = () => { const mutationOptions: UseMutationOptions<void, DefaultError, Options> = { 112 102 mutationFn: async (options) => { 113 103 const { data } = await putCallWithoutParametersAndResponse({ 114 104 ...options, ··· 116 106 }); 117 107 return data; 118 108 } 119 - }; 109 + }; return mutationOptions; }; 120 110 121 111 export const postCallWithoutParametersAndResponseOptions = (options?: Options) => { return queryOptions({ 122 112 queryFn: async ({ queryKey }) => { 123 113 const { data } = await postCallWithoutParametersAndResponse({ 124 114 ...options, 125 - ...queryKey[0].params, 115 + ...queryKey[0], 126 116 throwOnError: true 127 117 }); 128 118 return data; 129 119 }, 130 120 queryKey: [ 131 - { 132 - params: createQueryKeyParams(options), 133 - scope: 'postCallWithoutParametersAndResponse' 134 - } 121 + createQueryKey("postCallWithoutParametersAndResponse", options) 135 122 ] 136 123 }); }; 137 124 138 - export const postCallWithoutParametersAndResponseMutation: UseMutationOptions<void, DefaultError, Options> = { 125 + export const postCallWithoutParametersAndResponseMutation = () => { const mutationOptions: UseMutationOptions<void, DefaultError, Options> = { 139 126 mutationFn: async (options) => { 140 127 const { data } = await postCallWithoutParametersAndResponse({ 141 128 ...options, ··· 143 130 }); 144 131 return data; 145 132 } 146 - }; 133 + }; return mutationOptions; }; 147 134 148 - export const deleteCallWithoutParametersAndResponseMutation: UseMutationOptions<void, DefaultError, Options> = { 135 + export const deleteCallWithoutParametersAndResponseMutation = () => { const mutationOptions: UseMutationOptions<void, DefaultError, Options> = { 149 136 mutationFn: async (options) => { 150 137 const { data } = await deleteCallWithoutParametersAndResponse({ 151 138 ...options, ··· 153 140 }); 154 141 return data; 155 142 } 156 - }; 143 + }; return mutationOptions; }; 157 144 158 - export const patchCallWithoutParametersAndResponseMutation: UseMutationOptions<void, DefaultError, Options> = { 145 + export const patchCallWithoutParametersAndResponseMutation = () => { const mutationOptions: UseMutationOptions<void, DefaultError, Options> = { 159 146 mutationFn: async (options) => { 160 147 const { data } = await patchCallWithoutParametersAndResponse({ 161 148 ...options, ··· 163 150 }); 164 151 return data; 165 152 } 166 - }; 153 + }; return mutationOptions; }; 167 154 168 - export const deleteFooMutation: UseMutationOptions<void, DefaultError, Options<DeleteFooData3>> = { 155 + export const deleteFooMutation = () => { const mutationOptions: UseMutationOptions<void, DefaultError, Options<DeleteFooData3>> = { 169 156 mutationFn: async (options) => { 170 157 const { data } = await deleteFoo({ 171 158 ...options, ··· 173 160 }); 174 161 return data; 175 162 } 176 - }; 163 + }; return mutationOptions; }; 177 164 178 165 export const callWithDescriptionsOptions = (options?: Options<CallWithDescriptionsData>) => { return queryOptions({ 179 166 queryFn: async ({ queryKey }) => { 180 167 const { data } = await callWithDescriptions({ 181 168 ...options, 182 - ...queryKey[0].params, 169 + ...queryKey[0], 183 170 throwOnError: true 184 171 }); 185 172 return data; 186 173 }, 187 174 queryKey: [ 188 - { 189 - params: createQueryKeyParams(options), 190 - scope: 'callWithDescriptions' 191 - } 175 + createQueryKey("callWithDescriptions", options) 192 176 ] 193 177 }); }; 194 178 195 - export const callWithDescriptionsMutation: UseMutationOptions<void, DefaultError, Options<CallWithDescriptionsData>> = { 179 + export const callWithDescriptionsMutation = () => { const mutationOptions: UseMutationOptions<void, DefaultError, Options<CallWithDescriptionsData>> = { 196 180 mutationFn: async (options) => { 197 181 const { data } = await callWithDescriptions({ 198 182 ...options, ··· 200 184 }); 201 185 return data; 202 186 } 203 - }; 187 + }; return mutationOptions; }; 204 188 205 189 export const deprecatedCallOptions = (options: Options<DeprecatedCallData>) => { return queryOptions({ 206 190 queryFn: async ({ queryKey }) => { 207 191 const { data } = await deprecatedCall({ 208 192 ...options, 209 - ...queryKey[0].params, 193 + ...queryKey[0], 210 194 throwOnError: true 211 195 }); 212 196 return data; 213 197 }, 214 198 queryKey: [ 215 - { 216 - params: createQueryKeyParams(options), 217 - scope: 'deprecatedCall' 218 - } 199 + createQueryKey("deprecatedCall", options) 219 200 ] 220 201 }); }; 221 202 222 - export const deprecatedCallMutation: UseMutationOptions<void, DefaultError, Options<DeprecatedCallData>> = { 203 + export const deprecatedCallMutation = () => { const mutationOptions: UseMutationOptions<void, DefaultError, Options<DeprecatedCallData>> = { 223 204 mutationFn: async (options) => { 224 205 const { data } = await deprecatedCall({ 225 206 ...options, ··· 227 208 }); 228 209 return data; 229 210 } 230 - }; 211 + }; return mutationOptions; }; 231 212 232 213 export const callWithParametersOptions = (options: Options<CallWithParametersData>) => { return queryOptions({ 233 214 queryFn: async ({ queryKey }) => { 234 215 const { data } = await callWithParameters({ 235 216 ...options, 236 - ...queryKey[0].params, 217 + ...queryKey[0], 237 218 throwOnError: true 238 219 }); 239 220 return data; 240 221 }, 241 222 queryKey: [ 242 - { 243 - params: createQueryKeyParams(options), 244 - scope: 'callWithParameters' 245 - } 223 + createQueryKey("callWithParameters", options) 246 224 ] 247 225 }); }; 248 226 249 - export const callWithParametersInfiniteOptions = (options: Options<CallWithParametersData>) => { return infiniteQueryOptions<void, DefaultError, InfiniteData<void>, QueryKey<Options<CallWithParametersData>>, string | QueryKey<Options<CallWithParametersData>>[0]['params']>( 227 + export const callWithParametersInfiniteOptions = (options: Options<CallWithParametersData>) => { return infiniteQueryOptions<void, DefaultError, InfiniteData<void>, QueryKey<Options<CallWithParametersData>>, string | QueryKey<Options<CallWithParametersData>>[0]>( 250 228 // @ts-ignore 251 229 { 252 230 queryFn: async ({ pageParam, queryKey }) => { 253 231 // @ts-ignore 254 - const page: QueryKey<Options<CallWithParametersData>>[0]['params'] = typeof pageParam === "object" ? pageParam : { 232 + const page: QueryKey<Options<CallWithParametersData>>[0] = typeof pageParam === "object" ? pageParam : { 255 233 query: { 256 234 cursor: pageParam 257 235 } ··· 259 237 const { data } = await callWithParameters({ 260 238 ...options, 261 239 body: { 262 - ...queryKey[0].params.body as any, 240 + ...queryKey[0].body as any, 263 241 ...page.body as any 264 242 }, 265 243 headers: { 266 - ...queryKey[0].params.headers, 244 + ...queryKey[0].headers, 267 245 ...page.headers 268 246 }, 269 247 path: { 270 - ...queryKey[0].params.path, 248 + ...queryKey[0].path, 271 249 ...page.path 272 250 }, 273 251 query: { 274 - ...queryKey[0].params.query, 252 + ...queryKey[0].query, 275 253 ...page.query 276 254 }, 255 + baseUrl: client.getConfig().baseUrl, 277 256 throwOnError: true 278 257 }); 279 258 return data; 280 259 }, 281 260 queryKey: [ 282 - { 283 - infinite: true, 284 - params: createQueryKeyParams(options), 285 - scope: 'callWithParameters' 286 - } 261 + createQueryKey("callWithParameters", options, true) 287 262 ] 288 263 }); }; 289 264 290 - export const callWithParametersMutation: UseMutationOptions<void, DefaultError, Options<CallWithParametersData>> = { 265 + export const callWithParametersMutation = () => { const mutationOptions: UseMutationOptions<void, DefaultError, Options<CallWithParametersData>> = { 291 266 mutationFn: async (options) => { 292 267 const { data } = await callWithParameters({ 293 268 ...options, ··· 295 270 }); 296 271 return data; 297 272 } 298 - }; 273 + }; return mutationOptions; }; 299 274 300 275 export const callWithWeirdParameterNamesOptions = (options: Options<CallWithWeirdParameterNamesData>) => { return queryOptions({ 301 276 queryFn: async ({ queryKey }) => { 302 277 const { data } = await callWithWeirdParameterNames({ 303 278 ...options, 304 - ...queryKey[0].params, 279 + ...queryKey[0], 305 280 throwOnError: true 306 281 }); 307 282 return data; 308 283 }, 309 284 queryKey: [ 310 - { 311 - params: createQueryKeyParams(options), 312 - scope: 'callWithWeirdParameterNames' 313 - } 285 + createQueryKey("callWithWeirdParameterNames", options) 314 286 ] 315 287 }); }; 316 288 317 - export const callWithWeirdParameterNamesMutation: UseMutationOptions<void, DefaultError, Options<CallWithWeirdParameterNamesData>> = { 289 + export const callWithWeirdParameterNamesMutation = () => { const mutationOptions: UseMutationOptions<void, DefaultError, Options<CallWithWeirdParameterNamesData>> = { 318 290 mutationFn: async (options) => { 319 291 const { data } = await callWithWeirdParameterNames({ 320 292 ...options, ··· 322 294 }); 323 295 return data; 324 296 } 325 - }; 297 + }; return mutationOptions; }; 326 298 327 299 export const getCallWithOptionalParamOptions = (options: Options<GetCallWithOptionalParamData>) => { return queryOptions({ 328 300 queryFn: async ({ queryKey }) => { 329 301 const { data } = await getCallWithOptionalParam({ 330 302 ...options, 331 - ...queryKey[0].params, 303 + ...queryKey[0], 332 304 throwOnError: true 333 305 }); 334 306 return data; 335 307 }, 336 308 queryKey: [ 337 - { 338 - params: createQueryKeyParams(options), 339 - scope: 'getCallWithOptionalParam' 340 - } 309 + createQueryKey("getCallWithOptionalParam", options) 341 310 ] 342 311 }); }; 343 312 344 - export const getCallWithOptionalParamInfiniteOptions = (options: Options<GetCallWithOptionalParamData>) => { return infiniteQueryOptions<void, DefaultError, InfiniteData<void>, QueryKey<Options<GetCallWithOptionalParamData>>, number | QueryKey<Options<GetCallWithOptionalParamData>>[0]['params']>( 313 + export const getCallWithOptionalParamInfiniteOptions = (options: Options<GetCallWithOptionalParamData>) => { return infiniteQueryOptions<void, DefaultError, InfiniteData<void>, QueryKey<Options<GetCallWithOptionalParamData>>, number | QueryKey<Options<GetCallWithOptionalParamData>>[0]>( 345 314 // @ts-ignore 346 315 { 347 316 queryFn: async ({ pageParam, queryKey }) => { 348 317 // @ts-ignore 349 - const page: QueryKey<Options<GetCallWithOptionalParamData>>[0]['params'] = typeof pageParam === "object" ? pageParam : { 318 + const page: QueryKey<Options<GetCallWithOptionalParamData>>[0] = typeof pageParam === "object" ? pageParam : { 350 319 query: { 351 320 page: pageParam 352 321 } ··· 354 323 const { data } = await getCallWithOptionalParam({ 355 324 ...options, 356 325 body: { 357 - ...queryKey[0].params.body as any, 326 + ...queryKey[0].body as any, 358 327 ...page.body as any 359 328 }, 360 329 headers: { 361 - ...queryKey[0].params.headers, 330 + ...queryKey[0].headers, 362 331 ...page.headers 363 332 }, 364 333 path: { 365 - ...queryKey[0].params.path, 334 + ...queryKey[0].path, 366 335 ...page.path 367 336 }, 368 337 query: { 369 - ...queryKey[0].params.query, 338 + ...queryKey[0].query, 370 339 ...page.query 371 340 }, 341 + baseUrl: client.getConfig().baseUrl, 372 342 throwOnError: true 373 343 }); 374 344 return data; 375 345 }, 376 346 queryKey: [ 377 - { 378 - infinite: true, 379 - params: createQueryKeyParams(options), 380 - scope: 'getCallWithOptionalParam' 381 - } 347 + createQueryKey("getCallWithOptionalParam", options, true) 382 348 ] 383 349 }); }; 384 350 ··· 386 352 queryFn: async ({ queryKey }) => { 387 353 const { data } = await postCallWithOptionalParam({ 388 354 ...options, 389 - ...queryKey[0].params, 355 + ...queryKey[0], 390 356 throwOnError: true 391 357 }); 392 358 return data; 393 359 }, 394 360 queryKey: [ 395 - { 396 - params: createQueryKeyParams(options), 397 - scope: 'postCallWithOptionalParam' 398 - } 361 + createQueryKey("postCallWithOptionalParam", options) 399 362 ] 400 363 }); }; 401 364 402 - export const postCallWithOptionalParamInfiniteOptions = (options: Options<PostCallWithOptionalParamData>) => { return infiniteQueryOptions<PostCallWithOptionalParamResponse, PostCallWithOptionalParamError, InfiniteData<PostCallWithOptionalParamResponse>, QueryKey<Options<PostCallWithOptionalParamData>>, number | QueryKey<Options<PostCallWithOptionalParamData>>[0]['params']>( 365 + export const postCallWithOptionalParamInfiniteOptions = (options: Options<PostCallWithOptionalParamData>) => { return infiniteQueryOptions<PostCallWithOptionalParamResponse, PostCallWithOptionalParamError, InfiniteData<PostCallWithOptionalParamResponse>, QueryKey<Options<PostCallWithOptionalParamData>>, number | QueryKey<Options<PostCallWithOptionalParamData>>[0]>( 403 366 // @ts-ignore 404 367 { 405 368 queryFn: async ({ pageParam, queryKey }) => { 406 369 // @ts-ignore 407 - const page: QueryKey<Options<PostCallWithOptionalParamData>>[0]['params'] = typeof pageParam === "object" ? pageParam : { 370 + const page: QueryKey<Options<PostCallWithOptionalParamData>>[0] = typeof pageParam === "object" ? pageParam : { 408 371 body: { 409 372 offset: pageParam 410 373 } ··· 412 375 const { data } = await postCallWithOptionalParam({ 413 376 ...options, 414 377 body: { 415 - ...queryKey[0].params.body as any, 378 + ...queryKey[0].body as any, 416 379 ...page.body as any 417 380 }, 418 381 headers: { 419 - ...queryKey[0].params.headers, 382 + ...queryKey[0].headers, 420 383 ...page.headers 421 384 }, 422 385 path: { 423 - ...queryKey[0].params.path, 386 + ...queryKey[0].path, 424 387 ...page.path 425 388 }, 426 389 query: { 427 - ...queryKey[0].params.query, 390 + ...queryKey[0].query, 428 391 ...page.query 429 392 }, 393 + baseUrl: client.getConfig().baseUrl, 430 394 throwOnError: true 431 395 }); 432 396 return data; 433 397 }, 434 398 queryKey: [ 435 - { 436 - infinite: true, 437 - params: createQueryKeyParams(options), 438 - scope: 'postCallWithOptionalParam' 439 - } 399 + createQueryKey("postCallWithOptionalParam", options, true) 440 400 ] 441 401 }); }; 442 402 443 - export const postCallWithOptionalParamMutation: UseMutationOptions<PostCallWithOptionalParamResponse, PostCallWithOptionalParamError, Options<PostCallWithOptionalParamData>> = { 403 + export const postCallWithOptionalParamMutation = () => { const mutationOptions: UseMutationOptions<PostCallWithOptionalParamResponse, PostCallWithOptionalParamError, Options<PostCallWithOptionalParamData>> = { 444 404 mutationFn: async (options) => { 445 405 const { data } = await postCallWithOptionalParam({ 446 406 ...options, ··· 448 408 }); 449 409 return data; 450 410 } 451 - }; 411 + }; return mutationOptions; }; 452 412 453 413 export const postApiVbyApiVersionRequestBodyOptions = (options?: Options<PostApiVbyApiVersionRequestBodyData>) => { return queryOptions({ 454 414 queryFn: async ({ queryKey }) => { 455 415 const { data } = await postApiVbyApiVersionRequestBody({ 456 416 ...options, 457 - ...queryKey[0].params, 417 + ...queryKey[0], 458 418 throwOnError: true 459 419 }); 460 420 return data; 461 421 }, 462 422 queryKey: [ 463 - { 464 - params: createQueryKeyParams(options), 465 - scope: 'postApiVbyApiVersionRequestBody' 466 - } 423 + createQueryKey("postApiVbyApiVersionRequestBody", options) 467 424 ] 468 425 }); }; 469 426 470 - export const postApiVbyApiVersionRequestBodyMutation: UseMutationOptions<void, DefaultError, Options<PostApiVbyApiVersionRequestBodyData>> = { 427 + export const postApiVbyApiVersionRequestBodyMutation = () => { const mutationOptions: UseMutationOptions<void, DefaultError, Options<PostApiVbyApiVersionRequestBodyData>> = { 471 428 mutationFn: async (options) => { 472 429 const { data } = await postApiVbyApiVersionRequestBody({ 473 430 ...options, ··· 475 432 }); 476 433 return data; 477 434 } 478 - }; 435 + }; return mutationOptions; }; 479 436 480 437 export const postApiVbyApiVersionFormDataOptions = (options?: Options<PostApiVbyApiVersionFormDataData>) => { return queryOptions({ 481 438 queryFn: async ({ queryKey }) => { 482 439 const { data } = await postApiVbyApiVersionFormData({ 483 440 ...options, 484 - ...queryKey[0].params, 441 + ...queryKey[0], 485 442 throwOnError: true 486 443 }); 487 444 return data; 488 445 }, 489 446 queryKey: [ 490 - { 491 - params: createQueryKeyParams(options), 492 - scope: 'postApiVbyApiVersionFormData' 493 - } 447 + createQueryKey("postApiVbyApiVersionFormData", options) 494 448 ] 495 449 }); }; 496 450 497 - export const postApiVbyApiVersionFormDataMutation: UseMutationOptions<void, DefaultError, Options<PostApiVbyApiVersionFormDataData>> = { 451 + export const postApiVbyApiVersionFormDataMutation = () => { const mutationOptions: UseMutationOptions<void, DefaultError, Options<PostApiVbyApiVersionFormDataData>> = { 498 452 mutationFn: async (options) => { 499 453 const { data } = await postApiVbyApiVersionFormData({ 500 454 ...options, ··· 502 456 }); 503 457 return data; 504 458 } 505 - }; 459 + }; return mutationOptions; }; 506 460 507 461 export const callWithDefaultParametersOptions = (options?: Options<CallWithDefaultParametersData>) => { return queryOptions({ 508 462 queryFn: async ({ queryKey }) => { 509 463 const { data } = await callWithDefaultParameters({ 510 464 ...options, 511 - ...queryKey[0].params, 465 + ...queryKey[0], 512 466 throwOnError: true 513 467 }); 514 468 return data; 515 469 }, 516 470 queryKey: [ 517 - { 518 - params: createQueryKeyParams(options), 519 - scope: 'callWithDefaultParameters' 520 - } 471 + createQueryKey("callWithDefaultParameters", options) 521 472 ] 522 473 }); }; 523 474 ··· 525 476 queryFn: async ({ queryKey }) => { 526 477 const { data } = await callWithDefaultOptionalParameters({ 527 478 ...options, 528 - ...queryKey[0].params, 479 + ...queryKey[0], 529 480 throwOnError: true 530 481 }); 531 482 return data; 532 483 }, 533 484 queryKey: [ 534 - { 535 - params: createQueryKeyParams(options), 536 - scope: 'callWithDefaultOptionalParameters' 537 - } 485 + createQueryKey("callWithDefaultOptionalParameters", options) 538 486 ] 539 487 }); }; 540 488 541 - export const callWithDefaultOptionalParametersMutation: UseMutationOptions<void, DefaultError, Options<CallWithDefaultOptionalParametersData>> = { 489 + export const callWithDefaultOptionalParametersMutation = () => { const mutationOptions: UseMutationOptions<void, DefaultError, Options<CallWithDefaultOptionalParametersData>> = { 542 490 mutationFn: async (options) => { 543 491 const { data } = await callWithDefaultOptionalParameters({ 544 492 ...options, ··· 546 494 }); 547 495 return data; 548 496 } 549 - }; 497 + }; return mutationOptions; }; 550 498 551 - export const callToTestOrderOfParamsMutation: UseMutationOptions<void, DefaultError, Options<CallToTestOrderOfParamsData>> = { 499 + export const callToTestOrderOfParamsMutation = () => { const mutationOptions: UseMutationOptions<void, DefaultError, Options<CallToTestOrderOfParamsData>> = { 552 500 mutationFn: async (options) => { 553 501 const { data } = await callToTestOrderOfParams({ 554 502 ...options, ··· 556 504 }); 557 505 return data; 558 506 } 559 - }; 507 + }; return mutationOptions; }; 560 508 561 509 export const duplicateNameOptions = (options?: Options) => { return queryOptions({ 562 510 queryFn: async ({ queryKey }) => { 563 511 const { data } = await duplicateName({ 564 512 ...options, 565 - ...queryKey[0].params, 513 + ...queryKey[0], 566 514 throwOnError: true 567 515 }); 568 516 return data; 569 517 }, 570 518 queryKey: [ 571 - { 572 - params: createQueryKeyParams(options), 573 - scope: 'duplicateName' 574 - } 519 + createQueryKey("duplicateName", options) 575 520 ] 576 521 }); }; 577 522 ··· 579 524 queryFn: async ({ queryKey }) => { 580 525 const { data } = await duplicateName1({ 581 526 ...options, 582 - ...queryKey[0].params, 527 + ...queryKey[0], 583 528 throwOnError: true 584 529 }); 585 530 return data; 586 531 }, 587 532 queryKey: [ 588 - { 589 - params: createQueryKeyParams(options), 590 - scope: 'duplicateName1' 591 - } 533 + createQueryKey("duplicateName1", options) 592 534 ] 593 535 }); }; 594 536 595 - export const duplicateName1Mutation: UseMutationOptions<void, DefaultError, Options> = { 537 + export const duplicateName1Mutation = () => { const mutationOptions: UseMutationOptions<void, DefaultError, Options> = { 596 538 mutationFn: async (options) => { 597 539 const { data } = await duplicateName1({ 598 540 ...options, ··· 600 542 }); 601 543 return data; 602 544 } 603 - }; 545 + }; return mutationOptions; }; 604 546 605 - export const duplicateName2Mutation: UseMutationOptions<void, DefaultError, Options> = { 547 + export const duplicateName2Mutation = () => { const mutationOptions: UseMutationOptions<void, DefaultError, Options> = { 606 548 mutationFn: async (options) => { 607 549 const { data } = await duplicateName2({ 608 550 ...options, ··· 610 552 }); 611 553 return data; 612 554 } 613 - }; 555 + }; return mutationOptions; }; 614 556 615 - export const duplicateName3Mutation: UseMutationOptions<void, DefaultError, Options> = { 557 + export const duplicateName3Mutation = () => { const mutationOptions: UseMutationOptions<void, DefaultError, Options> = { 616 558 mutationFn: async (options) => { 617 559 const { data } = await duplicateName3({ 618 560 ...options, ··· 620 562 }); 621 563 return data; 622 564 } 623 - }; 565 + }; return mutationOptions; }; 624 566 625 567 export const callWithNoContentResponseOptions = (options?: Options) => { return queryOptions({ 626 568 queryFn: async ({ queryKey }) => { 627 569 const { data } = await callWithNoContentResponse({ 628 570 ...options, 629 - ...queryKey[0].params, 571 + ...queryKey[0], 630 572 throwOnError: true 631 573 }); 632 574 return data; 633 575 }, 634 576 queryKey: [ 635 - { 636 - params: createQueryKeyParams(options), 637 - scope: 'callWithNoContentResponse' 638 - } 577 + createQueryKey("callWithNoContentResponse", options) 639 578 ] 640 579 }); }; 641 580 ··· 643 582 queryFn: async ({ queryKey }) => { 644 583 const { data } = await callWithResponseAndNoContentResponse({ 645 584 ...options, 646 - ...queryKey[0].params, 585 + ...queryKey[0], 647 586 throwOnError: true 648 587 }); 649 588 return data; 650 589 }, 651 590 queryKey: [ 652 - { 653 - params: createQueryKeyParams(options), 654 - scope: 'callWithResponseAndNoContentResponse' 655 - } 591 + createQueryKey("callWithResponseAndNoContentResponse", options) 656 592 ] 657 593 }); }; 658 594 ··· 660 596 queryFn: async ({ queryKey }) => { 661 597 const { data } = await dummyA({ 662 598 ...options, 663 - ...queryKey[0].params, 599 + ...queryKey[0], 664 600 throwOnError: true 665 601 }); 666 602 return data; 667 603 }, 668 604 queryKey: [ 669 - { 670 - params: createQueryKeyParams(options), 671 - scope: 'dummyA' 672 - } 605 + createQueryKey("dummyA", options) 673 606 ] 674 607 }); }; 675 608 ··· 677 610 queryFn: async ({ queryKey }) => { 678 611 const { data } = await dummyB({ 679 612 ...options, 680 - ...queryKey[0].params, 613 + ...queryKey[0], 681 614 throwOnError: true 682 615 }); 683 616 return data; 684 617 }, 685 618 queryKey: [ 686 - { 687 - params: createQueryKeyParams(options), 688 - scope: 'dummyB' 689 - } 619 + createQueryKey("dummyB", options) 690 620 ] 691 621 }); }; 692 622 ··· 694 624 queryFn: async ({ queryKey }) => { 695 625 const { data } = await callWithResponse({ 696 626 ...options, 697 - ...queryKey[0].params, 627 + ...queryKey[0], 698 628 throwOnError: true 699 629 }); 700 630 return data; 701 631 }, 702 632 queryKey: [ 703 - { 704 - params: createQueryKeyParams(options), 705 - scope: 'callWithResponse' 706 - } 633 + createQueryKey("callWithResponse", options) 707 634 ] 708 635 }); }; 709 636 ··· 711 638 queryFn: async ({ queryKey }) => { 712 639 const { data } = await callWithDuplicateResponses({ 713 640 ...options, 714 - ...queryKey[0].params, 641 + ...queryKey[0], 715 642 throwOnError: true 716 643 }); 717 644 return data; 718 645 }, 719 646 queryKey: [ 720 - { 721 - params: createQueryKeyParams(options), 722 - scope: 'callWithDuplicateResponses' 723 - } 647 + createQueryKey("callWithDuplicateResponses", options) 724 648 ] 725 649 }); }; 726 650 727 - export const callWithDuplicateResponsesMutation: UseMutationOptions<CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesError, Options> = { 651 + export const callWithDuplicateResponsesMutation = () => { const mutationOptions: UseMutationOptions<CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesError, Options> = { 728 652 mutationFn: async (options) => { 729 653 const { data } = await callWithDuplicateResponses({ 730 654 ...options, ··· 732 656 }); 733 657 return data; 734 658 } 735 - }; 659 + }; return mutationOptions; }; 736 660 737 - export const callWithResponsesMutation: UseMutationOptions<CallWithResponsesResponse, CallWithResponsesError, Options> = { 661 + export const callWithResponsesMutation = () => { const mutationOptions: UseMutationOptions<CallWithResponsesResponse, CallWithResponsesError, Options> = { 738 662 mutationFn: async (options) => { 739 663 const { data } = await callWithResponses({ 740 664 ...options, ··· 742 666 }); 743 667 return data; 744 668 } 745 - }; 669 + }; return mutationOptions; }; 746 670 747 671 export const collectionFormatOptions = (options: Options<CollectionFormatData>) => { return queryOptions({ 748 672 queryFn: async ({ queryKey }) => { 749 673 const { data } = await collectionFormat({ 750 674 ...options, 751 - ...queryKey[0].params, 675 + ...queryKey[0], 752 676 throwOnError: true 753 677 }); 754 678 return data; 755 679 }, 756 680 queryKey: [ 757 - { 758 - params: createQueryKeyParams(options), 759 - scope: 'collectionFormat' 760 - } 681 + createQueryKey("collectionFormat", options) 761 682 ] 762 683 }); }; 763 684 ··· 765 686 queryFn: async ({ queryKey }) => { 766 687 const { data } = await types({ 767 688 ...options, 768 - ...queryKey[0].params, 689 + ...queryKey[0], 769 690 throwOnError: true 770 691 }); 771 692 return data; 772 693 }, 773 694 queryKey: [ 774 - { 775 - params: createQueryKeyParams(options), 776 - scope: 'types' 777 - } 695 + createQueryKey("types", options) 778 696 ] 779 697 }); }; 780 698 ··· 782 700 queryFn: async ({ queryKey }) => { 783 701 const { data } = await uploadFile({ 784 702 ...options, 785 - ...queryKey[0].params, 703 + ...queryKey[0], 786 704 throwOnError: true 787 705 }); 788 706 return data; 789 707 }, 790 708 queryKey: [ 791 - { 792 - params: createQueryKeyParams(options), 793 - scope: 'uploadFile' 794 - } 709 + createQueryKey("uploadFile", options) 795 710 ] 796 711 }); }; 797 712 798 - export const uploadFileMutation: UseMutationOptions<UploadFileResponse, UploadFileError, Options<UploadFileData>> = { 713 + export const uploadFileMutation = () => { const mutationOptions: UseMutationOptions<UploadFileResponse, UploadFileError, Options<UploadFileData>> = { 799 714 mutationFn: async (options) => { 800 715 const { data } = await uploadFile({ 801 716 ...options, ··· 803 718 }); 804 719 return data; 805 720 } 806 - }; 721 + }; return mutationOptions; }; 807 722 808 723 export const fileResponseOptions = (options: Options<FileResponseData>) => { return queryOptions({ 809 724 queryFn: async ({ queryKey }) => { 810 725 const { data } = await fileResponse({ 811 726 ...options, 812 - ...queryKey[0].params, 727 + ...queryKey[0], 813 728 throwOnError: true 814 729 }); 815 730 return data; 816 731 }, 817 732 queryKey: [ 818 - { 819 - params: createQueryKeyParams(options), 820 - scope: 'fileResponse' 821 - } 733 + createQueryKey("fileResponse", options) 822 734 ] 823 735 }); }; 824 736 ··· 826 738 queryFn: async ({ queryKey }) => { 827 739 const { data } = await complexTypes({ 828 740 ...options, 829 - ...queryKey[0].params, 741 + ...queryKey[0], 830 742 throwOnError: true 831 743 }); 832 744 return data; 833 745 }, 834 746 queryKey: [ 835 - { 836 - params: createQueryKeyParams(options), 837 - scope: 'complexTypes' 838 - } 747 + createQueryKey("complexTypes", options) 839 748 ] 840 749 }); }; 841 750 ··· 843 752 queryFn: async ({ queryKey }) => { 844 753 const { data } = await multipartRequest({ 845 754 ...options, 846 - ...queryKey[0].params, 755 + ...queryKey[0], 847 756 throwOnError: true 848 757 }); 849 758 return data; 850 759 }, 851 760 queryKey: [ 852 - { 853 - params: createQueryKeyParams(options), 854 - scope: 'multipartRequest' 855 - } 761 + createQueryKey("multipartRequest", options) 856 762 ] 857 763 }); }; 858 764 859 - export const multipartRequestMutation: UseMutationOptions<void, DefaultError, Options<MultipartRequestData>> = { 765 + export const multipartRequestMutation = () => { const mutationOptions: UseMutationOptions<void, DefaultError, Options<MultipartRequestData>> = { 860 766 mutationFn: async (options) => { 861 767 const { data } = await multipartRequest({ 862 768 ...options, ··· 864 770 }); 865 771 return data; 866 772 } 867 - }; 773 + }; return mutationOptions; }; 868 774 869 775 export const multipartResponseOptions = (options?: Options) => { return queryOptions({ 870 776 queryFn: async ({ queryKey }) => { 871 777 const { data } = await multipartResponse({ 872 778 ...options, 873 - ...queryKey[0].params, 779 + ...queryKey[0], 874 780 throwOnError: true 875 781 }); 876 782 return data; 877 783 }, 878 784 queryKey: [ 879 - { 880 - params: createQueryKeyParams(options), 881 - scope: 'multipartResponse' 882 - } 785 + createQueryKey("multipartResponse", options) 883 786 ] 884 787 }); }; 885 788 886 - export const complexParamsMutation: UseMutationOptions<ComplexParamsResponse, ComplexParamsError, Options<ComplexParamsData>> = { 789 + export const complexParamsMutation = () => { const mutationOptions: UseMutationOptions<ComplexParamsResponse, ComplexParamsError, Options<ComplexParamsData>> = { 887 790 mutationFn: async (options) => { 888 791 const { data } = await complexParams({ 889 792 ...options, ··· 891 794 }); 892 795 return data; 893 796 } 894 - }; 797 + }; return mutationOptions; }; 895 798 896 799 export const callWithResultFromHeaderOptions = (options?: Options) => { return queryOptions({ 897 800 queryFn: async ({ queryKey }) => { 898 801 const { data } = await callWithResultFromHeader({ 899 802 ...options, 900 - ...queryKey[0].params, 803 + ...queryKey[0], 901 804 throwOnError: true 902 805 }); 903 806 return data; 904 807 }, 905 808 queryKey: [ 906 - { 907 - params: createQueryKeyParams(options), 908 - scope: 'callWithResultFromHeader' 909 - } 809 + createQueryKey("callWithResultFromHeader", options) 910 810 ] 911 811 }); }; 912 812 913 - export const callWithResultFromHeaderMutation: UseMutationOptions<CallWithResultFromHeaderResponse, CallWithResultFromHeaderError, Options> = { 813 + export const callWithResultFromHeaderMutation = () => { const mutationOptions: UseMutationOptions<CallWithResultFromHeaderResponse, CallWithResultFromHeaderError, Options> = { 914 814 mutationFn: async (options) => { 915 815 const { data } = await callWithResultFromHeader({ 916 816 ...options, ··· 918 818 }); 919 819 return data; 920 820 } 921 - }; 821 + }; return mutationOptions; }; 922 822 923 823 export const testErrorCodeOptions = (options: Options<TestErrorCodeData>) => { return queryOptions({ 924 824 queryFn: async ({ queryKey }) => { 925 825 const { data } = await testErrorCode({ 926 826 ...options, 927 - ...queryKey[0].params, 827 + ...queryKey[0], 928 828 throwOnError: true 929 829 }); 930 830 return data; 931 831 }, 932 832 queryKey: [ 933 - { 934 - params: createQueryKeyParams(options), 935 - scope: 'testErrorCode' 936 - } 833 + createQueryKey("testErrorCode", options) 937 834 ] 938 835 }); }; 939 836 940 - export const testErrorCodeMutation: UseMutationOptions<TestErrorCodeResponse, TestErrorCodeError, Options<TestErrorCodeData>> = { 837 + export const testErrorCodeMutation = () => { const mutationOptions: UseMutationOptions<TestErrorCodeResponse, TestErrorCodeError, Options<TestErrorCodeData>> = { 941 838 mutationFn: async (options) => { 942 839 const { data } = await testErrorCode({ 943 840 ...options, ··· 945 842 }); 946 843 return data; 947 844 } 948 - }; 845 + }; return mutationOptions; }; 949 846 950 847 export const nonAsciiæøåÆøÅöôêÊ字符串Options = (options: Options<NonAsciiæøåÆøÅöôêÊ字符串Data>) => { return queryOptions({ 951 848 queryFn: async ({ queryKey }) => { 952 849 const { data } = await nonAsciiæøåÆøÅöôêÊ字符串({ 953 850 ...options, 954 - ...queryKey[0].params, 851 + ...queryKey[0], 955 852 throwOnError: true 956 853 }); 957 854 return data; 958 855 }, 959 856 queryKey: [ 960 - { 961 - params: createQueryKeyParams(options), 962 - scope: 'nonAsciiæøåÆøÅöôêÊ字符串' 963 - } 857 + createQueryKey("nonAsciiæøåÆøÅöôêÊ字符串", options) 964 858 ] 965 859 }); }; 966 860 967 - export const nonAsciiæøåÆøÅöôêÊ字符串Mutation: UseMutationOptions<NonAsciiæøåÆøÅöôêÊ字符串Response, NonAsciiæøåÆøÅöôêÊ字符串Error, Options<NonAsciiæøåÆøÅöôêÊ字符串Data>> = { 861 + export const nonAsciiæøåÆøÅöôêÊ字符串Mutation = () => { const mutationOptions: UseMutationOptions<NonAsciiæøåÆøÅöôêÊ字符串Response, NonAsciiæøåÆøÅöôêÊ字符串Error, Options<NonAsciiæøåÆøÅöôêÊ字符串Data>> = { 968 862 mutationFn: async (options) => { 969 863 const { data } = await nonAsciiæøåÆøÅöôêÊ字符串({ 970 864 ...options, ··· 972 866 }); 973 867 return data; 974 868 } 975 - }; 869 + }; return mutationOptions; }; 976 870 977 - export const putWithFormUrlEncodedMutation: UseMutationOptions<void, DefaultError, Options<PutWithFormUrlEncodedData>> = { 871 + export const putWithFormUrlEncodedMutation = () => { const mutationOptions: UseMutationOptions<void, DefaultError, Options<PutWithFormUrlEncodedData>> = { 978 872 mutationFn: async (options) => { 979 873 const { data } = await putWithFormUrlEncoded({ 980 874 ...options, ··· 982 876 }); 983 877 return data; 984 878 } 985 - }; 879 + }; return mutationOptions; };
+22 -23
packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-fetch-plugin-tanstack-react-query_transform/@tanstack/react-query.gen.ts.snap
··· 3 3 import type { Options } from '@hey-api/client-fetch'; 4 4 import { queryOptions, type UseMutationOptions } from '@tanstack/react-query'; 5 5 import type { ParentModelWithDatesError, ParentModelWithDatesResponse, ModelWithDatesError, ModelWithDatesResponse, ModelWithDatesArrayError, ModelWithDatesArrayResponse, ArrayOfDatesError, ArrayOfDatesResponse, DateError, DateResponse, MultipleResponsesError, MultipleResponsesResponse } from '../types.gen'; 6 - import { parentModelWithDates, modelWithDates, modelWithDatesArray, arrayOfDates, date, multipleResponses } from '../services.gen'; 6 + import { client, parentModelWithDates, modelWithDates, modelWithDatesArray, arrayOfDates, date, multipleResponses } from '../services.gen'; 7 7 8 8 type QueryKey<TOptions extends Options> = [ 9 - { 9 + Pick<TOptions, 'baseUrl' | 'body' | 'headers' | 'path' | 'query'> & { 10 + _id: string; 10 11 infinite?: boolean; 11 - params: Pick<TOptions, "body" | "headers" | "path" | "query">; 12 - scope: string; 13 12 } 14 13 ]; 15 14 16 - const createQueryKeyParams = <TOptions extends Options>(options?: TOptions): QueryKey<TOptions>[0]["params"] => { 17 - const params: QueryKey<TOptions>[0]["params"] = {} as QueryKey<TOptions>[0]["params"]; 15 + const createQueryKey = <TOptions extends Options>(id: string, options?: TOptions, infinite?: boolean): QueryKey<TOptions>[0] => { 16 + const params: QueryKey<TOptions>[0] = { _id: id, baseUrl: client.getConfig().baseUrl } as QueryKey<TOptions>[0]; 17 + if (infinite) { 18 + params.infinite = infinite; 19 + } 18 20 if (options?.body) { 19 21 params.body = options.body; 20 22 } ··· 34 36 queryFn: async ({ queryKey }) => { 35 37 const { data } = await parentModelWithDates({ 36 38 ...options, 37 - ...queryKey[0].params, 39 + ...queryKey[0], 38 40 throwOnError: true 39 41 }); 40 42 return data; 41 43 }, 42 44 queryKey: [ 43 - { 44 - params: createQueryKeyParams(options), 45 - scope: 'parentModelWithDates' 46 - } 45 + createQueryKey("parentModelWithDates", options) 47 46 ] 48 47 }); }; 49 48 50 - export const parentModelWithDatesMutation: UseMutationOptions<ParentModelWithDatesResponse, ParentModelWithDatesError, Options> = { 49 + export const parentModelWithDatesMutation = () => { const mutationOptions: UseMutationOptions<ParentModelWithDatesResponse, ParentModelWithDatesError, Options> = { 51 50 mutationFn: async (options) => { 52 51 const { data } = await parentModelWithDates({ 53 52 ...options, ··· 55 54 }); 56 55 return data; 57 56 } 58 - }; 57 + }; return mutationOptions; }; 59 58 60 - export const modelWithDatesMutation: UseMutationOptions<ModelWithDatesResponse, ModelWithDatesError, Options> = { 59 + export const modelWithDatesMutation = () => { const mutationOptions: UseMutationOptions<ModelWithDatesResponse, ModelWithDatesError, Options> = { 61 60 mutationFn: async (options) => { 62 61 const { data } = await modelWithDates({ 63 62 ...options, ··· 65 64 }); 66 65 return data; 67 66 } 68 - }; 67 + }; return mutationOptions; }; 69 68 70 - export const modelWithDatesArrayMutation: UseMutationOptions<ModelWithDatesArrayResponse, ModelWithDatesArrayError, Options> = { 69 + export const modelWithDatesArrayMutation = () => { const mutationOptions: UseMutationOptions<ModelWithDatesArrayResponse, ModelWithDatesArrayError, Options> = { 71 70 mutationFn: async (options) => { 72 71 const { data } = await modelWithDatesArray({ 73 72 ...options, ··· 75 74 }); 76 75 return data; 77 76 } 78 - }; 77 + }; return mutationOptions; }; 79 78 80 - export const arrayOfDatesMutation: UseMutationOptions<ArrayOfDatesResponse, ArrayOfDatesError, Options> = { 79 + export const arrayOfDatesMutation = () => { const mutationOptions: UseMutationOptions<ArrayOfDatesResponse, ArrayOfDatesError, Options> = { 81 80 mutationFn: async (options) => { 82 81 const { data } = await arrayOfDates({ 83 82 ...options, ··· 85 84 }); 86 85 return data; 87 86 } 88 - }; 87 + }; return mutationOptions; }; 89 88 90 - export const dateMutation: UseMutationOptions<DateResponse, DateError, Options> = { 89 + export const dateMutation = () => { const mutationOptions: UseMutationOptions<DateResponse, DateError, Options> = { 91 90 mutationFn: async (options) => { 92 91 const { data } = await date({ 93 92 ...options, ··· 95 94 }); 96 95 return data; 97 96 } 98 - }; 97 + }; return mutationOptions; }; 99 98 100 - export const multipleResponsesMutation: UseMutationOptions<MultipleResponsesResponse, MultipleResponsesError, Options> = { 99 + export const multipleResponsesMutation = () => { const mutationOptions: UseMutationOptions<MultipleResponsesResponse, MultipleResponsesError, Options> = { 101 100 mutationFn: async (options) => { 102 101 const { data } = await multipleResponses({ 103 102 ...options, ··· 105 104 }); 106 105 return data; 107 106 } 108 - }; 107 + }; return mutationOptions; };
+152 -258
packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-fetch-plugin-tanstack-solid-query/@tanstack/solid-query.gen.ts.snap
··· 2 2 3 3 import type { Options } from '@hey-api/client-fetch'; 4 4 import { queryOptions, type MutationOptions, type DefaultError, infiniteQueryOptions, type InfiniteData } from '@tanstack/solid-query'; 5 - import { export_, import_, apiVVersionOdataControllerCount, getCallWithoutParametersAndResponse, putCallWithoutParametersAndResponse, postCallWithoutParametersAndResponse, deleteCallWithoutParametersAndResponse, patchCallWithoutParametersAndResponse, deleteFoo, callWithDescriptions, deprecatedCall, callWithParameters, callWithWeirdParameterNames, getCallWithOptionalParam, postCallWithOptionalParam, postApiVbyApiVersionRequestBody, postApiVbyApiVersionFormData, callWithDefaultParameters, callWithDefaultOptionalParameters, callToTestOrderOfParams, duplicateName, duplicateName1, duplicateName2, duplicateName3, callWithNoContentResponse, callWithResponseAndNoContentResponse, dummyA, dummyB, callWithResponse, callWithDuplicateResponses, callWithResponses, collectionFormat, types, uploadFile, fileResponse, complexTypes, multipartRequest, multipartResponse, complexParams, callWithResultFromHeader, testErrorCode, nonAsciiæøåÆøÅöôêÊ字符串, putWithFormUrlEncoded } from '../services.gen'; 5 + import { client, export_, import_, apiVVersionOdataControllerCount, getCallWithoutParametersAndResponse, putCallWithoutParametersAndResponse, postCallWithoutParametersAndResponse, deleteCallWithoutParametersAndResponse, patchCallWithoutParametersAndResponse, deleteFoo, callWithDescriptions, deprecatedCall, callWithParameters, callWithWeirdParameterNames, getCallWithOptionalParam, postCallWithOptionalParam, postApiVbyApiVersionRequestBody, postApiVbyApiVersionFormData, callWithDefaultParameters, callWithDefaultOptionalParameters, callToTestOrderOfParams, duplicateName, duplicateName1, duplicateName2, duplicateName3, callWithNoContentResponse, callWithResponseAndNoContentResponse, dummyA, dummyB, callWithResponse, callWithDuplicateResponses, callWithResponses, collectionFormat, types, uploadFile, fileResponse, complexTypes, multipartRequest, multipartResponse, complexParams, callWithResultFromHeader, testErrorCode, nonAsciiæøåÆøÅöôêÊ字符串, putWithFormUrlEncoded } from '../services.gen'; 6 6 import type { ImportData, ImportError, ImportResponse, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamError, PostCallWithOptionalParamResponse, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, UploadFileData, UploadFileError, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartRequestData, ComplexParamsData, ComplexParamsError, ComplexParamsResponse, CallWithResultFromHeaderError, CallWithResultFromHeaderResponse, TestErrorCodeData, TestErrorCodeError, TestErrorCodeResponse, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Error, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; 7 7 8 8 type QueryKey<TOptions extends Options> = [ 9 - { 9 + Pick<TOptions, 'baseUrl' | 'body' | 'headers' | 'path' | 'query'> & { 10 + _id: string; 10 11 infinite?: boolean; 11 - params: Pick<TOptions, "body" | "headers" | "path" | "query">; 12 - scope: string; 13 12 } 14 13 ]; 15 14 16 - const createQueryKeyParams = <TOptions extends Options>(options?: TOptions): QueryKey<TOptions>[0]["params"] => { 17 - const params: QueryKey<TOptions>[0]["params"] = {} as QueryKey<TOptions>[0]["params"]; 15 + const createQueryKey = <TOptions extends Options>(id: string, options?: TOptions, infinite?: boolean): QueryKey<TOptions>[0] => { 16 + const params: QueryKey<TOptions>[0] = { _id: id, baseUrl: client.getConfig().baseUrl } as QueryKey<TOptions>[0]; 17 + if (infinite) { 18 + params.infinite = infinite; 19 + } 18 20 if (options?.body) { 19 21 params.body = options.body; 20 22 } ··· 34 36 queryFn: async ({ queryKey }) => { 35 37 const { data } = await export_({ 36 38 ...options, 37 - ...queryKey[0].params, 39 + ...queryKey[0], 38 40 throwOnError: true 39 41 }); 40 42 return data; 41 43 }, 42 44 queryKey: [ 43 - { 44 - params: createQueryKeyParams(options), 45 - scope: 'export' 46 - } 45 + createQueryKey("export", options) 47 46 ] 48 47 }); }; 49 48 ··· 51 50 queryFn: async ({ queryKey }) => { 52 51 const { data } = await import_({ 53 52 ...options, 54 - ...queryKey[0].params, 53 + ...queryKey[0], 55 54 throwOnError: true 56 55 }); 57 56 return data; 58 57 }, 59 58 queryKey: [ 60 - { 61 - params: createQueryKeyParams(options), 62 - scope: 'import' 63 - } 59 + createQueryKey("import", options) 64 60 ] 65 61 }); }; 66 62 67 - export const importMutation: MutationOptions<ImportResponse, ImportError, Options<ImportData>> = { 63 + export const importMutation = () => { const mutationOptions: MutationOptions<ImportResponse, ImportError, Options<ImportData>> = { 68 64 mutationFn: async (options) => { 69 65 const { data } = await import_({ 70 66 ...options, ··· 72 68 }); 73 69 return data; 74 70 } 75 - }; 71 + }; return mutationOptions; }; 76 72 77 73 export const apiVVersionOdataControllerCountOptions = (options?: Options) => { return queryOptions({ 78 74 queryFn: async ({ queryKey }) => { 79 75 const { data } = await apiVVersionOdataControllerCount({ 80 76 ...options, 81 - ...queryKey[0].params, 77 + ...queryKey[0], 82 78 throwOnError: true 83 79 }); 84 80 return data; 85 81 }, 86 82 queryKey: [ 87 - { 88 - params: createQueryKeyParams(options), 89 - scope: 'apiVVersionOdataControllerCount' 90 - } 83 + createQueryKey("apiVVersionOdataControllerCount", options) 91 84 ] 92 85 }); }; 93 86 ··· 95 88 queryFn: async ({ queryKey }) => { 96 89 const { data } = await getCallWithoutParametersAndResponse({ 97 90 ...options, 98 - ...queryKey[0].params, 91 + ...queryKey[0], 99 92 throwOnError: true 100 93 }); 101 94 return data; 102 95 }, 103 96 queryKey: [ 104 - { 105 - params: createQueryKeyParams(options), 106 - scope: 'getCallWithoutParametersAndResponse' 107 - } 97 + createQueryKey("getCallWithoutParametersAndResponse", options) 108 98 ] 109 99 }); }; 110 100 111 - export const putCallWithoutParametersAndResponseMutation: MutationOptions<void, DefaultError, Options> = { 101 + export const putCallWithoutParametersAndResponseMutation = () => { const mutationOptions: MutationOptions<void, DefaultError, Options> = { 112 102 mutationFn: async (options) => { 113 103 const { data } = await putCallWithoutParametersAndResponse({ 114 104 ...options, ··· 116 106 }); 117 107 return data; 118 108 } 119 - }; 109 + }; return mutationOptions; }; 120 110 121 111 export const postCallWithoutParametersAndResponseOptions = (options?: Options) => { return queryOptions({ 122 112 queryFn: async ({ queryKey }) => { 123 113 const { data } = await postCallWithoutParametersAndResponse({ 124 114 ...options, 125 - ...queryKey[0].params, 115 + ...queryKey[0], 126 116 throwOnError: true 127 117 }); 128 118 return data; 129 119 }, 130 120 queryKey: [ 131 - { 132 - params: createQueryKeyParams(options), 133 - scope: 'postCallWithoutParametersAndResponse' 134 - } 121 + createQueryKey("postCallWithoutParametersAndResponse", options) 135 122 ] 136 123 }); }; 137 124 138 - export const postCallWithoutParametersAndResponseMutation: MutationOptions<void, DefaultError, Options> = { 125 + export const postCallWithoutParametersAndResponseMutation = () => { const mutationOptions: MutationOptions<void, DefaultError, Options> = { 139 126 mutationFn: async (options) => { 140 127 const { data } = await postCallWithoutParametersAndResponse({ 141 128 ...options, ··· 143 130 }); 144 131 return data; 145 132 } 146 - }; 133 + }; return mutationOptions; }; 147 134 148 - export const deleteCallWithoutParametersAndResponseMutation: MutationOptions<void, DefaultError, Options> = { 135 + export const deleteCallWithoutParametersAndResponseMutation = () => { const mutationOptions: MutationOptions<void, DefaultError, Options> = { 149 136 mutationFn: async (options) => { 150 137 const { data } = await deleteCallWithoutParametersAndResponse({ 151 138 ...options, ··· 153 140 }); 154 141 return data; 155 142 } 156 - }; 143 + }; return mutationOptions; }; 157 144 158 - export const patchCallWithoutParametersAndResponseMutation: MutationOptions<void, DefaultError, Options> = { 145 + export const patchCallWithoutParametersAndResponseMutation = () => { const mutationOptions: MutationOptions<void, DefaultError, Options> = { 159 146 mutationFn: async (options) => { 160 147 const { data } = await patchCallWithoutParametersAndResponse({ 161 148 ...options, ··· 163 150 }); 164 151 return data; 165 152 } 166 - }; 153 + }; return mutationOptions; }; 167 154 168 - export const deleteFooMutation: MutationOptions<void, DefaultError, Options<DeleteFooData3>> = { 155 + export const deleteFooMutation = () => { const mutationOptions: MutationOptions<void, DefaultError, Options<DeleteFooData3>> = { 169 156 mutationFn: async (options) => { 170 157 const { data } = await deleteFoo({ 171 158 ...options, ··· 173 160 }); 174 161 return data; 175 162 } 176 - }; 163 + }; return mutationOptions; }; 177 164 178 165 export const callWithDescriptionsOptions = (options?: Options<CallWithDescriptionsData>) => { return queryOptions({ 179 166 queryFn: async ({ queryKey }) => { 180 167 const { data } = await callWithDescriptions({ 181 168 ...options, 182 - ...queryKey[0].params, 169 + ...queryKey[0], 183 170 throwOnError: true 184 171 }); 185 172 return data; 186 173 }, 187 174 queryKey: [ 188 - { 189 - params: createQueryKeyParams(options), 190 - scope: 'callWithDescriptions' 191 - } 175 + createQueryKey("callWithDescriptions", options) 192 176 ] 193 177 }); }; 194 178 195 - export const callWithDescriptionsMutation: MutationOptions<void, DefaultError, Options<CallWithDescriptionsData>> = { 179 + export const callWithDescriptionsMutation = () => { const mutationOptions: MutationOptions<void, DefaultError, Options<CallWithDescriptionsData>> = { 196 180 mutationFn: async (options) => { 197 181 const { data } = await callWithDescriptions({ 198 182 ...options, ··· 200 184 }); 201 185 return data; 202 186 } 203 - }; 187 + }; return mutationOptions; }; 204 188 205 189 export const deprecatedCallOptions = (options: Options<DeprecatedCallData>) => { return queryOptions({ 206 190 queryFn: async ({ queryKey }) => { 207 191 const { data } = await deprecatedCall({ 208 192 ...options, 209 - ...queryKey[0].params, 193 + ...queryKey[0], 210 194 throwOnError: true 211 195 }); 212 196 return data; 213 197 }, 214 198 queryKey: [ 215 - { 216 - params: createQueryKeyParams(options), 217 - scope: 'deprecatedCall' 218 - } 199 + createQueryKey("deprecatedCall", options) 219 200 ] 220 201 }); }; 221 202 222 - export const deprecatedCallMutation: MutationOptions<void, DefaultError, Options<DeprecatedCallData>> = { 203 + export const deprecatedCallMutation = () => { const mutationOptions: MutationOptions<void, DefaultError, Options<DeprecatedCallData>> = { 223 204 mutationFn: async (options) => { 224 205 const { data } = await deprecatedCall({ 225 206 ...options, ··· 227 208 }); 228 209 return data; 229 210 } 230 - }; 211 + }; return mutationOptions; }; 231 212 232 213 export const callWithParametersOptions = (options: Options<CallWithParametersData>) => { return queryOptions({ 233 214 queryFn: async ({ queryKey }) => { 234 215 const { data } = await callWithParameters({ 235 216 ...options, 236 - ...queryKey[0].params, 217 + ...queryKey[0], 237 218 throwOnError: true 238 219 }); 239 220 return data; 240 221 }, 241 222 queryKey: [ 242 - { 243 - params: createQueryKeyParams(options), 244 - scope: 'callWithParameters' 245 - } 223 + createQueryKey("callWithParameters", options) 246 224 ] 247 225 }); }; 248 226 249 - export const callWithParametersInfiniteOptions = (options: Options<CallWithParametersData>) => { return infiniteQueryOptions<void, DefaultError, InfiniteData<void>, QueryKey<Options<CallWithParametersData>>, string | QueryKey<Options<CallWithParametersData>>[0]['params']>( 227 + export const callWithParametersInfiniteOptions = (options: Options<CallWithParametersData>) => { return infiniteQueryOptions<void, DefaultError, InfiniteData<void>, QueryKey<Options<CallWithParametersData>>, string | QueryKey<Options<CallWithParametersData>>[0]>( 250 228 // @ts-ignore 251 229 { 252 230 queryFn: async ({ pageParam, queryKey }) => { 253 231 // @ts-ignore 254 - const page: QueryKey<Options<CallWithParametersData>>[0]['params'] = typeof pageParam === "object" ? pageParam : { 232 + const page: QueryKey<Options<CallWithParametersData>>[0] = typeof pageParam === "object" ? pageParam : { 255 233 query: { 256 234 cursor: pageParam 257 235 } ··· 259 237 const { data } = await callWithParameters({ 260 238 ...options, 261 239 body: { 262 - ...queryKey[0].params.body as any, 240 + ...queryKey[0].body as any, 263 241 ...page.body as any 264 242 }, 265 243 headers: { 266 - ...queryKey[0].params.headers, 244 + ...queryKey[0].headers, 267 245 ...page.headers 268 246 }, 269 247 path: { 270 - ...queryKey[0].params.path, 248 + ...queryKey[0].path, 271 249 ...page.path 272 250 }, 273 251 query: { 274 - ...queryKey[0].params.query, 252 + ...queryKey[0].query, 275 253 ...page.query 276 254 }, 255 + baseUrl: client.getConfig().baseUrl, 277 256 throwOnError: true 278 257 }); 279 258 return data; 280 259 }, 281 260 queryKey: [ 282 - { 283 - infinite: true, 284 - params: createQueryKeyParams(options), 285 - scope: 'callWithParameters' 286 - } 261 + createQueryKey("callWithParameters", options, true) 287 262 ] 288 263 }); }; 289 264 290 - export const callWithParametersMutation: MutationOptions<void, DefaultError, Options<CallWithParametersData>> = { 265 + export const callWithParametersMutation = () => { const mutationOptions: MutationOptions<void, DefaultError, Options<CallWithParametersData>> = { 291 266 mutationFn: async (options) => { 292 267 const { data } = await callWithParameters({ 293 268 ...options, ··· 295 270 }); 296 271 return data; 297 272 } 298 - }; 273 + }; return mutationOptions; }; 299 274 300 275 export const callWithWeirdParameterNamesOptions = (options: Options<CallWithWeirdParameterNamesData>) => { return queryOptions({ 301 276 queryFn: async ({ queryKey }) => { 302 277 const { data } = await callWithWeirdParameterNames({ 303 278 ...options, 304 - ...queryKey[0].params, 279 + ...queryKey[0], 305 280 throwOnError: true 306 281 }); 307 282 return data; 308 283 }, 309 284 queryKey: [ 310 - { 311 - params: createQueryKeyParams(options), 312 - scope: 'callWithWeirdParameterNames' 313 - } 285 + createQueryKey("callWithWeirdParameterNames", options) 314 286 ] 315 287 }); }; 316 288 317 - export const callWithWeirdParameterNamesMutation: MutationOptions<void, DefaultError, Options<CallWithWeirdParameterNamesData>> = { 289 + export const callWithWeirdParameterNamesMutation = () => { const mutationOptions: MutationOptions<void, DefaultError, Options<CallWithWeirdParameterNamesData>> = { 318 290 mutationFn: async (options) => { 319 291 const { data } = await callWithWeirdParameterNames({ 320 292 ...options, ··· 322 294 }); 323 295 return data; 324 296 } 325 - }; 297 + }; return mutationOptions; }; 326 298 327 299 export const getCallWithOptionalParamOptions = (options: Options<GetCallWithOptionalParamData>) => { return queryOptions({ 328 300 queryFn: async ({ queryKey }) => { 329 301 const { data } = await getCallWithOptionalParam({ 330 302 ...options, 331 - ...queryKey[0].params, 303 + ...queryKey[0], 332 304 throwOnError: true 333 305 }); 334 306 return data; 335 307 }, 336 308 queryKey: [ 337 - { 338 - params: createQueryKeyParams(options), 339 - scope: 'getCallWithOptionalParam' 340 - } 309 + createQueryKey("getCallWithOptionalParam", options) 341 310 ] 342 311 }); }; 343 312 344 - export const getCallWithOptionalParamInfiniteOptions = (options: Options<GetCallWithOptionalParamData>) => { return infiniteQueryOptions<void, DefaultError, InfiniteData<void>, QueryKey<Options<GetCallWithOptionalParamData>>, number | QueryKey<Options<GetCallWithOptionalParamData>>[0]['params']>( 313 + export const getCallWithOptionalParamInfiniteOptions = (options: Options<GetCallWithOptionalParamData>) => { return infiniteQueryOptions<void, DefaultError, InfiniteData<void>, QueryKey<Options<GetCallWithOptionalParamData>>, number | QueryKey<Options<GetCallWithOptionalParamData>>[0]>( 345 314 // @ts-ignore 346 315 { 347 316 queryFn: async ({ pageParam, queryKey }) => { 348 317 // @ts-ignore 349 - const page: QueryKey<Options<GetCallWithOptionalParamData>>[0]['params'] = typeof pageParam === "object" ? pageParam : { 318 + const page: QueryKey<Options<GetCallWithOptionalParamData>>[0] = typeof pageParam === "object" ? pageParam : { 350 319 query: { 351 320 page: pageParam 352 321 } ··· 354 323 const { data } = await getCallWithOptionalParam({ 355 324 ...options, 356 325 body: { 357 - ...queryKey[0].params.body as any, 326 + ...queryKey[0].body as any, 358 327 ...page.body as any 359 328 }, 360 329 headers: { 361 - ...queryKey[0].params.headers, 330 + ...queryKey[0].headers, 362 331 ...page.headers 363 332 }, 364 333 path: { 365 - ...queryKey[0].params.path, 334 + ...queryKey[0].path, 366 335 ...page.path 367 336 }, 368 337 query: { 369 - ...queryKey[0].params.query, 338 + ...queryKey[0].query, 370 339 ...page.query 371 340 }, 341 + baseUrl: client.getConfig().baseUrl, 372 342 throwOnError: true 373 343 }); 374 344 return data; 375 345 }, 376 346 queryKey: [ 377 - { 378 - infinite: true, 379 - params: createQueryKeyParams(options), 380 - scope: 'getCallWithOptionalParam' 381 - } 347 + createQueryKey("getCallWithOptionalParam", options, true) 382 348 ] 383 349 }); }; 384 350 ··· 386 352 queryFn: async ({ queryKey }) => { 387 353 const { data } = await postCallWithOptionalParam({ 388 354 ...options, 389 - ...queryKey[0].params, 355 + ...queryKey[0], 390 356 throwOnError: true 391 357 }); 392 358 return data; 393 359 }, 394 360 queryKey: [ 395 - { 396 - params: createQueryKeyParams(options), 397 - scope: 'postCallWithOptionalParam' 398 - } 361 + createQueryKey("postCallWithOptionalParam", options) 399 362 ] 400 363 }); }; 401 364 402 - export const postCallWithOptionalParamInfiniteOptions = (options: Options<PostCallWithOptionalParamData>) => { return infiniteQueryOptions<PostCallWithOptionalParamResponse, PostCallWithOptionalParamError, InfiniteData<PostCallWithOptionalParamResponse>, QueryKey<Options<PostCallWithOptionalParamData>>, number | QueryKey<Options<PostCallWithOptionalParamData>>[0]['params']>( 365 + export const postCallWithOptionalParamInfiniteOptions = (options: Options<PostCallWithOptionalParamData>) => { return infiniteQueryOptions<PostCallWithOptionalParamResponse, PostCallWithOptionalParamError, InfiniteData<PostCallWithOptionalParamResponse>, QueryKey<Options<PostCallWithOptionalParamData>>, number | QueryKey<Options<PostCallWithOptionalParamData>>[0]>( 403 366 // @ts-ignore 404 367 { 405 368 queryFn: async ({ pageParam, queryKey }) => { 406 369 // @ts-ignore 407 - const page: QueryKey<Options<PostCallWithOptionalParamData>>[0]['params'] = typeof pageParam === "object" ? pageParam : { 370 + const page: QueryKey<Options<PostCallWithOptionalParamData>>[0] = typeof pageParam === "object" ? pageParam : { 408 371 body: { 409 372 offset: pageParam 410 373 } ··· 412 375 const { data } = await postCallWithOptionalParam({ 413 376 ...options, 414 377 body: { 415 - ...queryKey[0].params.body as any, 378 + ...queryKey[0].body as any, 416 379 ...page.body as any 417 380 }, 418 381 headers: { 419 - ...queryKey[0].params.headers, 382 + ...queryKey[0].headers, 420 383 ...page.headers 421 384 }, 422 385 path: { 423 - ...queryKey[0].params.path, 386 + ...queryKey[0].path, 424 387 ...page.path 425 388 }, 426 389 query: { 427 - ...queryKey[0].params.query, 390 + ...queryKey[0].query, 428 391 ...page.query 429 392 }, 393 + baseUrl: client.getConfig().baseUrl, 430 394 throwOnError: true 431 395 }); 432 396 return data; 433 397 }, 434 398 queryKey: [ 435 - { 436 - infinite: true, 437 - params: createQueryKeyParams(options), 438 - scope: 'postCallWithOptionalParam' 439 - } 399 + createQueryKey("postCallWithOptionalParam", options, true) 440 400 ] 441 401 }); }; 442 402 443 - export const postCallWithOptionalParamMutation: MutationOptions<PostCallWithOptionalParamResponse, PostCallWithOptionalParamError, Options<PostCallWithOptionalParamData>> = { 403 + export const postCallWithOptionalParamMutation = () => { const mutationOptions: MutationOptions<PostCallWithOptionalParamResponse, PostCallWithOptionalParamError, Options<PostCallWithOptionalParamData>> = { 444 404 mutationFn: async (options) => { 445 405 const { data } = await postCallWithOptionalParam({ 446 406 ...options, ··· 448 408 }); 449 409 return data; 450 410 } 451 - }; 411 + }; return mutationOptions; }; 452 412 453 413 export const postApiVbyApiVersionRequestBodyOptions = (options?: Options<PostApiVbyApiVersionRequestBodyData>) => { return queryOptions({ 454 414 queryFn: async ({ queryKey }) => { 455 415 const { data } = await postApiVbyApiVersionRequestBody({ 456 416 ...options, 457 - ...queryKey[0].params, 417 + ...queryKey[0], 458 418 throwOnError: true 459 419 }); 460 420 return data; 461 421 }, 462 422 queryKey: [ 463 - { 464 - params: createQueryKeyParams(options), 465 - scope: 'postApiVbyApiVersionRequestBody' 466 - } 423 + createQueryKey("postApiVbyApiVersionRequestBody", options) 467 424 ] 468 425 }); }; 469 426 470 - export const postApiVbyApiVersionRequestBodyMutation: MutationOptions<void, DefaultError, Options<PostApiVbyApiVersionRequestBodyData>> = { 427 + export const postApiVbyApiVersionRequestBodyMutation = () => { const mutationOptions: MutationOptions<void, DefaultError, Options<PostApiVbyApiVersionRequestBodyData>> = { 471 428 mutationFn: async (options) => { 472 429 const { data } = await postApiVbyApiVersionRequestBody({ 473 430 ...options, ··· 475 432 }); 476 433 return data; 477 434 } 478 - }; 435 + }; return mutationOptions; }; 479 436 480 437 export const postApiVbyApiVersionFormDataOptions = (options?: Options<PostApiVbyApiVersionFormDataData>) => { return queryOptions({ 481 438 queryFn: async ({ queryKey }) => { 482 439 const { data } = await postApiVbyApiVersionFormData({ 483 440 ...options, 484 - ...queryKey[0].params, 441 + ...queryKey[0], 485 442 throwOnError: true 486 443 }); 487 444 return data; 488 445 }, 489 446 queryKey: [ 490 - { 491 - params: createQueryKeyParams(options), 492 - scope: 'postApiVbyApiVersionFormData' 493 - } 447 + createQueryKey("postApiVbyApiVersionFormData", options) 494 448 ] 495 449 }); }; 496 450 497 - export const postApiVbyApiVersionFormDataMutation: MutationOptions<void, DefaultError, Options<PostApiVbyApiVersionFormDataData>> = { 451 + export const postApiVbyApiVersionFormDataMutation = () => { const mutationOptions: MutationOptions<void, DefaultError, Options<PostApiVbyApiVersionFormDataData>> = { 498 452 mutationFn: async (options) => { 499 453 const { data } = await postApiVbyApiVersionFormData({ 500 454 ...options, ··· 502 456 }); 503 457 return data; 504 458 } 505 - }; 459 + }; return mutationOptions; }; 506 460 507 461 export const callWithDefaultParametersOptions = (options?: Options<CallWithDefaultParametersData>) => { return queryOptions({ 508 462 queryFn: async ({ queryKey }) => { 509 463 const { data } = await callWithDefaultParameters({ 510 464 ...options, 511 - ...queryKey[0].params, 465 + ...queryKey[0], 512 466 throwOnError: true 513 467 }); 514 468 return data; 515 469 }, 516 470 queryKey: [ 517 - { 518 - params: createQueryKeyParams(options), 519 - scope: 'callWithDefaultParameters' 520 - } 471 + createQueryKey("callWithDefaultParameters", options) 521 472 ] 522 473 }); }; 523 474 ··· 525 476 queryFn: async ({ queryKey }) => { 526 477 const { data } = await callWithDefaultOptionalParameters({ 527 478 ...options, 528 - ...queryKey[0].params, 479 + ...queryKey[0], 529 480 throwOnError: true 530 481 }); 531 482 return data; 532 483 }, 533 484 queryKey: [ 534 - { 535 - params: createQueryKeyParams(options), 536 - scope: 'callWithDefaultOptionalParameters' 537 - } 485 + createQueryKey("callWithDefaultOptionalParameters", options) 538 486 ] 539 487 }); }; 540 488 541 - export const callWithDefaultOptionalParametersMutation: MutationOptions<void, DefaultError, Options<CallWithDefaultOptionalParametersData>> = { 489 + export const callWithDefaultOptionalParametersMutation = () => { const mutationOptions: MutationOptions<void, DefaultError, Options<CallWithDefaultOptionalParametersData>> = { 542 490 mutationFn: async (options) => { 543 491 const { data } = await callWithDefaultOptionalParameters({ 544 492 ...options, ··· 546 494 }); 547 495 return data; 548 496 } 549 - }; 497 + }; return mutationOptions; }; 550 498 551 - export const callToTestOrderOfParamsMutation: MutationOptions<void, DefaultError, Options<CallToTestOrderOfParamsData>> = { 499 + export const callToTestOrderOfParamsMutation = () => { const mutationOptions: MutationOptions<void, DefaultError, Options<CallToTestOrderOfParamsData>> = { 552 500 mutationFn: async (options) => { 553 501 const { data } = await callToTestOrderOfParams({ 554 502 ...options, ··· 556 504 }); 557 505 return data; 558 506 } 559 - }; 507 + }; return mutationOptions; }; 560 508 561 509 export const duplicateNameOptions = (options?: Options) => { return queryOptions({ 562 510 queryFn: async ({ queryKey }) => { 563 511 const { data } = await duplicateName({ 564 512 ...options, 565 - ...queryKey[0].params, 513 + ...queryKey[0], 566 514 throwOnError: true 567 515 }); 568 516 return data; 569 517 }, 570 518 queryKey: [ 571 - { 572 - params: createQueryKeyParams(options), 573 - scope: 'duplicateName' 574 - } 519 + createQueryKey("duplicateName", options) 575 520 ] 576 521 }); }; 577 522 ··· 579 524 queryFn: async ({ queryKey }) => { 580 525 const { data } = await duplicateName1({ 581 526 ...options, 582 - ...queryKey[0].params, 527 + ...queryKey[0], 583 528 throwOnError: true 584 529 }); 585 530 return data; 586 531 }, 587 532 queryKey: [ 588 - { 589 - params: createQueryKeyParams(options), 590 - scope: 'duplicateName1' 591 - } 533 + createQueryKey("duplicateName1", options) 592 534 ] 593 535 }); }; 594 536 595 - export const duplicateName1Mutation: MutationOptions<void, DefaultError, Options> = { 537 + export const duplicateName1Mutation = () => { const mutationOptions: MutationOptions<void, DefaultError, Options> = { 596 538 mutationFn: async (options) => { 597 539 const { data } = await duplicateName1({ 598 540 ...options, ··· 600 542 }); 601 543 return data; 602 544 } 603 - }; 545 + }; return mutationOptions; }; 604 546 605 - export const duplicateName2Mutation: MutationOptions<void, DefaultError, Options> = { 547 + export const duplicateName2Mutation = () => { const mutationOptions: MutationOptions<void, DefaultError, Options> = { 606 548 mutationFn: async (options) => { 607 549 const { data } = await duplicateName2({ 608 550 ...options, ··· 610 552 }); 611 553 return data; 612 554 } 613 - }; 555 + }; return mutationOptions; }; 614 556 615 - export const duplicateName3Mutation: MutationOptions<void, DefaultError, Options> = { 557 + export const duplicateName3Mutation = () => { const mutationOptions: MutationOptions<void, DefaultError, Options> = { 616 558 mutationFn: async (options) => { 617 559 const { data } = await duplicateName3({ 618 560 ...options, ··· 620 562 }); 621 563 return data; 622 564 } 623 - }; 565 + }; return mutationOptions; }; 624 566 625 567 export const callWithNoContentResponseOptions = (options?: Options) => { return queryOptions({ 626 568 queryFn: async ({ queryKey }) => { 627 569 const { data } = await callWithNoContentResponse({ 628 570 ...options, 629 - ...queryKey[0].params, 571 + ...queryKey[0], 630 572 throwOnError: true 631 573 }); 632 574 return data; 633 575 }, 634 576 queryKey: [ 635 - { 636 - params: createQueryKeyParams(options), 637 - scope: 'callWithNoContentResponse' 638 - } 577 + createQueryKey("callWithNoContentResponse", options) 639 578 ] 640 579 }); }; 641 580 ··· 643 582 queryFn: async ({ queryKey }) => { 644 583 const { data } = await callWithResponseAndNoContentResponse({ 645 584 ...options, 646 - ...queryKey[0].params, 585 + ...queryKey[0], 647 586 throwOnError: true 648 587 }); 649 588 return data; 650 589 }, 651 590 queryKey: [ 652 - { 653 - params: createQueryKeyParams(options), 654 - scope: 'callWithResponseAndNoContentResponse' 655 - } 591 + createQueryKey("callWithResponseAndNoContentResponse", options) 656 592 ] 657 593 }); }; 658 594 ··· 660 596 queryFn: async ({ queryKey }) => { 661 597 const { data } = await dummyA({ 662 598 ...options, 663 - ...queryKey[0].params, 599 + ...queryKey[0], 664 600 throwOnError: true 665 601 }); 666 602 return data; 667 603 }, 668 604 queryKey: [ 669 - { 670 - params: createQueryKeyParams(options), 671 - scope: 'dummyA' 672 - } 605 + createQueryKey("dummyA", options) 673 606 ] 674 607 }); }; 675 608 ··· 677 610 queryFn: async ({ queryKey }) => { 678 611 const { data } = await dummyB({ 679 612 ...options, 680 - ...queryKey[0].params, 613 + ...queryKey[0], 681 614 throwOnError: true 682 615 }); 683 616 return data; 684 617 }, 685 618 queryKey: [ 686 - { 687 - params: createQueryKeyParams(options), 688 - scope: 'dummyB' 689 - } 619 + createQueryKey("dummyB", options) 690 620 ] 691 621 }); }; 692 622 ··· 694 624 queryFn: async ({ queryKey }) => { 695 625 const { data } = await callWithResponse({ 696 626 ...options, 697 - ...queryKey[0].params, 627 + ...queryKey[0], 698 628 throwOnError: true 699 629 }); 700 630 return data; 701 631 }, 702 632 queryKey: [ 703 - { 704 - params: createQueryKeyParams(options), 705 - scope: 'callWithResponse' 706 - } 633 + createQueryKey("callWithResponse", options) 707 634 ] 708 635 }); }; 709 636 ··· 711 638 queryFn: async ({ queryKey }) => { 712 639 const { data } = await callWithDuplicateResponses({ 713 640 ...options, 714 - ...queryKey[0].params, 641 + ...queryKey[0], 715 642 throwOnError: true 716 643 }); 717 644 return data; 718 645 }, 719 646 queryKey: [ 720 - { 721 - params: createQueryKeyParams(options), 722 - scope: 'callWithDuplicateResponses' 723 - } 647 + createQueryKey("callWithDuplicateResponses", options) 724 648 ] 725 649 }); }; 726 650 727 - export const callWithDuplicateResponsesMutation: MutationOptions<CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesError, Options> = { 651 + export const callWithDuplicateResponsesMutation = () => { const mutationOptions: MutationOptions<CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesError, Options> = { 728 652 mutationFn: async (options) => { 729 653 const { data } = await callWithDuplicateResponses({ 730 654 ...options, ··· 732 656 }); 733 657 return data; 734 658 } 735 - }; 659 + }; return mutationOptions; }; 736 660 737 - export const callWithResponsesMutation: MutationOptions<CallWithResponsesResponse, CallWithResponsesError, Options> = { 661 + export const callWithResponsesMutation = () => { const mutationOptions: MutationOptions<CallWithResponsesResponse, CallWithResponsesError, Options> = { 738 662 mutationFn: async (options) => { 739 663 const { data } = await callWithResponses({ 740 664 ...options, ··· 742 666 }); 743 667 return data; 744 668 } 745 - }; 669 + }; return mutationOptions; }; 746 670 747 671 export const collectionFormatOptions = (options: Options<CollectionFormatData>) => { return queryOptions({ 748 672 queryFn: async ({ queryKey }) => { 749 673 const { data } = await collectionFormat({ 750 674 ...options, 751 - ...queryKey[0].params, 675 + ...queryKey[0], 752 676 throwOnError: true 753 677 }); 754 678 return data; 755 679 }, 756 680 queryKey: [ 757 - { 758 - params: createQueryKeyParams(options), 759 - scope: 'collectionFormat' 760 - } 681 + createQueryKey("collectionFormat", options) 761 682 ] 762 683 }); }; 763 684 ··· 765 686 queryFn: async ({ queryKey }) => { 766 687 const { data } = await types({ 767 688 ...options, 768 - ...queryKey[0].params, 689 + ...queryKey[0], 769 690 throwOnError: true 770 691 }); 771 692 return data; 772 693 }, 773 694 queryKey: [ 774 - { 775 - params: createQueryKeyParams(options), 776 - scope: 'types' 777 - } 695 + createQueryKey("types", options) 778 696 ] 779 697 }); }; 780 698 ··· 782 700 queryFn: async ({ queryKey }) => { 783 701 const { data } = await uploadFile({ 784 702 ...options, 785 - ...queryKey[0].params, 703 + ...queryKey[0], 786 704 throwOnError: true 787 705 }); 788 706 return data; 789 707 }, 790 708 queryKey: [ 791 - { 792 - params: createQueryKeyParams(options), 793 - scope: 'uploadFile' 794 - } 709 + createQueryKey("uploadFile", options) 795 710 ] 796 711 }); }; 797 712 798 - export const uploadFileMutation: MutationOptions<UploadFileResponse, UploadFileError, Options<UploadFileData>> = { 713 + export const uploadFileMutation = () => { const mutationOptions: MutationOptions<UploadFileResponse, UploadFileError, Options<UploadFileData>> = { 799 714 mutationFn: async (options) => { 800 715 const { data } = await uploadFile({ 801 716 ...options, ··· 803 718 }); 804 719 return data; 805 720 } 806 - }; 721 + }; return mutationOptions; }; 807 722 808 723 export const fileResponseOptions = (options: Options<FileResponseData>) => { return queryOptions({ 809 724 queryFn: async ({ queryKey }) => { 810 725 const { data } = await fileResponse({ 811 726 ...options, 812 - ...queryKey[0].params, 727 + ...queryKey[0], 813 728 throwOnError: true 814 729 }); 815 730 return data; 816 731 }, 817 732 queryKey: [ 818 - { 819 - params: createQueryKeyParams(options), 820 - scope: 'fileResponse' 821 - } 733 + createQueryKey("fileResponse", options) 822 734 ] 823 735 }); }; 824 736 ··· 826 738 queryFn: async ({ queryKey }) => { 827 739 const { data } = await complexTypes({ 828 740 ...options, 829 - ...queryKey[0].params, 741 + ...queryKey[0], 830 742 throwOnError: true 831 743 }); 832 744 return data; 833 745 }, 834 746 queryKey: [ 835 - { 836 - params: createQueryKeyParams(options), 837 - scope: 'complexTypes' 838 - } 747 + createQueryKey("complexTypes", options) 839 748 ] 840 749 }); }; 841 750 ··· 843 752 queryFn: async ({ queryKey }) => { 844 753 const { data } = await multipartRequest({ 845 754 ...options, 846 - ...queryKey[0].params, 755 + ...queryKey[0], 847 756 throwOnError: true 848 757 }); 849 758 return data; 850 759 }, 851 760 queryKey: [ 852 - { 853 - params: createQueryKeyParams(options), 854 - scope: 'multipartRequest' 855 - } 761 + createQueryKey("multipartRequest", options) 856 762 ] 857 763 }); }; 858 764 859 - export const multipartRequestMutation: MutationOptions<void, DefaultError, Options<MultipartRequestData>> = { 765 + export const multipartRequestMutation = () => { const mutationOptions: MutationOptions<void, DefaultError, Options<MultipartRequestData>> = { 860 766 mutationFn: async (options) => { 861 767 const { data } = await multipartRequest({ 862 768 ...options, ··· 864 770 }); 865 771 return data; 866 772 } 867 - }; 773 + }; return mutationOptions; }; 868 774 869 775 export const multipartResponseOptions = (options?: Options) => { return queryOptions({ 870 776 queryFn: async ({ queryKey }) => { 871 777 const { data } = await multipartResponse({ 872 778 ...options, 873 - ...queryKey[0].params, 779 + ...queryKey[0], 874 780 throwOnError: true 875 781 }); 876 782 return data; 877 783 }, 878 784 queryKey: [ 879 - { 880 - params: createQueryKeyParams(options), 881 - scope: 'multipartResponse' 882 - } 785 + createQueryKey("multipartResponse", options) 883 786 ] 884 787 }); }; 885 788 886 - export const complexParamsMutation: MutationOptions<ComplexParamsResponse, ComplexParamsError, Options<ComplexParamsData>> = { 789 + export const complexParamsMutation = () => { const mutationOptions: MutationOptions<ComplexParamsResponse, ComplexParamsError, Options<ComplexParamsData>> = { 887 790 mutationFn: async (options) => { 888 791 const { data } = await complexParams({ 889 792 ...options, ··· 891 794 }); 892 795 return data; 893 796 } 894 - }; 797 + }; return mutationOptions; }; 895 798 896 799 export const callWithResultFromHeaderOptions = (options?: Options) => { return queryOptions({ 897 800 queryFn: async ({ queryKey }) => { 898 801 const { data } = await callWithResultFromHeader({ 899 802 ...options, 900 - ...queryKey[0].params, 803 + ...queryKey[0], 901 804 throwOnError: true 902 805 }); 903 806 return data; 904 807 }, 905 808 queryKey: [ 906 - { 907 - params: createQueryKeyParams(options), 908 - scope: 'callWithResultFromHeader' 909 - } 809 + createQueryKey("callWithResultFromHeader", options) 910 810 ] 911 811 }); }; 912 812 913 - export const callWithResultFromHeaderMutation: MutationOptions<CallWithResultFromHeaderResponse, CallWithResultFromHeaderError, Options> = { 813 + export const callWithResultFromHeaderMutation = () => { const mutationOptions: MutationOptions<CallWithResultFromHeaderResponse, CallWithResultFromHeaderError, Options> = { 914 814 mutationFn: async (options) => { 915 815 const { data } = await callWithResultFromHeader({ 916 816 ...options, ··· 918 818 }); 919 819 return data; 920 820 } 921 - }; 821 + }; return mutationOptions; }; 922 822 923 823 export const testErrorCodeOptions = (options: Options<TestErrorCodeData>) => { return queryOptions({ 924 824 queryFn: async ({ queryKey }) => { 925 825 const { data } = await testErrorCode({ 926 826 ...options, 927 - ...queryKey[0].params, 827 + ...queryKey[0], 928 828 throwOnError: true 929 829 }); 930 830 return data; 931 831 }, 932 832 queryKey: [ 933 - { 934 - params: createQueryKeyParams(options), 935 - scope: 'testErrorCode' 936 - } 833 + createQueryKey("testErrorCode", options) 937 834 ] 938 835 }); }; 939 836 940 - export const testErrorCodeMutation: MutationOptions<TestErrorCodeResponse, TestErrorCodeError, Options<TestErrorCodeData>> = { 837 + export const testErrorCodeMutation = () => { const mutationOptions: MutationOptions<TestErrorCodeResponse, TestErrorCodeError, Options<TestErrorCodeData>> = { 941 838 mutationFn: async (options) => { 942 839 const { data } = await testErrorCode({ 943 840 ...options, ··· 945 842 }); 946 843 return data; 947 844 } 948 - }; 845 + }; return mutationOptions; }; 949 846 950 847 export const nonAsciiæøåÆøÅöôêÊ字符串Options = (options: Options<NonAsciiæøåÆøÅöôêÊ字符串Data>) => { return queryOptions({ 951 848 queryFn: async ({ queryKey }) => { 952 849 const { data } = await nonAsciiæøåÆøÅöôêÊ字符串({ 953 850 ...options, 954 - ...queryKey[0].params, 851 + ...queryKey[0], 955 852 throwOnError: true 956 853 }); 957 854 return data; 958 855 }, 959 856 queryKey: [ 960 - { 961 - params: createQueryKeyParams(options), 962 - scope: 'nonAsciiæøåÆøÅöôêÊ字符串' 963 - } 857 + createQueryKey("nonAsciiæøåÆøÅöôêÊ字符串", options) 964 858 ] 965 859 }); }; 966 860 967 - export const nonAsciiæøåÆøÅöôêÊ字符串Mutation: MutationOptions<NonAsciiæøåÆøÅöôêÊ字符串Response, NonAsciiæøåÆøÅöôêÊ字符串Error, Options<NonAsciiæøåÆøÅöôêÊ字符串Data>> = { 861 + export const nonAsciiæøåÆøÅöôêÊ字符串Mutation = () => { const mutationOptions: MutationOptions<NonAsciiæøåÆøÅöôêÊ字符串Response, NonAsciiæøåÆøÅöôêÊ字符串Error, Options<NonAsciiæøåÆøÅöôêÊ字符串Data>> = { 968 862 mutationFn: async (options) => { 969 863 const { data } = await nonAsciiæøåÆøÅöôêÊ字符串({ 970 864 ...options, ··· 972 866 }); 973 867 return data; 974 868 } 975 - }; 869 + }; return mutationOptions; }; 976 870 977 - export const putWithFormUrlEncodedMutation: MutationOptions<void, DefaultError, Options<PutWithFormUrlEncodedData>> = { 871 + export const putWithFormUrlEncodedMutation = () => { const mutationOptions: MutationOptions<void, DefaultError, Options<PutWithFormUrlEncodedData>> = { 978 872 mutationFn: async (options) => { 979 873 const { data } = await putWithFormUrlEncoded({ 980 874 ...options, ··· 982 876 }); 983 877 return data; 984 878 } 985 - }; 879 + }; return mutationOptions; };
+22 -23
packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-fetch-plugin-tanstack-solid-query_transform/@tanstack/solid-query.gen.ts.snap
··· 3 3 import type { Options } from '@hey-api/client-fetch'; 4 4 import { queryOptions, type MutationOptions } from '@tanstack/solid-query'; 5 5 import type { ParentModelWithDatesError, ParentModelWithDatesResponse, ModelWithDatesError, ModelWithDatesResponse, ModelWithDatesArrayError, ModelWithDatesArrayResponse, ArrayOfDatesError, ArrayOfDatesResponse, DateError, DateResponse, MultipleResponsesError, MultipleResponsesResponse } from '../types.gen'; 6 - import { parentModelWithDates, modelWithDates, modelWithDatesArray, arrayOfDates, date, multipleResponses } from '../services.gen'; 6 + import { client, parentModelWithDates, modelWithDates, modelWithDatesArray, arrayOfDates, date, multipleResponses } from '../services.gen'; 7 7 8 8 type QueryKey<TOptions extends Options> = [ 9 - { 9 + Pick<TOptions, 'baseUrl' | 'body' | 'headers' | 'path' | 'query'> & { 10 + _id: string; 10 11 infinite?: boolean; 11 - params: Pick<TOptions, "body" | "headers" | "path" | "query">; 12 - scope: string; 13 12 } 14 13 ]; 15 14 16 - const createQueryKeyParams = <TOptions extends Options>(options?: TOptions): QueryKey<TOptions>[0]["params"] => { 17 - const params: QueryKey<TOptions>[0]["params"] = {} as QueryKey<TOptions>[0]["params"]; 15 + const createQueryKey = <TOptions extends Options>(id: string, options?: TOptions, infinite?: boolean): QueryKey<TOptions>[0] => { 16 + const params: QueryKey<TOptions>[0] = { _id: id, baseUrl: client.getConfig().baseUrl } as QueryKey<TOptions>[0]; 17 + if (infinite) { 18 + params.infinite = infinite; 19 + } 18 20 if (options?.body) { 19 21 params.body = options.body; 20 22 } ··· 34 36 queryFn: async ({ queryKey }) => { 35 37 const { data } = await parentModelWithDates({ 36 38 ...options, 37 - ...queryKey[0].params, 39 + ...queryKey[0], 38 40 throwOnError: true 39 41 }); 40 42 return data; 41 43 }, 42 44 queryKey: [ 43 - { 44 - params: createQueryKeyParams(options), 45 - scope: 'parentModelWithDates' 46 - } 45 + createQueryKey("parentModelWithDates", options) 47 46 ] 48 47 }); }; 49 48 50 - export const parentModelWithDatesMutation: MutationOptions<ParentModelWithDatesResponse, ParentModelWithDatesError, Options> = { 49 + export const parentModelWithDatesMutation = () => { const mutationOptions: MutationOptions<ParentModelWithDatesResponse, ParentModelWithDatesError, Options> = { 51 50 mutationFn: async (options) => { 52 51 const { data } = await parentModelWithDates({ 53 52 ...options, ··· 55 54 }); 56 55 return data; 57 56 } 58 - }; 57 + }; return mutationOptions; }; 59 58 60 - export const modelWithDatesMutation: MutationOptions<ModelWithDatesResponse, ModelWithDatesError, Options> = { 59 + export const modelWithDatesMutation = () => { const mutationOptions: MutationOptions<ModelWithDatesResponse, ModelWithDatesError, Options> = { 61 60 mutationFn: async (options) => { 62 61 const { data } = await modelWithDates({ 63 62 ...options, ··· 65 64 }); 66 65 return data; 67 66 } 68 - }; 67 + }; return mutationOptions; }; 69 68 70 - export const modelWithDatesArrayMutation: MutationOptions<ModelWithDatesArrayResponse, ModelWithDatesArrayError, Options> = { 69 + export const modelWithDatesArrayMutation = () => { const mutationOptions: MutationOptions<ModelWithDatesArrayResponse, ModelWithDatesArrayError, Options> = { 71 70 mutationFn: async (options) => { 72 71 const { data } = await modelWithDatesArray({ 73 72 ...options, ··· 75 74 }); 76 75 return data; 77 76 } 78 - }; 77 + }; return mutationOptions; }; 79 78 80 - export const arrayOfDatesMutation: MutationOptions<ArrayOfDatesResponse, ArrayOfDatesError, Options> = { 79 + export const arrayOfDatesMutation = () => { const mutationOptions: MutationOptions<ArrayOfDatesResponse, ArrayOfDatesError, Options> = { 81 80 mutationFn: async (options) => { 82 81 const { data } = await arrayOfDates({ 83 82 ...options, ··· 85 84 }); 86 85 return data; 87 86 } 88 - }; 87 + }; return mutationOptions; }; 89 88 90 - export const dateMutation: MutationOptions<DateResponse, DateError, Options> = { 89 + export const dateMutation = () => { const mutationOptions: MutationOptions<DateResponse, DateError, Options> = { 91 90 mutationFn: async (options) => { 92 91 const { data } = await date({ 93 92 ...options, ··· 95 94 }); 96 95 return data; 97 96 } 98 - }; 97 + }; return mutationOptions; }; 99 98 100 - export const multipleResponsesMutation: MutationOptions<MultipleResponsesResponse, MultipleResponsesError, Options> = { 99 + export const multipleResponsesMutation = () => { const mutationOptions: MutationOptions<MultipleResponsesResponse, MultipleResponsesError, Options> = { 101 100 mutationFn: async (options) => { 102 101 const { data } = await multipleResponses({ 103 102 ...options, ··· 105 104 }); 106 105 return data; 107 106 } 108 - }; 107 + }; return mutationOptions; };
+152 -258
packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-fetch-plugin-tanstack-svelte-query/@tanstack/svelte-query.gen.ts.snap
··· 2 2 3 3 import type { Options } from '@hey-api/client-fetch'; 4 4 import { queryOptions, type MutationOptions, type DefaultError, infiniteQueryOptions, type InfiniteData } from '@tanstack/svelte-query'; 5 - import { export_, import_, apiVVersionOdataControllerCount, getCallWithoutParametersAndResponse, putCallWithoutParametersAndResponse, postCallWithoutParametersAndResponse, deleteCallWithoutParametersAndResponse, patchCallWithoutParametersAndResponse, deleteFoo, callWithDescriptions, deprecatedCall, callWithParameters, callWithWeirdParameterNames, getCallWithOptionalParam, postCallWithOptionalParam, postApiVbyApiVersionRequestBody, postApiVbyApiVersionFormData, callWithDefaultParameters, callWithDefaultOptionalParameters, callToTestOrderOfParams, duplicateName, duplicateName1, duplicateName2, duplicateName3, callWithNoContentResponse, callWithResponseAndNoContentResponse, dummyA, dummyB, callWithResponse, callWithDuplicateResponses, callWithResponses, collectionFormat, types, uploadFile, fileResponse, complexTypes, multipartRequest, multipartResponse, complexParams, callWithResultFromHeader, testErrorCode, nonAsciiæøåÆøÅöôêÊ字符串, putWithFormUrlEncoded } from '../services.gen'; 5 + import { client, export_, import_, apiVVersionOdataControllerCount, getCallWithoutParametersAndResponse, putCallWithoutParametersAndResponse, postCallWithoutParametersAndResponse, deleteCallWithoutParametersAndResponse, patchCallWithoutParametersAndResponse, deleteFoo, callWithDescriptions, deprecatedCall, callWithParameters, callWithWeirdParameterNames, getCallWithOptionalParam, postCallWithOptionalParam, postApiVbyApiVersionRequestBody, postApiVbyApiVersionFormData, callWithDefaultParameters, callWithDefaultOptionalParameters, callToTestOrderOfParams, duplicateName, duplicateName1, duplicateName2, duplicateName3, callWithNoContentResponse, callWithResponseAndNoContentResponse, dummyA, dummyB, callWithResponse, callWithDuplicateResponses, callWithResponses, collectionFormat, types, uploadFile, fileResponse, complexTypes, multipartRequest, multipartResponse, complexParams, callWithResultFromHeader, testErrorCode, nonAsciiæøåÆøÅöôêÊ字符串, putWithFormUrlEncoded } from '../services.gen'; 6 6 import type { ImportData, ImportError, ImportResponse, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamError, PostCallWithOptionalParamResponse, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, UploadFileData, UploadFileError, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartRequestData, ComplexParamsData, ComplexParamsError, ComplexParamsResponse, CallWithResultFromHeaderError, CallWithResultFromHeaderResponse, TestErrorCodeData, TestErrorCodeError, TestErrorCodeResponse, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Error, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; 7 7 8 8 type QueryKey<TOptions extends Options> = [ 9 - { 9 + Pick<TOptions, 'baseUrl' | 'body' | 'headers' | 'path' | 'query'> & { 10 + _id: string; 10 11 infinite?: boolean; 11 - params: Pick<TOptions, "body" | "headers" | "path" | "query">; 12 - scope: string; 13 12 } 14 13 ]; 15 14 16 - const createQueryKeyParams = <TOptions extends Options>(options?: TOptions): QueryKey<TOptions>[0]["params"] => { 17 - const params: QueryKey<TOptions>[0]["params"] = {} as QueryKey<TOptions>[0]["params"]; 15 + const createQueryKey = <TOptions extends Options>(id: string, options?: TOptions, infinite?: boolean): QueryKey<TOptions>[0] => { 16 + const params: QueryKey<TOptions>[0] = { _id: id, baseUrl: client.getConfig().baseUrl } as QueryKey<TOptions>[0]; 17 + if (infinite) { 18 + params.infinite = infinite; 19 + } 18 20 if (options?.body) { 19 21 params.body = options.body; 20 22 } ··· 34 36 queryFn: async ({ queryKey }) => { 35 37 const { data } = await export_({ 36 38 ...options, 37 - ...queryKey[0].params, 39 + ...queryKey[0], 38 40 throwOnError: true 39 41 }); 40 42 return data; 41 43 }, 42 44 queryKey: [ 43 - { 44 - params: createQueryKeyParams(options), 45 - scope: 'export' 46 - } 45 + createQueryKey("export", options) 47 46 ] 48 47 }); }; 49 48 ··· 51 50 queryFn: async ({ queryKey }) => { 52 51 const { data } = await import_({ 53 52 ...options, 54 - ...queryKey[0].params, 53 + ...queryKey[0], 55 54 throwOnError: true 56 55 }); 57 56 return data; 58 57 }, 59 58 queryKey: [ 60 - { 61 - params: createQueryKeyParams(options), 62 - scope: 'import' 63 - } 59 + createQueryKey("import", options) 64 60 ] 65 61 }); }; 66 62 67 - export const importMutation: MutationOptions<ImportResponse, ImportError, Options<ImportData>> = { 63 + export const importMutation = () => { const mutationOptions: MutationOptions<ImportResponse, ImportError, Options<ImportData>> = { 68 64 mutationFn: async (options) => { 69 65 const { data } = await import_({ 70 66 ...options, ··· 72 68 }); 73 69 return data; 74 70 } 75 - }; 71 + }; return mutationOptions; }; 76 72 77 73 export const apiVVersionOdataControllerCountOptions = (options?: Options) => { return queryOptions({ 78 74 queryFn: async ({ queryKey }) => { 79 75 const { data } = await apiVVersionOdataControllerCount({ 80 76 ...options, 81 - ...queryKey[0].params, 77 + ...queryKey[0], 82 78 throwOnError: true 83 79 }); 84 80 return data; 85 81 }, 86 82 queryKey: [ 87 - { 88 - params: createQueryKeyParams(options), 89 - scope: 'apiVVersionOdataControllerCount' 90 - } 83 + createQueryKey("apiVVersionOdataControllerCount", options) 91 84 ] 92 85 }); }; 93 86 ··· 95 88 queryFn: async ({ queryKey }) => { 96 89 const { data } = await getCallWithoutParametersAndResponse({ 97 90 ...options, 98 - ...queryKey[0].params, 91 + ...queryKey[0], 99 92 throwOnError: true 100 93 }); 101 94 return data; 102 95 }, 103 96 queryKey: [ 104 - { 105 - params: createQueryKeyParams(options), 106 - scope: 'getCallWithoutParametersAndResponse' 107 - } 97 + createQueryKey("getCallWithoutParametersAndResponse", options) 108 98 ] 109 99 }); }; 110 100 111 - export const putCallWithoutParametersAndResponseMutation: MutationOptions<void, DefaultError, Options> = { 101 + export const putCallWithoutParametersAndResponseMutation = () => { const mutationOptions: MutationOptions<void, DefaultError, Options> = { 112 102 mutationFn: async (options) => { 113 103 const { data } = await putCallWithoutParametersAndResponse({ 114 104 ...options, ··· 116 106 }); 117 107 return data; 118 108 } 119 - }; 109 + }; return mutationOptions; }; 120 110 121 111 export const postCallWithoutParametersAndResponseOptions = (options?: Options) => { return queryOptions({ 122 112 queryFn: async ({ queryKey }) => { 123 113 const { data } = await postCallWithoutParametersAndResponse({ 124 114 ...options, 125 - ...queryKey[0].params, 115 + ...queryKey[0], 126 116 throwOnError: true 127 117 }); 128 118 return data; 129 119 }, 130 120 queryKey: [ 131 - { 132 - params: createQueryKeyParams(options), 133 - scope: 'postCallWithoutParametersAndResponse' 134 - } 121 + createQueryKey("postCallWithoutParametersAndResponse", options) 135 122 ] 136 123 }); }; 137 124 138 - export const postCallWithoutParametersAndResponseMutation: MutationOptions<void, DefaultError, Options> = { 125 + export const postCallWithoutParametersAndResponseMutation = () => { const mutationOptions: MutationOptions<void, DefaultError, Options> = { 139 126 mutationFn: async (options) => { 140 127 const { data } = await postCallWithoutParametersAndResponse({ 141 128 ...options, ··· 143 130 }); 144 131 return data; 145 132 } 146 - }; 133 + }; return mutationOptions; }; 147 134 148 - export const deleteCallWithoutParametersAndResponseMutation: MutationOptions<void, DefaultError, Options> = { 135 + export const deleteCallWithoutParametersAndResponseMutation = () => { const mutationOptions: MutationOptions<void, DefaultError, Options> = { 149 136 mutationFn: async (options) => { 150 137 const { data } = await deleteCallWithoutParametersAndResponse({ 151 138 ...options, ··· 153 140 }); 154 141 return data; 155 142 } 156 - }; 143 + }; return mutationOptions; }; 157 144 158 - export const patchCallWithoutParametersAndResponseMutation: MutationOptions<void, DefaultError, Options> = { 145 + export const patchCallWithoutParametersAndResponseMutation = () => { const mutationOptions: MutationOptions<void, DefaultError, Options> = { 159 146 mutationFn: async (options) => { 160 147 const { data } = await patchCallWithoutParametersAndResponse({ 161 148 ...options, ··· 163 150 }); 164 151 return data; 165 152 } 166 - }; 153 + }; return mutationOptions; }; 167 154 168 - export const deleteFooMutation: MutationOptions<void, DefaultError, Options<DeleteFooData3>> = { 155 + export const deleteFooMutation = () => { const mutationOptions: MutationOptions<void, DefaultError, Options<DeleteFooData3>> = { 169 156 mutationFn: async (options) => { 170 157 const { data } = await deleteFoo({ 171 158 ...options, ··· 173 160 }); 174 161 return data; 175 162 } 176 - }; 163 + }; return mutationOptions; }; 177 164 178 165 export const callWithDescriptionsOptions = (options?: Options<CallWithDescriptionsData>) => { return queryOptions({ 179 166 queryFn: async ({ queryKey }) => { 180 167 const { data } = await callWithDescriptions({ 181 168 ...options, 182 - ...queryKey[0].params, 169 + ...queryKey[0], 183 170 throwOnError: true 184 171 }); 185 172 return data; 186 173 }, 187 174 queryKey: [ 188 - { 189 - params: createQueryKeyParams(options), 190 - scope: 'callWithDescriptions' 191 - } 175 + createQueryKey("callWithDescriptions", options) 192 176 ] 193 177 }); }; 194 178 195 - export const callWithDescriptionsMutation: MutationOptions<void, DefaultError, Options<CallWithDescriptionsData>> = { 179 + export const callWithDescriptionsMutation = () => { const mutationOptions: MutationOptions<void, DefaultError, Options<CallWithDescriptionsData>> = { 196 180 mutationFn: async (options) => { 197 181 const { data } = await callWithDescriptions({ 198 182 ...options, ··· 200 184 }); 201 185 return data; 202 186 } 203 - }; 187 + }; return mutationOptions; }; 204 188 205 189 export const deprecatedCallOptions = (options: Options<DeprecatedCallData>) => { return queryOptions({ 206 190 queryFn: async ({ queryKey }) => { 207 191 const { data } = await deprecatedCall({ 208 192 ...options, 209 - ...queryKey[0].params, 193 + ...queryKey[0], 210 194 throwOnError: true 211 195 }); 212 196 return data; 213 197 }, 214 198 queryKey: [ 215 - { 216 - params: createQueryKeyParams(options), 217 - scope: 'deprecatedCall' 218 - } 199 + createQueryKey("deprecatedCall", options) 219 200 ] 220 201 }); }; 221 202 222 - export const deprecatedCallMutation: MutationOptions<void, DefaultError, Options<DeprecatedCallData>> = { 203 + export const deprecatedCallMutation = () => { const mutationOptions: MutationOptions<void, DefaultError, Options<DeprecatedCallData>> = { 223 204 mutationFn: async (options) => { 224 205 const { data } = await deprecatedCall({ 225 206 ...options, ··· 227 208 }); 228 209 return data; 229 210 } 230 - }; 211 + }; return mutationOptions; }; 231 212 232 213 export const callWithParametersOptions = (options: Options<CallWithParametersData>) => { return queryOptions({ 233 214 queryFn: async ({ queryKey }) => { 234 215 const { data } = await callWithParameters({ 235 216 ...options, 236 - ...queryKey[0].params, 217 + ...queryKey[0], 237 218 throwOnError: true 238 219 }); 239 220 return data; 240 221 }, 241 222 queryKey: [ 242 - { 243 - params: createQueryKeyParams(options), 244 - scope: 'callWithParameters' 245 - } 223 + createQueryKey("callWithParameters", options) 246 224 ] 247 225 }); }; 248 226 249 - export const callWithParametersInfiniteOptions = (options: Options<CallWithParametersData>) => { return infiniteQueryOptions<void, DefaultError, InfiniteData<void>, QueryKey<Options<CallWithParametersData>>, string | QueryKey<Options<CallWithParametersData>>[0]['params']>( 227 + export const callWithParametersInfiniteOptions = (options: Options<CallWithParametersData>) => { return infiniteQueryOptions<void, DefaultError, InfiniteData<void>, QueryKey<Options<CallWithParametersData>>, string | QueryKey<Options<CallWithParametersData>>[0]>( 250 228 // @ts-ignore 251 229 { 252 230 queryFn: async ({ pageParam, queryKey }) => { 253 231 // @ts-ignore 254 - const page: QueryKey<Options<CallWithParametersData>>[0]['params'] = typeof pageParam === "object" ? pageParam : { 232 + const page: QueryKey<Options<CallWithParametersData>>[0] = typeof pageParam === "object" ? pageParam : { 255 233 query: { 256 234 cursor: pageParam 257 235 } ··· 259 237 const { data } = await callWithParameters({ 260 238 ...options, 261 239 body: { 262 - ...queryKey[0].params.body as any, 240 + ...queryKey[0].body as any, 263 241 ...page.body as any 264 242 }, 265 243 headers: { 266 - ...queryKey[0].params.headers, 244 + ...queryKey[0].headers, 267 245 ...page.headers 268 246 }, 269 247 path: { 270 - ...queryKey[0].params.path, 248 + ...queryKey[0].path, 271 249 ...page.path 272 250 }, 273 251 query: { 274 - ...queryKey[0].params.query, 252 + ...queryKey[0].query, 275 253 ...page.query 276 254 }, 255 + baseUrl: client.getConfig().baseUrl, 277 256 throwOnError: true 278 257 }); 279 258 return data; 280 259 }, 281 260 queryKey: [ 282 - { 283 - infinite: true, 284 - params: createQueryKeyParams(options), 285 - scope: 'callWithParameters' 286 - } 261 + createQueryKey("callWithParameters", options, true) 287 262 ] 288 263 }); }; 289 264 290 - export const callWithParametersMutation: MutationOptions<void, DefaultError, Options<CallWithParametersData>> = { 265 + export const callWithParametersMutation = () => { const mutationOptions: MutationOptions<void, DefaultError, Options<CallWithParametersData>> = { 291 266 mutationFn: async (options) => { 292 267 const { data } = await callWithParameters({ 293 268 ...options, ··· 295 270 }); 296 271 return data; 297 272 } 298 - }; 273 + }; return mutationOptions; }; 299 274 300 275 export const callWithWeirdParameterNamesOptions = (options: Options<CallWithWeirdParameterNamesData>) => { return queryOptions({ 301 276 queryFn: async ({ queryKey }) => { 302 277 const { data } = await callWithWeirdParameterNames({ 303 278 ...options, 304 - ...queryKey[0].params, 279 + ...queryKey[0], 305 280 throwOnError: true 306 281 }); 307 282 return data; 308 283 }, 309 284 queryKey: [ 310 - { 311 - params: createQueryKeyParams(options), 312 - scope: 'callWithWeirdParameterNames' 313 - } 285 + createQueryKey("callWithWeirdParameterNames", options) 314 286 ] 315 287 }); }; 316 288 317 - export const callWithWeirdParameterNamesMutation: MutationOptions<void, DefaultError, Options<CallWithWeirdParameterNamesData>> = { 289 + export const callWithWeirdParameterNamesMutation = () => { const mutationOptions: MutationOptions<void, DefaultError, Options<CallWithWeirdParameterNamesData>> = { 318 290 mutationFn: async (options) => { 319 291 const { data } = await callWithWeirdParameterNames({ 320 292 ...options, ··· 322 294 }); 323 295 return data; 324 296 } 325 - }; 297 + }; return mutationOptions; }; 326 298 327 299 export const getCallWithOptionalParamOptions = (options: Options<GetCallWithOptionalParamData>) => { return queryOptions({ 328 300 queryFn: async ({ queryKey }) => { 329 301 const { data } = await getCallWithOptionalParam({ 330 302 ...options, 331 - ...queryKey[0].params, 303 + ...queryKey[0], 332 304 throwOnError: true 333 305 }); 334 306 return data; 335 307 }, 336 308 queryKey: [ 337 - { 338 - params: createQueryKeyParams(options), 339 - scope: 'getCallWithOptionalParam' 340 - } 309 + createQueryKey("getCallWithOptionalParam", options) 341 310 ] 342 311 }); }; 343 312 344 - export const getCallWithOptionalParamInfiniteOptions = (options: Options<GetCallWithOptionalParamData>) => { return infiniteQueryOptions<void, DefaultError, InfiniteData<void>, QueryKey<Options<GetCallWithOptionalParamData>>, number | QueryKey<Options<GetCallWithOptionalParamData>>[0]['params']>( 313 + export const getCallWithOptionalParamInfiniteOptions = (options: Options<GetCallWithOptionalParamData>) => { return infiniteQueryOptions<void, DefaultError, InfiniteData<void>, QueryKey<Options<GetCallWithOptionalParamData>>, number | QueryKey<Options<GetCallWithOptionalParamData>>[0]>( 345 314 // @ts-ignore 346 315 { 347 316 queryFn: async ({ pageParam, queryKey }) => { 348 317 // @ts-ignore 349 - const page: QueryKey<Options<GetCallWithOptionalParamData>>[0]['params'] = typeof pageParam === "object" ? pageParam : { 318 + const page: QueryKey<Options<GetCallWithOptionalParamData>>[0] = typeof pageParam === "object" ? pageParam : { 350 319 query: { 351 320 page: pageParam 352 321 } ··· 354 323 const { data } = await getCallWithOptionalParam({ 355 324 ...options, 356 325 body: { 357 - ...queryKey[0].params.body as any, 326 + ...queryKey[0].body as any, 358 327 ...page.body as any 359 328 }, 360 329 headers: { 361 - ...queryKey[0].params.headers, 330 + ...queryKey[0].headers, 362 331 ...page.headers 363 332 }, 364 333 path: { 365 - ...queryKey[0].params.path, 334 + ...queryKey[0].path, 366 335 ...page.path 367 336 }, 368 337 query: { 369 - ...queryKey[0].params.query, 338 + ...queryKey[0].query, 370 339 ...page.query 371 340 }, 341 + baseUrl: client.getConfig().baseUrl, 372 342 throwOnError: true 373 343 }); 374 344 return data; 375 345 }, 376 346 queryKey: [ 377 - { 378 - infinite: true, 379 - params: createQueryKeyParams(options), 380 - scope: 'getCallWithOptionalParam' 381 - } 347 + createQueryKey("getCallWithOptionalParam", options, true) 382 348 ] 383 349 }); }; 384 350 ··· 386 352 queryFn: async ({ queryKey }) => { 387 353 const { data } = await postCallWithOptionalParam({ 388 354 ...options, 389 - ...queryKey[0].params, 355 + ...queryKey[0], 390 356 throwOnError: true 391 357 }); 392 358 return data; 393 359 }, 394 360 queryKey: [ 395 - { 396 - params: createQueryKeyParams(options), 397 - scope: 'postCallWithOptionalParam' 398 - } 361 + createQueryKey("postCallWithOptionalParam", options) 399 362 ] 400 363 }); }; 401 364 402 - export const postCallWithOptionalParamInfiniteOptions = (options: Options<PostCallWithOptionalParamData>) => { return infiniteQueryOptions<PostCallWithOptionalParamResponse, PostCallWithOptionalParamError, InfiniteData<PostCallWithOptionalParamResponse>, QueryKey<Options<PostCallWithOptionalParamData>>, number | QueryKey<Options<PostCallWithOptionalParamData>>[0]['params']>( 365 + export const postCallWithOptionalParamInfiniteOptions = (options: Options<PostCallWithOptionalParamData>) => { return infiniteQueryOptions<PostCallWithOptionalParamResponse, PostCallWithOptionalParamError, InfiniteData<PostCallWithOptionalParamResponse>, QueryKey<Options<PostCallWithOptionalParamData>>, number | QueryKey<Options<PostCallWithOptionalParamData>>[0]>( 403 366 // @ts-ignore 404 367 { 405 368 queryFn: async ({ pageParam, queryKey }) => { 406 369 // @ts-ignore 407 - const page: QueryKey<Options<PostCallWithOptionalParamData>>[0]['params'] = typeof pageParam === "object" ? pageParam : { 370 + const page: QueryKey<Options<PostCallWithOptionalParamData>>[0] = typeof pageParam === "object" ? pageParam : { 408 371 body: { 409 372 offset: pageParam 410 373 } ··· 412 375 const { data } = await postCallWithOptionalParam({ 413 376 ...options, 414 377 body: { 415 - ...queryKey[0].params.body as any, 378 + ...queryKey[0].body as any, 416 379 ...page.body as any 417 380 }, 418 381 headers: { 419 - ...queryKey[0].params.headers, 382 + ...queryKey[0].headers, 420 383 ...page.headers 421 384 }, 422 385 path: { 423 - ...queryKey[0].params.path, 386 + ...queryKey[0].path, 424 387 ...page.path 425 388 }, 426 389 query: { 427 - ...queryKey[0].params.query, 390 + ...queryKey[0].query, 428 391 ...page.query 429 392 }, 393 + baseUrl: client.getConfig().baseUrl, 430 394 throwOnError: true 431 395 }); 432 396 return data; 433 397 }, 434 398 queryKey: [ 435 - { 436 - infinite: true, 437 - params: createQueryKeyParams(options), 438 - scope: 'postCallWithOptionalParam' 439 - } 399 + createQueryKey("postCallWithOptionalParam", options, true) 440 400 ] 441 401 }); }; 442 402 443 - export const postCallWithOptionalParamMutation: MutationOptions<PostCallWithOptionalParamResponse, PostCallWithOptionalParamError, Options<PostCallWithOptionalParamData>> = { 403 + export const postCallWithOptionalParamMutation = () => { const mutationOptions: MutationOptions<PostCallWithOptionalParamResponse, PostCallWithOptionalParamError, Options<PostCallWithOptionalParamData>> = { 444 404 mutationFn: async (options) => { 445 405 const { data } = await postCallWithOptionalParam({ 446 406 ...options, ··· 448 408 }); 449 409 return data; 450 410 } 451 - }; 411 + }; return mutationOptions; }; 452 412 453 413 export const postApiVbyApiVersionRequestBodyOptions = (options?: Options<PostApiVbyApiVersionRequestBodyData>) => { return queryOptions({ 454 414 queryFn: async ({ queryKey }) => { 455 415 const { data } = await postApiVbyApiVersionRequestBody({ 456 416 ...options, 457 - ...queryKey[0].params, 417 + ...queryKey[0], 458 418 throwOnError: true 459 419 }); 460 420 return data; 461 421 }, 462 422 queryKey: [ 463 - { 464 - params: createQueryKeyParams(options), 465 - scope: 'postApiVbyApiVersionRequestBody' 466 - } 423 + createQueryKey("postApiVbyApiVersionRequestBody", options) 467 424 ] 468 425 }); }; 469 426 470 - export const postApiVbyApiVersionRequestBodyMutation: MutationOptions<void, DefaultError, Options<PostApiVbyApiVersionRequestBodyData>> = { 427 + export const postApiVbyApiVersionRequestBodyMutation = () => { const mutationOptions: MutationOptions<void, DefaultError, Options<PostApiVbyApiVersionRequestBodyData>> = { 471 428 mutationFn: async (options) => { 472 429 const { data } = await postApiVbyApiVersionRequestBody({ 473 430 ...options, ··· 475 432 }); 476 433 return data; 477 434 } 478 - }; 435 + }; return mutationOptions; }; 479 436 480 437 export const postApiVbyApiVersionFormDataOptions = (options?: Options<PostApiVbyApiVersionFormDataData>) => { return queryOptions({ 481 438 queryFn: async ({ queryKey }) => { 482 439 const { data } = await postApiVbyApiVersionFormData({ 483 440 ...options, 484 - ...queryKey[0].params, 441 + ...queryKey[0], 485 442 throwOnError: true 486 443 }); 487 444 return data; 488 445 }, 489 446 queryKey: [ 490 - { 491 - params: createQueryKeyParams(options), 492 - scope: 'postApiVbyApiVersionFormData' 493 - } 447 + createQueryKey("postApiVbyApiVersionFormData", options) 494 448 ] 495 449 }); }; 496 450 497 - export const postApiVbyApiVersionFormDataMutation: MutationOptions<void, DefaultError, Options<PostApiVbyApiVersionFormDataData>> = { 451 + export const postApiVbyApiVersionFormDataMutation = () => { const mutationOptions: MutationOptions<void, DefaultError, Options<PostApiVbyApiVersionFormDataData>> = { 498 452 mutationFn: async (options) => { 499 453 const { data } = await postApiVbyApiVersionFormData({ 500 454 ...options, ··· 502 456 }); 503 457 return data; 504 458 } 505 - }; 459 + }; return mutationOptions; }; 506 460 507 461 export const callWithDefaultParametersOptions = (options?: Options<CallWithDefaultParametersData>) => { return queryOptions({ 508 462 queryFn: async ({ queryKey }) => { 509 463 const { data } = await callWithDefaultParameters({ 510 464 ...options, 511 - ...queryKey[0].params, 465 + ...queryKey[0], 512 466 throwOnError: true 513 467 }); 514 468 return data; 515 469 }, 516 470 queryKey: [ 517 - { 518 - params: createQueryKeyParams(options), 519 - scope: 'callWithDefaultParameters' 520 - } 471 + createQueryKey("callWithDefaultParameters", options) 521 472 ] 522 473 }); }; 523 474 ··· 525 476 queryFn: async ({ queryKey }) => { 526 477 const { data } = await callWithDefaultOptionalParameters({ 527 478 ...options, 528 - ...queryKey[0].params, 479 + ...queryKey[0], 529 480 throwOnError: true 530 481 }); 531 482 return data; 532 483 }, 533 484 queryKey: [ 534 - { 535 - params: createQueryKeyParams(options), 536 - scope: 'callWithDefaultOptionalParameters' 537 - } 485 + createQueryKey("callWithDefaultOptionalParameters", options) 538 486 ] 539 487 }); }; 540 488 541 - export const callWithDefaultOptionalParametersMutation: MutationOptions<void, DefaultError, Options<CallWithDefaultOptionalParametersData>> = { 489 + export const callWithDefaultOptionalParametersMutation = () => { const mutationOptions: MutationOptions<void, DefaultError, Options<CallWithDefaultOptionalParametersData>> = { 542 490 mutationFn: async (options) => { 543 491 const { data } = await callWithDefaultOptionalParameters({ 544 492 ...options, ··· 546 494 }); 547 495 return data; 548 496 } 549 - }; 497 + }; return mutationOptions; }; 550 498 551 - export const callToTestOrderOfParamsMutation: MutationOptions<void, DefaultError, Options<CallToTestOrderOfParamsData>> = { 499 + export const callToTestOrderOfParamsMutation = () => { const mutationOptions: MutationOptions<void, DefaultError, Options<CallToTestOrderOfParamsData>> = { 552 500 mutationFn: async (options) => { 553 501 const { data } = await callToTestOrderOfParams({ 554 502 ...options, ··· 556 504 }); 557 505 return data; 558 506 } 559 - }; 507 + }; return mutationOptions; }; 560 508 561 509 export const duplicateNameOptions = (options?: Options) => { return queryOptions({ 562 510 queryFn: async ({ queryKey }) => { 563 511 const { data } = await duplicateName({ 564 512 ...options, 565 - ...queryKey[0].params, 513 + ...queryKey[0], 566 514 throwOnError: true 567 515 }); 568 516 return data; 569 517 }, 570 518 queryKey: [ 571 - { 572 - params: createQueryKeyParams(options), 573 - scope: 'duplicateName' 574 - } 519 + createQueryKey("duplicateName", options) 575 520 ] 576 521 }); }; 577 522 ··· 579 524 queryFn: async ({ queryKey }) => { 580 525 const { data } = await duplicateName1({ 581 526 ...options, 582 - ...queryKey[0].params, 527 + ...queryKey[0], 583 528 throwOnError: true 584 529 }); 585 530 return data; 586 531 }, 587 532 queryKey: [ 588 - { 589 - params: createQueryKeyParams(options), 590 - scope: 'duplicateName1' 591 - } 533 + createQueryKey("duplicateName1", options) 592 534 ] 593 535 }); }; 594 536 595 - export const duplicateName1Mutation: MutationOptions<void, DefaultError, Options> = { 537 + export const duplicateName1Mutation = () => { const mutationOptions: MutationOptions<void, DefaultError, Options> = { 596 538 mutationFn: async (options) => { 597 539 const { data } = await duplicateName1({ 598 540 ...options, ··· 600 542 }); 601 543 return data; 602 544 } 603 - }; 545 + }; return mutationOptions; }; 604 546 605 - export const duplicateName2Mutation: MutationOptions<void, DefaultError, Options> = { 547 + export const duplicateName2Mutation = () => { const mutationOptions: MutationOptions<void, DefaultError, Options> = { 606 548 mutationFn: async (options) => { 607 549 const { data } = await duplicateName2({ 608 550 ...options, ··· 610 552 }); 611 553 return data; 612 554 } 613 - }; 555 + }; return mutationOptions; }; 614 556 615 - export const duplicateName3Mutation: MutationOptions<void, DefaultError, Options> = { 557 + export const duplicateName3Mutation = () => { const mutationOptions: MutationOptions<void, DefaultError, Options> = { 616 558 mutationFn: async (options) => { 617 559 const { data } = await duplicateName3({ 618 560 ...options, ··· 620 562 }); 621 563 return data; 622 564 } 623 - }; 565 + }; return mutationOptions; }; 624 566 625 567 export const callWithNoContentResponseOptions = (options?: Options) => { return queryOptions({ 626 568 queryFn: async ({ queryKey }) => { 627 569 const { data } = await callWithNoContentResponse({ 628 570 ...options, 629 - ...queryKey[0].params, 571 + ...queryKey[0], 630 572 throwOnError: true 631 573 }); 632 574 return data; 633 575 }, 634 576 queryKey: [ 635 - { 636 - params: createQueryKeyParams(options), 637 - scope: 'callWithNoContentResponse' 638 - } 577 + createQueryKey("callWithNoContentResponse", options) 639 578 ] 640 579 }); }; 641 580 ··· 643 582 queryFn: async ({ queryKey }) => { 644 583 const { data } = await callWithResponseAndNoContentResponse({ 645 584 ...options, 646 - ...queryKey[0].params, 585 + ...queryKey[0], 647 586 throwOnError: true 648 587 }); 649 588 return data; 650 589 }, 651 590 queryKey: [ 652 - { 653 - params: createQueryKeyParams(options), 654 - scope: 'callWithResponseAndNoContentResponse' 655 - } 591 + createQueryKey("callWithResponseAndNoContentResponse", options) 656 592 ] 657 593 }); }; 658 594 ··· 660 596 queryFn: async ({ queryKey }) => { 661 597 const { data } = await dummyA({ 662 598 ...options, 663 - ...queryKey[0].params, 599 + ...queryKey[0], 664 600 throwOnError: true 665 601 }); 666 602 return data; 667 603 }, 668 604 queryKey: [ 669 - { 670 - params: createQueryKeyParams(options), 671 - scope: 'dummyA' 672 - } 605 + createQueryKey("dummyA", options) 673 606 ] 674 607 }); }; 675 608 ··· 677 610 queryFn: async ({ queryKey }) => { 678 611 const { data } = await dummyB({ 679 612 ...options, 680 - ...queryKey[0].params, 613 + ...queryKey[0], 681 614 throwOnError: true 682 615 }); 683 616 return data; 684 617 }, 685 618 queryKey: [ 686 - { 687 - params: createQueryKeyParams(options), 688 - scope: 'dummyB' 689 - } 619 + createQueryKey("dummyB", options) 690 620 ] 691 621 }); }; 692 622 ··· 694 624 queryFn: async ({ queryKey }) => { 695 625 const { data } = await callWithResponse({ 696 626 ...options, 697 - ...queryKey[0].params, 627 + ...queryKey[0], 698 628 throwOnError: true 699 629 }); 700 630 return data; 701 631 }, 702 632 queryKey: [ 703 - { 704 - params: createQueryKeyParams(options), 705 - scope: 'callWithResponse' 706 - } 633 + createQueryKey("callWithResponse", options) 707 634 ] 708 635 }); }; 709 636 ··· 711 638 queryFn: async ({ queryKey }) => { 712 639 const { data } = await callWithDuplicateResponses({ 713 640 ...options, 714 - ...queryKey[0].params, 641 + ...queryKey[0], 715 642 throwOnError: true 716 643 }); 717 644 return data; 718 645 }, 719 646 queryKey: [ 720 - { 721 - params: createQueryKeyParams(options), 722 - scope: 'callWithDuplicateResponses' 723 - } 647 + createQueryKey("callWithDuplicateResponses", options) 724 648 ] 725 649 }); }; 726 650 727 - export const callWithDuplicateResponsesMutation: MutationOptions<CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesError, Options> = { 651 + export const callWithDuplicateResponsesMutation = () => { const mutationOptions: MutationOptions<CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesError, Options> = { 728 652 mutationFn: async (options) => { 729 653 const { data } = await callWithDuplicateResponses({ 730 654 ...options, ··· 732 656 }); 733 657 return data; 734 658 } 735 - }; 659 + }; return mutationOptions; }; 736 660 737 - export const callWithResponsesMutation: MutationOptions<CallWithResponsesResponse, CallWithResponsesError, Options> = { 661 + export const callWithResponsesMutation = () => { const mutationOptions: MutationOptions<CallWithResponsesResponse, CallWithResponsesError, Options> = { 738 662 mutationFn: async (options) => { 739 663 const { data } = await callWithResponses({ 740 664 ...options, ··· 742 666 }); 743 667 return data; 744 668 } 745 - }; 669 + }; return mutationOptions; }; 746 670 747 671 export const collectionFormatOptions = (options: Options<CollectionFormatData>) => { return queryOptions({ 748 672 queryFn: async ({ queryKey }) => { 749 673 const { data } = await collectionFormat({ 750 674 ...options, 751 - ...queryKey[0].params, 675 + ...queryKey[0], 752 676 throwOnError: true 753 677 }); 754 678 return data; 755 679 }, 756 680 queryKey: [ 757 - { 758 - params: createQueryKeyParams(options), 759 - scope: 'collectionFormat' 760 - } 681 + createQueryKey("collectionFormat", options) 761 682 ] 762 683 }); }; 763 684 ··· 765 686 queryFn: async ({ queryKey }) => { 766 687 const { data } = await types({ 767 688 ...options, 768 - ...queryKey[0].params, 689 + ...queryKey[0], 769 690 throwOnError: true 770 691 }); 771 692 return data; 772 693 }, 773 694 queryKey: [ 774 - { 775 - params: createQueryKeyParams(options), 776 - scope: 'types' 777 - } 695 + createQueryKey("types", options) 778 696 ] 779 697 }); }; 780 698 ··· 782 700 queryFn: async ({ queryKey }) => { 783 701 const { data } = await uploadFile({ 784 702 ...options, 785 - ...queryKey[0].params, 703 + ...queryKey[0], 786 704 throwOnError: true 787 705 }); 788 706 return data; 789 707 }, 790 708 queryKey: [ 791 - { 792 - params: createQueryKeyParams(options), 793 - scope: 'uploadFile' 794 - } 709 + createQueryKey("uploadFile", options) 795 710 ] 796 711 }); }; 797 712 798 - export const uploadFileMutation: MutationOptions<UploadFileResponse, UploadFileError, Options<UploadFileData>> = { 713 + export const uploadFileMutation = () => { const mutationOptions: MutationOptions<UploadFileResponse, UploadFileError, Options<UploadFileData>> = { 799 714 mutationFn: async (options) => { 800 715 const { data } = await uploadFile({ 801 716 ...options, ··· 803 718 }); 804 719 return data; 805 720 } 806 - }; 721 + }; return mutationOptions; }; 807 722 808 723 export const fileResponseOptions = (options: Options<FileResponseData>) => { return queryOptions({ 809 724 queryFn: async ({ queryKey }) => { 810 725 const { data } = await fileResponse({ 811 726 ...options, 812 - ...queryKey[0].params, 727 + ...queryKey[0], 813 728 throwOnError: true 814 729 }); 815 730 return data; 816 731 }, 817 732 queryKey: [ 818 - { 819 - params: createQueryKeyParams(options), 820 - scope: 'fileResponse' 821 - } 733 + createQueryKey("fileResponse", options) 822 734 ] 823 735 }); }; 824 736 ··· 826 738 queryFn: async ({ queryKey }) => { 827 739 const { data } = await complexTypes({ 828 740 ...options, 829 - ...queryKey[0].params, 741 + ...queryKey[0], 830 742 throwOnError: true 831 743 }); 832 744 return data; 833 745 }, 834 746 queryKey: [ 835 - { 836 - params: createQueryKeyParams(options), 837 - scope: 'complexTypes' 838 - } 747 + createQueryKey("complexTypes", options) 839 748 ] 840 749 }); }; 841 750 ··· 843 752 queryFn: async ({ queryKey }) => { 844 753 const { data } = await multipartRequest({ 845 754 ...options, 846 - ...queryKey[0].params, 755 + ...queryKey[0], 847 756 throwOnError: true 848 757 }); 849 758 return data; 850 759 }, 851 760 queryKey: [ 852 - { 853 - params: createQueryKeyParams(options), 854 - scope: 'multipartRequest' 855 - } 761 + createQueryKey("multipartRequest", options) 856 762 ] 857 763 }); }; 858 764 859 - export const multipartRequestMutation: MutationOptions<void, DefaultError, Options<MultipartRequestData>> = { 765 + export const multipartRequestMutation = () => { const mutationOptions: MutationOptions<void, DefaultError, Options<MultipartRequestData>> = { 860 766 mutationFn: async (options) => { 861 767 const { data } = await multipartRequest({ 862 768 ...options, ··· 864 770 }); 865 771 return data; 866 772 } 867 - }; 773 + }; return mutationOptions; }; 868 774 869 775 export const multipartResponseOptions = (options?: Options) => { return queryOptions({ 870 776 queryFn: async ({ queryKey }) => { 871 777 const { data } = await multipartResponse({ 872 778 ...options, 873 - ...queryKey[0].params, 779 + ...queryKey[0], 874 780 throwOnError: true 875 781 }); 876 782 return data; 877 783 }, 878 784 queryKey: [ 879 - { 880 - params: createQueryKeyParams(options), 881 - scope: 'multipartResponse' 882 - } 785 + createQueryKey("multipartResponse", options) 883 786 ] 884 787 }); }; 885 788 886 - export const complexParamsMutation: MutationOptions<ComplexParamsResponse, ComplexParamsError, Options<ComplexParamsData>> = { 789 + export const complexParamsMutation = () => { const mutationOptions: MutationOptions<ComplexParamsResponse, ComplexParamsError, Options<ComplexParamsData>> = { 887 790 mutationFn: async (options) => { 888 791 const { data } = await complexParams({ 889 792 ...options, ··· 891 794 }); 892 795 return data; 893 796 } 894 - }; 797 + }; return mutationOptions; }; 895 798 896 799 export const callWithResultFromHeaderOptions = (options?: Options) => { return queryOptions({ 897 800 queryFn: async ({ queryKey }) => { 898 801 const { data } = await callWithResultFromHeader({ 899 802 ...options, 900 - ...queryKey[0].params, 803 + ...queryKey[0], 901 804 throwOnError: true 902 805 }); 903 806 return data; 904 807 }, 905 808 queryKey: [ 906 - { 907 - params: createQueryKeyParams(options), 908 - scope: 'callWithResultFromHeader' 909 - } 809 + createQueryKey("callWithResultFromHeader", options) 910 810 ] 911 811 }); }; 912 812 913 - export const callWithResultFromHeaderMutation: MutationOptions<CallWithResultFromHeaderResponse, CallWithResultFromHeaderError, Options> = { 813 + export const callWithResultFromHeaderMutation = () => { const mutationOptions: MutationOptions<CallWithResultFromHeaderResponse, CallWithResultFromHeaderError, Options> = { 914 814 mutationFn: async (options) => { 915 815 const { data } = await callWithResultFromHeader({ 916 816 ...options, ··· 918 818 }); 919 819 return data; 920 820 } 921 - }; 821 + }; return mutationOptions; }; 922 822 923 823 export const testErrorCodeOptions = (options: Options<TestErrorCodeData>) => { return queryOptions({ 924 824 queryFn: async ({ queryKey }) => { 925 825 const { data } = await testErrorCode({ 926 826 ...options, 927 - ...queryKey[0].params, 827 + ...queryKey[0], 928 828 throwOnError: true 929 829 }); 930 830 return data; 931 831 }, 932 832 queryKey: [ 933 - { 934 - params: createQueryKeyParams(options), 935 - scope: 'testErrorCode' 936 - } 833 + createQueryKey("testErrorCode", options) 937 834 ] 938 835 }); }; 939 836 940 - export const testErrorCodeMutation: MutationOptions<TestErrorCodeResponse, TestErrorCodeError, Options<TestErrorCodeData>> = { 837 + export const testErrorCodeMutation = () => { const mutationOptions: MutationOptions<TestErrorCodeResponse, TestErrorCodeError, Options<TestErrorCodeData>> = { 941 838 mutationFn: async (options) => { 942 839 const { data } = await testErrorCode({ 943 840 ...options, ··· 945 842 }); 946 843 return data; 947 844 } 948 - }; 845 + }; return mutationOptions; }; 949 846 950 847 export const nonAsciiæøåÆøÅöôêÊ字符串Options = (options: Options<NonAsciiæøåÆøÅöôêÊ字符串Data>) => { return queryOptions({ 951 848 queryFn: async ({ queryKey }) => { 952 849 const { data } = await nonAsciiæøåÆøÅöôêÊ字符串({ 953 850 ...options, 954 - ...queryKey[0].params, 851 + ...queryKey[0], 955 852 throwOnError: true 956 853 }); 957 854 return data; 958 855 }, 959 856 queryKey: [ 960 - { 961 - params: createQueryKeyParams(options), 962 - scope: 'nonAsciiæøåÆøÅöôêÊ字符串' 963 - } 857 + createQueryKey("nonAsciiæøåÆøÅöôêÊ字符串", options) 964 858 ] 965 859 }); }; 966 860 967 - export const nonAsciiæøåÆøÅöôêÊ字符串Mutation: MutationOptions<NonAsciiæøåÆøÅöôêÊ字符串Response, NonAsciiæøåÆøÅöôêÊ字符串Error, Options<NonAsciiæøåÆøÅöôêÊ字符串Data>> = { 861 + export const nonAsciiæøåÆøÅöôêÊ字符串Mutation = () => { const mutationOptions: MutationOptions<NonAsciiæøåÆøÅöôêÊ字符串Response, NonAsciiæøåÆøÅöôêÊ字符串Error, Options<NonAsciiæøåÆøÅöôêÊ字符串Data>> = { 968 862 mutationFn: async (options) => { 969 863 const { data } = await nonAsciiæøåÆøÅöôêÊ字符串({ 970 864 ...options, ··· 972 866 }); 973 867 return data; 974 868 } 975 - }; 869 + }; return mutationOptions; }; 976 870 977 - export const putWithFormUrlEncodedMutation: MutationOptions<void, DefaultError, Options<PutWithFormUrlEncodedData>> = { 871 + export const putWithFormUrlEncodedMutation = () => { const mutationOptions: MutationOptions<void, DefaultError, Options<PutWithFormUrlEncodedData>> = { 978 872 mutationFn: async (options) => { 979 873 const { data } = await putWithFormUrlEncoded({ 980 874 ...options, ··· 982 876 }); 983 877 return data; 984 878 } 985 - }; 879 + }; return mutationOptions; };
+22 -23
packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-fetch-plugin-tanstack-svelte-query_transform/@tanstack/svelte-query.gen.ts.snap
··· 3 3 import type { Options } from '@hey-api/client-fetch'; 4 4 import { queryOptions, type MutationOptions } from '@tanstack/svelte-query'; 5 5 import type { ParentModelWithDatesError, ParentModelWithDatesResponse, ModelWithDatesError, ModelWithDatesResponse, ModelWithDatesArrayError, ModelWithDatesArrayResponse, ArrayOfDatesError, ArrayOfDatesResponse, DateError, DateResponse, MultipleResponsesError, MultipleResponsesResponse } from '../types.gen'; 6 - import { parentModelWithDates, modelWithDates, modelWithDatesArray, arrayOfDates, date, multipleResponses } from '../services.gen'; 6 + import { client, parentModelWithDates, modelWithDates, modelWithDatesArray, arrayOfDates, date, multipleResponses } from '../services.gen'; 7 7 8 8 type QueryKey<TOptions extends Options> = [ 9 - { 9 + Pick<TOptions, 'baseUrl' | 'body' | 'headers' | 'path' | 'query'> & { 10 + _id: string; 10 11 infinite?: boolean; 11 - params: Pick<TOptions, "body" | "headers" | "path" | "query">; 12 - scope: string; 13 12 } 14 13 ]; 15 14 16 - const createQueryKeyParams = <TOptions extends Options>(options?: TOptions): QueryKey<TOptions>[0]["params"] => { 17 - const params: QueryKey<TOptions>[0]["params"] = {} as QueryKey<TOptions>[0]["params"]; 15 + const createQueryKey = <TOptions extends Options>(id: string, options?: TOptions, infinite?: boolean): QueryKey<TOptions>[0] => { 16 + const params: QueryKey<TOptions>[0] = { _id: id, baseUrl: client.getConfig().baseUrl } as QueryKey<TOptions>[0]; 17 + if (infinite) { 18 + params.infinite = infinite; 19 + } 18 20 if (options?.body) { 19 21 params.body = options.body; 20 22 } ··· 34 36 queryFn: async ({ queryKey }) => { 35 37 const { data } = await parentModelWithDates({ 36 38 ...options, 37 - ...queryKey[0].params, 39 + ...queryKey[0], 38 40 throwOnError: true 39 41 }); 40 42 return data; 41 43 }, 42 44 queryKey: [ 43 - { 44 - params: createQueryKeyParams(options), 45 - scope: 'parentModelWithDates' 46 - } 45 + createQueryKey("parentModelWithDates", options) 47 46 ] 48 47 }); }; 49 48 50 - export const parentModelWithDatesMutation: MutationOptions<ParentModelWithDatesResponse, ParentModelWithDatesError, Options> = { 49 + export const parentModelWithDatesMutation = () => { const mutationOptions: MutationOptions<ParentModelWithDatesResponse, ParentModelWithDatesError, Options> = { 51 50 mutationFn: async (options) => { 52 51 const { data } = await parentModelWithDates({ 53 52 ...options, ··· 55 54 }); 56 55 return data; 57 56 } 58 - }; 57 + }; return mutationOptions; }; 59 58 60 - export const modelWithDatesMutation: MutationOptions<ModelWithDatesResponse, ModelWithDatesError, Options> = { 59 + export const modelWithDatesMutation = () => { const mutationOptions: MutationOptions<ModelWithDatesResponse, ModelWithDatesError, Options> = { 61 60 mutationFn: async (options) => { 62 61 const { data } = await modelWithDates({ 63 62 ...options, ··· 65 64 }); 66 65 return data; 67 66 } 68 - }; 67 + }; return mutationOptions; }; 69 68 70 - export const modelWithDatesArrayMutation: MutationOptions<ModelWithDatesArrayResponse, ModelWithDatesArrayError, Options> = { 69 + export const modelWithDatesArrayMutation = () => { const mutationOptions: MutationOptions<ModelWithDatesArrayResponse, ModelWithDatesArrayError, Options> = { 71 70 mutationFn: async (options) => { 72 71 const { data } = await modelWithDatesArray({ 73 72 ...options, ··· 75 74 }); 76 75 return data; 77 76 } 78 - }; 77 + }; return mutationOptions; }; 79 78 80 - export const arrayOfDatesMutation: MutationOptions<ArrayOfDatesResponse, ArrayOfDatesError, Options> = { 79 + export const arrayOfDatesMutation = () => { const mutationOptions: MutationOptions<ArrayOfDatesResponse, ArrayOfDatesError, Options> = { 81 80 mutationFn: async (options) => { 82 81 const { data } = await arrayOfDates({ 83 82 ...options, ··· 85 84 }); 86 85 return data; 87 86 } 88 - }; 87 + }; return mutationOptions; }; 89 88 90 - export const dateMutation: MutationOptions<DateResponse, DateError, Options> = { 89 + export const dateMutation = () => { const mutationOptions: MutationOptions<DateResponse, DateError, Options> = { 91 90 mutationFn: async (options) => { 92 91 const { data } = await date({ 93 92 ...options, ··· 95 94 }); 96 95 return data; 97 96 } 98 - }; 97 + }; return mutationOptions; }; 99 98 100 - export const multipleResponsesMutation: MutationOptions<MultipleResponsesResponse, MultipleResponsesError, Options> = { 99 + export const multipleResponsesMutation = () => { const mutationOptions: MutationOptions<MultipleResponsesResponse, MultipleResponsesError, Options> = { 101 100 mutationFn: async (options) => { 102 101 const { data } = await multipleResponses({ 103 102 ...options, ··· 105 104 }); 106 105 return data; 107 106 } 108 - }; 107 + }; return mutationOptions; };
+152 -258
packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-fetch-plugin-tanstack-vue-query/@tanstack/vue-query.gen.ts.snap
··· 2 2 3 3 import type { Options } from '@hey-api/client-fetch'; 4 4 import { queryOptions, type UseMutationOptions, type DefaultError, infiniteQueryOptions, type InfiniteData } from '@tanstack/vue-query'; 5 - import { export_, import_, apiVVersionOdataControllerCount, getCallWithoutParametersAndResponse, putCallWithoutParametersAndResponse, postCallWithoutParametersAndResponse, deleteCallWithoutParametersAndResponse, patchCallWithoutParametersAndResponse, deleteFoo, callWithDescriptions, deprecatedCall, callWithParameters, callWithWeirdParameterNames, getCallWithOptionalParam, postCallWithOptionalParam, postApiVbyApiVersionRequestBody, postApiVbyApiVersionFormData, callWithDefaultParameters, callWithDefaultOptionalParameters, callToTestOrderOfParams, duplicateName, duplicateName1, duplicateName2, duplicateName3, callWithNoContentResponse, callWithResponseAndNoContentResponse, dummyA, dummyB, callWithResponse, callWithDuplicateResponses, callWithResponses, collectionFormat, types, uploadFile, fileResponse, complexTypes, multipartRequest, multipartResponse, complexParams, callWithResultFromHeader, testErrorCode, nonAsciiæøåÆøÅöôêÊ字符串, putWithFormUrlEncoded } from '../services.gen'; 5 + import { client, export_, import_, apiVVersionOdataControllerCount, getCallWithoutParametersAndResponse, putCallWithoutParametersAndResponse, postCallWithoutParametersAndResponse, deleteCallWithoutParametersAndResponse, patchCallWithoutParametersAndResponse, deleteFoo, callWithDescriptions, deprecatedCall, callWithParameters, callWithWeirdParameterNames, getCallWithOptionalParam, postCallWithOptionalParam, postApiVbyApiVersionRequestBody, postApiVbyApiVersionFormData, callWithDefaultParameters, callWithDefaultOptionalParameters, callToTestOrderOfParams, duplicateName, duplicateName1, duplicateName2, duplicateName3, callWithNoContentResponse, callWithResponseAndNoContentResponse, dummyA, dummyB, callWithResponse, callWithDuplicateResponses, callWithResponses, collectionFormat, types, uploadFile, fileResponse, complexTypes, multipartRequest, multipartResponse, complexParams, callWithResultFromHeader, testErrorCode, nonAsciiæøåÆøÅöôêÊ字符串, putWithFormUrlEncoded } from '../services.gen'; 6 6 import type { ImportData, ImportError, ImportResponse, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamError, PostCallWithOptionalParamResponse, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, UploadFileData, UploadFileError, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartRequestData, ComplexParamsData, ComplexParamsError, ComplexParamsResponse, CallWithResultFromHeaderError, CallWithResultFromHeaderResponse, TestErrorCodeData, TestErrorCodeError, TestErrorCodeResponse, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Error, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; 7 7 8 8 type QueryKey<TOptions extends Options> = [ 9 - { 9 + Pick<TOptions, 'baseUrl' | 'body' | 'headers' | 'path' | 'query'> & { 10 + _id: string; 10 11 infinite?: boolean; 11 - params: Pick<TOptions, "body" | "headers" | "path" | "query">; 12 - scope: string; 13 12 } 14 13 ]; 15 14 16 - const createQueryKeyParams = <TOptions extends Options>(options?: TOptions): QueryKey<TOptions>[0]["params"] => { 17 - const params: QueryKey<TOptions>[0]["params"] = {} as QueryKey<TOptions>[0]["params"]; 15 + const createQueryKey = <TOptions extends Options>(id: string, options?: TOptions, infinite?: boolean): QueryKey<TOptions>[0] => { 16 + const params: QueryKey<TOptions>[0] = { _id: id, baseUrl: client.getConfig().baseUrl } as QueryKey<TOptions>[0]; 17 + if (infinite) { 18 + params.infinite = infinite; 19 + } 18 20 if (options?.body) { 19 21 params.body = options.body; 20 22 } ··· 34 36 queryFn: async ({ queryKey }) => { 35 37 const { data } = await export_({ 36 38 ...options, 37 - ...queryKey[0].params, 39 + ...queryKey[0], 38 40 throwOnError: true 39 41 }); 40 42 return data; 41 43 }, 42 44 queryKey: [ 43 - { 44 - params: createQueryKeyParams(options), 45 - scope: 'export' 46 - } 45 + createQueryKey("export", options) 47 46 ] 48 47 }); }; 49 48 ··· 51 50 queryFn: async ({ queryKey }) => { 52 51 const { data } = await import_({ 53 52 ...options, 54 - ...queryKey[0].params, 53 + ...queryKey[0], 55 54 throwOnError: true 56 55 }); 57 56 return data; 58 57 }, 59 58 queryKey: [ 60 - { 61 - params: createQueryKeyParams(options), 62 - scope: 'import' 63 - } 59 + createQueryKey("import", options) 64 60 ] 65 61 }); }; 66 62 67 - export const importMutation: UseMutationOptions<ImportResponse, ImportError, Options<ImportData>> = { 63 + export const importMutation = () => { const mutationOptions: UseMutationOptions<ImportResponse, ImportError, Options<ImportData>> = { 68 64 mutationFn: async (options) => { 69 65 const { data } = await import_({ 70 66 ...options, ··· 72 68 }); 73 69 return data; 74 70 } 75 - }; 71 + }; return mutationOptions; }; 76 72 77 73 export const apiVVersionOdataControllerCountOptions = (options?: Options) => { return queryOptions({ 78 74 queryFn: async ({ queryKey }) => { 79 75 const { data } = await apiVVersionOdataControllerCount({ 80 76 ...options, 81 - ...queryKey[0].params, 77 + ...queryKey[0], 82 78 throwOnError: true 83 79 }); 84 80 return data; 85 81 }, 86 82 queryKey: [ 87 - { 88 - params: createQueryKeyParams(options), 89 - scope: 'apiVVersionOdataControllerCount' 90 - } 83 + createQueryKey("apiVVersionOdataControllerCount", options) 91 84 ] 92 85 }); }; 93 86 ··· 95 88 queryFn: async ({ queryKey }) => { 96 89 const { data } = await getCallWithoutParametersAndResponse({ 97 90 ...options, 98 - ...queryKey[0].params, 91 + ...queryKey[0], 99 92 throwOnError: true 100 93 }); 101 94 return data; 102 95 }, 103 96 queryKey: [ 104 - { 105 - params: createQueryKeyParams(options), 106 - scope: 'getCallWithoutParametersAndResponse' 107 - } 97 + createQueryKey("getCallWithoutParametersAndResponse", options) 108 98 ] 109 99 }); }; 110 100 111 - export const putCallWithoutParametersAndResponseMutation: UseMutationOptions<void, DefaultError, Options> = { 101 + export const putCallWithoutParametersAndResponseMutation = () => { const mutationOptions: UseMutationOptions<void, DefaultError, Options> = { 112 102 mutationFn: async (options) => { 113 103 const { data } = await putCallWithoutParametersAndResponse({ 114 104 ...options, ··· 116 106 }); 117 107 return data; 118 108 } 119 - }; 109 + }; return mutationOptions; }; 120 110 121 111 export const postCallWithoutParametersAndResponseOptions = (options?: Options) => { return queryOptions({ 122 112 queryFn: async ({ queryKey }) => { 123 113 const { data } = await postCallWithoutParametersAndResponse({ 124 114 ...options, 125 - ...queryKey[0].params, 115 + ...queryKey[0], 126 116 throwOnError: true 127 117 }); 128 118 return data; 129 119 }, 130 120 queryKey: [ 131 - { 132 - params: createQueryKeyParams(options), 133 - scope: 'postCallWithoutParametersAndResponse' 134 - } 121 + createQueryKey("postCallWithoutParametersAndResponse", options) 135 122 ] 136 123 }); }; 137 124 138 - export const postCallWithoutParametersAndResponseMutation: UseMutationOptions<void, DefaultError, Options> = { 125 + export const postCallWithoutParametersAndResponseMutation = () => { const mutationOptions: UseMutationOptions<void, DefaultError, Options> = { 139 126 mutationFn: async (options) => { 140 127 const { data } = await postCallWithoutParametersAndResponse({ 141 128 ...options, ··· 143 130 }); 144 131 return data; 145 132 } 146 - }; 133 + }; return mutationOptions; }; 147 134 148 - export const deleteCallWithoutParametersAndResponseMutation: UseMutationOptions<void, DefaultError, Options> = { 135 + export const deleteCallWithoutParametersAndResponseMutation = () => { const mutationOptions: UseMutationOptions<void, DefaultError, Options> = { 149 136 mutationFn: async (options) => { 150 137 const { data } = await deleteCallWithoutParametersAndResponse({ 151 138 ...options, ··· 153 140 }); 154 141 return data; 155 142 } 156 - }; 143 + }; return mutationOptions; }; 157 144 158 - export const patchCallWithoutParametersAndResponseMutation: UseMutationOptions<void, DefaultError, Options> = { 145 + export const patchCallWithoutParametersAndResponseMutation = () => { const mutationOptions: UseMutationOptions<void, DefaultError, Options> = { 159 146 mutationFn: async (options) => { 160 147 const { data } = await patchCallWithoutParametersAndResponse({ 161 148 ...options, ··· 163 150 }); 164 151 return data; 165 152 } 166 - }; 153 + }; return mutationOptions; }; 167 154 168 - export const deleteFooMutation: UseMutationOptions<void, DefaultError, Options<DeleteFooData3>> = { 155 + export const deleteFooMutation = () => { const mutationOptions: UseMutationOptions<void, DefaultError, Options<DeleteFooData3>> = { 169 156 mutationFn: async (options) => { 170 157 const { data } = await deleteFoo({ 171 158 ...options, ··· 173 160 }); 174 161 return data; 175 162 } 176 - }; 163 + }; return mutationOptions; }; 177 164 178 165 export const callWithDescriptionsOptions = (options?: Options<CallWithDescriptionsData>) => { return queryOptions({ 179 166 queryFn: async ({ queryKey }) => { 180 167 const { data } = await callWithDescriptions({ 181 168 ...options, 182 - ...queryKey[0].params, 169 + ...queryKey[0], 183 170 throwOnError: true 184 171 }); 185 172 return data; 186 173 }, 187 174 queryKey: [ 188 - { 189 - params: createQueryKeyParams(options), 190 - scope: 'callWithDescriptions' 191 - } 175 + createQueryKey("callWithDescriptions", options) 192 176 ] 193 177 }); }; 194 178 195 - export const callWithDescriptionsMutation: UseMutationOptions<void, DefaultError, Options<CallWithDescriptionsData>> = { 179 + export const callWithDescriptionsMutation = () => { const mutationOptions: UseMutationOptions<void, DefaultError, Options<CallWithDescriptionsData>> = { 196 180 mutationFn: async (options) => { 197 181 const { data } = await callWithDescriptions({ 198 182 ...options, ··· 200 184 }); 201 185 return data; 202 186 } 203 - }; 187 + }; return mutationOptions; }; 204 188 205 189 export const deprecatedCallOptions = (options: Options<DeprecatedCallData>) => { return queryOptions({ 206 190 queryFn: async ({ queryKey }) => { 207 191 const { data } = await deprecatedCall({ 208 192 ...options, 209 - ...queryKey[0].params, 193 + ...queryKey[0], 210 194 throwOnError: true 211 195 }); 212 196 return data; 213 197 }, 214 198 queryKey: [ 215 - { 216 - params: createQueryKeyParams(options), 217 - scope: 'deprecatedCall' 218 - } 199 + createQueryKey("deprecatedCall", options) 219 200 ] 220 201 }); }; 221 202 222 - export const deprecatedCallMutation: UseMutationOptions<void, DefaultError, Options<DeprecatedCallData>> = { 203 + export const deprecatedCallMutation = () => { const mutationOptions: UseMutationOptions<void, DefaultError, Options<DeprecatedCallData>> = { 223 204 mutationFn: async (options) => { 224 205 const { data } = await deprecatedCall({ 225 206 ...options, ··· 227 208 }); 228 209 return data; 229 210 } 230 - }; 211 + }; return mutationOptions; }; 231 212 232 213 export const callWithParametersOptions = (options: Options<CallWithParametersData>) => { return queryOptions({ 233 214 queryFn: async ({ queryKey }) => { 234 215 const { data } = await callWithParameters({ 235 216 ...options, 236 - ...queryKey[0].params, 217 + ...queryKey[0], 237 218 throwOnError: true 238 219 }); 239 220 return data; 240 221 }, 241 222 queryKey: [ 242 - { 243 - params: createQueryKeyParams(options), 244 - scope: 'callWithParameters' 245 - } 223 + createQueryKey("callWithParameters", options) 246 224 ] 247 225 }); }; 248 226 249 - export const callWithParametersInfiniteOptions = (options: Options<CallWithParametersData>) => { return infiniteQueryOptions<void, DefaultError, InfiniteData<void>, QueryKey<Options<CallWithParametersData>>, string | QueryKey<Options<CallWithParametersData>>[0]['params']>( 227 + export const callWithParametersInfiniteOptions = (options: Options<CallWithParametersData>) => { return infiniteQueryOptions<void, DefaultError, InfiniteData<void>, QueryKey<Options<CallWithParametersData>>, string | QueryKey<Options<CallWithParametersData>>[0]>( 250 228 // @ts-ignore 251 229 { 252 230 queryFn: async ({ pageParam, queryKey }) => { 253 231 // @ts-ignore 254 - const page: QueryKey<Options<CallWithParametersData>>[0]['params'] = typeof pageParam === "object" ? pageParam : { 232 + const page: QueryKey<Options<CallWithParametersData>>[0] = typeof pageParam === "object" ? pageParam : { 255 233 query: { 256 234 cursor: pageParam 257 235 } ··· 259 237 const { data } = await callWithParameters({ 260 238 ...options, 261 239 body: { 262 - ...queryKey[0].params.body as any, 240 + ...queryKey[0].body as any, 263 241 ...page.body as any 264 242 }, 265 243 headers: { 266 - ...queryKey[0].params.headers, 244 + ...queryKey[0].headers, 267 245 ...page.headers 268 246 }, 269 247 path: { 270 - ...queryKey[0].params.path, 248 + ...queryKey[0].path, 271 249 ...page.path 272 250 }, 273 251 query: { 274 - ...queryKey[0].params.query, 252 + ...queryKey[0].query, 275 253 ...page.query 276 254 }, 255 + baseUrl: client.getConfig().baseUrl, 277 256 throwOnError: true 278 257 }); 279 258 return data; 280 259 }, 281 260 queryKey: [ 282 - { 283 - infinite: true, 284 - params: createQueryKeyParams(options), 285 - scope: 'callWithParameters' 286 - } 261 + createQueryKey("callWithParameters", options, true) 287 262 ] 288 263 }); }; 289 264 290 - export const callWithParametersMutation: UseMutationOptions<void, DefaultError, Options<CallWithParametersData>> = { 265 + export const callWithParametersMutation = () => { const mutationOptions: UseMutationOptions<void, DefaultError, Options<CallWithParametersData>> = { 291 266 mutationFn: async (options) => { 292 267 const { data } = await callWithParameters({ 293 268 ...options, ··· 295 270 }); 296 271 return data; 297 272 } 298 - }; 273 + }; return mutationOptions; }; 299 274 300 275 export const callWithWeirdParameterNamesOptions = (options: Options<CallWithWeirdParameterNamesData>) => { return queryOptions({ 301 276 queryFn: async ({ queryKey }) => { 302 277 const { data } = await callWithWeirdParameterNames({ 303 278 ...options, 304 - ...queryKey[0].params, 279 + ...queryKey[0], 305 280 throwOnError: true 306 281 }); 307 282 return data; 308 283 }, 309 284 queryKey: [ 310 - { 311 - params: createQueryKeyParams(options), 312 - scope: 'callWithWeirdParameterNames' 313 - } 285 + createQueryKey("callWithWeirdParameterNames", options) 314 286 ] 315 287 }); }; 316 288 317 - export const callWithWeirdParameterNamesMutation: UseMutationOptions<void, DefaultError, Options<CallWithWeirdParameterNamesData>> = { 289 + export const callWithWeirdParameterNamesMutation = () => { const mutationOptions: UseMutationOptions<void, DefaultError, Options<CallWithWeirdParameterNamesData>> = { 318 290 mutationFn: async (options) => { 319 291 const { data } = await callWithWeirdParameterNames({ 320 292 ...options, ··· 322 294 }); 323 295 return data; 324 296 } 325 - }; 297 + }; return mutationOptions; }; 326 298 327 299 export const getCallWithOptionalParamOptions = (options: Options<GetCallWithOptionalParamData>) => { return queryOptions({ 328 300 queryFn: async ({ queryKey }) => { 329 301 const { data } = await getCallWithOptionalParam({ 330 302 ...options, 331 - ...queryKey[0].params, 303 + ...queryKey[0], 332 304 throwOnError: true 333 305 }); 334 306 return data; 335 307 }, 336 308 queryKey: [ 337 - { 338 - params: createQueryKeyParams(options), 339 - scope: 'getCallWithOptionalParam' 340 - } 309 + createQueryKey("getCallWithOptionalParam", options) 341 310 ] 342 311 }); }; 343 312 344 - export const getCallWithOptionalParamInfiniteOptions = (options: Options<GetCallWithOptionalParamData>) => { return infiniteQueryOptions<void, DefaultError, InfiniteData<void>, QueryKey<Options<GetCallWithOptionalParamData>>, number | QueryKey<Options<GetCallWithOptionalParamData>>[0]['params']>( 313 + export const getCallWithOptionalParamInfiniteOptions = (options: Options<GetCallWithOptionalParamData>) => { return infiniteQueryOptions<void, DefaultError, InfiniteData<void>, QueryKey<Options<GetCallWithOptionalParamData>>, number | QueryKey<Options<GetCallWithOptionalParamData>>[0]>( 345 314 // @ts-ignore 346 315 { 347 316 queryFn: async ({ pageParam, queryKey }) => { 348 317 // @ts-ignore 349 - const page: QueryKey<Options<GetCallWithOptionalParamData>>[0]['params'] = typeof pageParam === "object" ? pageParam : { 318 + const page: QueryKey<Options<GetCallWithOptionalParamData>>[0] = typeof pageParam === "object" ? pageParam : { 350 319 query: { 351 320 page: pageParam 352 321 } ··· 354 323 const { data } = await getCallWithOptionalParam({ 355 324 ...options, 356 325 body: { 357 - ...queryKey[0].params.body as any, 326 + ...queryKey[0].body as any, 358 327 ...page.body as any 359 328 }, 360 329 headers: { 361 - ...queryKey[0].params.headers, 330 + ...queryKey[0].headers, 362 331 ...page.headers 363 332 }, 364 333 path: { 365 - ...queryKey[0].params.path, 334 + ...queryKey[0].path, 366 335 ...page.path 367 336 }, 368 337 query: { 369 - ...queryKey[0].params.query, 338 + ...queryKey[0].query, 370 339 ...page.query 371 340 }, 341 + baseUrl: client.getConfig().baseUrl, 372 342 throwOnError: true 373 343 }); 374 344 return data; 375 345 }, 376 346 queryKey: [ 377 - { 378 - infinite: true, 379 - params: createQueryKeyParams(options), 380 - scope: 'getCallWithOptionalParam' 381 - } 347 + createQueryKey("getCallWithOptionalParam", options, true) 382 348 ] 383 349 }); }; 384 350 ··· 386 352 queryFn: async ({ queryKey }) => { 387 353 const { data } = await postCallWithOptionalParam({ 388 354 ...options, 389 - ...queryKey[0].params, 355 + ...queryKey[0], 390 356 throwOnError: true 391 357 }); 392 358 return data; 393 359 }, 394 360 queryKey: [ 395 - { 396 - params: createQueryKeyParams(options), 397 - scope: 'postCallWithOptionalParam' 398 - } 361 + createQueryKey("postCallWithOptionalParam", options) 399 362 ] 400 363 }); }; 401 364 402 - export const postCallWithOptionalParamInfiniteOptions = (options: Options<PostCallWithOptionalParamData>) => { return infiniteQueryOptions<PostCallWithOptionalParamResponse, PostCallWithOptionalParamError, InfiniteData<PostCallWithOptionalParamResponse>, QueryKey<Options<PostCallWithOptionalParamData>>, number | QueryKey<Options<PostCallWithOptionalParamData>>[0]['params']>( 365 + export const postCallWithOptionalParamInfiniteOptions = (options: Options<PostCallWithOptionalParamData>) => { return infiniteQueryOptions<PostCallWithOptionalParamResponse, PostCallWithOptionalParamError, InfiniteData<PostCallWithOptionalParamResponse>, QueryKey<Options<PostCallWithOptionalParamData>>, number | QueryKey<Options<PostCallWithOptionalParamData>>[0]>( 403 366 // @ts-ignore 404 367 { 405 368 queryFn: async ({ pageParam, queryKey }) => { 406 369 // @ts-ignore 407 - const page: QueryKey<Options<PostCallWithOptionalParamData>>[0]['params'] = typeof pageParam === "object" ? pageParam : { 370 + const page: QueryKey<Options<PostCallWithOptionalParamData>>[0] = typeof pageParam === "object" ? pageParam : { 408 371 body: { 409 372 offset: pageParam 410 373 } ··· 412 375 const { data } = await postCallWithOptionalParam({ 413 376 ...options, 414 377 body: { 415 - ...queryKey[0].params.body as any, 378 + ...queryKey[0].body as any, 416 379 ...page.body as any 417 380 }, 418 381 headers: { 419 - ...queryKey[0].params.headers, 382 + ...queryKey[0].headers, 420 383 ...page.headers 421 384 }, 422 385 path: { 423 - ...queryKey[0].params.path, 386 + ...queryKey[0].path, 424 387 ...page.path 425 388 }, 426 389 query: { 427 - ...queryKey[0].params.query, 390 + ...queryKey[0].query, 428 391 ...page.query 429 392 }, 393 + baseUrl: client.getConfig().baseUrl, 430 394 throwOnError: true 431 395 }); 432 396 return data; 433 397 }, 434 398 queryKey: [ 435 - { 436 - infinite: true, 437 - params: createQueryKeyParams(options), 438 - scope: 'postCallWithOptionalParam' 439 - } 399 + createQueryKey("postCallWithOptionalParam", options, true) 440 400 ] 441 401 }); }; 442 402 443 - export const postCallWithOptionalParamMutation: UseMutationOptions<PostCallWithOptionalParamResponse, PostCallWithOptionalParamError, Options<PostCallWithOptionalParamData>> = { 403 + export const postCallWithOptionalParamMutation = () => { const mutationOptions: UseMutationOptions<PostCallWithOptionalParamResponse, PostCallWithOptionalParamError, Options<PostCallWithOptionalParamData>> = { 444 404 mutationFn: async (options) => { 445 405 const { data } = await postCallWithOptionalParam({ 446 406 ...options, ··· 448 408 }); 449 409 return data; 450 410 } 451 - }; 411 + }; return mutationOptions; }; 452 412 453 413 export const postApiVbyApiVersionRequestBodyOptions = (options?: Options<PostApiVbyApiVersionRequestBodyData>) => { return queryOptions({ 454 414 queryFn: async ({ queryKey }) => { 455 415 const { data } = await postApiVbyApiVersionRequestBody({ 456 416 ...options, 457 - ...queryKey[0].params, 417 + ...queryKey[0], 458 418 throwOnError: true 459 419 }); 460 420 return data; 461 421 }, 462 422 queryKey: [ 463 - { 464 - params: createQueryKeyParams(options), 465 - scope: 'postApiVbyApiVersionRequestBody' 466 - } 423 + createQueryKey("postApiVbyApiVersionRequestBody", options) 467 424 ] 468 425 }); }; 469 426 470 - export const postApiVbyApiVersionRequestBodyMutation: UseMutationOptions<void, DefaultError, Options<PostApiVbyApiVersionRequestBodyData>> = { 427 + export const postApiVbyApiVersionRequestBodyMutation = () => { const mutationOptions: UseMutationOptions<void, DefaultError, Options<PostApiVbyApiVersionRequestBodyData>> = { 471 428 mutationFn: async (options) => { 472 429 const { data } = await postApiVbyApiVersionRequestBody({ 473 430 ...options, ··· 475 432 }); 476 433 return data; 477 434 } 478 - }; 435 + }; return mutationOptions; }; 479 436 480 437 export const postApiVbyApiVersionFormDataOptions = (options?: Options<PostApiVbyApiVersionFormDataData>) => { return queryOptions({ 481 438 queryFn: async ({ queryKey }) => { 482 439 const { data } = await postApiVbyApiVersionFormData({ 483 440 ...options, 484 - ...queryKey[0].params, 441 + ...queryKey[0], 485 442 throwOnError: true 486 443 }); 487 444 return data; 488 445 }, 489 446 queryKey: [ 490 - { 491 - params: createQueryKeyParams(options), 492 - scope: 'postApiVbyApiVersionFormData' 493 - } 447 + createQueryKey("postApiVbyApiVersionFormData", options) 494 448 ] 495 449 }); }; 496 450 497 - export const postApiVbyApiVersionFormDataMutation: UseMutationOptions<void, DefaultError, Options<PostApiVbyApiVersionFormDataData>> = { 451 + export const postApiVbyApiVersionFormDataMutation = () => { const mutationOptions: UseMutationOptions<void, DefaultError, Options<PostApiVbyApiVersionFormDataData>> = { 498 452 mutationFn: async (options) => { 499 453 const { data } = await postApiVbyApiVersionFormData({ 500 454 ...options, ··· 502 456 }); 503 457 return data; 504 458 } 505 - }; 459 + }; return mutationOptions; }; 506 460 507 461 export const callWithDefaultParametersOptions = (options?: Options<CallWithDefaultParametersData>) => { return queryOptions({ 508 462 queryFn: async ({ queryKey }) => { 509 463 const { data } = await callWithDefaultParameters({ 510 464 ...options, 511 - ...queryKey[0].params, 465 + ...queryKey[0], 512 466 throwOnError: true 513 467 }); 514 468 return data; 515 469 }, 516 470 queryKey: [ 517 - { 518 - params: createQueryKeyParams(options), 519 - scope: 'callWithDefaultParameters' 520 - } 471 + createQueryKey("callWithDefaultParameters", options) 521 472 ] 522 473 }); }; 523 474 ··· 525 476 queryFn: async ({ queryKey }) => { 526 477 const { data } = await callWithDefaultOptionalParameters({ 527 478 ...options, 528 - ...queryKey[0].params, 479 + ...queryKey[0], 529 480 throwOnError: true 530 481 }); 531 482 return data; 532 483 }, 533 484 queryKey: [ 534 - { 535 - params: createQueryKeyParams(options), 536 - scope: 'callWithDefaultOptionalParameters' 537 - } 485 + createQueryKey("callWithDefaultOptionalParameters", options) 538 486 ] 539 487 }); }; 540 488 541 - export const callWithDefaultOptionalParametersMutation: UseMutationOptions<void, DefaultError, Options<CallWithDefaultOptionalParametersData>> = { 489 + export const callWithDefaultOptionalParametersMutation = () => { const mutationOptions: UseMutationOptions<void, DefaultError, Options<CallWithDefaultOptionalParametersData>> = { 542 490 mutationFn: async (options) => { 543 491 const { data } = await callWithDefaultOptionalParameters({ 544 492 ...options, ··· 546 494 }); 547 495 return data; 548 496 } 549 - }; 497 + }; return mutationOptions; }; 550 498 551 - export const callToTestOrderOfParamsMutation: UseMutationOptions<void, DefaultError, Options<CallToTestOrderOfParamsData>> = { 499 + export const callToTestOrderOfParamsMutation = () => { const mutationOptions: UseMutationOptions<void, DefaultError, Options<CallToTestOrderOfParamsData>> = { 552 500 mutationFn: async (options) => { 553 501 const { data } = await callToTestOrderOfParams({ 554 502 ...options, ··· 556 504 }); 557 505 return data; 558 506 } 559 - }; 507 + }; return mutationOptions; }; 560 508 561 509 export const duplicateNameOptions = (options?: Options) => { return queryOptions({ 562 510 queryFn: async ({ queryKey }) => { 563 511 const { data } = await duplicateName({ 564 512 ...options, 565 - ...queryKey[0].params, 513 + ...queryKey[0], 566 514 throwOnError: true 567 515 }); 568 516 return data; 569 517 }, 570 518 queryKey: [ 571 - { 572 - params: createQueryKeyParams(options), 573 - scope: 'duplicateName' 574 - } 519 + createQueryKey("duplicateName", options) 575 520 ] 576 521 }); }; 577 522 ··· 579 524 queryFn: async ({ queryKey }) => { 580 525 const { data } = await duplicateName1({ 581 526 ...options, 582 - ...queryKey[0].params, 527 + ...queryKey[0], 583 528 throwOnError: true 584 529 }); 585 530 return data; 586 531 }, 587 532 queryKey: [ 588 - { 589 - params: createQueryKeyParams(options), 590 - scope: 'duplicateName1' 591 - } 533 + createQueryKey("duplicateName1", options) 592 534 ] 593 535 }); }; 594 536 595 - export const duplicateName1Mutation: UseMutationOptions<void, DefaultError, Options> = { 537 + export const duplicateName1Mutation = () => { const mutationOptions: UseMutationOptions<void, DefaultError, Options> = { 596 538 mutationFn: async (options) => { 597 539 const { data } = await duplicateName1({ 598 540 ...options, ··· 600 542 }); 601 543 return data; 602 544 } 603 - }; 545 + }; return mutationOptions; }; 604 546 605 - export const duplicateName2Mutation: UseMutationOptions<void, DefaultError, Options> = { 547 + export const duplicateName2Mutation = () => { const mutationOptions: UseMutationOptions<void, DefaultError, Options> = { 606 548 mutationFn: async (options) => { 607 549 const { data } = await duplicateName2({ 608 550 ...options, ··· 610 552 }); 611 553 return data; 612 554 } 613 - }; 555 + }; return mutationOptions; }; 614 556 615 - export const duplicateName3Mutation: UseMutationOptions<void, DefaultError, Options> = { 557 + export const duplicateName3Mutation = () => { const mutationOptions: UseMutationOptions<void, DefaultError, Options> = { 616 558 mutationFn: async (options) => { 617 559 const { data } = await duplicateName3({ 618 560 ...options, ··· 620 562 }); 621 563 return data; 622 564 } 623 - }; 565 + }; return mutationOptions; }; 624 566 625 567 export const callWithNoContentResponseOptions = (options?: Options) => { return queryOptions({ 626 568 queryFn: async ({ queryKey }) => { 627 569 const { data } = await callWithNoContentResponse({ 628 570 ...options, 629 - ...queryKey[0].params, 571 + ...queryKey[0], 630 572 throwOnError: true 631 573 }); 632 574 return data; 633 575 }, 634 576 queryKey: [ 635 - { 636 - params: createQueryKeyParams(options), 637 - scope: 'callWithNoContentResponse' 638 - } 577 + createQueryKey("callWithNoContentResponse", options) 639 578 ] 640 579 }); }; 641 580 ··· 643 582 queryFn: async ({ queryKey }) => { 644 583 const { data } = await callWithResponseAndNoContentResponse({ 645 584 ...options, 646 - ...queryKey[0].params, 585 + ...queryKey[0], 647 586 throwOnError: true 648 587 }); 649 588 return data; 650 589 }, 651 590 queryKey: [ 652 - { 653 - params: createQueryKeyParams(options), 654 - scope: 'callWithResponseAndNoContentResponse' 655 - } 591 + createQueryKey("callWithResponseAndNoContentResponse", options) 656 592 ] 657 593 }); }; 658 594 ··· 660 596 queryFn: async ({ queryKey }) => { 661 597 const { data } = await dummyA({ 662 598 ...options, 663 - ...queryKey[0].params, 599 + ...queryKey[0], 664 600 throwOnError: true 665 601 }); 666 602 return data; 667 603 }, 668 604 queryKey: [ 669 - { 670 - params: createQueryKeyParams(options), 671 - scope: 'dummyA' 672 - } 605 + createQueryKey("dummyA", options) 673 606 ] 674 607 }); }; 675 608 ··· 677 610 queryFn: async ({ queryKey }) => { 678 611 const { data } = await dummyB({ 679 612 ...options, 680 - ...queryKey[0].params, 613 + ...queryKey[0], 681 614 throwOnError: true 682 615 }); 683 616 return data; 684 617 }, 685 618 queryKey: [ 686 - { 687 - params: createQueryKeyParams(options), 688 - scope: 'dummyB' 689 - } 619 + createQueryKey("dummyB", options) 690 620 ] 691 621 }); }; 692 622 ··· 694 624 queryFn: async ({ queryKey }) => { 695 625 const { data } = await callWithResponse({ 696 626 ...options, 697 - ...queryKey[0].params, 627 + ...queryKey[0], 698 628 throwOnError: true 699 629 }); 700 630 return data; 701 631 }, 702 632 queryKey: [ 703 - { 704 - params: createQueryKeyParams(options), 705 - scope: 'callWithResponse' 706 - } 633 + createQueryKey("callWithResponse", options) 707 634 ] 708 635 }); }; 709 636 ··· 711 638 queryFn: async ({ queryKey }) => { 712 639 const { data } = await callWithDuplicateResponses({ 713 640 ...options, 714 - ...queryKey[0].params, 641 + ...queryKey[0], 715 642 throwOnError: true 716 643 }); 717 644 return data; 718 645 }, 719 646 queryKey: [ 720 - { 721 - params: createQueryKeyParams(options), 722 - scope: 'callWithDuplicateResponses' 723 - } 647 + createQueryKey("callWithDuplicateResponses", options) 724 648 ] 725 649 }); }; 726 650 727 - export const callWithDuplicateResponsesMutation: UseMutationOptions<CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesError, Options> = { 651 + export const callWithDuplicateResponsesMutation = () => { const mutationOptions: UseMutationOptions<CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesError, Options> = { 728 652 mutationFn: async (options) => { 729 653 const { data } = await callWithDuplicateResponses({ 730 654 ...options, ··· 732 656 }); 733 657 return data; 734 658 } 735 - }; 659 + }; return mutationOptions; }; 736 660 737 - export const callWithResponsesMutation: UseMutationOptions<CallWithResponsesResponse, CallWithResponsesError, Options> = { 661 + export const callWithResponsesMutation = () => { const mutationOptions: UseMutationOptions<CallWithResponsesResponse, CallWithResponsesError, Options> = { 738 662 mutationFn: async (options) => { 739 663 const { data } = await callWithResponses({ 740 664 ...options, ··· 742 666 }); 743 667 return data; 744 668 } 745 - }; 669 + }; return mutationOptions; }; 746 670 747 671 export const collectionFormatOptions = (options: Options<CollectionFormatData>) => { return queryOptions({ 748 672 queryFn: async ({ queryKey }) => { 749 673 const { data } = await collectionFormat({ 750 674 ...options, 751 - ...queryKey[0].params, 675 + ...queryKey[0], 752 676 throwOnError: true 753 677 }); 754 678 return data; 755 679 }, 756 680 queryKey: [ 757 - { 758 - params: createQueryKeyParams(options), 759 - scope: 'collectionFormat' 760 - } 681 + createQueryKey("collectionFormat", options) 761 682 ] 762 683 }); }; 763 684 ··· 765 686 queryFn: async ({ queryKey }) => { 766 687 const { data } = await types({ 767 688 ...options, 768 - ...queryKey[0].params, 689 + ...queryKey[0], 769 690 throwOnError: true 770 691 }); 771 692 return data; 772 693 }, 773 694 queryKey: [ 774 - { 775 - params: createQueryKeyParams(options), 776 - scope: 'types' 777 - } 695 + createQueryKey("types", options) 778 696 ] 779 697 }); }; 780 698 ··· 782 700 queryFn: async ({ queryKey }) => { 783 701 const { data } = await uploadFile({ 784 702 ...options, 785 - ...queryKey[0].params, 703 + ...queryKey[0], 786 704 throwOnError: true 787 705 }); 788 706 return data; 789 707 }, 790 708 queryKey: [ 791 - { 792 - params: createQueryKeyParams(options), 793 - scope: 'uploadFile' 794 - } 709 + createQueryKey("uploadFile", options) 795 710 ] 796 711 }); }; 797 712 798 - export const uploadFileMutation: UseMutationOptions<UploadFileResponse, UploadFileError, Options<UploadFileData>> = { 713 + export const uploadFileMutation = () => { const mutationOptions: UseMutationOptions<UploadFileResponse, UploadFileError, Options<UploadFileData>> = { 799 714 mutationFn: async (options) => { 800 715 const { data } = await uploadFile({ 801 716 ...options, ··· 803 718 }); 804 719 return data; 805 720 } 806 - }; 721 + }; return mutationOptions; }; 807 722 808 723 export const fileResponseOptions = (options: Options<FileResponseData>) => { return queryOptions({ 809 724 queryFn: async ({ queryKey }) => { 810 725 const { data } = await fileResponse({ 811 726 ...options, 812 - ...queryKey[0].params, 727 + ...queryKey[0], 813 728 throwOnError: true 814 729 }); 815 730 return data; 816 731 }, 817 732 queryKey: [ 818 - { 819 - params: createQueryKeyParams(options), 820 - scope: 'fileResponse' 821 - } 733 + createQueryKey("fileResponse", options) 822 734 ] 823 735 }); }; 824 736 ··· 826 738 queryFn: async ({ queryKey }) => { 827 739 const { data } = await complexTypes({ 828 740 ...options, 829 - ...queryKey[0].params, 741 + ...queryKey[0], 830 742 throwOnError: true 831 743 }); 832 744 return data; 833 745 }, 834 746 queryKey: [ 835 - { 836 - params: createQueryKeyParams(options), 837 - scope: 'complexTypes' 838 - } 747 + createQueryKey("complexTypes", options) 839 748 ] 840 749 }); }; 841 750 ··· 843 752 queryFn: async ({ queryKey }) => { 844 753 const { data } = await multipartRequest({ 845 754 ...options, 846 - ...queryKey[0].params, 755 + ...queryKey[0], 847 756 throwOnError: true 848 757 }); 849 758 return data; 850 759 }, 851 760 queryKey: [ 852 - { 853 - params: createQueryKeyParams(options), 854 - scope: 'multipartRequest' 855 - } 761 + createQueryKey("multipartRequest", options) 856 762 ] 857 763 }); }; 858 764 859 - export const multipartRequestMutation: UseMutationOptions<void, DefaultError, Options<MultipartRequestData>> = { 765 + export const multipartRequestMutation = () => { const mutationOptions: UseMutationOptions<void, DefaultError, Options<MultipartRequestData>> = { 860 766 mutationFn: async (options) => { 861 767 const { data } = await multipartRequest({ 862 768 ...options, ··· 864 770 }); 865 771 return data; 866 772 } 867 - }; 773 + }; return mutationOptions; }; 868 774 869 775 export const multipartResponseOptions = (options?: Options) => { return queryOptions({ 870 776 queryFn: async ({ queryKey }) => { 871 777 const { data } = await multipartResponse({ 872 778 ...options, 873 - ...queryKey[0].params, 779 + ...queryKey[0], 874 780 throwOnError: true 875 781 }); 876 782 return data; 877 783 }, 878 784 queryKey: [ 879 - { 880 - params: createQueryKeyParams(options), 881 - scope: 'multipartResponse' 882 - } 785 + createQueryKey("multipartResponse", options) 883 786 ] 884 787 }); }; 885 788 886 - export const complexParamsMutation: UseMutationOptions<ComplexParamsResponse, ComplexParamsError, Options<ComplexParamsData>> = { 789 + export const complexParamsMutation = () => { const mutationOptions: UseMutationOptions<ComplexParamsResponse, ComplexParamsError, Options<ComplexParamsData>> = { 887 790 mutationFn: async (options) => { 888 791 const { data } = await complexParams({ 889 792 ...options, ··· 891 794 }); 892 795 return data; 893 796 } 894 - }; 797 + }; return mutationOptions; }; 895 798 896 799 export const callWithResultFromHeaderOptions = (options?: Options) => { return queryOptions({ 897 800 queryFn: async ({ queryKey }) => { 898 801 const { data } = await callWithResultFromHeader({ 899 802 ...options, 900 - ...queryKey[0].params, 803 + ...queryKey[0], 901 804 throwOnError: true 902 805 }); 903 806 return data; 904 807 }, 905 808 queryKey: [ 906 - { 907 - params: createQueryKeyParams(options), 908 - scope: 'callWithResultFromHeader' 909 - } 809 + createQueryKey("callWithResultFromHeader", options) 910 810 ] 911 811 }); }; 912 812 913 - export const callWithResultFromHeaderMutation: UseMutationOptions<CallWithResultFromHeaderResponse, CallWithResultFromHeaderError, Options> = { 813 + export const callWithResultFromHeaderMutation = () => { const mutationOptions: UseMutationOptions<CallWithResultFromHeaderResponse, CallWithResultFromHeaderError, Options> = { 914 814 mutationFn: async (options) => { 915 815 const { data } = await callWithResultFromHeader({ 916 816 ...options, ··· 918 818 }); 919 819 return data; 920 820 } 921 - }; 821 + }; return mutationOptions; }; 922 822 923 823 export const testErrorCodeOptions = (options: Options<TestErrorCodeData>) => { return queryOptions({ 924 824 queryFn: async ({ queryKey }) => { 925 825 const { data } = await testErrorCode({ 926 826 ...options, 927 - ...queryKey[0].params, 827 + ...queryKey[0], 928 828 throwOnError: true 929 829 }); 930 830 return data; 931 831 }, 932 832 queryKey: [ 933 - { 934 - params: createQueryKeyParams(options), 935 - scope: 'testErrorCode' 936 - } 833 + createQueryKey("testErrorCode", options) 937 834 ] 938 835 }); }; 939 836 940 - export const testErrorCodeMutation: UseMutationOptions<TestErrorCodeResponse, TestErrorCodeError, Options<TestErrorCodeData>> = { 837 + export const testErrorCodeMutation = () => { const mutationOptions: UseMutationOptions<TestErrorCodeResponse, TestErrorCodeError, Options<TestErrorCodeData>> = { 941 838 mutationFn: async (options) => { 942 839 const { data } = await testErrorCode({ 943 840 ...options, ··· 945 842 }); 946 843 return data; 947 844 } 948 - }; 845 + }; return mutationOptions; }; 949 846 950 847 export const nonAsciiæøåÆøÅöôêÊ字符串Options = (options: Options<NonAsciiæøåÆøÅöôêÊ字符串Data>) => { return queryOptions({ 951 848 queryFn: async ({ queryKey }) => { 952 849 const { data } = await nonAsciiæøåÆøÅöôêÊ字符串({ 953 850 ...options, 954 - ...queryKey[0].params, 851 + ...queryKey[0], 955 852 throwOnError: true 956 853 }); 957 854 return data; 958 855 }, 959 856 queryKey: [ 960 - { 961 - params: createQueryKeyParams(options), 962 - scope: 'nonAsciiæøåÆøÅöôêÊ字符串' 963 - } 857 + createQueryKey("nonAsciiæøåÆøÅöôêÊ字符串", options) 964 858 ] 965 859 }); }; 966 860 967 - export const nonAsciiæøåÆøÅöôêÊ字符串Mutation: UseMutationOptions<NonAsciiæøåÆøÅöôêÊ字符串Response, NonAsciiæøåÆøÅöôêÊ字符串Error, Options<NonAsciiæøåÆøÅöôêÊ字符串Data>> = { 861 + export const nonAsciiæøåÆøÅöôêÊ字符串Mutation = () => { const mutationOptions: UseMutationOptions<NonAsciiæøåÆøÅöôêÊ字符串Response, NonAsciiæøåÆøÅöôêÊ字符串Error, Options<NonAsciiæøåÆøÅöôêÊ字符串Data>> = { 968 862 mutationFn: async (options) => { 969 863 const { data } = await nonAsciiæøåÆøÅöôêÊ字符串({ 970 864 ...options, ··· 972 866 }); 973 867 return data; 974 868 } 975 - }; 869 + }; return mutationOptions; }; 976 870 977 - export const putWithFormUrlEncodedMutation: UseMutationOptions<void, DefaultError, Options<PutWithFormUrlEncodedData>> = { 871 + export const putWithFormUrlEncodedMutation = () => { const mutationOptions: UseMutationOptions<void, DefaultError, Options<PutWithFormUrlEncodedData>> = { 978 872 mutationFn: async (options) => { 979 873 const { data } = await putWithFormUrlEncoded({ 980 874 ...options, ··· 982 876 }); 983 877 return data; 984 878 } 985 - }; 879 + }; return mutationOptions; };
+22 -23
packages/openapi-ts/test/__snapshots__/test/generated/v3-hey-api-client-fetch-plugin-tanstack-vue-query_transform/@tanstack/vue-query.gen.ts.snap
··· 3 3 import type { Options } from '@hey-api/client-fetch'; 4 4 import { queryOptions, type UseMutationOptions } from '@tanstack/vue-query'; 5 5 import type { ParentModelWithDatesError, ParentModelWithDatesResponse, ModelWithDatesError, ModelWithDatesResponse, ModelWithDatesArrayError, ModelWithDatesArrayResponse, ArrayOfDatesError, ArrayOfDatesResponse, DateError, DateResponse, MultipleResponsesError, MultipleResponsesResponse } from '../types.gen'; 6 - import { parentModelWithDates, modelWithDates, modelWithDatesArray, arrayOfDates, date, multipleResponses } from '../services.gen'; 6 + import { client, parentModelWithDates, modelWithDates, modelWithDatesArray, arrayOfDates, date, multipleResponses } from '../services.gen'; 7 7 8 8 type QueryKey<TOptions extends Options> = [ 9 - { 9 + Pick<TOptions, 'baseUrl' | 'body' | 'headers' | 'path' | 'query'> & { 10 + _id: string; 10 11 infinite?: boolean; 11 - params: Pick<TOptions, "body" | "headers" | "path" | "query">; 12 - scope: string; 13 12 } 14 13 ]; 15 14 16 - const createQueryKeyParams = <TOptions extends Options>(options?: TOptions): QueryKey<TOptions>[0]["params"] => { 17 - const params: QueryKey<TOptions>[0]["params"] = {} as QueryKey<TOptions>[0]["params"]; 15 + const createQueryKey = <TOptions extends Options>(id: string, options?: TOptions, infinite?: boolean): QueryKey<TOptions>[0] => { 16 + const params: QueryKey<TOptions>[0] = { _id: id, baseUrl: client.getConfig().baseUrl } as QueryKey<TOptions>[0]; 17 + if (infinite) { 18 + params.infinite = infinite; 19 + } 18 20 if (options?.body) { 19 21 params.body = options.body; 20 22 } ··· 34 36 queryFn: async ({ queryKey }) => { 35 37 const { data } = await parentModelWithDates({ 36 38 ...options, 37 - ...queryKey[0].params, 39 + ...queryKey[0], 38 40 throwOnError: true 39 41 }); 40 42 return data; 41 43 }, 42 44 queryKey: [ 43 - { 44 - params: createQueryKeyParams(options), 45 - scope: 'parentModelWithDates' 46 - } 45 + createQueryKey("parentModelWithDates", options) 47 46 ] 48 47 }); }; 49 48 50 - export const parentModelWithDatesMutation: UseMutationOptions<ParentModelWithDatesResponse, ParentModelWithDatesError, Options> = { 49 + export const parentModelWithDatesMutation = () => { const mutationOptions: UseMutationOptions<ParentModelWithDatesResponse, ParentModelWithDatesError, Options> = { 51 50 mutationFn: async (options) => { 52 51 const { data } = await parentModelWithDates({ 53 52 ...options, ··· 55 54 }); 56 55 return data; 57 56 } 58 - }; 57 + }; return mutationOptions; }; 59 58 60 - export const modelWithDatesMutation: UseMutationOptions<ModelWithDatesResponse, ModelWithDatesError, Options> = { 59 + export const modelWithDatesMutation = () => { const mutationOptions: UseMutationOptions<ModelWithDatesResponse, ModelWithDatesError, Options> = { 61 60 mutationFn: async (options) => { 62 61 const { data } = await modelWithDates({ 63 62 ...options, ··· 65 64 }); 66 65 return data; 67 66 } 68 - }; 67 + }; return mutationOptions; }; 69 68 70 - export const modelWithDatesArrayMutation: UseMutationOptions<ModelWithDatesArrayResponse, ModelWithDatesArrayError, Options> = { 69 + export const modelWithDatesArrayMutation = () => { const mutationOptions: UseMutationOptions<ModelWithDatesArrayResponse, ModelWithDatesArrayError, Options> = { 71 70 mutationFn: async (options) => { 72 71 const { data } = await modelWithDatesArray({ 73 72 ...options, ··· 75 74 }); 76 75 return data; 77 76 } 78 - }; 77 + }; return mutationOptions; }; 79 78 80 - export const arrayOfDatesMutation: UseMutationOptions<ArrayOfDatesResponse, ArrayOfDatesError, Options> = { 79 + export const arrayOfDatesMutation = () => { const mutationOptions: UseMutationOptions<ArrayOfDatesResponse, ArrayOfDatesError, Options> = { 81 80 mutationFn: async (options) => { 82 81 const { data } = await arrayOfDates({ 83 82 ...options, ··· 85 84 }); 86 85 return data; 87 86 } 88 - }; 87 + }; return mutationOptions; }; 89 88 90 - export const dateMutation: UseMutationOptions<DateResponse, DateError, Options> = { 89 + export const dateMutation = () => { const mutationOptions: UseMutationOptions<DateResponse, DateError, Options> = { 91 90 mutationFn: async (options) => { 92 91 const { data } = await date({ 93 92 ...options, ··· 95 94 }); 96 95 return data; 97 96 } 98 - }; 97 + }; return mutationOptions; }; 99 98 100 - export const multipleResponsesMutation: UseMutationOptions<MultipleResponsesResponse, MultipleResponsesError, Options> = { 99 + export const multipleResponsesMutation = () => { const mutationOptions: UseMutationOptions<MultipleResponsesResponse, MultipleResponsesError, Options> = { 101 100 mutationFn: async (options) => { 102 101 const { data } = await multipleResponses({ 103 102 ...options, ··· 105 104 }); 106 105 return data; 107 106 } 108 - }; 107 + }; return mutationOptions; };