@kubb/plugin-swr 3.10.10 → 3.10.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.
@@ -1,7 +1,7 @@
1
1
  import { Operation } from '@kubb/oas';
2
2
  import { OperationSchemas } from '@kubb/plugin-oas';
3
3
  import { ReactNode } from 'react';
4
- import { P as PluginSwr, T as Transformer } from './types-Cgv0WD2s.cjs';
4
+ import { P as PluginSwr, T as Transformer } from './types-DVQ2siUx.cjs';
5
5
  import { FunctionParams } from '@kubb/react';
6
6
  import '@kubb/core';
7
7
  import '@kubb/plugin-client';
@@ -1,7 +1,7 @@
1
1
  import { Operation } from '@kubb/oas';
2
2
  import { OperationSchemas } from '@kubb/plugin-oas';
3
3
  import { ReactNode } from 'react';
4
- import { P as PluginSwr, T as Transformer } from './types-Cgv0WD2s.js';
4
+ import { P as PluginSwr, T as Transformer } from './types-DVQ2siUx.js';
5
5
  import { FunctionParams } from '@kubb/react';
6
6
  import '@kubb/core';
7
7
  import '@kubb/plugin-client';
@@ -1,5 +1,5 @@
1
1
  import * as _kubb_plugin_oas from '@kubb/plugin-oas';
2
- import { P as PluginSwr } from './types-Cgv0WD2s.cjs';
2
+ import { P as PluginSwr } from './types-DVQ2siUx.cjs';
3
3
  import '@kubb/core';
4
4
  import '@kubb/oas';
5
5
  import '@kubb/plugin-client';
@@ -1,5 +1,5 @@
1
1
  import * as _kubb_plugin_oas from '@kubb/plugin-oas';
2
- import { P as PluginSwr } from './types-Cgv0WD2s.js';
2
+ import { P as PluginSwr } from './types-DVQ2siUx.js';
3
3
  import '@kubb/core';
4
4
  import '@kubb/oas';
5
5
  import '@kubb/plugin-client';
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 PluginSwr } from './types-Cgv0WD2s.cjs';
2
+ import { O as Options, P as PluginSwr } from './types-DVQ2siUx.cjs';
3
3
  import '@kubb/oas';
4
4
  import '@kubb/plugin-client';
5
5
  import '@kubb/plugin-oas';
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 PluginSwr } from './types-Cgv0WD2s.js';
2
+ import { O as Options, P as PluginSwr } from './types-DVQ2siUx.js';
3
3
  import '@kubb/oas';
4
4
  import '@kubb/plugin-client';
5
5
  import '@kubb/plugin-oas';
@@ -0,0 +1,134 @@
1
+ import { Output, Group, PluginFactoryOptions, ResolveNameParams } from '@kubb/core';
2
+ import { Oas, contentType, Operation, HttpMethod } from '@kubb/oas';
3
+ import { PluginClient } from '@kubb/plugin-client';
4
+ import { Exclude, Include, Override, ResolvePathOptions, OperationSchemas, Generator } from '@kubb/plugin-oas';
5
+
6
+ type TransformerProps = {
7
+ operation: Operation;
8
+ schemas: OperationSchemas;
9
+ casing: 'camelcase' | undefined;
10
+ };
11
+ type Transformer = (props: TransformerProps) => unknown[];
12
+ /**
13
+ * Customize the queryKey
14
+ */
15
+ type QueryKey = Transformer;
16
+ /**
17
+ * Customize the mutationKey
18
+ */
19
+ type MutationKey = Transformer;
20
+ type Query = {
21
+ /**
22
+ * Define which HttpMethods can be used for queries
23
+ * @default ['get']
24
+ */
25
+ methods?: Array<HttpMethod>;
26
+ /**
27
+ * Path to the useQuery that will be used to do the useQuery functionality.
28
+ * It will be used as `import { useQuery } from '${importPath}'`.
29
+ * It allows both relative and absolute path.
30
+ * the path will be applied as is, so relative path should be based on the file being generated.
31
+ * @default 'swr'
32
+ */
33
+ importPath?: string;
34
+ };
35
+ type Mutation = {
36
+ /**
37
+ * Define which HttpMethods can be used for queries
38
+ * @default ['post', 'put', 'delete', 'patch']
39
+ */
40
+ methods?: Array<HttpMethod>;
41
+ /**
42
+ * Path to the useQuery that will be used to do the useQuery functionality.
43
+ * It will be used as `import { useQuery } from '${importPath}'`.
44
+ * It allows both relative and absolute path.
45
+ * the path will be applied as is, so relative path should be based on the file being generated.
46
+ * @default 'swr/mutation'
47
+ */
48
+ importPath?: string;
49
+ };
50
+ type Options = {
51
+ /**
52
+ * Specify the export location for the files and define the behavior of the output
53
+ * @default { path: 'hooks', barrelType: 'named' }
54
+ */
55
+ output?: Output<Oas>;
56
+ /**
57
+ * Define which contentType should be used.
58
+ * By default, the first JSON valid mediaType will be used
59
+ */
60
+ contentType?: contentType;
61
+ /**
62
+ * Group the SWR hooks based on the provided name.
63
+ */
64
+ group?: Group;
65
+ /**
66
+ * Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
67
+ */
68
+ exclude?: Array<Exclude>;
69
+ /**
70
+ * Array containing include parameters to include tags/operations/methods/paths.
71
+ */
72
+ include?: Array<Include>;
73
+ /**
74
+ * Array containing override parameters to override `options` based on tags/operations/methods/paths.
75
+ */
76
+ override?: Array<Override<ResolvedOptions>>;
77
+ client?: Pick<PluginClient['options'], 'dataReturnType' | 'importPath' | 'baseURL'>;
78
+ queryKey?: QueryKey;
79
+ query?: Query | false;
80
+ mutationKey?: MutationKey;
81
+ mutation?: Mutation | false;
82
+ /**
83
+ * How to style your params, by default no casing is applied
84
+ * - 'camelcase' will use camelcase for the params names
85
+ */
86
+ paramsCasing?: 'camelcase';
87
+ /**
88
+ * How to pass your params
89
+ * - 'object' will return the params and pathParams as an object.
90
+ * - 'inline' will return the params as comma separated params.
91
+ * @default 'inline'
92
+ */
93
+ paramsType?: 'object' | 'inline';
94
+ /**
95
+ * How to pass your pathParams.
96
+ * - 'object' will return the pathParams as an object.
97
+ * - 'inline' will return the pathParams as comma separated params.
98
+ * @default 'inline'
99
+ */
100
+ pathParamsType?: PluginClient['options']['pathParamsType'];
101
+ /**
102
+ * Which parser should be used before returning the data to `swr`.
103
+ * `'zod'` will use `@kubb/plugin-zod` to parse the data.
104
+ */
105
+ parser?: PluginClient['options']['parser'];
106
+ transformers?: {
107
+ /**
108
+ * Customize the names based on the type that is provided by the plugin.
109
+ */
110
+ name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
111
+ };
112
+ /**
113
+ * Define some generators next to the swr generators
114
+ */
115
+ generators?: Array<Generator<PluginSwr>>;
116
+ };
117
+ type ResolvedOptions = {
118
+ output: Output<Oas>;
119
+ client: Required<Omit<NonNullable<PluginSwr['options']['client']>, 'baseURL'>> & {
120
+ baseURL?: string;
121
+ };
122
+ parser: Required<NonNullable<Options['parser']>>;
123
+ queryKey: QueryKey | undefined;
124
+ query: NonNullable<Required<Query>> | false;
125
+ mutationKey: MutationKey | undefined;
126
+ mutation: NonNullable<Required<Mutation>> | false;
127
+ paramsCasing: Options['paramsCasing'];
128
+ paramsType: NonNullable<Options['paramsType']>;
129
+ pathParamsType: NonNullable<Options['pathParamsType']>;
130
+ group: Options['group'];
131
+ };
132
+ type PluginSwr = PluginFactoryOptions<'plugin-swr', Options, ResolvedOptions, never, ResolvePathOptions>;
133
+
134
+ export type { Options as O, PluginSwr as P, Transformer as T };
@@ -0,0 +1,134 @@
1
+ import { Output, Group, PluginFactoryOptions, ResolveNameParams } from '@kubb/core';
2
+ import { Oas, contentType, Operation, HttpMethod } from '@kubb/oas';
3
+ import { PluginClient } from '@kubb/plugin-client';
4
+ import { Exclude, Include, Override, ResolvePathOptions, OperationSchemas, Generator } from '@kubb/plugin-oas';
5
+
6
+ type TransformerProps = {
7
+ operation: Operation;
8
+ schemas: OperationSchemas;
9
+ casing: 'camelcase' | undefined;
10
+ };
11
+ type Transformer = (props: TransformerProps) => unknown[];
12
+ /**
13
+ * Customize the queryKey
14
+ */
15
+ type QueryKey = Transformer;
16
+ /**
17
+ * Customize the mutationKey
18
+ */
19
+ type MutationKey = Transformer;
20
+ type Query = {
21
+ /**
22
+ * Define which HttpMethods can be used for queries
23
+ * @default ['get']
24
+ */
25
+ methods?: Array<HttpMethod>;
26
+ /**
27
+ * Path to the useQuery that will be used to do the useQuery functionality.
28
+ * It will be used as `import { useQuery } from '${importPath}'`.
29
+ * It allows both relative and absolute path.
30
+ * the path will be applied as is, so relative path should be based on the file being generated.
31
+ * @default 'swr'
32
+ */
33
+ importPath?: string;
34
+ };
35
+ type Mutation = {
36
+ /**
37
+ * Define which HttpMethods can be used for queries
38
+ * @default ['post', 'put', 'delete', 'patch']
39
+ */
40
+ methods?: Array<HttpMethod>;
41
+ /**
42
+ * Path to the useQuery that will be used to do the useQuery functionality.
43
+ * It will be used as `import { useQuery } from '${importPath}'`.
44
+ * It allows both relative and absolute path.
45
+ * the path will be applied as is, so relative path should be based on the file being generated.
46
+ * @default 'swr/mutation'
47
+ */
48
+ importPath?: string;
49
+ };
50
+ type Options = {
51
+ /**
52
+ * Specify the export location for the files and define the behavior of the output
53
+ * @default { path: 'hooks', barrelType: 'named' }
54
+ */
55
+ output?: Output<Oas>;
56
+ /**
57
+ * Define which contentType should be used.
58
+ * By default, the first JSON valid mediaType will be used
59
+ */
60
+ contentType?: contentType;
61
+ /**
62
+ * Group the SWR hooks based on the provided name.
63
+ */
64
+ group?: Group;
65
+ /**
66
+ * Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
67
+ */
68
+ exclude?: Array<Exclude>;
69
+ /**
70
+ * Array containing include parameters to include tags/operations/methods/paths.
71
+ */
72
+ include?: Array<Include>;
73
+ /**
74
+ * Array containing override parameters to override `options` based on tags/operations/methods/paths.
75
+ */
76
+ override?: Array<Override<ResolvedOptions>>;
77
+ client?: Pick<PluginClient['options'], 'dataReturnType' | 'importPath' | 'baseURL'>;
78
+ queryKey?: QueryKey;
79
+ query?: Query | false;
80
+ mutationKey?: MutationKey;
81
+ mutation?: Mutation | false;
82
+ /**
83
+ * How to style your params, by default no casing is applied
84
+ * - 'camelcase' will use camelcase for the params names
85
+ */
86
+ paramsCasing?: 'camelcase';
87
+ /**
88
+ * How to pass your params
89
+ * - 'object' will return the params and pathParams as an object.
90
+ * - 'inline' will return the params as comma separated params.
91
+ * @default 'inline'
92
+ */
93
+ paramsType?: 'object' | 'inline';
94
+ /**
95
+ * How to pass your pathParams.
96
+ * - 'object' will return the pathParams as an object.
97
+ * - 'inline' will return the pathParams as comma separated params.
98
+ * @default 'inline'
99
+ */
100
+ pathParamsType?: PluginClient['options']['pathParamsType'];
101
+ /**
102
+ * Which parser should be used before returning the data to `swr`.
103
+ * `'zod'` will use `@kubb/plugin-zod` to parse the data.
104
+ */
105
+ parser?: PluginClient['options']['parser'];
106
+ transformers?: {
107
+ /**
108
+ * Customize the names based on the type that is provided by the plugin.
109
+ */
110
+ name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
111
+ };
112
+ /**
113
+ * Define some generators next to the swr generators
114
+ */
115
+ generators?: Array<Generator<PluginSwr>>;
116
+ };
117
+ type ResolvedOptions = {
118
+ output: Output<Oas>;
119
+ client: Required<Omit<NonNullable<PluginSwr['options']['client']>, 'baseURL'>> & {
120
+ baseURL?: string;
121
+ };
122
+ parser: Required<NonNullable<Options['parser']>>;
123
+ queryKey: QueryKey | undefined;
124
+ query: NonNullable<Required<Query>> | false;
125
+ mutationKey: MutationKey | undefined;
126
+ mutation: NonNullable<Required<Mutation>> | false;
127
+ paramsCasing: Options['paramsCasing'];
128
+ paramsType: NonNullable<Options['paramsType']>;
129
+ pathParamsType: NonNullable<Options['pathParamsType']>;
130
+ group: Options['group'];
131
+ };
132
+ type PluginSwr = PluginFactoryOptions<'plugin-swr', Options, ResolvedOptions, never, ResolvePathOptions>;
133
+
134
+ export type { Options as O, PluginSwr as P, Transformer as T };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-swr",
3
- "version": "3.10.10",
3
+ "version": "3.10.11",
4
4
  "description": "Generator plugin-swr",
5
5
  "keywords": [
6
6
  "typescript",
@@ -63,22 +63,22 @@
63
63
  "!/**/__tests__/**"
64
64
  ],
65
65
  "dependencies": {
66
- "remeda": "^2.21.3",
67
- "@kubb/core": "3.10.10",
68
- "@kubb/oas": "3.10.10",
69
- "@kubb/plugin-client": "3.10.10",
70
- "@kubb/plugin-oas": "3.10.10",
71
- "@kubb/plugin-ts": "3.10.10",
72
- "@kubb/plugin-zod": "3.10.10",
73
- "@kubb/react": "3.10.10"
66
+ "remeda": "^2.21.4",
67
+ "@kubb/core": "3.10.11",
68
+ "@kubb/oas": "3.10.11",
69
+ "@kubb/plugin-client": "3.10.11",
70
+ "@kubb/plugin-oas": "3.10.11",
71
+ "@kubb/plugin-ts": "3.10.11",
72
+ "@kubb/plugin-zod": "3.10.11",
73
+ "@kubb/react": "3.10.11"
74
74
  },
75
75
  "devDependencies": {
76
76
  "@types/react": "^18.3.21",
77
77
  "react": "^18.3.1",
78
78
  "tsup": "^8.4.0",
79
79
  "typescript": "^5.8.3",
80
- "@kubb/config-ts": "3.10.10",
81
- "@kubb/config-tsup": "3.10.10"
80
+ "@kubb/config-ts": "3.10.11",
81
+ "@kubb/config-tsup": "3.10.11"
82
82
  },
83
83
  "peerDependencies": {
84
84
  "@kubb/react": "^3.0.0"
package/src/types.ts CHANGED
@@ -1,8 +1,7 @@
1
1
  import type { Group, Output, PluginFactoryOptions, ResolveNameParams } from '@kubb/core'
2
- import type { HttpMethod, Oas, Operation, contentType } from '@kubb/oas'
2
+ import type { contentType, HttpMethod, Oas, Operation } from '@kubb/oas'
3
3
  import type { PluginClient } from '@kubb/plugin-client'
4
4
  import type { Exclude, Generator, Include, OperationSchemas, Override, ResolvePathOptions } from '@kubb/plugin-oas'
5
- import type { PluginReactQuery } from '@kubb/plugin-react-query'
6
5
 
7
6
  type TransformerProps = {
8
7
  operation: Operation
@@ -124,7 +123,7 @@ export type Options = {
124
123
 
125
124
  type ResolvedOptions = {
126
125
  output: Output<Oas>
127
- client: Required<Omit<NonNullable<PluginReactQuery['options']['client']>, 'baseURL'>> & { baseURL?: string }
126
+ client: Required<Omit<NonNullable<PluginSwr['options']['client']>, 'baseURL'>> & { baseURL?: string }
128
127
  parser: Required<NonNullable<Options['parser']>>
129
128
  queryKey: QueryKey | undefined
130
129
  query: NonNullable<Required<Query>> | false
@@ -1,298 +0,0 @@
1
- import { PluginFactoryOptions, Output, Group, ResolveNameParams } from '@kubb/core';
2
- import { Oas, contentType, Operation, HttpMethod } from '@kubb/oas';
3
- import { PluginClient } from '@kubb/plugin-client';
4
- import { Exclude, Include, Override, OperationSchemas, Generator, ResolvePathOptions } from '@kubb/plugin-oas';
5
-
6
- type TransformerProps$1 = {
7
- operation: Operation;
8
- schemas: OperationSchemas;
9
- casing: 'camelcase' | undefined;
10
- };
11
- type Transformer$1 = (props: TransformerProps$1) => unknown[];
12
- type Suspense = object;
13
- /**
14
- * Customize the queryKey
15
- */
16
- type QueryKey$1 = Transformer$1;
17
- /**
18
- * Customize the mutationKey
19
- */
20
- type MutationKey$1 = Transformer$1;
21
- type Query$1 = {
22
- /**
23
- * Define which HttpMethods can be used for queries
24
- * @default ['get']
25
- */
26
- methods: Array<HttpMethod>;
27
- /**
28
- * Path to the useQuery that will be used to do the useQuery functionality.
29
- * It will be used as `import { useQuery } from '${importPath}'`.
30
- * It allows both relative and absolute path.
31
- * the path will be applied as is, so relative path should be based on the file being generated.
32
- * @default '@tanstack/react-query'
33
- */
34
- importPath?: string;
35
- };
36
- type Mutation$1 = {
37
- /**
38
- * Define which HttpMethods can be used for mutations
39
- * @default ['post', 'put', 'delete']
40
- */
41
- methods: Array<HttpMethod>;
42
- /**
43
- * Path to the useQuery that will be used to do the useQuery functionality.
44
- * It will be used as `import { useQuery } from '${importPath}'`.
45
- * It allows both relative and absolute path.
46
- * the path will be applied as is, so relative path should be based on the file being generated.
47
- * @default '@tanstack/react-query'
48
- */
49
- importPath?: string;
50
- };
51
- type Infinite = {
52
- /**
53
- * Specify the params key used for `pageParam`.
54
- * @default 'id'
55
- */
56
- queryParam: string;
57
- /**
58
- * Which field of the data will be used, set it to undefined when no cursor is known.
59
- */
60
- cursorParam?: string | undefined;
61
- /**
62
- * The initial value, the value of the first page.
63
- * @default 0
64
- */
65
- initialPageParam: unknown;
66
- };
67
- type Options$1 = {
68
- /**
69
- * Specify the export location for the files and define the behavior of the output
70
- * @default { path: 'hooks', barrelType: 'named' }
71
- */
72
- output?: Output<Oas>;
73
- /**
74
- * Define which contentType should be used.
75
- * By default, the first JSON valid mediaType will be used
76
- */
77
- contentType?: contentType;
78
- /**
79
- * Group the @tanstack/query hooks based on the provided name.
80
- */
81
- group?: Group;
82
- client?: Pick<PluginClient['options'], 'dataReturnType' | 'importPath' | 'baseURL'>;
83
- /**
84
- * Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
85
- */
86
- exclude?: Array<Exclude>;
87
- /**
88
- * Array containing include parameters to include tags/operations/methods/paths.
89
- */
90
- include?: Array<Include>;
91
- /**
92
- * Array containing override parameters to override `options` based on tags/operations/methods/paths.
93
- */
94
- override?: Array<Override<ResolvedOptions$1>>;
95
- /**
96
- * How to style your params, by default no casing is applied
97
- * - 'camelcase' will use camelcase for the params names
98
- */
99
- paramsCasing?: 'camelcase';
100
- /**
101
- * How to pass your params
102
- * - 'object' will return the params and pathParams as an object.
103
- * - 'inline' will return the params as comma separated params.
104
- * @default 'inline'
105
- */
106
- paramsType?: 'object' | 'inline';
107
- /**
108
- * How to pass your pathParams.
109
- * - 'object' will return the pathParams as an object.
110
- * - 'inline' will return the pathParams as comma separated params.
111
- * @default 'inline'
112
- */
113
- pathParamsType?: PluginClient['options']['pathParamsType'];
114
- /**
115
- * When set, an infiniteQuery hooks will be added.
116
- */
117
- infinite?: Partial<Infinite> | false;
118
- /**
119
- * When set, a suspenseQuery hooks will be added.
120
- */
121
- suspense?: Partial<Suspense> | false;
122
- queryKey?: QueryKey$1;
123
- /**
124
- * Override some useQuery behaviours.
125
- */
126
- query?: Partial<Query$1> | false;
127
- mutationKey?: MutationKey$1;
128
- /**
129
- * Override some useMutation behaviours.
130
- */
131
- mutation?: Partial<Mutation$1> | false;
132
- /**
133
- * Which parser should be used before returning the data to `@tanstack/query`.
134
- * `'zod'` will use `@kubb/plugin-zod` to parse the data.
135
- */
136
- parser?: PluginClient['options']['parser'];
137
- transformers?: {
138
- /**
139
- * Customize the names based on the type that is provided by the plugin.
140
- */
141
- name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
142
- };
143
- /**
144
- * Define some generators next to the react-query generators
145
- */
146
- generators?: Array<Generator<PluginReactQuery>>;
147
- };
148
- type ResolvedOptions$1 = {
149
- output: Output<Oas>;
150
- group: Options$1['group'];
151
- client: Required<Omit<NonNullable<PluginReactQuery['options']['client']>, 'baseURL'>> & {
152
- baseURL?: string;
153
- };
154
- parser: Required<NonNullable<Options$1['parser']>>;
155
- pathParamsType: NonNullable<Options$1['pathParamsType']>;
156
- paramsCasing: Options$1['paramsCasing'];
157
- paramsType: NonNullable<Options$1['paramsType']>;
158
- /**
159
- * Only used of infinite
160
- */
161
- infinite: NonNullable<Infinite> | false;
162
- suspense: Suspense | false;
163
- queryKey: QueryKey$1 | undefined;
164
- query: NonNullable<Required<Query$1>> | false;
165
- mutationKey: MutationKey$1 | undefined;
166
- mutation: NonNullable<Required<Mutation$1>> | false;
167
- };
168
- type PluginReactQuery = PluginFactoryOptions<'plugin-react-query', Options$1, ResolvedOptions$1, never, ResolvePathOptions>;
169
-
170
- type TransformerProps = {
171
- operation: Operation;
172
- schemas: OperationSchemas;
173
- casing: 'camelcase' | undefined;
174
- };
175
- type Transformer = (props: TransformerProps) => unknown[];
176
- /**
177
- * Customize the queryKey
178
- */
179
- type QueryKey = Transformer;
180
- /**
181
- * Customize the mutationKey
182
- */
183
- type MutationKey = Transformer;
184
- type Query = {
185
- /**
186
- * Define which HttpMethods can be used for queries
187
- * @default ['get']
188
- */
189
- methods?: Array<HttpMethod>;
190
- /**
191
- * Path to the useQuery that will be used to do the useQuery functionality.
192
- * It will be used as `import { useQuery } from '${importPath}'`.
193
- * It allows both relative and absolute path.
194
- * the path will be applied as is, so relative path should be based on the file being generated.
195
- * @default 'swr'
196
- */
197
- importPath?: string;
198
- };
199
- type Mutation = {
200
- /**
201
- * Define which HttpMethods can be used for queries
202
- * @default ['post', 'put', 'delete', 'patch']
203
- */
204
- methods?: Array<HttpMethod>;
205
- /**
206
- * Path to the useQuery that will be used to do the useQuery functionality.
207
- * It will be used as `import { useQuery } from '${importPath}'`.
208
- * It allows both relative and absolute path.
209
- * the path will be applied as is, so relative path should be based on the file being generated.
210
- * @default 'swr/mutation'
211
- */
212
- importPath?: string;
213
- };
214
- type Options = {
215
- /**
216
- * Specify the export location for the files and define the behavior of the output
217
- * @default { path: 'hooks', barrelType: 'named' }
218
- */
219
- output?: Output<Oas>;
220
- /**
221
- * Define which contentType should be used.
222
- * By default, the first JSON valid mediaType will be used
223
- */
224
- contentType?: contentType;
225
- /**
226
- * Group the SWR hooks based on the provided name.
227
- */
228
- group?: Group;
229
- /**
230
- * Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
231
- */
232
- exclude?: Array<Exclude>;
233
- /**
234
- * Array containing include parameters to include tags/operations/methods/paths.
235
- */
236
- include?: Array<Include>;
237
- /**
238
- * Array containing override parameters to override `options` based on tags/operations/methods/paths.
239
- */
240
- override?: Array<Override<ResolvedOptions>>;
241
- client?: Pick<PluginClient['options'], 'dataReturnType' | 'importPath' | 'baseURL'>;
242
- queryKey?: QueryKey;
243
- query?: Query | false;
244
- mutationKey?: MutationKey;
245
- mutation?: Mutation | false;
246
- /**
247
- * How to style your params, by default no casing is applied
248
- * - 'camelcase' will use camelcase for the params names
249
- */
250
- paramsCasing?: 'camelcase';
251
- /**
252
- * How to pass your params
253
- * - 'object' will return the params and pathParams as an object.
254
- * - 'inline' will return the params as comma separated params.
255
- * @default 'inline'
256
- */
257
- paramsType?: 'object' | 'inline';
258
- /**
259
- * How to pass your pathParams.
260
- * - 'object' will return the pathParams as an object.
261
- * - 'inline' will return the pathParams as comma separated params.
262
- * @default 'inline'
263
- */
264
- pathParamsType?: PluginClient['options']['pathParamsType'];
265
- /**
266
- * Which parser should be used before returning the data to `swr`.
267
- * `'zod'` will use `@kubb/plugin-zod` to parse the data.
268
- */
269
- parser?: PluginClient['options']['parser'];
270
- transformers?: {
271
- /**
272
- * Customize the names based on the type that is provided by the plugin.
273
- */
274
- name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
275
- };
276
- /**
277
- * Define some generators next to the swr generators
278
- */
279
- generators?: Array<Generator<PluginSwr>>;
280
- };
281
- type ResolvedOptions = {
282
- output: Output<Oas>;
283
- client: Required<Omit<NonNullable<PluginReactQuery['options']['client']>, 'baseURL'>> & {
284
- baseURL?: string;
285
- };
286
- parser: Required<NonNullable<Options['parser']>>;
287
- queryKey: QueryKey | undefined;
288
- query: NonNullable<Required<Query>> | false;
289
- mutationKey: MutationKey | undefined;
290
- mutation: NonNullable<Required<Mutation>> | false;
291
- paramsCasing: Options['paramsCasing'];
292
- paramsType: NonNullable<Options['paramsType']>;
293
- pathParamsType: NonNullable<Options['pathParamsType']>;
294
- group: Options['group'];
295
- };
296
- type PluginSwr = PluginFactoryOptions<'plugin-swr', Options, ResolvedOptions, never, ResolvePathOptions>;
297
-
298
- export type { Options as O, PluginSwr as P, Transformer as T };
@@ -1,298 +0,0 @@
1
- import { PluginFactoryOptions, Output, Group, ResolveNameParams } from '@kubb/core';
2
- import { Oas, contentType, Operation, HttpMethod } from '@kubb/oas';
3
- import { PluginClient } from '@kubb/plugin-client';
4
- import { Exclude, Include, Override, OperationSchemas, Generator, ResolvePathOptions } from '@kubb/plugin-oas';
5
-
6
- type TransformerProps$1 = {
7
- operation: Operation;
8
- schemas: OperationSchemas;
9
- casing: 'camelcase' | undefined;
10
- };
11
- type Transformer$1 = (props: TransformerProps$1) => unknown[];
12
- type Suspense = object;
13
- /**
14
- * Customize the queryKey
15
- */
16
- type QueryKey$1 = Transformer$1;
17
- /**
18
- * Customize the mutationKey
19
- */
20
- type MutationKey$1 = Transformer$1;
21
- type Query$1 = {
22
- /**
23
- * Define which HttpMethods can be used for queries
24
- * @default ['get']
25
- */
26
- methods: Array<HttpMethod>;
27
- /**
28
- * Path to the useQuery that will be used to do the useQuery functionality.
29
- * It will be used as `import { useQuery } from '${importPath}'`.
30
- * It allows both relative and absolute path.
31
- * the path will be applied as is, so relative path should be based on the file being generated.
32
- * @default '@tanstack/react-query'
33
- */
34
- importPath?: string;
35
- };
36
- type Mutation$1 = {
37
- /**
38
- * Define which HttpMethods can be used for mutations
39
- * @default ['post', 'put', 'delete']
40
- */
41
- methods: Array<HttpMethod>;
42
- /**
43
- * Path to the useQuery that will be used to do the useQuery functionality.
44
- * It will be used as `import { useQuery } from '${importPath}'`.
45
- * It allows both relative and absolute path.
46
- * the path will be applied as is, so relative path should be based on the file being generated.
47
- * @default '@tanstack/react-query'
48
- */
49
- importPath?: string;
50
- };
51
- type Infinite = {
52
- /**
53
- * Specify the params key used for `pageParam`.
54
- * @default 'id'
55
- */
56
- queryParam: string;
57
- /**
58
- * Which field of the data will be used, set it to undefined when no cursor is known.
59
- */
60
- cursorParam?: string | undefined;
61
- /**
62
- * The initial value, the value of the first page.
63
- * @default 0
64
- */
65
- initialPageParam: unknown;
66
- };
67
- type Options$1 = {
68
- /**
69
- * Specify the export location for the files and define the behavior of the output
70
- * @default { path: 'hooks', barrelType: 'named' }
71
- */
72
- output?: Output<Oas>;
73
- /**
74
- * Define which contentType should be used.
75
- * By default, the first JSON valid mediaType will be used
76
- */
77
- contentType?: contentType;
78
- /**
79
- * Group the @tanstack/query hooks based on the provided name.
80
- */
81
- group?: Group;
82
- client?: Pick<PluginClient['options'], 'dataReturnType' | 'importPath' | 'baseURL'>;
83
- /**
84
- * Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
85
- */
86
- exclude?: Array<Exclude>;
87
- /**
88
- * Array containing include parameters to include tags/operations/methods/paths.
89
- */
90
- include?: Array<Include>;
91
- /**
92
- * Array containing override parameters to override `options` based on tags/operations/methods/paths.
93
- */
94
- override?: Array<Override<ResolvedOptions$1>>;
95
- /**
96
- * How to style your params, by default no casing is applied
97
- * - 'camelcase' will use camelcase for the params names
98
- */
99
- paramsCasing?: 'camelcase';
100
- /**
101
- * How to pass your params
102
- * - 'object' will return the params and pathParams as an object.
103
- * - 'inline' will return the params as comma separated params.
104
- * @default 'inline'
105
- */
106
- paramsType?: 'object' | 'inline';
107
- /**
108
- * How to pass your pathParams.
109
- * - 'object' will return the pathParams as an object.
110
- * - 'inline' will return the pathParams as comma separated params.
111
- * @default 'inline'
112
- */
113
- pathParamsType?: PluginClient['options']['pathParamsType'];
114
- /**
115
- * When set, an infiniteQuery hooks will be added.
116
- */
117
- infinite?: Partial<Infinite> | false;
118
- /**
119
- * When set, a suspenseQuery hooks will be added.
120
- */
121
- suspense?: Partial<Suspense> | false;
122
- queryKey?: QueryKey$1;
123
- /**
124
- * Override some useQuery behaviours.
125
- */
126
- query?: Partial<Query$1> | false;
127
- mutationKey?: MutationKey$1;
128
- /**
129
- * Override some useMutation behaviours.
130
- */
131
- mutation?: Partial<Mutation$1> | false;
132
- /**
133
- * Which parser should be used before returning the data to `@tanstack/query`.
134
- * `'zod'` will use `@kubb/plugin-zod` to parse the data.
135
- */
136
- parser?: PluginClient['options']['parser'];
137
- transformers?: {
138
- /**
139
- * Customize the names based on the type that is provided by the plugin.
140
- */
141
- name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
142
- };
143
- /**
144
- * Define some generators next to the react-query generators
145
- */
146
- generators?: Array<Generator<PluginReactQuery>>;
147
- };
148
- type ResolvedOptions$1 = {
149
- output: Output<Oas>;
150
- group: Options$1['group'];
151
- client: Required<Omit<NonNullable<PluginReactQuery['options']['client']>, 'baseURL'>> & {
152
- baseURL?: string;
153
- };
154
- parser: Required<NonNullable<Options$1['parser']>>;
155
- pathParamsType: NonNullable<Options$1['pathParamsType']>;
156
- paramsCasing: Options$1['paramsCasing'];
157
- paramsType: NonNullable<Options$1['paramsType']>;
158
- /**
159
- * Only used of infinite
160
- */
161
- infinite: NonNullable<Infinite> | false;
162
- suspense: Suspense | false;
163
- queryKey: QueryKey$1 | undefined;
164
- query: NonNullable<Required<Query$1>> | false;
165
- mutationKey: MutationKey$1 | undefined;
166
- mutation: NonNullable<Required<Mutation$1>> | false;
167
- };
168
- type PluginReactQuery = PluginFactoryOptions<'plugin-react-query', Options$1, ResolvedOptions$1, never, ResolvePathOptions>;
169
-
170
- type TransformerProps = {
171
- operation: Operation;
172
- schemas: OperationSchemas;
173
- casing: 'camelcase' | undefined;
174
- };
175
- type Transformer = (props: TransformerProps) => unknown[];
176
- /**
177
- * Customize the queryKey
178
- */
179
- type QueryKey = Transformer;
180
- /**
181
- * Customize the mutationKey
182
- */
183
- type MutationKey = Transformer;
184
- type Query = {
185
- /**
186
- * Define which HttpMethods can be used for queries
187
- * @default ['get']
188
- */
189
- methods?: Array<HttpMethod>;
190
- /**
191
- * Path to the useQuery that will be used to do the useQuery functionality.
192
- * It will be used as `import { useQuery } from '${importPath}'`.
193
- * It allows both relative and absolute path.
194
- * the path will be applied as is, so relative path should be based on the file being generated.
195
- * @default 'swr'
196
- */
197
- importPath?: string;
198
- };
199
- type Mutation = {
200
- /**
201
- * Define which HttpMethods can be used for queries
202
- * @default ['post', 'put', 'delete', 'patch']
203
- */
204
- methods?: Array<HttpMethod>;
205
- /**
206
- * Path to the useQuery that will be used to do the useQuery functionality.
207
- * It will be used as `import { useQuery } from '${importPath}'`.
208
- * It allows both relative and absolute path.
209
- * the path will be applied as is, so relative path should be based on the file being generated.
210
- * @default 'swr/mutation'
211
- */
212
- importPath?: string;
213
- };
214
- type Options = {
215
- /**
216
- * Specify the export location for the files and define the behavior of the output
217
- * @default { path: 'hooks', barrelType: 'named' }
218
- */
219
- output?: Output<Oas>;
220
- /**
221
- * Define which contentType should be used.
222
- * By default, the first JSON valid mediaType will be used
223
- */
224
- contentType?: contentType;
225
- /**
226
- * Group the SWR hooks based on the provided name.
227
- */
228
- group?: Group;
229
- /**
230
- * Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
231
- */
232
- exclude?: Array<Exclude>;
233
- /**
234
- * Array containing include parameters to include tags/operations/methods/paths.
235
- */
236
- include?: Array<Include>;
237
- /**
238
- * Array containing override parameters to override `options` based on tags/operations/methods/paths.
239
- */
240
- override?: Array<Override<ResolvedOptions>>;
241
- client?: Pick<PluginClient['options'], 'dataReturnType' | 'importPath' | 'baseURL'>;
242
- queryKey?: QueryKey;
243
- query?: Query | false;
244
- mutationKey?: MutationKey;
245
- mutation?: Mutation | false;
246
- /**
247
- * How to style your params, by default no casing is applied
248
- * - 'camelcase' will use camelcase for the params names
249
- */
250
- paramsCasing?: 'camelcase';
251
- /**
252
- * How to pass your params
253
- * - 'object' will return the params and pathParams as an object.
254
- * - 'inline' will return the params as comma separated params.
255
- * @default 'inline'
256
- */
257
- paramsType?: 'object' | 'inline';
258
- /**
259
- * How to pass your pathParams.
260
- * - 'object' will return the pathParams as an object.
261
- * - 'inline' will return the pathParams as comma separated params.
262
- * @default 'inline'
263
- */
264
- pathParamsType?: PluginClient['options']['pathParamsType'];
265
- /**
266
- * Which parser should be used before returning the data to `swr`.
267
- * `'zod'` will use `@kubb/plugin-zod` to parse the data.
268
- */
269
- parser?: PluginClient['options']['parser'];
270
- transformers?: {
271
- /**
272
- * Customize the names based on the type that is provided by the plugin.
273
- */
274
- name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
275
- };
276
- /**
277
- * Define some generators next to the swr generators
278
- */
279
- generators?: Array<Generator<PluginSwr>>;
280
- };
281
- type ResolvedOptions = {
282
- output: Output<Oas>;
283
- client: Required<Omit<NonNullable<PluginReactQuery['options']['client']>, 'baseURL'>> & {
284
- baseURL?: string;
285
- };
286
- parser: Required<NonNullable<Options['parser']>>;
287
- queryKey: QueryKey | undefined;
288
- query: NonNullable<Required<Query>> | false;
289
- mutationKey: MutationKey | undefined;
290
- mutation: NonNullable<Required<Mutation>> | false;
291
- paramsCasing: Options['paramsCasing'];
292
- paramsType: NonNullable<Options['paramsType']>;
293
- pathParamsType: NonNullable<Options['pathParamsType']>;
294
- group: Options['group'];
295
- };
296
- type PluginSwr = PluginFactoryOptions<'plugin-swr', Options, ResolvedOptions, never, ResolvePathOptions>;
297
-
298
- export type { Options as O, PluginSwr as P, Transformer as T };