@kubb/plugin-client 5.9.0-canary.20261029T124214 → 5.9.0

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
@@ -23,13 +23,13 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
23
23
  value: mod,
24
24
  enumerable: true
25
25
  }) : target, mod));
26
- let kubb_kit = require("kubb/kit");
26
+ let _kubb_kit = require("@kubb/kit");
27
27
  let node_path = require("node:path");
28
28
  node_path = __toESM(node_path, 1);
29
29
  let _kubb_plugin_ts = require("@kubb/plugin-ts");
30
30
  let _kubb_plugin_zod = require("@kubb/plugin-zod");
31
- let kubb_jsx = require("kubb/jsx");
32
- let kubb_jsx_jsx_runtime = require("kubb/jsx/jsx-runtime");
31
+ let _kubb_renderer_jsx = require("@kubb/renderer-jsx");
32
+ let _kubb_renderer_jsx_jsx_runtime = require("@kubb/renderer-jsx/jsx-runtime");
33
33
  // ../../internals/shared/src/operation.ts
34
34
  /**
35
35
  * Builds the `ResolverFileParams` every operation generator passes to
@@ -51,19 +51,19 @@ function operationFileEntry(node, name, extname = ".ts") {
51
51
  };
52
52
  }
53
53
  /**
54
- * Resolves a dependency plugin's generated file for `node.operationId`, cached in `cache` (the
55
- * current node's `ctx.cache`) under the resolver's own plugin name. Several dependents reading the
54
+ * Resolves a dependency plugin's generated file for `node.operationId`, cached in `memo` (the
55
+ * build's `ctx.memo`) under the resolver's own plugin name and the operation. Several dependents reading the
56
56
  * same dependency for the same operation in one pass (a query plugin's several hook generators, the
57
57
  * MCP handler, ...) share one computed name and path instead of each calling `resolver.file` again.
58
58
  *
59
59
  * @example Cache `plugin-ts`'s file for the current operation
60
60
  * ```ts
61
- * const fileTs = resolveDependencyOperationFile({ cache: ctx.cache, node, resolver: tsResolver, root, output })
61
+ * const fileTs = resolveDependencyOperationFile({ memo: ctx.memo, node, resolver: tsResolver, root, output })
62
62
  * ```
63
63
  */
64
64
  function resolveDependencyOperationFile(options) {
65
- const { cache, node, resolver, root, output, group } = options;
66
- return cache.ensureItem(`${resolver.pluginName}:operationFile`, () => resolver.file({
65
+ const { memo, node, resolver, root, output, group } = options;
66
+ return memo(`${resolver.pluginName}:operationFile:${node.operationId}`, () => resolver.file({
67
67
  ...operationFileEntry(node, node.operationId),
68
68
  root,
69
69
  output,
@@ -73,7 +73,7 @@ function resolveDependencyOperationFile(options) {
73
73
  function getOperationLink(node, link) {
74
74
  if (!link) return null;
75
75
  if (typeof link === "function") return link(node) ?? null;
76
- return node.path ? `{@link ${kubb_kit.Url.toPath(node.path)}}` : null;
76
+ return node.path ? `{@link ${_kubb_kit.Url.toPath(node.path)}}` : null;
77
77
  }
78
78
  /**
79
79
  * Derives the shared `ContentTypeInfo` shape from a list of content types, tracking whether several
@@ -379,7 +379,7 @@ function isIdentifier(name) {
379
379
  * The shared top-level `name` of the operation plugins, computed once per operation name and build.
380
380
  */
381
381
  function resolveOperationName(name) {
382
- return this.memo(`operation:${name}`, () => ensureValidVarName((0, kubb_kit.camelCase)(name)));
382
+ return this.memo(`operation:${name}`, () => ensureValidVarName((0, _kubb_kit.camelCase)(name)));
383
383
  }
384
384
  /**
385
385
  * Builds the allocation key for a declaration an operation owns. `scope` names which declaration
@@ -422,7 +422,7 @@ function createGroupConfig(group) {
422
422
  if (!group) return null;
423
423
  const defaultName = (ctx) => {
424
424
  if (group.type === "path") return `${ctx.group.split("/")[1]}`;
425
- return (0, kubb_kit.camelCase)(ctx.group);
425
+ return (0, _kubb_kit.camelCase)(ctx.group);
426
426
  };
427
427
  return {
428
428
  ...group,
@@ -435,7 +435,7 @@ var compatibility = {
435
435
  "node": ">=22.22"
436
436
  };
437
437
  // package.json
438
- var version = "5.9.0-canary.20261029T124214";
438
+ var version = "5.9.0";
439
439
  // ../../internals/client/src/builders/validatorOptions.ts
440
440
  /**
441
441
  * Returns `true` when any direction of the validator uses zod (used for dependency checks).
@@ -669,7 +669,7 @@ function serializeBodyEncoding(node) {
669
669
  * ```
670
670
  */
671
671
  function buildStyles({ node }) {
672
- if (!kubb_kit.ast.isHttpOperationNode(node)) return null;
672
+ if (!_kubb_kit.ast.isHttpOperationNode(node)) return null;
673
673
  const groups = {
674
674
  path: [],
675
675
  query: [],
@@ -838,7 +838,7 @@ function buildGroupedOptionsSignature({ node, types, returnType, throwOnErrorDef
838
838
  * the source.
839
839
  */
840
840
  function Operation({ name, node, types, validatorHooks, returnType, throwOnErrorDefault, security }) {
841
- if (!kubb_kit.ast.isHttpOperationNode(node)) return null;
841
+ if (!_kubb_kit.ast.isHttpOperationNode(node)) return null;
842
842
  const signature = buildGroupedOptionsSignature({
843
843
  node,
844
844
  types,
@@ -864,11 +864,11 @@ function Operation({ name, node, types, validatorHooks, returnType, throwOnError
864
864
  returnType,
865
865
  throwOnErrorDefault
866
866
  });
867
- return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Source, {
867
+ return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Source, {
868
868
  name,
869
869
  isExportable: true,
870
870
  isIndexable: true,
871
- children: /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsxs)(kubb_jsx.Function, {
871
+ children: /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx.Function, {
872
872
  name,
873
873
  export: true,
874
874
  generics: signature.generics,
@@ -881,7 +881,7 @@ function Operation({ name, node, types, validatorHooks, returnType, throwOnError
881
881
  }) },
882
882
  children: [
883
883
  mergeContentType ? "const { client: request = client, contentType, ...config } = options" : "const { client: request = client, ...config } = options",
884
- /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)("br", {}),
884
+ /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)("br", {}),
885
885
  returnStatement
886
886
  ]
887
887
  })
@@ -939,8 +939,8 @@ function resolveOperationTypes(driver, pluginName) {
939
939
  group: pluginTs.options?.group ?? void 0
940
940
  };
941
941
  }
942
- if (!pluginZod?.options?.inferred) throw new kubb_kit.Diagnostics.Error({
943
- code: kubb_kit.Diagnostics.code.missingDependency,
942
+ if (!pluginZod?.options?.inferred) throw new _kubb_kit.Diagnostics.Error({
943
+ code: _kubb_kit.Diagnostics.code.missingDependency,
944
944
  severity: "error",
945
945
  message: `Plugin "${pluginName}" has no source for operation types.`,
946
946
  help: `Add \`pluginTs()\` before "${pluginName}", or add \`pluginZod({ inferred: true })\`.`,
@@ -966,11 +966,11 @@ function resolveOperationTypes(driver, pluginName) {
966
966
  * identical.
967
967
  */
968
968
  function createClientGenerator(name) {
969
- return (0, kubb_kit.defineGenerator)({
969
+ return (0, _kubb_kit.defineGenerator)({
970
970
  name,
971
- renderer: kubb_jsx.jsxRenderer,
971
+ renderer: _kubb_renderer_jsx.jsxRenderer,
972
972
  operation(node, ctx) {
973
- if (!kubb_kit.ast.isHttpOperationNode(node)) return null;
973
+ if (!_kubb_kit.ast.isHttpOperationNode(node)) return null;
974
974
  const { config, driver, resolver, root } = ctx;
975
975
  const { output, validator, returnType, throwOnErrorDefault, group, importPath } = ctx.options;
976
976
  const types = resolveOperationTypes(driver, ctx.plugin.name);
@@ -996,7 +996,7 @@ function createClientGenerator(name) {
996
996
  group: group ?? void 0
997
997
  }),
998
998
  fileTypes: resolveDependencyOperationFile({
999
- cache: ctx.cache,
999
+ memo: ctx.memo,
1000
1000
  node,
1001
1001
  resolver: types.resolver,
1002
1002
  root,
@@ -1039,7 +1039,7 @@ function createClientGenerator(name) {
1039
1039
  "RequestResult"
1040
1040
  ];
1041
1041
  })();
1042
- return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsxs)(kubb_jsx.File, {
1042
+ return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx.File, {
1043
1043
  baseName: meta.file.baseName,
1044
1044
  path: meta.file.path,
1045
1045
  meta: meta.file.meta,
@@ -1060,34 +1060,34 @@ function createClientGenerator(name) {
1060
1060
  }
1061
1061
  }),
1062
1062
  children: [
1063
- /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
1063
+ /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
1064
1064
  name: clientValueImports,
1065
1065
  root: clientRoot,
1066
1066
  path: clientPath
1067
1067
  }),
1068
- /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
1068
+ /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
1069
1069
  name: clientTypeImports,
1070
1070
  root: clientRoot,
1071
1071
  path: clientPath,
1072
1072
  isTypeOnly: true
1073
1073
  }),
1074
- meta.fileTypes && importedTypeNames.length > 0 && /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
1074
+ meta.fileTypes && importedTypeNames.length > 0 && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
1075
1075
  name: Array.from(new Set(importedTypeNames)),
1076
1076
  root: meta.file.path,
1077
1077
  path: meta.fileTypes.path,
1078
1078
  isTypeOnly: true
1079
1079
  }),
1080
- meta.fileZod && importedZodNames.length > 0 && /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
1080
+ meta.fileZod && importedZodNames.length > 0 && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
1081
1081
  name: importedZodNames,
1082
1082
  root: meta.file.path,
1083
1083
  path: meta.fileZod.path
1084
1084
  }),
1085
- validatorHooks.headers && /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
1085
+ validatorHooks.headers && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
1086
1086
  name: ["toHeadersStandardSchema"],
1087
1087
  root: clientRoot,
1088
1088
  path: standardSchemaPath
1089
1089
  }),
1090
- /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(Operation, {
1090
+ /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(Operation, {
1091
1091
  name: meta.name,
1092
1092
  node,
1093
1093
  types,
@@ -1107,7 +1107,7 @@ function createClientGenerator(name) {
1107
1107
  * drops union members a broader scalar already covers, keeping the generated response and error
1108
1108
  * unions tidy. A plugin wires them with `ctx.setMacros([...defaultMacros, ...userMacros])`.
1109
1109
  */
1110
- const defaultMacros = [kubb_kit.macroSimplifyUnion];
1110
+ const defaultMacros = [_kubb_kit.macroSimplifyUnion];
1111
1111
  // ../../internals/client/src/resolver.ts
1112
1112
  /**
1113
1113
  * Default resolver shared by the client plugins. Functions use safe camelCase identifiers and
@@ -1119,17 +1119,17 @@ const defaultMacros = [kubb_kit.macroSimplifyUnion];
1119
1119
  * resolverClient.groupName('pet') // 'PetClient'
1120
1120
  * ```
1121
1121
  */
1122
- const resolverClient = (0, kubb_kit.createResolver)({
1122
+ const resolverClient = (0, _kubb_kit.createResolver)({
1123
1123
  pluginName: "plugin-contract-client",
1124
1124
  name: resolveOperationName,
1125
1125
  className(name) {
1126
- return ensureValidVarName((0, kubb_kit.pascalCase)(name));
1126
+ return ensureValidVarName((0, _kubb_kit.pascalCase)(name));
1127
1127
  },
1128
1128
  groupName(name) {
1129
- return ensureValidVarName((0, kubb_kit.pascalCase)(`${name} Client`));
1129
+ return ensureValidVarName((0, _kubb_kit.pascalCase)(`${name} Client`));
1130
1130
  },
1131
1131
  propertyName(name) {
1132
- return ensureValidVarName((0, kubb_kit.camelCase)(name));
1132
+ return ensureValidVarName((0, _kubb_kit.camelCase)(name));
1133
1133
  }
1134
1134
  });
1135
1135
  // src/generators/clientGenerator.tsx
@@ -1154,7 +1154,7 @@ const pluginClientName = "plugin-client";
1154
1154
  * pluginClient({ importPath: '../api/client' })
1155
1155
  * ```
1156
1156
  */
1157
- const pluginClient = (0, kubb_kit.defineExtension)({
1157
+ const pluginClient = (0, _kubb_kit.defineExtension)({
1158
1158
  kind: "plugin",
1159
1159
  meta: {
1160
1160
  name: pluginClientName,
@@ -1170,10 +1170,10 @@ const pluginClient = (0, kubb_kit.defineExtension)({
1170
1170
  path: "clients",
1171
1171
  barrel: { type: "named" }
1172
1172
  }, exclude = [], include, override = [], importPath, throwOnErrorDefault = true, validator = false, group, resolver: userResolver } = options;
1173
- const resolver = userResolver ? kubb_kit.Resolver.merge(resolverClient, userResolver) : resolverClient;
1174
- (0, kubb_kit.setResolver)(resolver);
1175
- (0, kubb_kit.setMacros)([...defaultMacros, ...options.macros ?? []]);
1176
- (0, kubb_kit.addGenerator)(clientGenerator);
1173
+ const resolver = userResolver ? _kubb_kit.Resolver.merge(resolverClient, userResolver) : resolverClient;
1174
+ (0, _kubb_kit.setResolver)(resolver);
1175
+ (0, _kubb_kit.setMacros)([...defaultMacros, ...options.macros ?? []]);
1176
+ (0, _kubb_kit.addGenerator)(clientGenerator);
1177
1177
  return {
1178
1178
  output,
1179
1179
  exclude,