@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 +35 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +35 -17
- package/dist/index.js.map +1 -1
- package/docs/options.md +1 -1
- package/package.json +5 -5
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Exclude, Group, Include, Output, OutputOptions, Override, PluginType, Resolver, ResolverPatch, ast } from "kubb/kit";
|
|
2
2
|
import "@kubb/plugin-zod";
|
|
3
|
+
import "@kubb/plugin-ts";
|
|
3
4
|
//#region ../../internals/client/src/types.d.ts
|
|
4
5
|
/**
|
|
5
6
|
* Validator applied to the request and response using schemas from `@kubb/plugin-zod`.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Exclude, Group, Include, Output, OutputOptions, Override, PluginType, Resolver, ResolverPatch, ast } from "kubb/kit";
|
|
2
2
|
import "@kubb/plugin-zod";
|
|
3
|
+
import "@kubb/plugin-ts";
|
|
3
4
|
//#region ../../internals/client/src/types.d.ts
|
|
4
5
|
/**
|
|
5
6
|
* Validator applied to the request and response using schemas from `@kubb/plugin-zod`.
|
package/dist/index.js
CHANGED
|
@@ -856,14 +856,35 @@ function Operation({ name, node, types, zodResolver, validator, returnType, thro
|
|
|
856
856
|
//#endregion
|
|
857
857
|
//#region ../../internals/client/src/resolveOperationTypes.ts
|
|
858
858
|
/**
|
|
859
|
-
*
|
|
859
|
+
* A `plugin-ts` shaped resolver whose operation type names point at the types `pluginZod({ inferred })`
|
|
860
|
+
* exports next to each schema, so code written against `plugin-ts` names picks up the zod types.
|
|
861
|
+
*/
|
|
862
|
+
function toZodTypeResolver(resolver) {
|
|
863
|
+
const type = (name) => resolver.schema.type(name);
|
|
864
|
+
return {
|
|
865
|
+
...resolver,
|
|
866
|
+
file: resolver.file.bind(resolver),
|
|
867
|
+
param: {
|
|
868
|
+
name: (node, p) => type(resolver.param.name(node, p)),
|
|
869
|
+
path: (node, p) => type(resolver.param.path(node, p)),
|
|
870
|
+
query: (node, p) => type(resolver.param.query(node, p)),
|
|
871
|
+
headers: (node, p) => type(resolver.param.headers(node, p))
|
|
872
|
+
},
|
|
873
|
+
response: {
|
|
874
|
+
body: (node) => type(resolver.response.body(node)),
|
|
875
|
+
status: (node, statusCode) => type(resolver.response.status(node, statusCode)),
|
|
876
|
+
response: (node) => type(resolver.response.response(node)),
|
|
877
|
+
responses: (node) => type(resolver.response.responses(node)),
|
|
878
|
+
options: (node) => resolver.response.options(node)
|
|
879
|
+
}
|
|
880
|
+
};
|
|
881
|
+
}
|
|
882
|
+
/**
|
|
883
|
+
* Picks the plugin generated clients, query hooks, and MCP handlers take their operation types from.
|
|
860
884
|
*
|
|
861
|
-
* `
|
|
862
|
-
*
|
|
863
|
-
*
|
|
864
|
-
* `z.infer` carries what the codecs decode to (a `Temporal` instance, a `Date`) rather than the raw
|
|
865
|
-
* wire type. Throws `KUBB_MISSING_DEPENDENCY` for `pluginName` when neither is available, since the
|
|
866
|
-
* client has nothing to type against.
|
|
885
|
+
* `pluginZod({ inferred: 'codec' })` wins, so a codec param takes its domain value. Otherwise `plugin-ts`
|
|
886
|
+
* wins when it is in the pipeline, and without it any `pluginZod({ inferred })`. Throws
|
|
887
|
+
* `KUBB_MISSING_DEPENDENCY` for `pluginName` when neither is available.
|
|
867
888
|
*
|
|
868
889
|
* @example
|
|
869
890
|
* ```ts
|
|
@@ -873,16 +894,16 @@ function Operation({ name, node, types, zodResolver, validator, returnType, thro
|
|
|
873
894
|
*/
|
|
874
895
|
function resolveOperationTypes(driver, pluginName) {
|
|
875
896
|
const pluginTs = driver.getPlugin(pluginTsName);
|
|
876
|
-
|
|
897
|
+
const pluginZod = driver.getPlugin(pluginZodName);
|
|
898
|
+
if (pluginTs && pluginZod?.options?.inferred !== "codec") {
|
|
877
899
|
const resolver = driver.getResolver(pluginTsName);
|
|
878
900
|
return {
|
|
879
901
|
response: resolver.response,
|
|
880
902
|
resolver,
|
|
881
903
|
output: pluginTs.options?.output,
|
|
882
|
-
group: pluginTs.options?.group
|
|
904
|
+
group: pluginTs.options?.group ?? void 0
|
|
883
905
|
};
|
|
884
906
|
}
|
|
885
|
-
const pluginZod = driver.getPlugin(pluginZodName);
|
|
886
907
|
if (!pluginZod?.options?.inferred) throw new Diagnostics.Error({
|
|
887
908
|
code: Diagnostics.code.missingDependency,
|
|
888
909
|
severity: "error",
|
|
@@ -891,15 +912,12 @@ function resolveOperationTypes(driver, pluginName) {
|
|
|
891
912
|
location: { kind: "config" },
|
|
892
913
|
plugin: pluginName
|
|
893
914
|
});
|
|
894
|
-
const resolver = driver.getResolver(pluginZodName);
|
|
915
|
+
const resolver = toZodTypeResolver(driver.getResolver(pluginZodName));
|
|
895
916
|
return {
|
|
896
|
-
response:
|
|
897
|
-
options: resolver.response.options,
|
|
898
|
-
responses: (node) => resolver.schema.type(resolver.response.responses(node))
|
|
899
|
-
},
|
|
917
|
+
response: resolver.response,
|
|
900
918
|
resolver,
|
|
901
919
|
output: pluginZod.options.output,
|
|
902
|
-
group: pluginZod.options.group
|
|
920
|
+
group: pluginZod.options.group ?? void 0
|
|
903
921
|
};
|
|
904
922
|
}
|
|
905
923
|
//#endregion
|
|
@@ -1462,7 +1480,7 @@ var compatibility = {
|
|
|
1462
1480
|
};
|
|
1463
1481
|
//#endregion
|
|
1464
1482
|
//#region package.json
|
|
1465
|
-
var version = "5.
|
|
1483
|
+
var version = "5.10.0-canary.20261024T203516";
|
|
1466
1484
|
//#endregion
|
|
1467
1485
|
//#region src/templates.ts
|
|
1468
1486
|
/** Absolute path to the fetch client template, copied into `.kubb/client.ts`. */
|