@kubb/plugin-swr 3.0.0-alpha.9 → 3.0.0-beta.2

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 (61) hide show
  1. package/README.md +14 -5
  2. package/dist/chunk-4EGGCGSE.js +217 -0
  3. package/dist/chunk-4EGGCGSE.js.map +1 -0
  4. package/dist/chunk-H23WKEYP.js +243 -0
  5. package/dist/chunk-H23WKEYP.js.map +1 -0
  6. package/dist/chunk-JWGWABV5.cjs +249 -0
  7. package/dist/chunk-JWGWABV5.cjs.map +1 -0
  8. package/dist/chunk-PTOQHHST.cjs +220 -0
  9. package/dist/chunk-PTOQHHST.cjs.map +1 -0
  10. package/dist/components.cjs +23 -6
  11. package/dist/components.cjs.map +1 -1
  12. package/dist/components.d.cts +88 -6
  13. package/dist/components.d.ts +88 -6
  14. package/dist/components.js +2 -10
  15. package/dist/components.js.map +1 -1
  16. package/dist/generators.cjs +17 -0
  17. package/dist/generators.cjs.map +1 -0
  18. package/dist/generators.d.cts +11 -0
  19. package/dist/generators.d.ts +11 -0
  20. package/dist/generators.js +4 -0
  21. package/dist/generators.js.map +1 -0
  22. package/dist/index.cjs +93 -123
  23. package/dist/index.cjs.map +1 -1
  24. package/dist/index.d.cts +2 -4
  25. package/dist/index.d.ts +2 -4
  26. package/dist/index.js +77 -114
  27. package/dist/index.js.map +1 -1
  28. package/dist/types-DaH2Sc1M.d.cts +103 -0
  29. package/dist/types-DaH2Sc1M.d.ts +103 -0
  30. package/package.json +23 -17
  31. package/src/components/Mutation.tsx +93 -227
  32. package/src/components/MutationKey.tsx +48 -0
  33. package/src/components/Query.tsx +93 -259
  34. package/src/components/QueryKey.tsx +73 -0
  35. package/src/components/QueryOptions.tsx +54 -177
  36. package/src/components/index.ts +2 -0
  37. package/src/generators/__snapshots__/clientDataReturnTypeFull.ts +43 -0
  38. package/src/generators/__snapshots__/clientGetImportPath.ts +43 -0
  39. package/src/generators/__snapshots__/clientPostImportPath.ts +32 -0
  40. package/src/generators/__snapshots__/findByTags.ts +43 -0
  41. package/src/generators/__snapshots__/findByTagsPathParamsObject.ts +43 -0
  42. package/src/generators/__snapshots__/findByTagsWithZod.ts +43 -0
  43. package/src/generators/__snapshots__/getAsMutation.ts +34 -0
  44. package/src/generators/__snapshots__/postAsQuery.ts +41 -0
  45. package/src/generators/__snapshots__/updatePetById.ts +32 -0
  46. package/src/generators/__snapshots__/updatePetByIdPathParamsObject.ts +36 -0
  47. package/src/generators/index.ts +2 -0
  48. package/src/generators/mutationGenerator.tsx +109 -0
  49. package/src/generators/queryGenerator.tsx +114 -0
  50. package/src/plugin.ts +71 -52
  51. package/src/types.ts +62 -78
  52. package/dist/chunk-TGLXUPN4.cjs +0 -536
  53. package/dist/chunk-TGLXUPN4.cjs.map +0 -1
  54. package/dist/chunk-XWXMQJD6.js +0 -536
  55. package/dist/chunk-XWXMQJD6.js.map +0 -1
  56. package/dist/index-B3C-JOIU.d.cts +0 -299
  57. package/dist/index-B3C-JOIU.d.ts +0 -299
  58. package/src/OperationGenerator.tsx +0 -75
  59. package/src/components/SchemaType.tsx +0 -63
  60. package/src/components/__snapshots__/Mutation/Pets.ts +0 -46
  61. package/src/components/__snapshots__/Query/showPetById.ts +0 -59
@@ -1,299 +0,0 @@
1
- import { URLPath } from '@kubb/core/utils';
2
- import { HttpMethod } from '@kubb/oas';
3
- import { ReactNode } from 'react';
4
- import { PluginFactoryOptions, ResolveNameParams } from '@kubb/core';
5
- import * as KubbFile from '@kubb/fs/types';
6
- import { ResolvePathOptions, Exclude, Include, Override } from '@kubb/plugin-oas';
7
-
8
- type TemplateProps$2 = {
9
- /**
10
- * Name of the function
11
- */
12
- name: string;
13
- /**
14
- * Parameters/options/props that need to be used
15
- */
16
- params: string;
17
- /**
18
- * Generics that needs to be added for TypeScript
19
- */
20
- generics?: string;
21
- /**
22
- * ReturnType(see async for adding Promise type)
23
- */
24
- returnType?: string;
25
- /**
26
- * Options for JSdocs
27
- */
28
- JSDoc?: {
29
- comments: string[];
30
- };
31
- hook: {
32
- name: string;
33
- generics?: string;
34
- };
35
- client: {
36
- method: HttpMethod;
37
- generics: string;
38
- withQueryParams: boolean;
39
- withPathParams: boolean;
40
- withData: boolean;
41
- withHeaders: boolean;
42
- path: URLPath;
43
- };
44
- dataReturnType: NonNullable<PluginSwr['options']['dataReturnType']>;
45
- };
46
- declare function Template$2({ name, generics, returnType, params, JSDoc, client, hook, dataReturnType }: TemplateProps$2): ReactNode;
47
- declare const defaultTemplates$1: {
48
- readonly default: typeof Template$2;
49
- };
50
- type Props$2 = {
51
- factory: {
52
- name: string;
53
- };
54
- /**
55
- * This will make it possible to override the default behaviour.
56
- */
57
- Template?: React.ComponentType<TemplateProps$2>;
58
- };
59
- declare function Mutation({ factory, Template }: Props$2): ReactNode;
60
- declare namespace Mutation {
61
- var File: ({ templates }: FileProps$1) => ReactNode;
62
- var templates: {
63
- readonly default: typeof Template$2;
64
- };
65
- }
66
- type FileProps$1 = {
67
- /**
68
- * This will make it possible to override the default behaviour.
69
- */
70
- templates?: typeof defaultTemplates$1;
71
- };
72
-
73
- type TemplateProps$1 = {
74
- /**
75
- * Name of the function
76
- */
77
- name: string;
78
- /**
79
- * Parameters/options/props that need to be used
80
- */
81
- params: string;
82
- /**
83
- * Generics that needs to be added for TypeScript
84
- */
85
- generics?: string;
86
- /**
87
- * ReturnType(see async for adding Promise type)
88
- */
89
- returnType?: string;
90
- /**
91
- * Options for JSdocs
92
- */
93
- JSDoc?: {
94
- comments: string[];
95
- };
96
- client: {
97
- generics: string;
98
- method: HttpMethod;
99
- path: URLPath;
100
- withQueryParams: boolean;
101
- withPathParams: boolean;
102
- withData: boolean;
103
- withHeaders: boolean;
104
- contentType: string;
105
- };
106
- dataReturnType: NonNullable<PluginSwr['options']['dataReturnType']>;
107
- parser: string | undefined;
108
- };
109
- declare function Template$1({ name, params, generics, returnType, JSDoc, client, dataReturnType, parser }: TemplateProps$1): ReactNode;
110
- type Props$1 = {
111
- factory: {
112
- name: string;
113
- };
114
- dataReturnType: NonNullable<PluginSwr['options']['dataReturnType']>;
115
- /**
116
- * This will make it possible to override the default behaviour.
117
- */
118
- Template?: React.ComponentType<TemplateProps$1>;
119
- };
120
- declare function QueryOptions({ factory, dataReturnType, Template }: Props$1): ReactNode;
121
- declare namespace QueryOptions {
122
- var templates: {
123
- readonly default: typeof Template$1;
124
- };
125
- }
126
-
127
- type TemplateProps = {
128
- /**
129
- * Name of the function
130
- */
131
- name: string;
132
- /**
133
- * Parameters/options/props that need to be used
134
- */
135
- params: string;
136
- /**
137
- * Generics that needs to be added for TypeScript
138
- */
139
- generics?: string;
140
- /**
141
- * ReturnType(see async for adding Promise type)
142
- */
143
- returnType?: string;
144
- /**
145
- * Options for JSdocs
146
- */
147
- JSDoc?: {
148
- comments: string[];
149
- };
150
- hook: {
151
- name: string;
152
- generics?: string;
153
- queryOptions: string;
154
- };
155
- client: {
156
- path: URLPath;
157
- withQueryParams: boolean;
158
- };
159
- };
160
- declare function Template({ name, generics, returnType, params, JSDoc, hook, client }: TemplateProps): ReactNode;
161
- declare const defaultTemplates: {
162
- readonly default: typeof Template;
163
- };
164
- type Props = {
165
- factory: {
166
- name: string;
167
- };
168
- /**
169
- * This will make it possible to override the default behaviour.
170
- */
171
- Template?: React.ComponentType<TemplateProps>;
172
- /**
173
- * This will make it possible to override the default behaviour.
174
- */
175
- QueryOptionsTemplate?: React.ComponentType<React.ComponentProps<typeof QueryOptions.templates.default>>;
176
- };
177
- declare function Query({ factory, Template, QueryOptionsTemplate }: Props): ReactNode;
178
- declare namespace Query {
179
- var File: ({ templates }: FileProps) => ReactNode;
180
- var templates: {
181
- readonly default: typeof Template;
182
- };
183
- }
184
- type FileProps = {
185
- /**
186
- * This will make it possible to override the default behaviour.
187
- */
188
- templates?: {
189
- query: typeof defaultTemplates;
190
- queryOptions: typeof QueryOptions.templates;
191
- };
192
- };
193
-
194
- type Templates = {
195
- mutation?: typeof Mutation.templates | false;
196
- query?: typeof Query.templates | false;
197
- queryOptions?: typeof QueryOptions.templates | false;
198
- };
199
- type Options = {
200
- output?: {
201
- /**
202
- * Output to save the SWR hooks.
203
- * @default `"hooks"`
204
- */
205
- path: string;
206
- /**
207
- * Name to be used for the `export * as {{exportAs}} from './'`
208
- */
209
- exportAs?: string;
210
- /**
211
- * Add an extension to the generated imports and exports, default it will not use an extension
212
- */
213
- extName?: KubbFile.Extname;
214
- /**
215
- * Define what needs to exported, here you can also disable the export of barrel files
216
- * @default `'barrel'`
217
- */
218
- exportType?: 'barrel' | 'barrelNamed' | false;
219
- };
220
- /**
221
- * Group the SWR hooks based on the provided name.
222
- */
223
- group?: {
224
- /**
225
- * Tag will group based on the operation tag inside the Swagger file
226
- */
227
- type: 'tag';
228
- /**
229
- * Relative path to save the grouped SWR hooks.
230
- *
231
- * `{{tag}}` will be replaced by the current tagName.
232
- * @example `${output}/{{tag}}Controller` => `hooks/PetController`
233
- * @default `${output}/{{tag}}Controller`
234
- */
235
- output?: string;
236
- /**
237
- * Name to be used for the `export * as {{exportAs}} from './`
238
- * @default `"{{tag}}SWRHooks"`
239
- */
240
- exportAs?: string;
241
- };
242
- /**
243
- * Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
244
- */
245
- exclude?: Array<Exclude>;
246
- /**
247
- * Array containing include parameters to include tags/operations/methods/paths.
248
- */
249
- include?: Array<Include>;
250
- /**
251
- * Array containing override parameters to override `options` based on tags/operations/methods/paths.
252
- */
253
- override?: Array<Override<ResolvedOptions>>;
254
- client?: {
255
- /**
256
- * Path to the client import path that will be used to do the API calls.
257
- * It will be used as `import client from '${client.importPath}'`.
258
- * It allow both relative and absolute path.
259
- * the path will be applied as is, so relative path shoule be based on the file being generated.
260
- * @default '@kubb/plugin-client/client'
261
- */
262
- importPath?: string;
263
- };
264
- /**
265
- * ReturnType that needs to be used when calling client().
266
- *
267
- * `Data` will return ResponseConfig[data].
268
- *
269
- * `Full` will return ResponseConfig.
270
- * @default `'data'`
271
- * @private
272
- */
273
- dataReturnType?: 'data' | 'full';
274
- transformers?: {
275
- /**
276
- * Customize the names based on the type that is provided by the plugin.
277
- */
278
- name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
279
- };
280
- /**
281
- * Which parser can be used before returning the data to `@tanstack/query`.
282
- * `'zod'` will use `@kubb/plugin-zod` to parse the data.
283
- */
284
- parser?: 'zod';
285
- /**
286
- * Make it possible to override one of the templates
287
- */
288
- templates?: Partial<Templates>;
289
- };
290
- type ResolvedOptions = {
291
- extName: KubbFile.Extname | undefined;
292
- client: Required<NonNullable<Options['client']>>;
293
- dataReturnType: NonNullable<Options['dataReturnType']>;
294
- templates: NonNullable<Templates>;
295
- parser: Options['parser'];
296
- };
297
- type PluginSwr = PluginFactoryOptions<'plugin-swr', Options, ResolvedOptions, never, ResolvePathOptions>;
298
-
299
- export { Mutation as M, type Options as O, type PluginSwr as P, Query as Q, QueryOptions as a };
@@ -1,299 +0,0 @@
1
- import { URLPath } from '@kubb/core/utils';
2
- import { HttpMethod } from '@kubb/oas';
3
- import { ReactNode } from 'react';
4
- import { PluginFactoryOptions, ResolveNameParams } from '@kubb/core';
5
- import * as KubbFile from '@kubb/fs/types';
6
- import { ResolvePathOptions, Exclude, Include, Override } from '@kubb/plugin-oas';
7
-
8
- type TemplateProps$2 = {
9
- /**
10
- * Name of the function
11
- */
12
- name: string;
13
- /**
14
- * Parameters/options/props that need to be used
15
- */
16
- params: string;
17
- /**
18
- * Generics that needs to be added for TypeScript
19
- */
20
- generics?: string;
21
- /**
22
- * ReturnType(see async for adding Promise type)
23
- */
24
- returnType?: string;
25
- /**
26
- * Options for JSdocs
27
- */
28
- JSDoc?: {
29
- comments: string[];
30
- };
31
- hook: {
32
- name: string;
33
- generics?: string;
34
- };
35
- client: {
36
- method: HttpMethod;
37
- generics: string;
38
- withQueryParams: boolean;
39
- withPathParams: boolean;
40
- withData: boolean;
41
- withHeaders: boolean;
42
- path: URLPath;
43
- };
44
- dataReturnType: NonNullable<PluginSwr['options']['dataReturnType']>;
45
- };
46
- declare function Template$2({ name, generics, returnType, params, JSDoc, client, hook, dataReturnType }: TemplateProps$2): ReactNode;
47
- declare const defaultTemplates$1: {
48
- readonly default: typeof Template$2;
49
- };
50
- type Props$2 = {
51
- factory: {
52
- name: string;
53
- };
54
- /**
55
- * This will make it possible to override the default behaviour.
56
- */
57
- Template?: React.ComponentType<TemplateProps$2>;
58
- };
59
- declare function Mutation({ factory, Template }: Props$2): ReactNode;
60
- declare namespace Mutation {
61
- var File: ({ templates }: FileProps$1) => ReactNode;
62
- var templates: {
63
- readonly default: typeof Template$2;
64
- };
65
- }
66
- type FileProps$1 = {
67
- /**
68
- * This will make it possible to override the default behaviour.
69
- */
70
- templates?: typeof defaultTemplates$1;
71
- };
72
-
73
- type TemplateProps$1 = {
74
- /**
75
- * Name of the function
76
- */
77
- name: string;
78
- /**
79
- * Parameters/options/props that need to be used
80
- */
81
- params: string;
82
- /**
83
- * Generics that needs to be added for TypeScript
84
- */
85
- generics?: string;
86
- /**
87
- * ReturnType(see async for adding Promise type)
88
- */
89
- returnType?: string;
90
- /**
91
- * Options for JSdocs
92
- */
93
- JSDoc?: {
94
- comments: string[];
95
- };
96
- client: {
97
- generics: string;
98
- method: HttpMethod;
99
- path: URLPath;
100
- withQueryParams: boolean;
101
- withPathParams: boolean;
102
- withData: boolean;
103
- withHeaders: boolean;
104
- contentType: string;
105
- };
106
- dataReturnType: NonNullable<PluginSwr['options']['dataReturnType']>;
107
- parser: string | undefined;
108
- };
109
- declare function Template$1({ name, params, generics, returnType, JSDoc, client, dataReturnType, parser }: TemplateProps$1): ReactNode;
110
- type Props$1 = {
111
- factory: {
112
- name: string;
113
- };
114
- dataReturnType: NonNullable<PluginSwr['options']['dataReturnType']>;
115
- /**
116
- * This will make it possible to override the default behaviour.
117
- */
118
- Template?: React.ComponentType<TemplateProps$1>;
119
- };
120
- declare function QueryOptions({ factory, dataReturnType, Template }: Props$1): ReactNode;
121
- declare namespace QueryOptions {
122
- var templates: {
123
- readonly default: typeof Template$1;
124
- };
125
- }
126
-
127
- type TemplateProps = {
128
- /**
129
- * Name of the function
130
- */
131
- name: string;
132
- /**
133
- * Parameters/options/props that need to be used
134
- */
135
- params: string;
136
- /**
137
- * Generics that needs to be added for TypeScript
138
- */
139
- generics?: string;
140
- /**
141
- * ReturnType(see async for adding Promise type)
142
- */
143
- returnType?: string;
144
- /**
145
- * Options for JSdocs
146
- */
147
- JSDoc?: {
148
- comments: string[];
149
- };
150
- hook: {
151
- name: string;
152
- generics?: string;
153
- queryOptions: string;
154
- };
155
- client: {
156
- path: URLPath;
157
- withQueryParams: boolean;
158
- };
159
- };
160
- declare function Template({ name, generics, returnType, params, JSDoc, hook, client }: TemplateProps): ReactNode;
161
- declare const defaultTemplates: {
162
- readonly default: typeof Template;
163
- };
164
- type Props = {
165
- factory: {
166
- name: string;
167
- };
168
- /**
169
- * This will make it possible to override the default behaviour.
170
- */
171
- Template?: React.ComponentType<TemplateProps>;
172
- /**
173
- * This will make it possible to override the default behaviour.
174
- */
175
- QueryOptionsTemplate?: React.ComponentType<React.ComponentProps<typeof QueryOptions.templates.default>>;
176
- };
177
- declare function Query({ factory, Template, QueryOptionsTemplate }: Props): ReactNode;
178
- declare namespace Query {
179
- var File: ({ templates }: FileProps) => ReactNode;
180
- var templates: {
181
- readonly default: typeof Template;
182
- };
183
- }
184
- type FileProps = {
185
- /**
186
- * This will make it possible to override the default behaviour.
187
- */
188
- templates?: {
189
- query: typeof defaultTemplates;
190
- queryOptions: typeof QueryOptions.templates;
191
- };
192
- };
193
-
194
- type Templates = {
195
- mutation?: typeof Mutation.templates | false;
196
- query?: typeof Query.templates | false;
197
- queryOptions?: typeof QueryOptions.templates | false;
198
- };
199
- type Options = {
200
- output?: {
201
- /**
202
- * Output to save the SWR hooks.
203
- * @default `"hooks"`
204
- */
205
- path: string;
206
- /**
207
- * Name to be used for the `export * as {{exportAs}} from './'`
208
- */
209
- exportAs?: string;
210
- /**
211
- * Add an extension to the generated imports and exports, default it will not use an extension
212
- */
213
- extName?: KubbFile.Extname;
214
- /**
215
- * Define what needs to exported, here you can also disable the export of barrel files
216
- * @default `'barrel'`
217
- */
218
- exportType?: 'barrel' | 'barrelNamed' | false;
219
- };
220
- /**
221
- * Group the SWR hooks based on the provided name.
222
- */
223
- group?: {
224
- /**
225
- * Tag will group based on the operation tag inside the Swagger file
226
- */
227
- type: 'tag';
228
- /**
229
- * Relative path to save the grouped SWR hooks.
230
- *
231
- * `{{tag}}` will be replaced by the current tagName.
232
- * @example `${output}/{{tag}}Controller` => `hooks/PetController`
233
- * @default `${output}/{{tag}}Controller`
234
- */
235
- output?: string;
236
- /**
237
- * Name to be used for the `export * as {{exportAs}} from './`
238
- * @default `"{{tag}}SWRHooks"`
239
- */
240
- exportAs?: string;
241
- };
242
- /**
243
- * Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
244
- */
245
- exclude?: Array<Exclude>;
246
- /**
247
- * Array containing include parameters to include tags/operations/methods/paths.
248
- */
249
- include?: Array<Include>;
250
- /**
251
- * Array containing override parameters to override `options` based on tags/operations/methods/paths.
252
- */
253
- override?: Array<Override<ResolvedOptions>>;
254
- client?: {
255
- /**
256
- * Path to the client import path that will be used to do the API calls.
257
- * It will be used as `import client from '${client.importPath}'`.
258
- * It allow both relative and absolute path.
259
- * the path will be applied as is, so relative path shoule be based on the file being generated.
260
- * @default '@kubb/plugin-client/client'
261
- */
262
- importPath?: string;
263
- };
264
- /**
265
- * ReturnType that needs to be used when calling client().
266
- *
267
- * `Data` will return ResponseConfig[data].
268
- *
269
- * `Full` will return ResponseConfig.
270
- * @default `'data'`
271
- * @private
272
- */
273
- dataReturnType?: 'data' | 'full';
274
- transformers?: {
275
- /**
276
- * Customize the names based on the type that is provided by the plugin.
277
- */
278
- name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
279
- };
280
- /**
281
- * Which parser can be used before returning the data to `@tanstack/query`.
282
- * `'zod'` will use `@kubb/plugin-zod` to parse the data.
283
- */
284
- parser?: 'zod';
285
- /**
286
- * Make it possible to override one of the templates
287
- */
288
- templates?: Partial<Templates>;
289
- };
290
- type ResolvedOptions = {
291
- extName: KubbFile.Extname | undefined;
292
- client: Required<NonNullable<Options['client']>>;
293
- dataReturnType: NonNullable<Options['dataReturnType']>;
294
- templates: NonNullable<Templates>;
295
- parser: Options['parser'];
296
- };
297
- type PluginSwr = PluginFactoryOptions<'plugin-swr', Options, ResolvedOptions, never, ResolvePathOptions>;
298
-
299
- export { Mutation as M, type Options as O, type PluginSwr as P, Query as Q, QueryOptions as a };
@@ -1,75 +0,0 @@
1
- import { OperationGenerator as Generator } from '@kubb/plugin-oas'
2
- import { Oas } from '@kubb/plugin-oas/components'
3
- import { App, createRoot } from '@kubb/react'
4
-
5
- import { Mutation } from './components/Mutation.tsx'
6
- import { Query } from './components/Query.tsx'
7
-
8
- import type { Operation } from '@kubb/oas'
9
- import type { OperationMethodResult } from '@kubb/plugin-oas'
10
- import type { FileMeta, PluginSwr } from './types.ts'
11
-
12
- export class OperationGenerator extends Generator<PluginSwr['resolvedOptions'], PluginSwr, FileMeta> {
13
- async get(operation: Operation, options: PluginSwr['resolvedOptions']): OperationMethodResult<FileMeta> {
14
- const { oas, pluginManager, plugin, mode } = this.context
15
-
16
- const root = createRoot({
17
- logger: pluginManager.logger,
18
- })
19
-
20
- if (!options.templates?.query || !options.templates?.queryOptions) {
21
- return []
22
- }
23
-
24
- root.render(
25
- <App pluginManager={pluginManager} plugin={{ ...plugin, options }} mode={mode}>
26
- <Oas oas={oas} operations={[operation]} generator={this}>
27
- <Oas.Operation operation={operation}>
28
- <Query.File
29
- templates={{
30
- query: options.templates.query,
31
- queryOptions: options.templates.queryOptions,
32
- }}
33
- />
34
- </Oas.Operation>
35
- </Oas>
36
- </App>,
37
- )
38
-
39
- return root.files
40
- }
41
-
42
- async post(operation: Operation, options: PluginSwr['resolvedOptions']): OperationMethodResult<FileMeta> {
43
- const { oas, pluginManager, plugin, mode } = this.context
44
-
45
- const root = createRoot({
46
- logger: pluginManager.logger,
47
- })
48
-
49
- if (!options.templates?.mutation) {
50
- return []
51
- }
52
-
53
- root.render(
54
- <App pluginManager={pluginManager} plugin={{ ...plugin, options }} mode={mode}>
55
- <Oas oas={oas} operations={[operation]} generator={this}>
56
- <Oas.Operation operation={operation}>
57
- <Mutation.File templates={options.templates.mutation} />
58
- </Oas.Operation>
59
- </Oas>
60
- </App>,
61
- )
62
-
63
- return root.files
64
- }
65
-
66
- async put(operation: Operation, options: PluginSwr['resolvedOptions']): OperationMethodResult<FileMeta> {
67
- return this.post(operation, options)
68
- }
69
- async patch(operation: Operation, options: PluginSwr['resolvedOptions']): OperationMethodResult<FileMeta> {
70
- return this.post(operation, options)
71
- }
72
- async delete(operation: Operation, options: PluginSwr['resolvedOptions']): OperationMethodResult<FileMeta> {
73
- return this.post(operation, options)
74
- }
75
- }