@kubb/plugin-react-query 5.8.0-canary.20261027T072349 → 5.8.0-canary.20261027T170749

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -472,6 +472,24 @@ function getNestedAccessor(param, accessor) {
472
472
  function resolveOperationName(name) {
473
473
  return ensureValidVarName(camelCase(name));
474
474
  }
475
+ /**
476
+ * Builds the allocation key for a declaration an operation owns. `scope` names which declaration
477
+ * it is, so two of them never share an allocation even when a custom resolver gives both the same
478
+ * name. Leave `scope` empty for the operation's own declaration.
479
+ *
480
+ * @example
481
+ * ```ts
482
+ * resolver.resolveName({ key: operationKey(node, 'response', 'status', 404), name })
483
+ * ```
484
+ */
485
+ function operationKey(node, ...scope) {
486
+ return [
487
+ "operation",
488
+ node.method,
489
+ node.path,
490
+ ...scope.map(String)
491
+ ];
492
+ }
475
493
  //#endregion
476
494
  //#region ../../internals/shared/src/group.ts
477
495
  /**
@@ -506,12 +524,12 @@ function createGroupConfig(group) {
506
524
  //#endregion
507
525
  //#region kubb-extension.json
508
526
  var compatibility = {
509
- "kubb": ">=5.8.3",
527
+ "kubb": ">=5.14.6",
510
528
  "node": ">=22.22"
511
529
  };
512
530
  //#endregion
513
531
  //#region package.json
514
- var version = "5.8.0-canary.20261027T072349";
532
+ var version = "5.8.0-canary.20261027T170749";
515
533
  //#endregion
516
534
  //#region ../../internals/client/src/resolveOperationTypes.ts
517
535
  /**
@@ -738,8 +756,12 @@ function resolveClientOperation(options) {
738
756
  group: operationOptions.group ?? void 0
739
757
  });
740
758
  const { importPath } = operationOptions;
759
+ const name = resolver.name(node.operationId);
741
760
  return {
742
- name: resolver.name(node.operationId),
761
+ name: resolver.resolveName({
762
+ key: operationKey(node),
763
+ name
764
+ }),
743
765
  path: file.path,
744
766
  clientPath: importPath === void 0 ? path.resolve(root, ".kubb/client.ts") : resolveImportPath({
745
767
  importPath,
@@ -1349,19 +1371,39 @@ function MutationKey({ name, node, transformer, typeName }) {
1349
1371
  function createQueryResolver(variant = "") {
1350
1372
  return {
1351
1373
  name(node) {
1352
- return `use${capitalize(this.name(node.operationId))}${variant}`;
1374
+ const name = `use${capitalize(this.name(node.operationId))}${variant}`;
1375
+ return this.resolveName({
1376
+ key: operationKey(node, "query", variant, "name"),
1377
+ name
1378
+ });
1353
1379
  },
1354
1380
  optionsName(node) {
1355
- return `${this.name(node.operationId)}${variant}QueryOptions`;
1381
+ const name = `${this.name(node.operationId)}${variant}QueryOptions`;
1382
+ return this.resolveName({
1383
+ key: operationKey(node, "query", variant, "optionsName"),
1384
+ name
1385
+ });
1356
1386
  },
1357
1387
  keyName(node) {
1358
- return `${this.name(node.operationId)}${variant}QueryKey`;
1388
+ const name = `${this.name(node.operationId)}${variant}QueryKey`;
1389
+ return this.resolveName({
1390
+ key: operationKey(node, "query", variant, "keyName"),
1391
+ name
1392
+ });
1359
1393
  },
1360
1394
  keyTypeName(node) {
1361
- return `${capitalize(this.name(node.operationId))}${variant}QueryKey`;
1395
+ const name = `${capitalize(this.name(node.operationId))}${variant}QueryKey`;
1396
+ return this.resolveName({
1397
+ key: operationKey(node, "query", variant, "keyTypeName"),
1398
+ name
1399
+ });
1362
1400
  },
1363
1401
  clientName(node) {
1364
- return `${this.name(node.operationId)}${variant}`;
1402
+ const name = `${this.name(node.operationId)}${variant}`;
1403
+ return this.resolveName({
1404
+ key: operationKey(node, "query", variant, "clientName"),
1405
+ name
1406
+ });
1365
1407
  }
1366
1408
  };
1367
1409
  }
@@ -1378,10 +1420,18 @@ function createQueryResolver(variant = "") {
1378
1420
  function createMutationResolver() {
1379
1421
  return {
1380
1422
  name(node) {
1381
- return `use${capitalize(this.name(node.operationId))}`;
1423
+ const name = `use${capitalize(this.name(node.operationId))}`;
1424
+ return this.resolveName({
1425
+ key: operationKey(node, "mutation", "name"),
1426
+ name
1427
+ });
1382
1428
  },
1383
1429
  keyName(node) {
1384
- return `${this.name(node.operationId)}MutationKey`;
1430
+ const name = `${this.name(node.operationId)}MutationKey`;
1431
+ return this.resolveName({
1432
+ key: operationKey(node, "mutation", "keyName"),
1433
+ name
1434
+ });
1385
1435
  }
1386
1436
  };
1387
1437
  }
@@ -2291,18 +2341,32 @@ const resolverReactQuery = createResolver({
2291
2341
  mutation: {
2292
2342
  ...createMutationResolver(),
2293
2343
  optionsName(node) {
2294
- return `${this.name(node.operationId)}MutationOptions`;
2344
+ const name = `${this.name(node.operationId)}MutationOptions`;
2345
+ return this.resolveName({
2346
+ key: operationKey(node, "mutation", "optionsName"),
2347
+ name
2348
+ });
2295
2349
  },
2296
2350
  typeName(node) {
2297
- return capitalize(this.name(node.operationId));
2351
+ const name = capitalize(this.name(node.operationId));
2352
+ return this.resolveName({
2353
+ key: operationKey(node, "mutation", "typeName"),
2354
+ name
2355
+ });
2298
2356
  }
2299
2357
  },
2300
2358
  hook: {
2301
2359
  optionsName() {
2302
- return "HookOptions";
2360
+ return this.resolveName({
2361
+ key: ["hook", "options"],
2362
+ name: "HookOptions"
2363
+ });
2303
2364
  },
2304
2365
  customOptionsName() {
2305
- return "getCustomHookOptions";
2366
+ return this.resolveName({
2367
+ key: ["hook", "custom-options"],
2368
+ name: "getCustomHookOptions"
2369
+ });
2306
2370
  }
2307
2371
  }
2308
2372
  });