@kubb/plugin-swr 5.1.1 → 5.1.3

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
@@ -388,34 +388,44 @@ function resolveContractClient(options) {
388
388
  * Resolves the contract client `<op>` a consumer (query hook, MCP handler) imports, by looking up
389
389
  * the registered contract client plugin's resolver and output. Works for any contract client plugin
390
390
  * (plugin-fetch or plugin-axios). Returns `null` when no contract plugin is in play (the inline
391
- * path). The plugin injects `.kubb/client.ts` at the global output root, the same path consumers
392
- * read `RequestConfig` / `ResponseErrorConfig` from.
391
+ * path), or when the client plugin's `exclude` / `include` leaves this operation out, since it then
392
+ * emits no `<op>` to import. The plugin injects `.kubb/client.ts` at the global output root, the
393
+ * same path consumers read `RequestConfig` / `ResponseErrorConfig` from.
393
394
  *
394
395
  * The result is cached in the current node's `cache` (`ctx.cache`) under the client plugin's name,
395
396
  * so several dependents reading the same client plugin for one operation in a single pass
396
397
  * (react-query's query/mutation/infinite generators, vue-query, swr, the MCP handler, ...) share
397
398
  * one computed result instead of each re-deriving the name and path.
398
399
  *
399
- * `returnType` mirrors the client plugin's own `returnType` option (`'full'` when unset), so a
400
- * dependent's generated call body can match it instead of assuming the full `RequestResult` shape.
400
+ * `returnType`, `output`, and `group` are the client plugin's options for this operation, after its
401
+ * `override` entries, the same resolution its own generator sees. A dependent's generated call body
402
+ * and import path therefore match the `<op>` actually emitted, even when an `override` changes it.
401
403
  */
402
404
  function resolveClientOperation(options) {
403
405
  const { clientPlugin, driver, node, root, output, cache } = options;
404
406
  if (!clientPlugin) return null;
405
407
  return cache.ensureItem(`${clientPlugin.pluginName}:clientOperation`, () => {
406
408
  const resolver = driver.getResolver(clientPlugin.pluginName);
407
- const plugin = driver.getPlugin(clientPlugin.pluginName);
409
+ const pluginOptions = driver.getPlugin(clientPlugin.pluginName)?.options ?? {};
410
+ const { exclude, include, override } = pluginOptions;
411
+ const operationOptions = Boolean(exclude?.length || include?.length || override?.length) && resolver.default ? resolver.default.options(node, {
412
+ options: pluginOptions,
413
+ exclude,
414
+ include,
415
+ override
416
+ }) : pluginOptions;
417
+ if (!operationOptions) return null;
408
418
  const file = resolver.file({
409
419
  ...operationFileEntry(node, node.operationId),
410
420
  root,
411
- output: plugin?.options?.output ?? output,
412
- group: plugin?.options?.group ?? void 0
421
+ output: operationOptions.output ?? output,
422
+ group: operationOptions.group ?? void 0
413
423
  });
414
424
  return {
415
425
  name: resolver.name(node.operationId),
416
426
  path: file.path,
417
427
  clientPath: path.resolve(root, ".kubb/client.ts"),
418
- returnType: plugin?.options?.returnType ?? "full"
428
+ returnType: operationOptions.returnType ?? "full"
419
429
  };
420
430
  });
421
431
  }
@@ -571,11 +581,11 @@ function resolveMutationConfig(mutation, options) {
571
581
  }
572
582
  /**
573
583
  * Classifies an operation as a query or a mutation from the resolved `query` / `mutation` method lists.
574
- * `query: false` still marks the operation as a query so the query-family generators keep matching it,
575
- * and a method already claimed by `query` never counts as a mutation.
584
+ * Disabled query and mutation configs do not claim operations, and a method already claimed by an
585
+ * enabled query config never counts as a mutation.
576
586
  */
577
587
  function classifyOperation(node, { query, mutation }) {
578
- const isQuery = query === false || !!query && query.methods.some((method) => node.method.toLowerCase() === method.toLowerCase());
588
+ const isQuery = !!query && query.methods.some((method) => node.method.toLowerCase() === method.toLowerCase());
579
589
  const queryMethods = new Set(query ? query.methods : []);
580
590
  return {
581
591
  isQuery,