@kubb/plugin-react-query 5.11.0-canary.20261110T080439 → 5.11.0-canary.20261110T135754

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.cjs CHANGED
@@ -52,24 +52,49 @@ function operationFileEntry(node, name, extname = ".ts") {
52
52
  };
53
53
  }
54
54
  /**
55
- * Resolves a dependency plugin's generated file for `node.operationId`, cached in `memo` (the
56
- * build's `ctx.memo`) under the resolver's own plugin name and the operation. Several dependents reading the
57
- * same dependency for the same operation in one pass (a query plugin's several hook generators, the
58
- * MCP handler, ...) share one computed name and path instead of each calling `resolver.file` again.
55
+ * Resolves the file a schema-emitting plugin (`plugin-ts`, `plugin-zod`, `plugin-faker`) writes
56
+ * `node` to, cached in `ctx.memo` under the resolver's plugin name and the
57
+ * operation. The plugin itself and every plugin that imports from it call this, so they all get
58
+ * the same path.
59
59
  *
60
- * @example Cache `plugin-ts`'s file for the current operation
60
+ * When that path matches the file of a component schema in `ctx.driver.inputNode`, ignoring case, the file name
61
+ * gets an `Operation` suffix: operation `point` goes to `PointOperation.ts` next to schema `Point.ts`.
62
+ * Otherwise the two merge into one file, or overwrite each other on a case-insensitive file system.
63
+ * Only the file name changes. The declarations keep their names.
64
+ *
65
+ * @example Resolve `plugin-ts`'s file for the current operation
61
66
  * ```ts
62
- * const fileTs = resolveDependencyOperationFile({ memo: ctx.memo, node, resolver: tsResolver, root, output })
67
+ * const fileTs = resolveOperationFile({ ctx, node, resolver: tsResolver, root, output })
63
68
  * ```
64
69
  */
65
- function resolveDependencyOperationFile(options) {
66
- const { memo, node, resolver, root, output, group } = options;
67
- return memo(`${resolver.pluginName}:operationFile:${node.operationId}`, () => resolver.file({
68
- ...operationFileEntry(node, node.operationId),
70
+ function resolveOperationFile(options) {
71
+ const { ctx, node, resolver, root, output } = options;
72
+ const { memo } = ctx;
73
+ const location = {
69
74
  root,
70
75
  output,
71
- group: group ?? void 0
72
- }));
76
+ group: options.group ?? void 0
77
+ };
78
+ return memo(`${resolver.pluginName}:operationFile:${node.operationId}`, () => {
79
+ const schemaPaths = memo(`${resolver.pluginName}:schemaFilePaths`, () => new Set((ctx.driver.inputNode?.schemas ?? []).flatMap((schema) => schema.name ? [resolver.file({
80
+ name: schema.name,
81
+ extname: ".ts",
82
+ ...location
83
+ }).path.toLowerCase()] : [])));
84
+ let file = resolver.file({
85
+ ...operationFileEntry(node, node.operationId),
86
+ ...location
87
+ });
88
+ for (let name = `${node.operationId}Operation`; schemaPaths.has(file.path.toLowerCase()); name += "Operation") {
89
+ const next = resolver.file({
90
+ ...operationFileEntry(node, name),
91
+ ...location
92
+ });
93
+ if (next.path === file.path) break;
94
+ file = next;
95
+ }
96
+ return file;
97
+ });
73
98
  }
74
99
  /**
75
100
  * The operation's method and path as plain text, such as `` `GET /pet/{petId}` ``. A path is not a valid `{@link}` target.
@@ -550,7 +575,7 @@ var compatibility = {
550
575
  "node": ">=22.22"
551
576
  };
552
577
  // package.json
553
- var version = "5.11.0-canary.20261110T080439";
578
+ var version = "5.11.0-canary.20261110T135754";
554
579
  // ../../internals/client/src/resolveClient.ts
555
580
  /**
556
581
  * Resolves which client plugin a consumer (react-query, vue-query, swr, mcp) should call for an
@@ -819,8 +844,8 @@ function resolveHookFile(node, ctx, options) {
819
844
  output,
820
845
  group: group ?? void 0
821
846
  });
822
- const fileTs = resolveDependencyOperationFile({
823
- memo: ctx.memo,
847
+ const fileTs = resolveOperationFile({
848
+ ctx,
824
849
  node,
825
850
  resolver: tsResolver,
826
851
  root,