@kubb/plugin-client 3.0.0-alpha.1 → 3.0.0-alpha.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 (53) hide show
  1. package/client.ts +1 -1
  2. package/dist/chunk-3NQF7BGA.cjs +58 -0
  3. package/dist/chunk-3NQF7BGA.cjs.map +1 -0
  4. package/dist/chunk-AZDWYBLW.cjs +4 -0
  5. package/dist/chunk-AZDWYBLW.cjs.map +1 -0
  6. package/dist/chunk-PO22ZUSH.cjs +125 -0
  7. package/dist/chunk-PO22ZUSH.cjs.map +1 -0
  8. package/dist/chunk-QBFKND4S.js +122 -0
  9. package/dist/chunk-QBFKND4S.js.map +1 -0
  10. package/dist/chunk-QLVGX3VO.js +56 -0
  11. package/dist/chunk-QLVGX3VO.js.map +1 -0
  12. package/dist/chunk-YJOVLRSC.js +3 -0
  13. package/dist/chunk-YJOVLRSC.js.map +1 -0
  14. package/dist/client.cjs +16 -7
  15. package/dist/client.cjs.map +1 -1
  16. package/dist/client.d.cts +1 -1
  17. package/dist/client.d.ts +1 -1
  18. package/dist/client.js +5 -6
  19. package/dist/client.js.map +1 -1
  20. package/dist/components.cjs +12 -4
  21. package/dist/components.cjs.map +1 -1
  22. package/dist/components.d.cts +3 -5
  23. package/dist/components.d.ts +3 -5
  24. package/dist/components.js +3 -8
  25. package/dist/components.js.map +1 -1
  26. package/dist/generators.cjs +13 -0
  27. package/dist/generators.cjs.map +1 -0
  28. package/dist/generators.d.cts +10 -0
  29. package/dist/generators.d.ts +10 -0
  30. package/dist/generators.js +4 -0
  31. package/dist/generators.js.map +1 -0
  32. package/dist/index.cjs +51 -104
  33. package/dist/index.cjs.map +1 -1
  34. package/dist/index.d.cts +3 -5
  35. package/dist/index.d.ts +3 -5
  36. package/dist/index.js +31 -91
  37. package/dist/index.js.map +1 -1
  38. package/dist/{types-xK4X9e5d.d.cts → types-DETYKDFZ.d.cts} +19 -108
  39. package/dist/{types-xK4X9e5d.d.ts → types-DETYKDFZ.d.ts} +19 -108
  40. package/package.json +22 -14
  41. package/src/components/Client.tsx +77 -198
  42. package/src/components/Operations.tsx +9 -75
  43. package/src/components/__snapshots__/Client/showPetById.ts +3 -6
  44. package/src/components/__snapshots__/Operations/showPetById.ts +5 -5
  45. package/src/generators/axiosGenerator.tsx +63 -0
  46. package/src/generators/index.ts +1 -0
  47. package/src/plugin.ts +21 -38
  48. package/src/types.ts +9 -3
  49. package/dist/chunk-W57BRY5O.js +0 -201
  50. package/dist/chunk-W57BRY5O.js.map +0 -1
  51. package/dist/chunk-W7F5CMU6.cjs +0 -201
  52. package/dist/chunk-W7F5CMU6.cjs.map +0 -1
  53. package/src/OperationGenerator.tsx +0 -65
@@ -1,123 +1,29 @@
1
1
  import { PluginFactoryOptions, ResolveNameParams } from '@kubb/core';
2
2
  import * as KubbFile from '@kubb/fs/types';
3
- import { ResolvePathOptions, Exclude, Include, Override } from '@kubb/plugin-oas';
4
- import { URLPath } from '@kubb/core/utils';
5
- import { HttpMethod, Operation } from '@kubb/oas';
6
- import { KubbNode, Params } from '@kubb/react';
7
- import { ComponentType, ComponentProps } from 'react';
3
+ import { Operation, HttpMethod } from '@kubb/oas';
4
+ import { OperationSchemas, ResolvePathOptions, Exclude, Include, Override } from '@kubb/plugin-oas';
5
+ import { KubbNode } from '@kubb/react/types';
8
6
 
9
- type TemplateProps$1 = {
7
+ type Props = {
10
8
  /**
11
9
  * Name of the function
12
10
  */
13
11
  name: string;
14
- /**
15
- * Parameters/options/props that need to be used
16
- */
17
- params: Params;
18
- /**
19
- * Generics that needs to be added for TypeScript
20
- */
21
- generics?: string;
22
- /**
23
- * ReturnType(see async for adding Promise type)
24
- */
25
- returnType?: string;
26
- /**
27
- * Options for JSdocs
28
- */
29
- JSDoc?: {
30
- comments: string[];
31
- };
32
- client: {
33
- baseURL: string | undefined;
34
- generics: string | string[];
35
- method: HttpMethod;
36
- path: URLPath;
37
- dataReturnType: PluginClient['options']['dataReturnType'];
38
- withQueryParams: boolean;
39
- withData: boolean;
40
- withHeaders: boolean;
41
- contentType: string;
42
- };
43
- };
44
- declare function Template$1({ name, generics, returnType, params, JSDoc, client }: TemplateProps$1): KubbNode;
45
- type RootTemplateProps$1 = {
46
- children?: React.ReactNode;
47
- };
48
- declare function RootTemplate$1({ children }: RootTemplateProps$1): JSX.Element;
49
- declare const defaultTemplates$1: {
50
- readonly default: typeof Template$1;
51
- readonly root: typeof RootTemplate$1;
52
- };
53
- type Templates$2 = Partial<typeof defaultTemplates$1>;
54
- type ClientProps = {
55
- baseURL: string | undefined;
56
- /**
57
- * This will make it possible to override the default behaviour.
58
- */
59
- Template?: ComponentType<ComponentProps<typeof Template$1>>;
60
- };
61
- declare function Client({ baseURL, Template }: ClientProps): KubbNode;
62
- declare namespace Client {
63
- var File: ({ baseURL, ...props }: FileProps$1) => KubbNode;
64
- var templates: {
65
- readonly default: typeof Template$1;
66
- readonly root: typeof RootTemplate$1;
67
- };
68
- }
69
- type FileProps$1 = {
70
- baseURL: string | undefined;
71
- /**
72
- * This will make it possible to override the default behaviour.
73
- */
74
- templates?: Templates$2;
12
+ options: PluginClient['resolvedOptions'];
13
+ typedSchemas: OperationSchemas;
14
+ operation: Operation;
75
15
  };
16
+ declare function Client({ name, options, typedSchemas, operation }: Props): KubbNode;
76
17
 
77
- type TemplateProps = {
78
- /**
79
- * Name of the function
80
- */
18
+ type OperationsProps = {
81
19
  name: string;
82
- operations: Operation[];
83
- baseURL: string | undefined;
84
- };
85
- declare function Template({ name, operations }: TemplateProps): KubbNode;
86
- type RootTemplateProps = {
87
- children?: React.ReactNode;
88
- };
89
- declare function RootTemplate({ children }: RootTemplateProps): JSX.Element;
90
- declare const defaultTemplates: {
91
- readonly default: typeof Template;
92
- readonly root: typeof RootTemplate;
93
- };
94
- type Templates$1 = Partial<typeof defaultTemplates>;
95
- type Props = {
96
- baseURL: string | undefined;
97
- /**
98
- * This will make it possible to override the default behaviour.
99
- */
100
- Template?: ComponentType<ComponentProps<typeof Template>>;
101
- };
102
- declare function Operations({ baseURL, Template }: Props): KubbNode;
103
- declare namespace Operations {
104
- var File: ({ baseURL, ...props }: FileProps) => KubbNode;
105
- var templates: {
106
- readonly default: typeof Template;
107
- readonly root: typeof RootTemplate;
108
- };
109
- }
110
- type FileProps = {
111
- baseURL: string | undefined;
112
- /**
113
- * This will make it possible to override the default behaviour.
114
- */
115
- templates?: Templates$1;
20
+ operations: Array<Operation>;
116
21
  };
22
+ declare function Operations({ name, operations }: OperationsProps): JSX.Element;
117
23
 
118
24
  type Templates = {
119
- operations?: typeof Operations.templates | false;
120
- client?: typeof Client.templates | false;
25
+ operations?: typeof Operations | false;
26
+ client?: typeof Client | false;
121
27
  };
122
28
  type Options = {
123
29
  output?: {
@@ -136,7 +42,7 @@ type Options = {
136
42
  extName?: KubbFile.Extname;
137
43
  /**
138
44
  * Define what needs to exported, here you can also disable the export of barrel files
139
- * @default `'barrel'`
45
+ * @default `'barrelNamed'`
140
46
  */
141
47
  exportType?: 'barrel' | 'barrelNamed' | false;
142
48
  };
@@ -183,6 +89,11 @@ type Options = {
183
89
  * @default '@kubb/plugin-client/client'
184
90
  */
185
91
  importPath?: string;
92
+ /**
93
+ * Define which HttpMethods can be used for queries
94
+ * @default ['get', 'post', 'put', 'delete']
95
+ */
96
+ methods?: Array<HttpMethod>;
186
97
  };
187
98
  /**
188
99
  * ReturnType that needs to be used when calling client().
@@ -1,123 +1,29 @@
1
1
  import { PluginFactoryOptions, ResolveNameParams } from '@kubb/core';
2
2
  import * as KubbFile from '@kubb/fs/types';
3
- import { ResolvePathOptions, Exclude, Include, Override } from '@kubb/plugin-oas';
4
- import { URLPath } from '@kubb/core/utils';
5
- import { HttpMethod, Operation } from '@kubb/oas';
6
- import { KubbNode, Params } from '@kubb/react';
7
- import { ComponentType, ComponentProps } from 'react';
3
+ import { Operation, HttpMethod } from '@kubb/oas';
4
+ import { OperationSchemas, ResolvePathOptions, Exclude, Include, Override } from '@kubb/plugin-oas';
5
+ import { KubbNode } from '@kubb/react/types';
8
6
 
9
- type TemplateProps$1 = {
7
+ type Props = {
10
8
  /**
11
9
  * Name of the function
12
10
  */
13
11
  name: string;
14
- /**
15
- * Parameters/options/props that need to be used
16
- */
17
- params: Params;
18
- /**
19
- * Generics that needs to be added for TypeScript
20
- */
21
- generics?: string;
22
- /**
23
- * ReturnType(see async for adding Promise type)
24
- */
25
- returnType?: string;
26
- /**
27
- * Options for JSdocs
28
- */
29
- JSDoc?: {
30
- comments: string[];
31
- };
32
- client: {
33
- baseURL: string | undefined;
34
- generics: string | string[];
35
- method: HttpMethod;
36
- path: URLPath;
37
- dataReturnType: PluginClient['options']['dataReturnType'];
38
- withQueryParams: boolean;
39
- withData: boolean;
40
- withHeaders: boolean;
41
- contentType: string;
42
- };
43
- };
44
- declare function Template$1({ name, generics, returnType, params, JSDoc, client }: TemplateProps$1): KubbNode;
45
- type RootTemplateProps$1 = {
46
- children?: React.ReactNode;
47
- };
48
- declare function RootTemplate$1({ children }: RootTemplateProps$1): JSX.Element;
49
- declare const defaultTemplates$1: {
50
- readonly default: typeof Template$1;
51
- readonly root: typeof RootTemplate$1;
52
- };
53
- type Templates$2 = Partial<typeof defaultTemplates$1>;
54
- type ClientProps = {
55
- baseURL: string | undefined;
56
- /**
57
- * This will make it possible to override the default behaviour.
58
- */
59
- Template?: ComponentType<ComponentProps<typeof Template$1>>;
60
- };
61
- declare function Client({ baseURL, Template }: ClientProps): KubbNode;
62
- declare namespace Client {
63
- var File: ({ baseURL, ...props }: FileProps$1) => KubbNode;
64
- var templates: {
65
- readonly default: typeof Template$1;
66
- readonly root: typeof RootTemplate$1;
67
- };
68
- }
69
- type FileProps$1 = {
70
- baseURL: string | undefined;
71
- /**
72
- * This will make it possible to override the default behaviour.
73
- */
74
- templates?: Templates$2;
12
+ options: PluginClient['resolvedOptions'];
13
+ typedSchemas: OperationSchemas;
14
+ operation: Operation;
75
15
  };
16
+ declare function Client({ name, options, typedSchemas, operation }: Props): KubbNode;
76
17
 
77
- type TemplateProps = {
78
- /**
79
- * Name of the function
80
- */
18
+ type OperationsProps = {
81
19
  name: string;
82
- operations: Operation[];
83
- baseURL: string | undefined;
84
- };
85
- declare function Template({ name, operations }: TemplateProps): KubbNode;
86
- type RootTemplateProps = {
87
- children?: React.ReactNode;
88
- };
89
- declare function RootTemplate({ children }: RootTemplateProps): JSX.Element;
90
- declare const defaultTemplates: {
91
- readonly default: typeof Template;
92
- readonly root: typeof RootTemplate;
93
- };
94
- type Templates$1 = Partial<typeof defaultTemplates>;
95
- type Props = {
96
- baseURL: string | undefined;
97
- /**
98
- * This will make it possible to override the default behaviour.
99
- */
100
- Template?: ComponentType<ComponentProps<typeof Template>>;
101
- };
102
- declare function Operations({ baseURL, Template }: Props): KubbNode;
103
- declare namespace Operations {
104
- var File: ({ baseURL, ...props }: FileProps) => KubbNode;
105
- var templates: {
106
- readonly default: typeof Template;
107
- readonly root: typeof RootTemplate;
108
- };
109
- }
110
- type FileProps = {
111
- baseURL: string | undefined;
112
- /**
113
- * This will make it possible to override the default behaviour.
114
- */
115
- templates?: Templates$1;
20
+ operations: Array<Operation>;
116
21
  };
22
+ declare function Operations({ name, operations }: OperationsProps): JSX.Element;
117
23
 
118
24
  type Templates = {
119
- operations?: typeof Operations.templates | false;
120
- client?: typeof Client.templates | false;
25
+ operations?: typeof Operations | false;
26
+ client?: typeof Client | false;
121
27
  };
122
28
  type Options = {
123
29
  output?: {
@@ -136,7 +42,7 @@ type Options = {
136
42
  extName?: KubbFile.Extname;
137
43
  /**
138
44
  * Define what needs to exported, here you can also disable the export of barrel files
139
- * @default `'barrel'`
45
+ * @default `'barrelNamed'`
140
46
  */
141
47
  exportType?: 'barrel' | 'barrelNamed' | false;
142
48
  };
@@ -183,6 +89,11 @@ type Options = {
183
89
  * @default '@kubb/plugin-client/client'
184
90
  */
185
91
  importPath?: string;
92
+ /**
93
+ * Define which HttpMethods can be used for queries
94
+ * @default ['get', 'post', 'put', 'delete']
95
+ */
96
+ methods?: Array<HttpMethod>;
186
97
  };
187
98
  /**
188
99
  * ReturnType that needs to be used when calling client().
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-client",
3
- "version": "3.0.0-alpha.1",
3
+ "version": "3.0.0-alpha.11",
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,27 @@
64
72
  "!/**/__tests__/**"
65
73
  ],
66
74
  "dependencies": {
67
- "@kubb/core": "3.0.0-alpha.1",
68
- "@kubb/fs": "3.0.0-alpha.1",
69
- "@kubb/oas": "3.0.0-alpha.1",
70
- "@kubb/parser-ts": "3.0.0-alpha.1",
71
- "@kubb/plugin-oas": "3.0.0-alpha.1",
72
- "@kubb/plugin-ts": "3.0.0-alpha.1",
73
- "@kubb/react": "3.0.0-alpha.1"
75
+ "@kubb/core": "3.0.0-alpha.11",
76
+ "@kubb/fs": "3.0.0-alpha.11",
77
+ "@kubb/oas": "3.0.0-alpha.11",
78
+ "@kubb/parser-ts": "3.0.0-alpha.11",
79
+ "@kubb/plugin-oas": "3.0.0-alpha.11",
80
+ "@kubb/plugin-ts": "3.0.0-alpha.11",
81
+ "@kubb/react": "3.0.0-alpha.11"
74
82
  },
75
83
  "devDependencies": {
76
- "@types/react": "^18.3.4",
77
- "axios": "^1.7.5",
84
+ "@types/react": "^18.3.5",
85
+ "axios": "^1.7.6",
78
86
  "react": "^18.3.1",
79
87
  "tsup": "^8.2.4",
80
88
  "typescript": "^5.5.4",
81
- "@kubb/config-biome": "3.0.0-alpha.1",
82
- "@kubb/config-ts": "3.0.0-alpha.1",
83
- "@kubb/config-tsup": "3.0.0-alpha.1"
89
+ "@kubb/config-biome": "3.0.0-alpha.11",
90
+ "@kubb/config-ts": "3.0.0-alpha.11",
91
+ "@kubb/config-tsup": "3.0.0-alpha.11"
84
92
  },
85
93
  "peerDependencies": {
86
94
  "axios": "^1.7.2",
87
- "@kubb/react": "3.0.0-alpha.1"
95
+ "@kubb/react": "3.0.0-alpha.11"
88
96
  },
89
97
  "peerDependenciesMeta": {
90
98
  "axios": {