@kubb/plugin-fetch 5.9.0 → 5.10.0-canary.20261024T203516

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
@@ -882,14 +882,35 @@ function Operation({ name, node, types, zodResolver, validator, returnType, thro
882
882
  //#endregion
883
883
  //#region ../../internals/client/src/resolveOperationTypes.ts
884
884
  /**
885
- * Picks the plugin a generated client takes its `Options` and `Responses` types from.
885
+ * A `plugin-ts` shaped resolver whose operation type names point at the types `pluginZod({ inferred })`
886
+ * exports next to each schema, so code written against `plugin-ts` names picks up the zod types.
887
+ */
888
+ function toZodTypeResolver(resolver) {
889
+ const type = (name) => resolver.schema.type(name);
890
+ return {
891
+ ...resolver,
892
+ file: resolver.file.bind(resolver),
893
+ param: {
894
+ name: (node, p) => type(resolver.param.name(node, p)),
895
+ path: (node, p) => type(resolver.param.path(node, p)),
896
+ query: (node, p) => type(resolver.param.query(node, p)),
897
+ headers: (node, p) => type(resolver.param.headers(node, p))
898
+ },
899
+ response: {
900
+ body: (node) => type(resolver.response.body(node)),
901
+ status: (node, statusCode) => type(resolver.response.status(node, statusCode)),
902
+ response: (node) => type(resolver.response.response(node)),
903
+ responses: (node) => type(resolver.response.responses(node)),
904
+ options: (node) => resolver.response.options(node)
905
+ }
906
+ };
907
+ }
908
+ /**
909
+ * Picks the plugin generated clients, query hooks, and MCP handlers take their operation types from.
886
910
  *
887
- * `plugin-ts` wins whenever it is in the pipeline, so existing configs keep the types they generate
888
- * today. Without it, `pluginZod({ inferred: true })` takes over: its inferred options and responses
889
- * types are built from the same shared schemas as the `plugin-ts` ones, so a client typed off
890
- * `z.infer` carries what the codecs decode to (a `Temporal` instance, a `Date`) rather than the raw
891
- * wire type. Throws `KUBB_MISSING_DEPENDENCY` for `pluginName` when neither is available, since the
892
- * client has nothing to type against.
911
+ * `pluginZod({ inferred: 'codec' })` wins, so a codec param takes its domain value. Otherwise `plugin-ts`
912
+ * wins when it is in the pipeline, and without it any `pluginZod({ inferred })`. Throws
913
+ * `KUBB_MISSING_DEPENDENCY` for `pluginName` when neither is available.
893
914
  *
894
915
  * @example
895
916
  * ```ts
@@ -899,16 +920,16 @@ function Operation({ name, node, types, zodResolver, validator, returnType, thro
899
920
  */
900
921
  function resolveOperationTypes(driver, pluginName) {
901
922
  const pluginTs = driver.getPlugin(_kubb_plugin_ts.pluginTsName);
902
- if (pluginTs) {
923
+ const pluginZod = driver.getPlugin(_kubb_plugin_zod.pluginZodName);
924
+ if (pluginTs && pluginZod?.options?.inferred !== "codec") {
903
925
  const resolver = driver.getResolver(_kubb_plugin_ts.pluginTsName);
904
926
  return {
905
927
  response: resolver.response,
906
928
  resolver,
907
929
  output: pluginTs.options?.output,
908
- group: pluginTs.options?.group
930
+ group: pluginTs.options?.group ?? void 0
909
931
  };
910
932
  }
911
- const pluginZod = driver.getPlugin(_kubb_plugin_zod.pluginZodName);
912
933
  if (!pluginZod?.options?.inferred) throw new kubb_kit.Diagnostics.Error({
913
934
  code: kubb_kit.Diagnostics.code.missingDependency,
914
935
  severity: "error",
@@ -917,15 +938,12 @@ function resolveOperationTypes(driver, pluginName) {
917
938
  location: { kind: "config" },
918
939
  plugin: pluginName
919
940
  });
920
- const resolver = driver.getResolver(_kubb_plugin_zod.pluginZodName);
941
+ const resolver = toZodTypeResolver(driver.getResolver(_kubb_plugin_zod.pluginZodName));
921
942
  return {
922
- response: {
923
- options: resolver.response.options,
924
- responses: (node) => resolver.schema.type(resolver.response.responses(node))
925
- },
943
+ response: resolver.response,
926
944
  resolver,
927
945
  output: pluginZod.options.output,
928
- group: pluginZod.options.group
946
+ group: pluginZod.options.group ?? void 0
929
947
  };
930
948
  }
931
949
  //#endregion
@@ -1488,7 +1506,7 @@ var compatibility = {
1488
1506
  };
1489
1507
  //#endregion
1490
1508
  //#region package.json
1491
- var version = "5.9.0";
1509
+ var version = "5.10.0-canary.20261024T203516";
1492
1510
  //#endregion
1493
1511
  //#region src/templates.ts
1494
1512
  /** Absolute path to the fetch client template, copied into `.kubb/client.ts`. */