@kubb/plugin-client 3.0.0-alpha.3 → 3.0.0-alpha.30

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.
Files changed (63) hide show
  1. package/README.md +13 -4
  2. package/client.ts +2 -2
  3. package/dist/chunk-ELPE4OER.cjs +183 -0
  4. package/dist/chunk-ELPE4OER.cjs.map +1 -0
  5. package/dist/chunk-RQSMSP6A.js +174 -0
  6. package/dist/chunk-RQSMSP6A.js.map +1 -0
  7. package/dist/chunk-X73EA6RA.cjs +133 -0
  8. package/dist/chunk-X73EA6RA.cjs.map +1 -0
  9. package/dist/chunk-YYBNZBCI.js +130 -0
  10. package/dist/chunk-YYBNZBCI.js.map +1 -0
  11. package/dist/client.cjs +16 -7
  12. package/dist/client.cjs.map +1 -1
  13. package/dist/client.d.cts +2 -2
  14. package/dist/client.d.ts +2 -2
  15. package/dist/client.js +5 -6
  16. package/dist/client.js.map +1 -1
  17. package/dist/components.cjs +11 -4
  18. package/dist/components.cjs.map +1 -1
  19. package/dist/components.d.cts +37 -7
  20. package/dist/components.d.ts +37 -7
  21. package/dist/components.js +2 -8
  22. package/dist/components.js.map +1 -1
  23. package/dist/generators.cjs +17 -0
  24. package/dist/generators.cjs.map +1 -0
  25. package/dist/generators.d.cts +9 -0
  26. package/dist/generators.d.ts +9 -0
  27. package/dist/generators.js +4 -0
  28. package/dist/generators.js.map +1 -0
  29. package/dist/index.cjs +10 -137
  30. package/dist/index.cjs.map +1 -1
  31. package/dist/index.d.cts +1 -6
  32. package/dist/index.d.ts +1 -6
  33. package/dist/index.js +3 -143
  34. package/dist/index.js.map +1 -1
  35. package/dist/types-Bc-y9yTU.d.cts +100 -0
  36. package/dist/types-Bc-y9yTU.d.ts +100 -0
  37. package/package.json +22 -17
  38. package/src/components/Client.tsx +111 -212
  39. package/src/components/Operations.tsx +9 -75
  40. package/src/generators/__snapshots__/deletePet.ts +13 -0
  41. package/src/generators/__snapshots__/deletePetObject.ts +15 -0
  42. package/src/generators/__snapshots__/findByTags.ts +13 -0
  43. package/src/generators/__snapshots__/findByTagsFull.ts +13 -0
  44. package/src/generators/__snapshots__/findByTagsWithZod.ts +13 -0
  45. package/src/generators/__snapshots__/findByTagsWithZodFull.ts +13 -0
  46. package/src/generators/__snapshots__/importPath.ts +13 -0
  47. package/src/generators/__snapshots__/operations.ts +82 -0
  48. package/src/generators/__snapshots__/updatePetById.ts +12 -0
  49. package/src/generators/clientGenerator.tsx +66 -0
  50. package/src/generators/index.ts +2 -0
  51. package/src/generators/operationsGenerator.tsx +26 -0
  52. package/src/plugin.ts +23 -42
  53. package/src/types.ts +27 -55
  54. package/dist/chunk-W57BRY5O.js +0 -201
  55. package/dist/chunk-W57BRY5O.js.map +0 -1
  56. package/dist/chunk-W7F5CMU6.cjs +0 -201
  57. package/dist/chunk-W7F5CMU6.cjs.map +0 -1
  58. package/dist/types-C14AAtNX.d.cts +0 -233
  59. package/dist/types-C14AAtNX.d.ts +0 -233
  60. package/src/OperationGenerator.tsx +0 -29
  61. package/src/components/__snapshots__/Client/showPetById.ts +0 -11
  62. package/src/components/__snapshots__/Operations/showPetById.ts +0 -6
  63. package/src/components/__snapshots__/Query/showPetById.ts +0 -15
package/dist/index.d.ts CHANGED
@@ -1,11 +1,6 @@
1
1
  import * as _kubb_core from '@kubb/core';
2
- import { O as Options, P as PluginClient } from './types-C14AAtNX.js';
3
- import '@kubb/fs/types';
2
+ import { O as Options, P as PluginClient } from './types-Bc-y9yTU.js';
4
3
  import '@kubb/plugin-oas';
5
- import '@kubb/core/utils';
6
- import '@kubb/oas';
7
- import '@kubb/react';
8
- import 'react';
9
4
 
10
5
  declare const pluginClientName = "plugin-client";
11
6
  declare const pluginClient: (options?: Options | undefined) => _kubb_core.UserPluginWithLifeCycle<PluginClient>;
package/dist/index.js CHANGED
@@ -1,144 +1,4 @@
1
- import {
2
- Client,
3
- Operations
4
- } from "./chunk-W57BRY5O.js";
5
-
6
- // src/plugin.ts
7
- import path from "path";
8
- import { FileManager, PluginManager, createPlugin } from "@kubb/core";
9
- import { camelCase } from "@kubb/core/transformers";
10
- import { renderTemplate } from "@kubb/core/utils";
11
- import { OperationGenerator, pluginOasName } from "@kubb/plugin-oas";
12
- import { getGroupedByTagFiles } from "@kubb/plugin-oas/utils";
13
-
14
- // src/OperationGenerator.tsx
15
- import { createReactParser } from "@kubb/plugin-oas";
16
- import "@kubb/plugin-oas/components";
17
- import "@kubb/react";
18
- import { jsx } from "@kubb/react/jsx-runtime";
19
- var clientParser = createReactParser({
20
- name: "plugin-client",
21
- Operations({ options }) {
22
- if (!options.templates.operations) {
23
- return null;
24
- }
25
- return /* @__PURE__ */ jsx(Operations.File, { baseURL: options.baseURL, templates: options.templates.operations });
26
- },
27
- Operation({ options, operation }) {
28
- const isEnabled = options.client.methods.some((method) => operation.method === method);
29
- if (!options.templates.client || !isEnabled) {
30
- return null;
31
- }
32
- return /* @__PURE__ */ jsx(Client.File, { baseURL: options.baseURL, templates: options.templates.client });
33
- }
34
- });
35
-
36
- // src/plugin.ts
37
- var pluginClientName = "plugin-client";
38
- var pluginClient = createPlugin((options) => {
39
- const {
40
- output = { path: "clients" },
41
- group,
42
- exclude = [],
43
- include,
44
- override = [],
45
- transformers = {},
46
- dataReturnType = "data",
47
- pathParamsType = "inline",
48
- templates
49
- } = options;
50
- const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`;
51
- return {
52
- name: pluginClientName,
53
- options: {
54
- extName: output.extName,
55
- dataReturnType,
56
- client: {
57
- importPath: "@kubb/plugin-client/client",
58
- methods: ["get", "post", "delete", "put"],
59
- ...options.client
60
- },
61
- pathParamsType,
62
- templates: {
63
- operations: Operations.templates,
64
- client: Client.templates,
65
- ...templates
66
- },
67
- baseURL: void 0
68
- },
69
- pre: [pluginOasName],
70
- resolvePath(baseName, pathMode, options2) {
71
- const root = path.resolve(this.config.root, this.config.output.path);
72
- const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path));
73
- if (mode === "single") {
74
- return path.resolve(root, output.path);
75
- }
76
- if (options2?.tag && group?.type === "tag") {
77
- const tag = camelCase(options2.tag);
78
- return path.resolve(root, renderTemplate(template, { tag }), baseName);
79
- }
80
- return path.resolve(root, output.path, baseName);
81
- },
82
- resolveName(name, type) {
83
- const resolvedName = camelCase(name, { isFile: type === "file" });
84
- if (type) {
85
- return transformers?.name?.(resolvedName, type) || resolvedName;
86
- }
87
- return resolvedName;
88
- },
89
- async buildStart() {
90
- const [swaggerPlugin] = PluginManager.getDependedPlugins(this.plugins, [pluginOasName]);
91
- const oas = await swaggerPlugin.context.getOas();
92
- const root = path.resolve(this.config.root, this.config.output.path);
93
- const mode = FileManager.getMode(path.resolve(root, output.path));
94
- const baseURL = await swaggerPlugin.context.getBaseURL();
95
- const operationGenerator = new OperationGenerator(
96
- {
97
- ...this.plugin.options,
98
- baseURL
99
- },
100
- {
101
- oas,
102
- pluginManager: this.pluginManager,
103
- plugin: this.plugin,
104
- contentType: swaggerPlugin.context.contentType,
105
- exclude,
106
- include,
107
- override,
108
- mode
109
- }
110
- );
111
- const files = await operationGenerator.build(clientParser);
112
- await this.addFile(...files);
113
- },
114
- async buildEnd() {
115
- if (this.config.output.write === false) {
116
- return;
117
- }
118
- const root = path.resolve(this.config.root, this.config.output.path);
119
- if (group?.type === "tag") {
120
- const rootFiles = await getGroupedByTagFiles({
121
- logger: this.logger,
122
- files: this.fileManager.files,
123
- plugin: this.plugin,
124
- template,
125
- exportAs: group.exportAs || "{{tag}}Service",
126
- root,
127
- output
128
- });
129
- await this.addFile(...rootFiles);
130
- }
131
- await this.fileManager.addIndexes({
132
- root,
133
- output,
134
- meta: { pluginKey: this.plugin.key },
135
- logger: this.logger
136
- });
137
- }
138
- };
139
- });
140
- export {
141
- pluginClient,
142
- pluginClientName
143
- };
1
+ export { pluginClient, pluginClientName } from './chunk-RQSMSP6A.js';
2
+ import './chunk-YYBNZBCI.js';
3
+ //# sourceMappingURL=index.js.map
144
4
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/plugin.ts","../src/OperationGenerator.tsx"],"sourcesContent":["import path from 'node:path'\n\nimport { FileManager, PluginManager, createPlugin } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\nimport { renderTemplate } from '@kubb/core/utils'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\nimport { getGroupedByTagFiles } from '@kubb/plugin-oas/utils'\n\nimport { clientParser } from './OperationGenerator.tsx'\nimport { Client, Operations } from './components/index.ts'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'\nimport type { PluginClient } from './types.ts'\n\nexport const pluginClientName = 'plugin-client' satisfies PluginClient['name']\n\nexport const pluginClient = createPlugin<PluginClient>((options) => {\n const {\n output = { path: 'clients' },\n group,\n exclude = [],\n include,\n override = [],\n transformers = {},\n dataReturnType = 'data',\n pathParamsType = 'inline',\n templates,\n } = options\n\n const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`\n\n return {\n name: pluginClientName,\n options: {\n extName: output.extName,\n dataReturnType,\n client: {\n importPath: '@kubb/plugin-client/client',\n methods: ['get', 'post', 'delete', 'put'],\n ...options.client,\n },\n pathParamsType,\n templates: {\n operations: Operations.templates,\n client: Client.templates,\n ...templates,\n },\n baseURL: undefined,\n },\n pre: [pluginOasName],\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (options?.tag && group?.type === 'tag') {\n const tag = camelCase(options.tag)\n\n return path.resolve(root, renderTemplate(template, { tag }), baseName)\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n const resolvedName = camelCase(name, { isFile: type === 'file' })\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async buildStart() {\n const [swaggerPlugin]: [Plugin<SwaggerPluginOptions>] = PluginManager.getDependedPlugins<SwaggerPluginOptions>(this.plugins, [pluginOasName])\n\n const oas = await swaggerPlugin.context.getOas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = FileManager.getMode(path.resolve(root, output.path))\n const baseURL = await swaggerPlugin.context.getBaseURL()\n\n const operationGenerator = new OperationGenerator(\n {\n ...this.plugin.options,\n baseURL,\n },\n {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType: swaggerPlugin.context.contentType,\n exclude,\n include,\n override,\n mode,\n },\n )\n\n const files = await operationGenerator.build(clientParser)\n\n await this.addFile(...files)\n },\n async buildEnd() {\n if (this.config.output.write === false) {\n return\n }\n\n const root = path.resolve(this.config.root, this.config.output.path)\n\n if (group?.type === 'tag') {\n const rootFiles = await getGroupedByTagFiles({\n logger: this.logger,\n files: this.fileManager.files,\n plugin: this.plugin,\n template,\n exportAs: group.exportAs || '{{tag}}Service',\n root,\n output,\n })\n\n await this.addFile(...rootFiles)\n }\n\n await this.fileManager.addIndexes({\n root,\n output,\n meta: { pluginKey: this.plugin.key },\n logger: this.logger,\n })\n },\n }\n})\n","import { createReactParser, OperationGenerator as Generator } from '@kubb/plugin-oas'\nimport { Oas } from '@kubb/plugin-oas/components'\nimport { App, createRoot } from '@kubb/react'\n\nimport { Client, Operations } from './components/index.ts'\n\nimport type { Operation } from '@kubb/oas'\nimport type { OperationMethodResult, OperationsByMethod } from '@kubb/plugin-oas'\nimport type { FileMeta, PluginClient } from './types.ts'\n\nexport const clientParser = createReactParser<PluginClient>({\n name: 'plugin-client',\n Operations({ options }) {\n if (!options.templates.operations) {\n return null\n }\n\n return <Operations.File baseURL={options.baseURL} templates={options.templates.operations} />\n },\n Operation({ options, operation }) {\n const isEnabled = options.client.methods.some((method) => operation.method === method)\n\n if (!options.templates.client || !isEnabled) {\n return null\n }\n\n return <Client.File baseURL={options.baseURL} templates={options.templates.client} />\n },\n})\n"],"mappings":"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","names":["options"]}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
@@ -0,0 +1,100 @@
1
+ import { PluginFactoryOptions, Output, ResolveNameParams } from '@kubb/core';
2
+ import { ResolvePathOptions, Exclude, Include, Override, Generator } from '@kubb/plugin-oas';
3
+
4
+ type Options = {
5
+ output?: Output;
6
+ /**
7
+ * Group the clients based on the provided name.
8
+ */
9
+ group?: {
10
+ /**
11
+ * Tag will group based on the operation tag inside the Swagger file
12
+ */
13
+ type: 'tag';
14
+ /**
15
+ * Relative path to save the grouped clients.
16
+ *
17
+ * `{{tag}}` will be replaced by the current tagName.
18
+ * @example `${output}/{{tag}}Controller` => `clients/PetController`
19
+ * @default `${output}/{{tag}}Controller`
20
+ */
21
+ output?: string;
22
+ /**
23
+ * Name to be used for the `export * as {{exportAs}} from './`
24
+ * @default `"{{tag}}Service"`
25
+ */
26
+ exportAs?: string;
27
+ };
28
+ /**
29
+ * Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
30
+ */
31
+ exclude?: Array<Exclude>;
32
+ /**
33
+ * Array containing include parameters to include tags/operations/methods/paths.
34
+ */
35
+ include?: Array<Include>;
36
+ /**
37
+ * Array containing override parameters to override `options` based on tags/operations/methods/paths.
38
+ */
39
+ override?: Array<Override<ResolvedOptions>>;
40
+ /**
41
+ * Create `operations.ts` file with all operations grouped by methods.
42
+ * @default `false`
43
+ */
44
+ operations?: boolean;
45
+ /**
46
+ * Path to the client import path that will be used to do the API calls.
47
+ * It will be used as `import client from '${client.importPath}'`.
48
+ * It allows both relative and absolute path.
49
+ * the path will be applied as is, so relative path should be based on the file being generated.
50
+ * @default '@kubb/plugin-client/client'
51
+ */
52
+ importPath?: string;
53
+ /**
54
+ * ReturnType that needs to be used when calling client().
55
+ *
56
+ * `Data` will return ResponseConfig[data].
57
+ *
58
+ * `Full` will return ResponseConfig.
59
+ * @default `'data'`
60
+ * @private
61
+ */
62
+ dataReturnType?: 'data' | 'full';
63
+ /**
64
+ * How to pass your pathParams.
65
+ *
66
+ * `object` will return the pathParams as an object.
67
+ *
68
+ * `inline` will return the pathParams as comma separated params.
69
+ * @default `'inline'`
70
+ * @private
71
+ */
72
+ pathParamsType?: 'object' | 'inline';
73
+ /**
74
+ * Which parser can be used before returning the data
75
+ * `'zod'` will use `@kubb/plugin-zod` to parse the data.
76
+ * @default 'client'
77
+ */
78
+ parser?: 'client' | 'zod';
79
+ transformers?: {
80
+ /**
81
+ * Customize the names based on the type that is provided by the plugin.
82
+ */
83
+ name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
84
+ };
85
+ /**
86
+ * Define some generators next to the client generators
87
+ */
88
+ generators?: Array<Generator<PluginClient>>;
89
+ };
90
+ type ResolvedOptions = {
91
+ output: Output;
92
+ baseURL: string | undefined;
93
+ parser: NonNullable<Options['parser']>;
94
+ importPath: NonNullable<Options['importPath']>;
95
+ dataReturnType: NonNullable<Options['dataReturnType']>;
96
+ pathParamsType: NonNullable<Options['pathParamsType']>;
97
+ };
98
+ type PluginClient = PluginFactoryOptions<'plugin-client', Options, ResolvedOptions, never, ResolvePathOptions>;
99
+
100
+ export type { Options as O, PluginClient as P };
@@ -0,0 +1,100 @@
1
+ import { PluginFactoryOptions, Output, ResolveNameParams } from '@kubb/core';
2
+ import { ResolvePathOptions, Exclude, Include, Override, Generator } from '@kubb/plugin-oas';
3
+
4
+ type Options = {
5
+ output?: Output;
6
+ /**
7
+ * Group the clients based on the provided name.
8
+ */
9
+ group?: {
10
+ /**
11
+ * Tag will group based on the operation tag inside the Swagger file
12
+ */
13
+ type: 'tag';
14
+ /**
15
+ * Relative path to save the grouped clients.
16
+ *
17
+ * `{{tag}}` will be replaced by the current tagName.
18
+ * @example `${output}/{{tag}}Controller` => `clients/PetController`
19
+ * @default `${output}/{{tag}}Controller`
20
+ */
21
+ output?: string;
22
+ /**
23
+ * Name to be used for the `export * as {{exportAs}} from './`
24
+ * @default `"{{tag}}Service"`
25
+ */
26
+ exportAs?: string;
27
+ };
28
+ /**
29
+ * Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
30
+ */
31
+ exclude?: Array<Exclude>;
32
+ /**
33
+ * Array containing include parameters to include tags/operations/methods/paths.
34
+ */
35
+ include?: Array<Include>;
36
+ /**
37
+ * Array containing override parameters to override `options` based on tags/operations/methods/paths.
38
+ */
39
+ override?: Array<Override<ResolvedOptions>>;
40
+ /**
41
+ * Create `operations.ts` file with all operations grouped by methods.
42
+ * @default `false`
43
+ */
44
+ operations?: boolean;
45
+ /**
46
+ * Path to the client import path that will be used to do the API calls.
47
+ * It will be used as `import client from '${client.importPath}'`.
48
+ * It allows both relative and absolute path.
49
+ * the path will be applied as is, so relative path should be based on the file being generated.
50
+ * @default '@kubb/plugin-client/client'
51
+ */
52
+ importPath?: string;
53
+ /**
54
+ * ReturnType that needs to be used when calling client().
55
+ *
56
+ * `Data` will return ResponseConfig[data].
57
+ *
58
+ * `Full` will return ResponseConfig.
59
+ * @default `'data'`
60
+ * @private
61
+ */
62
+ dataReturnType?: 'data' | 'full';
63
+ /**
64
+ * How to pass your pathParams.
65
+ *
66
+ * `object` will return the pathParams as an object.
67
+ *
68
+ * `inline` will return the pathParams as comma separated params.
69
+ * @default `'inline'`
70
+ * @private
71
+ */
72
+ pathParamsType?: 'object' | 'inline';
73
+ /**
74
+ * Which parser can be used before returning the data
75
+ * `'zod'` will use `@kubb/plugin-zod` to parse the data.
76
+ * @default 'client'
77
+ */
78
+ parser?: 'client' | 'zod';
79
+ transformers?: {
80
+ /**
81
+ * Customize the names based on the type that is provided by the plugin.
82
+ */
83
+ name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
84
+ };
85
+ /**
86
+ * Define some generators next to the client generators
87
+ */
88
+ generators?: Array<Generator<PluginClient>>;
89
+ };
90
+ type ResolvedOptions = {
91
+ output: Output;
92
+ baseURL: string | undefined;
93
+ parser: NonNullable<Options['parser']>;
94
+ importPath: NonNullable<Options['importPath']>;
95
+ dataReturnType: NonNullable<Options['dataReturnType']>;
96
+ pathParamsType: NonNullable<Options['pathParamsType']>;
97
+ };
98
+ type PluginClient = PluginFactoryOptions<'plugin-client', Options, ResolvedOptions, never, ResolvePathOptions>;
99
+
100
+ export type { Options as O, PluginClient as P };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-client",
3
- "version": "3.0.0-alpha.3",
3
+ "version": "3.0.0-alpha.30",
4
4
  "description": "Generator plugin-client",
5
5
  "keywords": [
6
6
  "typescript",
@@ -26,6 +26,11 @@
26
26
  "require": "./dist/index.cjs",
27
27
  "default": "./dist/index.cjs"
28
28
  },
29
+ "./generators": {
30
+ "import": "./dist/generators.js",
31
+ "require": "./dist/generators.cjs",
32
+ "default": "./dist/generators.cjs"
33
+ },
29
34
  "./components": {
30
35
  "import": "./dist/components.js",
31
36
  "require": "./dist/components.cjs",
@@ -51,6 +56,9 @@
51
56
  "*": {
52
57
  "components": [
53
58
  "./dist/components.d.ts"
59
+ ],
60
+ "generators": [
61
+ "./dist/generators.d.ts"
54
62
  ]
55
63
  }
56
64
  },
@@ -64,27 +72,24 @@
64
72
  "!/**/__tests__/**"
65
73
  ],
66
74
  "dependencies": {
67
- "@kubb/core": "3.0.0-alpha.3",
68
- "@kubb/fs": "3.0.0-alpha.3",
69
- "@kubb/oas": "3.0.0-alpha.3",
70
- "@kubb/parser-ts": "3.0.0-alpha.3",
71
- "@kubb/plugin-oas": "3.0.0-alpha.3",
72
- "@kubb/plugin-ts": "3.0.0-alpha.3",
73
- "@kubb/react": "3.0.0-alpha.3"
75
+ "@kubb/core": "3.0.0-alpha.30",
76
+ "@kubb/fs": "3.0.0-alpha.30",
77
+ "@kubb/oas": "3.0.0-alpha.30",
78
+ "@kubb/plugin-oas": "3.0.0-alpha.30",
79
+ "@kubb/plugin-ts": "3.0.0-alpha.30",
80
+ "@kubb/plugin-zod": "3.0.0-alpha.30",
81
+ "@kubb/react": "3.0.0-alpha.30"
74
82
  },
75
83
  "devDependencies": {
76
- "@types/react": "^18.3.4",
77
- "axios": "^1.7.5",
78
- "react": "^18.3.1",
79
- "tsup": "^8.2.4",
80
- "typescript": "^5.5.4",
81
- "@kubb/config-biome": "3.0.0-alpha.3",
82
- "@kubb/config-ts": "3.0.0-alpha.3",
83
- "@kubb/config-tsup": "3.0.0-alpha.3"
84
+ "axios": "^1.7.7",
85
+ "tsup": "^8.3.0",
86
+ "typescript": "^5.6.2",
87
+ "@kubb/config-ts": "3.0.0-alpha.30",
88
+ "@kubb/config-tsup": "3.0.0-alpha.30"
84
89
  },
85
90
  "peerDependencies": {
86
91
  "axios": "^1.7.2",
87
- "@kubb/react": "3.0.0-alpha.3"
92
+ "@kubb/react": "3.0.0-alpha.30"
88
93
  },
89
94
  "peerDependenciesMeta": {
90
95
  "axios": {