@kubb/plugin-client 3.0.0-beta.1 → 3.0.0-beta.11

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 (40) hide show
  1. package/client.ts +27 -6
  2. package/dist/{chunk-LI44LDXH.js → chunk-I2NEG5CE.js} +13 -9
  3. package/dist/chunk-I2NEG5CE.js.map +1 -0
  4. package/dist/{chunk-6W3SC7JK.cjs → chunk-IIY26RTZ.cjs} +15 -11
  5. package/dist/chunk-IIY26RTZ.cjs.map +1 -0
  6. package/dist/{chunk-YYBNZBCI.js → chunk-PHUXTZZT.js} +36 -7
  7. package/dist/chunk-PHUXTZZT.js.map +1 -0
  8. package/dist/{chunk-X73EA6RA.cjs → chunk-UBMTYBLG.cjs} +36 -7
  9. package/dist/chunk-UBMTYBLG.cjs.map +1 -0
  10. package/dist/client.cjs +21 -4
  11. package/dist/client.cjs.map +1 -1
  12. package/dist/client.d.cts +8 -2
  13. package/dist/client.d.ts +8 -2
  14. package/dist/client.js +20 -5
  15. package/dist/client.js.map +1 -1
  16. package/dist/components.cjs +3 -3
  17. package/dist/components.d.cts +5 -3
  18. package/dist/components.d.ts +5 -3
  19. package/dist/components.js +1 -1
  20. package/dist/generators.cjs +5 -5
  21. package/dist/generators.d.cts +1 -1
  22. package/dist/generators.d.ts +1 -1
  23. package/dist/generators.js +2 -2
  24. package/dist/index.cjs +4 -4
  25. package/dist/index.d.cts +1 -1
  26. package/dist/index.d.ts +1 -1
  27. package/dist/index.js +2 -2
  28. package/dist/{types-Bk_NZurp.d.cts → types-DXab6SYO.d.cts} +20 -14
  29. package/dist/{types-Bk_NZurp.d.ts → types-DXab6SYO.d.ts} +20 -14
  30. package/package.json +13 -13
  31. package/src/components/Client.tsx +46 -6
  32. package/src/generators/__snapshots__/deletePetObject.ts +1 -3
  33. package/src/generators/__snapshots__/findByTagsObject.ts +15 -0
  34. package/src/generators/clientGenerator.tsx +1 -0
  35. package/src/plugin.ts +11 -6
  36. package/src/types.ts +20 -14
  37. package/dist/chunk-6W3SC7JK.cjs.map +0 -1
  38. package/dist/chunk-LI44LDXH.js.map +0 -1
  39. package/dist/chunk-X73EA6RA.cjs.map +0 -1
  40. package/dist/chunk-YYBNZBCI.js.map +0 -1
@@ -1,16 +1,16 @@
1
1
  'use strict';
2
2
 
3
- var chunkX73EA6RA_cjs = require('./chunk-X73EA6RA.cjs');
3
+ var chunkUBMTYBLG_cjs = require('./chunk-UBMTYBLG.cjs');
4
4
 
5
5
 
6
6
 
7
7
  Object.defineProperty(exports, "Client", {
8
8
  enumerable: true,
9
- get: function () { return chunkX73EA6RA_cjs.Client; }
9
+ get: function () { return chunkUBMTYBLG_cjs.Client; }
10
10
  });
11
11
  Object.defineProperty(exports, "Operations", {
12
12
  enumerable: true,
13
- get: function () { return chunkX73EA6RA_cjs.Operations; }
13
+ get: function () { return chunkUBMTYBLG_cjs.Operations; }
14
14
  });
15
15
  //# sourceMappingURL=components.cjs.map
16
16
  //# sourceMappingURL=components.cjs.map
@@ -2,7 +2,7 @@ import { Operation } from '@kubb/oas';
2
2
  import { OperationSchemas } from '@kubb/plugin-oas';
3
3
  import { FunctionParams } from '@kubb/react';
4
4
  import { KubbNode } from '@kubb/react/types';
5
- import { P as PluginClient } from './types-Bk_NZurp.cjs';
5
+ import { P as PluginClient } from './types-DXab6SYO.cjs';
6
6
  import '@kubb/core';
7
7
 
8
8
  type Props = {
@@ -14,6 +14,7 @@ type Props = {
14
14
  isIndexable?: boolean;
15
15
  baseURL: string | undefined;
16
16
  dataReturnType: PluginClient['resolvedOptions']['dataReturnType'];
17
+ paramsType: PluginClient['resolvedOptions']['pathParamsType'];
17
18
  pathParamsType: PluginClient['resolvedOptions']['pathParamsType'];
18
19
  parser: PluginClient['resolvedOptions']['parser'] | undefined;
19
20
  typeSchemas: OperationSchemas;
@@ -21,12 +22,13 @@ type Props = {
21
22
  operation: Operation;
22
23
  };
23
24
  type GetParamsProps = {
25
+ paramsType: PluginClient['resolvedOptions']['paramsType'];
24
26
  pathParamsType: PluginClient['resolvedOptions']['pathParamsType'];
25
27
  typeSchemas: OperationSchemas;
26
28
  };
27
- declare function Client({ name, isExportable, isIndexable, typeSchemas, baseURL, dataReturnType, parser, zodSchemas, pathParamsType, operation, }: Props): KubbNode;
29
+ declare function Client({ name, isExportable, isIndexable, typeSchemas, baseURL, dataReturnType, parser, zodSchemas, paramsType, pathParamsType, operation, }: Props): KubbNode;
28
30
  declare namespace Client {
29
- var getParams: ({ pathParamsType, typeSchemas }: GetParamsProps) => FunctionParams;
31
+ var getParams: ({ paramsType, pathParamsType, typeSchemas }: GetParamsProps) => FunctionParams;
30
32
  }
31
33
 
32
34
  type OperationsProps = {
@@ -2,7 +2,7 @@ import { Operation } from '@kubb/oas';
2
2
  import { OperationSchemas } from '@kubb/plugin-oas';
3
3
  import { FunctionParams } from '@kubb/react';
4
4
  import { KubbNode } from '@kubb/react/types';
5
- import { P as PluginClient } from './types-Bk_NZurp.js';
5
+ import { P as PluginClient } from './types-DXab6SYO.js';
6
6
  import '@kubb/core';
7
7
 
8
8
  type Props = {
@@ -14,6 +14,7 @@ type Props = {
14
14
  isIndexable?: boolean;
15
15
  baseURL: string | undefined;
16
16
  dataReturnType: PluginClient['resolvedOptions']['dataReturnType'];
17
+ paramsType: PluginClient['resolvedOptions']['pathParamsType'];
17
18
  pathParamsType: PluginClient['resolvedOptions']['pathParamsType'];
18
19
  parser: PluginClient['resolvedOptions']['parser'] | undefined;
19
20
  typeSchemas: OperationSchemas;
@@ -21,12 +22,13 @@ type Props = {
21
22
  operation: Operation;
22
23
  };
23
24
  type GetParamsProps = {
25
+ paramsType: PluginClient['resolvedOptions']['paramsType'];
24
26
  pathParamsType: PluginClient['resolvedOptions']['pathParamsType'];
25
27
  typeSchemas: OperationSchemas;
26
28
  };
27
- declare function Client({ name, isExportable, isIndexable, typeSchemas, baseURL, dataReturnType, parser, zodSchemas, pathParamsType, operation, }: Props): KubbNode;
29
+ declare function Client({ name, isExportable, isIndexable, typeSchemas, baseURL, dataReturnType, parser, zodSchemas, paramsType, pathParamsType, operation, }: Props): KubbNode;
28
30
  declare namespace Client {
29
- var getParams: ({ pathParamsType, typeSchemas }: GetParamsProps) => FunctionParams;
31
+ var getParams: ({ paramsType, pathParamsType, typeSchemas }: GetParamsProps) => FunctionParams;
30
32
  }
31
33
 
32
34
  type OperationsProps = {
@@ -1,3 +1,3 @@
1
- export { Client, Operations } from './chunk-YYBNZBCI.js';
1
+ export { Client, Operations } from './chunk-PHUXTZZT.js';
2
2
  //# sourceMappingURL=components.js.map
3
3
  //# sourceMappingURL=components.js.map
@@ -1,21 +1,21 @@
1
1
  'use strict';
2
2
 
3
- var chunk6W3SC7JK_cjs = require('./chunk-6W3SC7JK.cjs');
4
- require('./chunk-X73EA6RA.cjs');
3
+ var chunkIIY26RTZ_cjs = require('./chunk-IIY26RTZ.cjs');
4
+ require('./chunk-UBMTYBLG.cjs');
5
5
 
6
6
 
7
7
 
8
8
  Object.defineProperty(exports, "clientGenerator", {
9
9
  enumerable: true,
10
- get: function () { return chunk6W3SC7JK_cjs.clientGenerator; }
10
+ get: function () { return chunkIIY26RTZ_cjs.clientGenerator; }
11
11
  });
12
12
  Object.defineProperty(exports, "groupedClientGenerator", {
13
13
  enumerable: true,
14
- get: function () { return chunk6W3SC7JK_cjs.groupedClientGenerator; }
14
+ get: function () { return chunkIIY26RTZ_cjs.groupedClientGenerator; }
15
15
  });
16
16
  Object.defineProperty(exports, "operationsGenerator", {
17
17
  enumerable: true,
18
- get: function () { return chunk6W3SC7JK_cjs.operationsGenerator; }
18
+ get: function () { return chunkIIY26RTZ_cjs.operationsGenerator; }
19
19
  });
20
20
  //# sourceMappingURL=generators.cjs.map
21
21
  //# sourceMappingURL=generators.cjs.map
@@ -1,5 +1,5 @@
1
1
  import * as _kubb_plugin_oas from '@kubb/plugin-oas';
2
- import { P as PluginClient } from './types-Bk_NZurp.cjs';
2
+ import { P as PluginClient } from './types-DXab6SYO.cjs';
3
3
  import '@kubb/core';
4
4
 
5
5
  declare const clientGenerator: _kubb_plugin_oas.Generator<PluginClient>;
@@ -1,5 +1,5 @@
1
1
  import * as _kubb_plugin_oas from '@kubb/plugin-oas';
2
- import { P as PluginClient } from './types-Bk_NZurp.js';
2
+ import { P as PluginClient } from './types-DXab6SYO.js';
3
3
  import '@kubb/core';
4
4
 
5
5
  declare const clientGenerator: _kubb_plugin_oas.Generator<PluginClient>;
@@ -1,4 +1,4 @@
1
- export { clientGenerator, groupedClientGenerator, operationsGenerator } from './chunk-LI44LDXH.js';
2
- import './chunk-YYBNZBCI.js';
1
+ export { clientGenerator, groupedClientGenerator, operationsGenerator } from './chunk-I2NEG5CE.js';
2
+ import './chunk-PHUXTZZT.js';
3
3
  //# sourceMappingURL=generators.js.map
4
4
  //# sourceMappingURL=generators.js.map
package/dist/index.cjs CHANGED
@@ -1,17 +1,17 @@
1
1
  'use strict';
2
2
 
3
- var chunk6W3SC7JK_cjs = require('./chunk-6W3SC7JK.cjs');
4
- require('./chunk-X73EA6RA.cjs');
3
+ var chunkIIY26RTZ_cjs = require('./chunk-IIY26RTZ.cjs');
4
+ require('./chunk-UBMTYBLG.cjs');
5
5
 
6
6
 
7
7
 
8
8
  Object.defineProperty(exports, "pluginClient", {
9
9
  enumerable: true,
10
- get: function () { return chunk6W3SC7JK_cjs.pluginClient; }
10
+ get: function () { return chunkIIY26RTZ_cjs.pluginClient; }
11
11
  });
12
12
  Object.defineProperty(exports, "pluginClientName", {
13
13
  enumerable: true,
14
- get: function () { return chunk6W3SC7JK_cjs.pluginClientName; }
14
+ get: function () { return chunkIIY26RTZ_cjs.pluginClientName; }
15
15
  });
16
16
  //# sourceMappingURL=index.cjs.map
17
17
  //# sourceMappingURL=index.cjs.map
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _kubb_core from '@kubb/core';
2
- import { O as Options, P as PluginClient } from './types-Bk_NZurp.cjs';
2
+ import { O as Options, P as PluginClient } from './types-DXab6SYO.cjs';
3
3
  import '@kubb/plugin-oas';
4
4
 
5
5
  declare const pluginClientName = "plugin-client";
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _kubb_core from '@kubb/core';
2
- import { O as Options, P as PluginClient } from './types-Bk_NZurp.js';
2
+ import { O as Options, P as PluginClient } from './types-DXab6SYO.js';
3
3
  import '@kubb/plugin-oas';
4
4
 
5
5
  declare const pluginClientName = "plugin-client";
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export { pluginClient, pluginClientName } from './chunk-LI44LDXH.js';
2
- import './chunk-YYBNZBCI.js';
1
+ export { pluginClient, pluginClientName } from './chunk-I2NEG5CE.js';
2
+ import './chunk-PHUXTZZT.js';
3
3
  //# sourceMappingURL=index.js.map
4
4
  //# sourceMappingURL=index.js.map
@@ -25,7 +25,7 @@ type Options = {
25
25
  override?: Array<Override<ResolvedOptions>>;
26
26
  /**
27
27
  * Create `operations.ts` file with all operations grouped by methods.
28
- * @default `false`
28
+ * @default false
29
29
  */
30
30
  operations?: boolean;
31
31
  /**
@@ -35,29 +35,34 @@ type Options = {
35
35
  * @default '@kubb/plugin-client/client'
36
36
  */
37
37
  importPath?: string;
38
+ /**
39
+ * Allows you to set a custom base url for all generated calls.
40
+ */
41
+ baseURL?: string;
38
42
  /**
39
43
  * ReturnType that will be used when calling the client.
40
- *
41
- * `Data` will return ResponseConfig[data].
42
- *
43
- * `Full` will return ResponseConfig.
44
- * @default `'data'`
45
- * @private
44
+ * - 'data' will return ResponseConfig[data].
45
+ * - 'full' will return ResponseConfig.
46
+ * @default 'data'
46
47
  */
47
48
  dataReturnType?: 'data' | 'full';
49
+ /**
50
+ * How to pass your params
51
+ * - 'object' will return the params and pathParams as an object.
52
+ * - 'inline' will return the params as comma separated params.
53
+ * @default 'inline'
54
+ */
55
+ paramsType?: 'object' | 'inline';
48
56
  /**
49
57
  * How to pass your pathParams.
50
- *
51
- * `object` will return the pathParams as an object.
52
- *
53
- * `inline` will return the pathParams as comma separated params.
54
- * @default `'inline'`
55
- * @private
58
+ * - 'object' will return the pathParams as an object.
59
+ * - 'inline' will return the pathParams as comma separated params.
60
+ * @default 'inline'
56
61
  */
57
62
  pathParamsType?: 'object' | 'inline';
58
63
  /**
59
64
  * Which parser can be used before returning the data
60
- * `'zod'` will use `@kubb/plugin-zod` to parse the data.
65
+ * - 'zod' will use `@kubb/plugin-zod` to parse the data.
61
66
  * @default 'client'
62
67
  */
63
68
  parser?: 'client' | 'zod';
@@ -80,6 +85,7 @@ type ResolvedOptions = {
80
85
  importPath: NonNullable<Options['importPath']>;
81
86
  dataReturnType: NonNullable<Options['dataReturnType']>;
82
87
  pathParamsType: NonNullable<Options['pathParamsType']>;
88
+ paramsType: NonNullable<Options['paramsType']>;
83
89
  };
84
90
  type PluginClient = PluginFactoryOptions<'plugin-client', Options, ResolvedOptions, never, ResolvePathOptions>;
85
91
 
@@ -25,7 +25,7 @@ type Options = {
25
25
  override?: Array<Override<ResolvedOptions>>;
26
26
  /**
27
27
  * Create `operations.ts` file with all operations grouped by methods.
28
- * @default `false`
28
+ * @default false
29
29
  */
30
30
  operations?: boolean;
31
31
  /**
@@ -35,29 +35,34 @@ type Options = {
35
35
  * @default '@kubb/plugin-client/client'
36
36
  */
37
37
  importPath?: string;
38
+ /**
39
+ * Allows you to set a custom base url for all generated calls.
40
+ */
41
+ baseURL?: string;
38
42
  /**
39
43
  * ReturnType that will be used when calling the client.
40
- *
41
- * `Data` will return ResponseConfig[data].
42
- *
43
- * `Full` will return ResponseConfig.
44
- * @default `'data'`
45
- * @private
44
+ * - 'data' will return ResponseConfig[data].
45
+ * - 'full' will return ResponseConfig.
46
+ * @default 'data'
46
47
  */
47
48
  dataReturnType?: 'data' | 'full';
49
+ /**
50
+ * How to pass your params
51
+ * - 'object' will return the params and pathParams as an object.
52
+ * - 'inline' will return the params as comma separated params.
53
+ * @default 'inline'
54
+ */
55
+ paramsType?: 'object' | 'inline';
48
56
  /**
49
57
  * How to pass your pathParams.
50
- *
51
- * `object` will return the pathParams as an object.
52
- *
53
- * `inline` will return the pathParams as comma separated params.
54
- * @default `'inline'`
55
- * @private
58
+ * - 'object' will return the pathParams as an object.
59
+ * - 'inline' will return the pathParams as comma separated params.
60
+ * @default 'inline'
56
61
  */
57
62
  pathParamsType?: 'object' | 'inline';
58
63
  /**
59
64
  * Which parser can be used before returning the data
60
- * `'zod'` will use `@kubb/plugin-zod` to parse the data.
65
+ * - 'zod' will use `@kubb/plugin-zod` to parse the data.
61
66
  * @default 'client'
62
67
  */
63
68
  parser?: 'client' | 'zod';
@@ -80,6 +85,7 @@ type ResolvedOptions = {
80
85
  importPath: NonNullable<Options['importPath']>;
81
86
  dataReturnType: NonNullable<Options['dataReturnType']>;
82
87
  pathParamsType: NonNullable<Options['pathParamsType']>;
88
+ paramsType: NonNullable<Options['paramsType']>;
83
89
  };
84
90
  type PluginClient = PluginFactoryOptions<'plugin-client', Options, ResolvedOptions, never, ResolvePathOptions>;
85
91
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-client",
3
- "version": "3.0.0-beta.1",
3
+ "version": "3.0.0-beta.11",
4
4
  "description": "Generator plugin-client",
5
5
  "keywords": [
6
6
  "typescript",
@@ -72,24 +72,24 @@
72
72
  "!/**/__tests__/**"
73
73
  ],
74
74
  "dependencies": {
75
- "@kubb/core": "3.0.0-beta.1",
76
- "@kubb/fs": "3.0.0-beta.1",
77
- "@kubb/oas": "3.0.0-beta.1",
78
- "@kubb/plugin-oas": "3.0.0-beta.1",
79
- "@kubb/plugin-ts": "3.0.0-beta.1",
80
- "@kubb/plugin-zod": "3.0.0-beta.1",
81
- "@kubb/react": "3.0.0-beta.1"
75
+ "@kubb/core": "3.0.0-beta.11",
76
+ "@kubb/fs": "3.0.0-beta.11",
77
+ "@kubb/oas": "3.0.0-beta.11",
78
+ "@kubb/plugin-oas": "3.0.0-beta.11",
79
+ "@kubb/plugin-ts": "3.0.0-beta.11",
80
+ "@kubb/plugin-zod": "3.0.0-beta.11",
81
+ "@kubb/react": "3.0.0-beta.11"
82
82
  },
83
83
  "devDependencies": {
84
84
  "axios": "^1.7.7",
85
- "tsup": "^8.3.0",
86
- "typescript": "^5.6.2",
87
- "@kubb/config-ts": "3.0.0-beta.1",
88
- "@kubb/config-tsup": "3.0.0-beta.1"
85
+ "tsup": "^8.3.5",
86
+ "typescript": "^5.6.3",
87
+ "@kubb/config-ts": "3.0.0-beta.11",
88
+ "@kubb/config-tsup": "3.0.0-beta.11"
89
89
  },
90
90
  "peerDependencies": {
91
91
  "axios": "^1.7.2",
92
- "@kubb/react": "3.0.0-beta.1"
92
+ "@kubb/react": "3.0.0-beta.11"
93
93
  },
94
94
  "peerDependenciesMeta": {
95
95
  "axios": {
@@ -17,6 +17,7 @@ type Props = {
17
17
 
18
18
  baseURL: string | undefined
19
19
  dataReturnType: PluginClient['resolvedOptions']['dataReturnType']
20
+ paramsType: PluginClient['resolvedOptions']['pathParamsType']
20
21
  pathParamsType: PluginClient['resolvedOptions']['pathParamsType']
21
22
  parser: PluginClient['resolvedOptions']['parser'] | undefined
22
23
  typeSchemas: OperationSchemas
@@ -25,16 +26,54 @@ type Props = {
25
26
  }
26
27
 
27
28
  type GetParamsProps = {
29
+ paramsType: PluginClient['resolvedOptions']['paramsType']
28
30
  pathParamsType: PluginClient['resolvedOptions']['pathParamsType']
29
31
  typeSchemas: OperationSchemas
30
32
  }
31
33
 
32
- function getParams({ pathParamsType, typeSchemas }: GetParamsProps) {
34
+ function getParams({ paramsType, pathParamsType, typeSchemas }: GetParamsProps) {
35
+ if (paramsType === 'object') {
36
+ return FunctionParams.factory({
37
+ data: {
38
+ mode: 'object',
39
+ children: {
40
+ ...getPathParams(typeSchemas.pathParams, { typed: true }),
41
+ data: typeSchemas.request?.name
42
+ ? {
43
+ type: typeSchemas.request?.name,
44
+ optional: isOptional(typeSchemas.request?.schema),
45
+ }
46
+ : undefined,
47
+ params: typeSchemas.queryParams?.name
48
+ ? {
49
+ type: typeSchemas.queryParams?.name,
50
+ optional: isOptional(typeSchemas.queryParams?.schema),
51
+ }
52
+ : undefined,
53
+ headers: typeSchemas.headerParams?.name
54
+ ? {
55
+ type: typeSchemas.headerParams?.name,
56
+ optional: isOptional(typeSchemas.headerParams?.schema),
57
+ }
58
+ : undefined,
59
+ },
60
+ },
61
+ config: {
62
+ type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : 'Partial<RequestConfig>',
63
+ default: '{}',
64
+ },
65
+ })
66
+ }
67
+
33
68
  return FunctionParams.factory({
34
- pathParams: {
35
- mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',
36
- children: getPathParams(typeSchemas.pathParams, { typed: true }),
37
- },
69
+ pathParams: typeSchemas.pathParams?.name
70
+ ? {
71
+ mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',
72
+ children: getPathParams(typeSchemas.pathParams, { typed: true }),
73
+ type: typeSchemas.pathParams?.name,
74
+ optional: isOptional(typeSchemas.pathParams?.schema),
75
+ }
76
+ : undefined,
38
77
  data: typeSchemas.request?.name
39
78
  ? {
40
79
  type: typeSchemas.request?.name,
@@ -69,6 +108,7 @@ export function Client({
69
108
  dataReturnType,
70
109
  parser,
71
110
  zodSchemas,
111
+ paramsType,
72
112
  pathParamsType,
73
113
  operation,
74
114
  }: Props): KubbNode {
@@ -85,7 +125,7 @@ export function Client({
85
125
  typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error',
86
126
  typeSchemas.request?.name || 'unknown',
87
127
  ].filter(Boolean)
88
- const params = getParams({ pathParamsType, typeSchemas })
128
+ const params = getParams({ paramsType, pathParamsType, typeSchemas })
89
129
  const clientParams = FunctionParams.factory({
90
130
  config: {
91
131
  mode: 'object',
@@ -7,9 +7,7 @@ import type { RequestConfig } from "@kubb/plugin-client/client";
7
7
  * @summary Deletes a pet
8
8
  * @link /pet/:petId
9
9
  */
10
- export async function deletePet({ petId }: {
11
- petId: DeletePetPathParams["petId"];
12
- }, headers?: DeletePetHeaderParams, config: Partial<RequestConfig> = {}) {
10
+ export async function deletePet({ petId }: DeletePetPathParams, headers?: DeletePetHeaderParams, config: Partial<RequestConfig> = {}) {
13
11
  const res = await client<DeletePetMutationResponse, DeletePet400, unknown>({ method: "DELETE", url: `/pet/${petId}`, headers: { ...headers, ...config.headers }, ...config });
14
12
  return res.data;
15
13
  }
@@ -0,0 +1,15 @@
1
+ /* eslint-disable no-alert, no-console */
2
+ import client from "@kubb/plugin-client/client";
3
+ import type { RequestConfig } from "@kubb/plugin-client/client";
4
+
5
+ /**
6
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
7
+ * @summary Finds Pets by tags
8
+ * @link /pet/findByTags
9
+ */
10
+ export async function findPetsByTags({ params }: {
11
+ params?: FindPetsByTagsQueryParams;
12
+ }, config: Partial<RequestConfig> = {}) {
13
+ const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: "GET", url: `/pet/findByTags`, params, ...config });
14
+ return res.data;
15
+ }
@@ -55,6 +55,7 @@ export const clientGenerator = createReactGenerator<PluginClient>({
55
55
  baseURL={options.baseURL}
56
56
  dataReturnType={options.dataReturnType}
57
57
  pathParamsType={options.pathParamsType}
58
+ paramsType={options.paramsType}
58
59
  typeSchemas={type.schemas}
59
60
  operation={operation}
60
61
  parser={options.parser}
package/src/plugin.ts CHANGED
@@ -24,7 +24,9 @@ export const pluginClient = createPlugin<PluginClient>((options) => {
24
24
  transformers = {},
25
25
  dataReturnType = 'data',
26
26
  pathParamsType = 'inline',
27
+ paramsType = 'inline',
27
28
  operations = false,
29
+ baseURL,
28
30
  generators = [clientGenerator, group ? groupedClientGenerator : undefined, operations ? operationsGenerator : undefined].filter(Boolean),
29
31
  importPath = '@kubb/plugin-client/client',
30
32
  parser = 'client',
@@ -38,8 +40,9 @@ export const pluginClient = createPlugin<PluginClient>((options) => {
38
40
  parser,
39
41
  dataReturnType,
40
42
  importPath,
41
- pathParamsType,
42
- baseURL: undefined,
43
+ paramsType,
44
+ pathParamsType: paramsType === 'object' ? 'object' : pathParamsType,
45
+ baseURL,
43
46
  },
44
47
  pre: [pluginOasName, parser === 'zod' ? pluginZodName : undefined].filter(Boolean),
45
48
  resolvePath(baseName, pathMode, options) {
@@ -80,10 +83,12 @@ export const pluginClient = createPlugin<PluginClient>((options) => {
80
83
  const baseURL = await swaggerPlugin.context.getBaseURL()
81
84
 
82
85
  const operationGenerator = new OperationGenerator(
83
- {
84
- ...this.plugin.options,
85
- baseURL,
86
- },
86
+ baseURL
87
+ ? {
88
+ ...this.plugin.options,
89
+ baseURL,
90
+ }
91
+ : this.plugin.options,
87
92
  {
88
93
  oas,
89
94
  pluginManager: this.pluginManager,
package/src/types.ts CHANGED
@@ -26,7 +26,7 @@ export type Options = {
26
26
  override?: Array<Override<ResolvedOptions>>
27
27
  /**
28
28
  * Create `operations.ts` file with all operations grouped by methods.
29
- * @default `false`
29
+ * @default false
30
30
  */
31
31
  operations?: boolean
32
32
  /**
@@ -36,29 +36,34 @@ export type Options = {
36
36
  * @default '@kubb/plugin-client/client'
37
37
  */
38
38
  importPath?: string
39
+ /**
40
+ * Allows you to set a custom base url for all generated calls.
41
+ */
42
+ baseURL?: string
39
43
  /**
40
44
  * ReturnType that will be used when calling the client.
41
- *
42
- * `Data` will return ResponseConfig[data].
43
- *
44
- * `Full` will return ResponseConfig.
45
- * @default `'data'`
46
- * @private
45
+ * - 'data' will return ResponseConfig[data].
46
+ * - 'full' will return ResponseConfig.
47
+ * @default 'data'
47
48
  */
48
49
  dataReturnType?: 'data' | 'full'
50
+ /**
51
+ * How to pass your params
52
+ * - 'object' will return the params and pathParams as an object.
53
+ * - 'inline' will return the params as comma separated params.
54
+ * @default 'inline'
55
+ */
56
+ paramsType?: 'object' | 'inline'
49
57
  /**
50
58
  * How to pass your pathParams.
51
- *
52
- * `object` will return the pathParams as an object.
53
- *
54
- * `inline` will return the pathParams as comma separated params.
55
- * @default `'inline'`
56
- * @private
59
+ * - 'object' will return the pathParams as an object.
60
+ * - 'inline' will return the pathParams as comma separated params.
61
+ * @default 'inline'
57
62
  */
58
63
  pathParamsType?: 'object' | 'inline'
59
64
  /**
60
65
  * Which parser can be used before returning the data
61
- * `'zod'` will use `@kubb/plugin-zod` to parse the data.
66
+ * - 'zod' will use `@kubb/plugin-zod` to parse the data.
62
67
  * @default 'client'
63
68
  */
64
69
  parser?: 'client' | 'zod'
@@ -82,6 +87,7 @@ type ResolvedOptions = {
82
87
  importPath: NonNullable<Options['importPath']>
83
88
  dataReturnType: NonNullable<Options['dataReturnType']>
84
89
  pathParamsType: NonNullable<Options['pathParamsType']>
90
+ paramsType: NonNullable<Options['paramsType']>
85
91
  }
86
92
 
87
93
  export type PluginClient = PluginFactoryOptions<'plugin-client', Options, ResolvedOptions, never, ResolvePathOptions>
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/generators/clientGenerator.tsx","../src/generators/groupedClientGenerator.tsx","../src/plugin.ts","../src/generators/operationsGenerator.tsx"],"names":["createReactGenerator","useApp","useOperationManager","pluginTsName","pluginZodName","File","jsx","Client","camelCase","jsxs","Function","createPlugin","transformers","pluginOasName","options","path","FileManager","PluginManager","OperationGenerator","Operations"],"mappings":";;;;;;;;;;;;;;;;;AAQO,IAAM,kBAAkBA,8BAAmC,CAAA;AAAA,EAChE,IAAM,EAAA,QAAA;AAAA,EACN,SAAU,CAAA,EAAE,OAAS,EAAA,SAAA,EAAa,EAAA;AAChC,IAAM,MAAA;AAAA,MACJ,MAAQ,EAAA;AAAA,QACN,OAAA,EAAS,EAAE,MAAO,EAAA;AAAA,OACpB;AAAA,QACEC,YAAqB,EAAA,CAAA;AACzB,IAAA,MAAM,EAAE,UAAA,EAAY,OAAS,EAAA,OAAA,KAAYC,yBAAoB,EAAA,CAAA;AAE7D,IAAA,MAAM,MAAS,GAAA;AAAA,MACb,MAAM,OAAQ,CAAA,SAAA,EAAW,EAAE,IAAA,EAAM,YAAY,CAAA;AAAA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J,SAAA,EAAW,KAAK,MAAO,CAAA,GAAA;AAAA,SACzB;AAAA,QACA,QAAQ,IAAK,CAAA,MAAA;AAAA,OACd,CAAA,CAAA;AAED,MAAM,MAAA,IAAA,CAAK,OAAQ,CAAA,GAAG,WAAW,CAAA,CAAA;AAAA,KACnC;AAAA,GACF,CAAA;AACF,CAAC,EAAA;AC9GM,IAAM,sBAAsBlB,8BAAmC,CAAA;AAAA,EACpE,IAAM,EAAA,QAAA;AAAA,EACN,UAAA,CAAW,EAAE,UAAA,EAAc,EAAA;AACzB,IAAM,MAAA;AAAA,MACJ,aAAA;AAAA,MACA,MAAQ,EAAA;AAAA,QACN,OAAA,EAAS,EAAE,MAAO,EAAA;AAAA,OACpB;AAAA,QACEC,YAAqB,EAAA,CAAA;AAEzB,IAAA,MAAM,IAAO,GAAA,YAAA,CAAA;AACb,IAAM,MAAA,IAAA,GAAO,aAAc,CAAA,OAAA,CAAQ,EAAE,IAAA,EAAM,OAAS,EAAA,KAAA,EAAO,SAAW,EAAA,CAAC,gBAAgB,CAAA,EAAG,CAAA,CAAA;AAE1F,IACE,uBAAAK,cAACD,CAAAA,UAAAA,EAAA,EAAK,QAAA,EAAU,KAAK,QAAU,EAAA,IAAA,EAAM,IAAK,CAAA,IAAA,EAAM,IAAM,EAAA,IAAA,CAAK,MAAM,MAAQ,EAAA,MAAA,EAAQ,MAAQ,EAAA,MAAA,EAAQ,MAAQ,EAAA,MAAA,EACvG,0BAAAC,cAAC,CAAAa,4BAAA,EAAA,EAAW,IAAY,EAAA,UAAA,EAAwB,CAClD,EAAA,CAAA,CAAA;AAAA,GAEJ;AACF,CAAC","file":"chunk-6W3SC7JK.cjs","sourcesContent":["import { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { File, useApp } from '@kubb/react'\nimport { Client } from '../components/Client'\nimport type { PluginClient } from '../types'\n\nexport const clientGenerator = createReactGenerator<PluginClient>({\n name: 'client',\n Operation({ options, operation }) {\n const {\n plugin: {\n options: { output },\n },\n } = useApp<PluginClient>()\n const { getSchemas, getName, getFile } = useOperationManager()\n\n const client = {\n name: getName(operation, { type: 'function' }),\n file: getFile(operation),\n }\n\n const type = {\n file: getFile(operation, { pluginKey: [pluginTsName] }),\n schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' }),\n }\n\n const zod = {\n file: getFile(operation, { pluginKey: [pluginZodName] }),\n schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: 'function' }),\n }\n\n return (\n <File baseName={client.file.baseName} path={client.file.path} meta={client.file.meta} banner={output?.banner} footer={output?.footer}>\n <File.Import name={'client'} path={options.importPath} />\n <File.Import name={['RequestConfig']} path={options.importPath} isTypeOnly />\n {options.parser === 'zod' && <File.Import name={[zod.schemas.response.name]} root={client.file.path} path={zod.file.path} />}\n <File.Import\n name={[\n type.schemas.request?.name,\n type.schemas.response.name,\n type.schemas.pathParams?.name,\n type.schemas.queryParams?.name,\n type.schemas.headerParams?.name,\n ...(type.schemas.statusCodes?.map((item) => item.name) || []),\n ].filter(Boolean)}\n root={client.file.path}\n path={type.file.path}\n isTypeOnly\n />\n\n <Client\n name={client.name}\n baseURL={options.baseURL}\n dataReturnType={options.dataReturnType}\n pathParamsType={options.pathParamsType}\n typeSchemas={type.schemas}\n operation={operation}\n parser={options.parser}\n zodSchemas={zod.schemas}\n />\n </File>\n )\n },\n})\n","import { camelCase } from '@kubb/core/transformers'\nimport type * as KubbFile from '@kubb/fs/types'\nimport { pluginClientName } from '@kubb/plugin-client'\nimport { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { File, Function, useApp } from '@kubb/react'\nimport type { PluginClient } from '../types'\n\nexport const groupedClientGenerator = createReactGenerator<PluginClient>({\n name: 'groupedClient',\n Operations({ operations }) {\n const {\n pluginManager,\n plugin: { options },\n } = useApp<PluginClient>()\n const { getName, getFile } = useOperationManager()\n\n const controllers = operations.reduce(\n (acc, operation) => {\n if (options.group?.type === 'tag') {\n const tag = operation.getTags().at(0)?.name\n const name = tag ? options.group?.name?.({ group: camelCase(tag) }) : undefined\n\n if (!tag || !name) {\n return acc\n }\n\n const file = pluginManager.getFile({\n name,\n extname: '.ts',\n pluginKey: [pluginClientName],\n options: { tag },\n })\n\n const client = {\n name: getName(operation, { type: 'function' }),\n file: getFile(operation),\n }\n\n const previousFile = acc.find((item) => item.file.path === file.path)\n\n if (previousFile) {\n previousFile.clients.push(client)\n } else {\n acc.push({ name, file, clients: [client] })\n }\n }\n\n return acc\n },\n [] as Array<{ name: string; file: KubbFile.File; clients: Array<{ name: string; file: KubbFile.File }> }>,\n )\n\n return controllers.map(({ name, file, clients }) => {\n return (\n <File key={file.path} baseName={file.baseName} path={file.path} meta={file.meta} banner={options.output?.banner} footer={options.output?.footer}>\n {clients.map((client) => (\n <File.Import key={client.name} name={[client.name]} root={file.path} path={client.file.path} />\n ))}\n\n <File.Source name={name} isExportable isIndexable>\n <Function export name={name}>\n {`return { ${clients.map((client) => client.name).join(', ')} }`}\n </Function>\n </File.Source>\n </File>\n )\n })\n },\n})\n","import path from 'node:path'\n\nimport { FileManager, type Group, PluginManager, createPlugin } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { operationsGenerator } from './generators'\nimport { clientGenerator } from './generators/clientGenerator.tsx'\nimport { groupedClientGenerator } from './generators/groupedClientGenerator.tsx'\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', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n transformers = {},\n dataReturnType = 'data',\n pathParamsType = 'inline',\n operations = false,\n generators = [clientGenerator, group ? groupedClientGenerator : undefined, operations ? operationsGenerator : undefined].filter(Boolean),\n importPath = '@kubb/plugin-client/client',\n parser = 'client',\n } = options\n\n return {\n name: pluginClientName,\n options: {\n output,\n group,\n parser,\n dataReturnType,\n importPath,\n pathParamsType,\n baseURL: undefined,\n },\n pre: [pluginOasName, parser === 'zod' ? pluginZodName : undefined].filter(Boolean),\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 (options?.tag && group?.type === 'tag') {\n const groupName: Group['name'] = group?.name ? group.name : (ctx) => `${ctx.group}Controller`\n\n return path.resolve(root, output.path, groupName({ group: camelCase(options.tag) }), baseName)\n }\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 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(...generators)\n\n await this.addFile(...files)\n\n const barrelFiles = await this.fileManager.getBarrelFiles({\n type: output.barrelType ?? 'named',\n root,\n output,\n files: this.fileManager.files,\n meta: {\n pluginKey: this.plugin.key,\n },\n logger: this.logger,\n })\n\n await this.addFile(...barrelFiles)\n },\n }\n})\n","import { pluginClientName } from '@kubb/plugin-client'\nimport { createReactGenerator } from '@kubb/plugin-oas'\nimport { File, useApp } from '@kubb/react'\nimport { Operations } from '../components/Operations'\nimport type { PluginClient } from '../types'\n\nexport const operationsGenerator = createReactGenerator<PluginClient>({\n name: 'client',\n Operations({ operations }) {\n const {\n pluginManager,\n plugin: {\n options: { output },\n },\n } = useApp<PluginClient>()\n\n const name = 'operations'\n const file = pluginManager.getFile({ name, extname: '.ts', pluginKey: [pluginClientName] })\n\n return (\n <File baseName={file.baseName} path={file.path} meta={file.meta} banner={output?.banner} footer={output?.footer}>\n <Operations name={name} operations={operations} />\n </File>\n )\n },\n})\n"]}