@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.cjs CHANGED
@@ -418,34 +418,44 @@ function resolveContractClient(options) {
418
418
  * Resolves the contract client `<op>` a consumer (query hook, MCP handler) imports, by looking up
419
419
  * the registered contract client plugin's resolver and output. Works for any contract client plugin
420
420
  * (plugin-fetch or plugin-axios). Returns `null` when no contract plugin is in play (the inline
421
- * path). The plugin injects `.kubb/client.ts` at the global output root, the same path consumers
422
- * read `RequestConfig` / `ResponseErrorConfig` from.
421
+ * path), or when the client plugin's `exclude` / `include` leaves this operation out, since it then
422
+ * emits no `<op>` to import. The plugin injects `.kubb/client.ts` at the global output root, the
423
+ * same path consumers read `RequestConfig` / `ResponseErrorConfig` from.
423
424
  *
424
425
  * The result is cached in the current node's `cache` (`ctx.cache`) under the client plugin's name,
425
426
  * so several dependents reading the same client plugin for one operation in a single pass
426
427
  * (react-query's query/mutation/infinite generators, vue-query, swr, the MCP handler, ...) share
427
428
  * one computed result instead of each re-deriving the name and path.
428
429
  *
429
- * `returnType` mirrors the client plugin's own `returnType` option (`'full'` when unset), so a
430
- * dependent's generated call body can match it instead of assuming the full `RequestResult` shape.
430
+ * `returnType`, `output`, and `group` are the client plugin's options for this operation, after its
431
+ * `override` entries, the same resolution its own generator sees. A dependent's generated call body
432
+ * and import path therefore match the `<op>` actually emitted, even when an `override` changes it.
431
433
  */
432
434
  function resolveClientOperation(options) {
433
435
  const { clientPlugin, driver, node, root, output, cache } = options;
434
436
  if (!clientPlugin) return null;
435
437
  return cache.ensureItem(`${clientPlugin.pluginName}:clientOperation`, () => {
436
438
  const resolver = driver.getResolver(clientPlugin.pluginName);
437
- const plugin = driver.getPlugin(clientPlugin.pluginName);
439
+ const pluginOptions = driver.getPlugin(clientPlugin.pluginName)?.options ?? {};
440
+ const { exclude, include, override } = pluginOptions;
441
+ const operationOptions = Boolean(exclude?.length || include?.length || override?.length) && resolver.default ? resolver.default.options(node, {
442
+ options: pluginOptions,
443
+ exclude,
444
+ include,
445
+ override
446
+ }) : pluginOptions;
447
+ if (!operationOptions) return null;
438
448
  const file = resolver.file({
439
449
  ...operationFileEntry(node, node.operationId),
440
450
  root,
441
- output: plugin?.options?.output ?? output,
442
- group: plugin?.options?.group ?? void 0
451
+ output: operationOptions.output ?? output,
452
+ group: operationOptions.group ?? void 0
443
453
  });
444
454
  return {
445
455
  name: resolver.name(node.operationId),
446
456
  path: file.path,
447
457
  clientPath: node_path.default.resolve(root, ".kubb/client.ts"),
448
- returnType: plugin?.options?.returnType ?? "full"
458
+ returnType: operationOptions.returnType ?? "full"
449
459
  };
450
460
  });
451
461
  }
@@ -601,11 +611,11 @@ function resolveMutationConfig(mutation, options) {
601
611
  }
602
612
  /**
603
613
  * Classifies an operation as a query or a mutation from the resolved `query` / `mutation` method lists.
604
- * `query: false` still marks the operation as a query so the query-family generators keep matching it,
605
- * and a method already claimed by `query` never counts as a mutation.
614
+ * Disabled query and mutation configs do not claim operations, and a method already claimed by an
615
+ * enabled query config never counts as a mutation.
606
616
  */
607
617
  function classifyOperation(node, { query, mutation }) {
608
- const isQuery = query === false || !!query && query.methods.some((method) => node.method.toLowerCase() === method.toLowerCase());
618
+ const isQuery = !!query && query.methods.some((method) => node.method.toLowerCase() === method.toLowerCase());
609
619
  const queryMethods = new Set(query ? query.methods : []);
610
620
  return {
611
621
  isQuery,