@kubb/plugin-react-query 5.0.0-alpha.2 → 5.0.0-alpha.21
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.
- package/dist/{components-CpyHYGOw.js → components-BMhCuuyw.js} +63 -10
- package/dist/components-BMhCuuyw.js.map +1 -0
- package/dist/{components-BHQT9ZLc.cjs → components-CyyBGYhf.cjs} +63 -10
- package/dist/components-CyyBGYhf.cjs.map +1 -0
- package/dist/components.cjs +1 -1
- package/dist/components.js +1 -1
- package/dist/{generators-BZn1n6rK.js → generators-17bLNXlW.js} +23 -23
- package/dist/generators-17bLNXlW.js.map +1 -0
- package/dist/{generators-B8Pq52sx.cjs → generators-mEEW3Ihs.cjs} +22 -22
- package/dist/generators-mEEW3Ihs.cjs.map +1 -0
- package/dist/generators.cjs +1 -1
- package/dist/generators.d.ts +8 -496
- package/dist/generators.js +1 -1
- package/dist/index.cjs +5 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/package.json +11 -11
- package/src/generators/customHookOptionsFileGenerator.tsx +3 -3
- package/src/generators/hookOptionsGenerator.tsx +4 -4
- package/src/generators/infiniteQueryGenerator.tsx +4 -4
- package/src/generators/mutationGenerator.tsx +4 -4
- package/src/generators/queryGenerator.tsx +4 -4
- package/src/generators/suspenseInfiniteQueryGenerator.tsx +4 -4
- package/src/generators/suspenseQueryGenerator.tsx +4 -4
- package/src/plugin.ts +4 -4
- package/dist/components-BHQT9ZLc.cjs.map +0 -1
- package/dist/components-CpyHYGOw.js.map +0 -1
- package/dist/generators-B8Pq52sx.cjs.map +0 -1
- package/dist/generators-BZn1n6rK.js.map +0 -1
package/dist/generators.d.ts
CHANGED
|
@@ -1,515 +1,27 @@
|
|
|
1
1
|
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
2
|
import { r as PluginReactQuery } from "./types--pHE21AC.js";
|
|
3
|
-
import
|
|
4
|
-
import { HttpMethod, Oas, Operation, SchemaObject, contentType } from "@kubb/oas";
|
|
5
|
-
import { Fabric } from "@kubb/react-fabric";
|
|
6
|
-
import { FabricReactNode } from "@kubb/react-fabric/types";
|
|
7
|
-
import { OperationNode, SchemaNode } from "@kubb/ast/types";
|
|
8
|
-
import { KubbFile } from "@kubb/fabric-core/types";
|
|
3
|
+
import * as _kubb_plugin_oas_generators0 from "@kubb/plugin-oas/generators";
|
|
9
4
|
|
|
10
|
-
//#region ../plugin-oas/src/types.d.ts
|
|
11
|
-
type GetOasOptions = {
|
|
12
|
-
validate?: boolean;
|
|
13
|
-
};
|
|
14
|
-
type Context$2 = {
|
|
15
|
-
getOas(options?: GetOasOptions): Promise<Oas>;
|
|
16
|
-
getBaseURL(): Promise<string | undefined>;
|
|
17
|
-
};
|
|
18
|
-
declare global {
|
|
19
|
-
namespace Kubb {
|
|
20
|
-
interface PluginContext extends Context$2 {}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* `propertyName` is the ref name + resolved with the nameResolver
|
|
25
|
-
* @example import { Pet } from './Pet'
|
|
26
|
-
*
|
|
27
|
-
* `originalName` is the original name used(in PascalCase), only used to remove duplicates
|
|
28
|
-
*
|
|
29
|
-
* `pluginName` can be used to override the current plugin being used, handy when you want to import a type/schema out of another plugin
|
|
30
|
-
* @example import a type(plugin-ts) for a mock file(swagger-faker)
|
|
31
|
-
*/
|
|
32
|
-
type Ref = {
|
|
33
|
-
propertyName: string;
|
|
34
|
-
originalName: string;
|
|
35
|
-
path: KubbFile.Path;
|
|
36
|
-
pluginName?: string;
|
|
37
|
-
};
|
|
38
|
-
type Refs = Record<string, Ref>;
|
|
39
|
-
type OperationSchema = {
|
|
40
|
-
/**
|
|
41
|
-
* Converted name, contains already `PathParams`, `QueryParams`, ...
|
|
42
|
-
*/
|
|
43
|
-
name: string;
|
|
44
|
-
schema: SchemaObject;
|
|
45
|
-
operation?: Operation;
|
|
46
|
-
/**
|
|
47
|
-
* OperationName in PascalCase, only being used in OperationGenerator
|
|
48
|
-
*/
|
|
49
|
-
operationName: string;
|
|
50
|
-
description?: string;
|
|
51
|
-
statusCode?: number;
|
|
52
|
-
keys?: string[];
|
|
53
|
-
keysToOmit?: string[];
|
|
54
|
-
withData?: boolean;
|
|
55
|
-
};
|
|
56
|
-
type OperationSchemas = {
|
|
57
|
-
pathParams?: OperationSchema & {
|
|
58
|
-
keysToOmit?: never;
|
|
59
|
-
};
|
|
60
|
-
queryParams?: OperationSchema & {
|
|
61
|
-
keysToOmit?: never;
|
|
62
|
-
};
|
|
63
|
-
headerParams?: OperationSchema & {
|
|
64
|
-
keysToOmit?: never;
|
|
65
|
-
};
|
|
66
|
-
request?: OperationSchema;
|
|
67
|
-
response: OperationSchema;
|
|
68
|
-
responses: Array<OperationSchema>;
|
|
69
|
-
statusCodes?: Array<OperationSchema>;
|
|
70
|
-
errors?: Array<OperationSchema>;
|
|
71
|
-
};
|
|
72
|
-
type ByTag = {
|
|
73
|
-
type: 'tag';
|
|
74
|
-
pattern: string | RegExp;
|
|
75
|
-
};
|
|
76
|
-
type ByOperationId = {
|
|
77
|
-
type: 'operationId';
|
|
78
|
-
pattern: string | RegExp;
|
|
79
|
-
};
|
|
80
|
-
type ByPath = {
|
|
81
|
-
type: 'path';
|
|
82
|
-
pattern: string | RegExp;
|
|
83
|
-
};
|
|
84
|
-
type ByMethod = {
|
|
85
|
-
type: 'method';
|
|
86
|
-
pattern: HttpMethod | RegExp;
|
|
87
|
-
};
|
|
88
|
-
type BySchemaName = {
|
|
89
|
-
type: 'schemaName';
|
|
90
|
-
pattern: string | RegExp;
|
|
91
|
-
};
|
|
92
|
-
type ByContentType = {
|
|
93
|
-
type: 'contentType';
|
|
94
|
-
pattern: string | RegExp;
|
|
95
|
-
};
|
|
96
|
-
type Exclude = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
|
|
97
|
-
type Include = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
|
|
98
|
-
type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName | ByContentType) & {
|
|
99
|
-
options: Partial<TOptions>;
|
|
100
|
-
};
|
|
101
|
-
//#endregion
|
|
102
|
-
//#region ../plugin-oas/src/OperationGenerator.d.ts
|
|
103
|
-
type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
104
|
-
fabric: Fabric;
|
|
105
|
-
oas: Oas;
|
|
106
|
-
exclude: Array<Exclude> | undefined;
|
|
107
|
-
include: Array<Include> | undefined;
|
|
108
|
-
override: Array<Override<TOptions>> | undefined;
|
|
109
|
-
contentType: contentType | undefined;
|
|
110
|
-
pluginManager: PluginManager;
|
|
111
|
-
events?: AsyncEventEmitter<KubbEvents>;
|
|
112
|
-
/**
|
|
113
|
-
* Current plugin
|
|
114
|
-
*/
|
|
115
|
-
plugin: Plugin<TPluginOptions>;
|
|
116
|
-
mode: KubbFile.Mode;
|
|
117
|
-
UNSTABLE_NAMING?: true;
|
|
118
|
-
};
|
|
119
|
-
declare class OperationGenerator<TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> {
|
|
120
|
-
#private;
|
|
121
|
-
constructor(options: TPluginOptions['resolvedOptions'], context: Context$1<TPluginOptions['resolvedOptions'], TPluginOptions>);
|
|
122
|
-
get options(): TPluginOptions['resolvedOptions'];
|
|
123
|
-
set options(options: TPluginOptions['resolvedOptions']);
|
|
124
|
-
get context(): Context$1<TPluginOptions['resolvedOptions'], TPluginOptions>;
|
|
125
|
-
getOptions(operation: Operation, method: HttpMethod): Partial<TPluginOptions['resolvedOptions']>;
|
|
126
|
-
getSchemas(operation: Operation, {
|
|
127
|
-
resolveName
|
|
128
|
-
}?: {
|
|
129
|
-
resolveName?: (name: string) => string;
|
|
130
|
-
}): OperationSchemas;
|
|
131
|
-
getOperations(): Promise<Array<{
|
|
132
|
-
path: string;
|
|
133
|
-
method: HttpMethod;
|
|
134
|
-
operation: Operation;
|
|
135
|
-
}>>;
|
|
136
|
-
build(...generators: Array<Generator<TPluginOptions, Version>>): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
137
|
-
}
|
|
138
|
-
//#endregion
|
|
139
|
-
//#region ../plugin-oas/src/SchemaMapper.d.ts
|
|
140
|
-
type SchemaKeywordMapper = {
|
|
141
|
-
object: {
|
|
142
|
-
keyword: 'object';
|
|
143
|
-
args: {
|
|
144
|
-
properties: {
|
|
145
|
-
[x: string]: Schema[];
|
|
146
|
-
};
|
|
147
|
-
additionalProperties: Schema[];
|
|
148
|
-
patternProperties?: Record<string, Schema[]>;
|
|
149
|
-
strict?: boolean;
|
|
150
|
-
};
|
|
151
|
-
};
|
|
152
|
-
url: {
|
|
153
|
-
keyword: 'url';
|
|
154
|
-
};
|
|
155
|
-
readOnly: {
|
|
156
|
-
keyword: 'readOnly';
|
|
157
|
-
};
|
|
158
|
-
writeOnly: {
|
|
159
|
-
keyword: 'writeOnly';
|
|
160
|
-
};
|
|
161
|
-
uuid: {
|
|
162
|
-
keyword: 'uuid';
|
|
163
|
-
};
|
|
164
|
-
email: {
|
|
165
|
-
keyword: 'email';
|
|
166
|
-
};
|
|
167
|
-
firstName: {
|
|
168
|
-
keyword: 'firstName';
|
|
169
|
-
};
|
|
170
|
-
lastName: {
|
|
171
|
-
keyword: 'lastName';
|
|
172
|
-
};
|
|
173
|
-
phone: {
|
|
174
|
-
keyword: 'phone';
|
|
175
|
-
};
|
|
176
|
-
password: {
|
|
177
|
-
keyword: 'password';
|
|
178
|
-
};
|
|
179
|
-
date: {
|
|
180
|
-
keyword: 'date';
|
|
181
|
-
args: {
|
|
182
|
-
type?: 'date' | 'string';
|
|
183
|
-
};
|
|
184
|
-
};
|
|
185
|
-
time: {
|
|
186
|
-
keyword: 'time';
|
|
187
|
-
args: {
|
|
188
|
-
type?: 'date' | 'string';
|
|
189
|
-
};
|
|
190
|
-
};
|
|
191
|
-
datetime: {
|
|
192
|
-
keyword: 'datetime';
|
|
193
|
-
args: {
|
|
194
|
-
offset?: boolean;
|
|
195
|
-
local?: boolean;
|
|
196
|
-
};
|
|
197
|
-
};
|
|
198
|
-
tuple: {
|
|
199
|
-
keyword: 'tuple';
|
|
200
|
-
args: {
|
|
201
|
-
items: Schema[];
|
|
202
|
-
min?: number;
|
|
203
|
-
max?: number;
|
|
204
|
-
rest?: Schema;
|
|
205
|
-
};
|
|
206
|
-
};
|
|
207
|
-
array: {
|
|
208
|
-
keyword: 'array';
|
|
209
|
-
args: {
|
|
210
|
-
items: Schema[];
|
|
211
|
-
min?: number;
|
|
212
|
-
max?: number;
|
|
213
|
-
unique?: boolean;
|
|
214
|
-
};
|
|
215
|
-
};
|
|
216
|
-
enum: {
|
|
217
|
-
keyword: 'enum';
|
|
218
|
-
args: {
|
|
219
|
-
name: string;
|
|
220
|
-
typeName: string;
|
|
221
|
-
asConst: boolean;
|
|
222
|
-
items: Array<{
|
|
223
|
-
name: string | number;
|
|
224
|
-
format: 'string' | 'number' | 'boolean';
|
|
225
|
-
value?: string | number | boolean;
|
|
226
|
-
}>;
|
|
227
|
-
};
|
|
228
|
-
};
|
|
229
|
-
and: {
|
|
230
|
-
keyword: 'and';
|
|
231
|
-
args: Schema[];
|
|
232
|
-
};
|
|
233
|
-
const: {
|
|
234
|
-
keyword: 'const';
|
|
235
|
-
args: {
|
|
236
|
-
name: string | number;
|
|
237
|
-
format: 'string' | 'number' | 'boolean';
|
|
238
|
-
value?: string | number | boolean;
|
|
239
|
-
};
|
|
240
|
-
};
|
|
241
|
-
union: {
|
|
242
|
-
keyword: 'union';
|
|
243
|
-
args: Schema[];
|
|
244
|
-
};
|
|
245
|
-
ref: {
|
|
246
|
-
keyword: 'ref';
|
|
247
|
-
args: {
|
|
248
|
-
name: string;
|
|
249
|
-
$ref: string;
|
|
250
|
-
/**
|
|
251
|
-
* Full qualified path.
|
|
252
|
-
*/
|
|
253
|
-
path: KubbFile.Path;
|
|
254
|
-
/**
|
|
255
|
-
* When true `File.Import` is used.
|
|
256
|
-
* When false a reference is used inside the current file.
|
|
257
|
-
*/
|
|
258
|
-
isImportable: boolean;
|
|
259
|
-
};
|
|
260
|
-
};
|
|
261
|
-
matches: {
|
|
262
|
-
keyword: 'matches';
|
|
263
|
-
args?: string;
|
|
264
|
-
};
|
|
265
|
-
boolean: {
|
|
266
|
-
keyword: 'boolean';
|
|
267
|
-
};
|
|
268
|
-
default: {
|
|
269
|
-
keyword: 'default';
|
|
270
|
-
args: string | number | boolean;
|
|
271
|
-
};
|
|
272
|
-
string: {
|
|
273
|
-
keyword: 'string';
|
|
274
|
-
};
|
|
275
|
-
integer: {
|
|
276
|
-
keyword: 'integer';
|
|
277
|
-
};
|
|
278
|
-
bigint: {
|
|
279
|
-
keyword: 'bigint';
|
|
280
|
-
};
|
|
281
|
-
number: {
|
|
282
|
-
keyword: 'number';
|
|
283
|
-
};
|
|
284
|
-
max: {
|
|
285
|
-
keyword: 'max';
|
|
286
|
-
args: number;
|
|
287
|
-
};
|
|
288
|
-
min: {
|
|
289
|
-
keyword: 'min';
|
|
290
|
-
args: number;
|
|
291
|
-
};
|
|
292
|
-
exclusiveMaximum: {
|
|
293
|
-
keyword: 'exclusiveMaximum';
|
|
294
|
-
args: number;
|
|
295
|
-
};
|
|
296
|
-
exclusiveMinimum: {
|
|
297
|
-
keyword: 'exclusiveMinimum';
|
|
298
|
-
args: number;
|
|
299
|
-
};
|
|
300
|
-
describe: {
|
|
301
|
-
keyword: 'describe';
|
|
302
|
-
args: string;
|
|
303
|
-
};
|
|
304
|
-
example: {
|
|
305
|
-
keyword: 'example';
|
|
306
|
-
args: string;
|
|
307
|
-
};
|
|
308
|
-
deprecated: {
|
|
309
|
-
keyword: 'deprecated';
|
|
310
|
-
};
|
|
311
|
-
optional: {
|
|
312
|
-
keyword: 'optional';
|
|
313
|
-
};
|
|
314
|
-
undefined: {
|
|
315
|
-
keyword: 'undefined';
|
|
316
|
-
};
|
|
317
|
-
nullish: {
|
|
318
|
-
keyword: 'nullish';
|
|
319
|
-
};
|
|
320
|
-
nullable: {
|
|
321
|
-
keyword: 'nullable';
|
|
322
|
-
};
|
|
323
|
-
null: {
|
|
324
|
-
keyword: 'null';
|
|
325
|
-
};
|
|
326
|
-
any: {
|
|
327
|
-
keyword: 'any';
|
|
328
|
-
};
|
|
329
|
-
unknown: {
|
|
330
|
-
keyword: 'unknown';
|
|
331
|
-
};
|
|
332
|
-
void: {
|
|
333
|
-
keyword: 'void';
|
|
334
|
-
};
|
|
335
|
-
blob: {
|
|
336
|
-
keyword: 'blob';
|
|
337
|
-
};
|
|
338
|
-
schema: {
|
|
339
|
-
keyword: 'schema';
|
|
340
|
-
args: {
|
|
341
|
-
type: 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'object';
|
|
342
|
-
format?: string;
|
|
343
|
-
};
|
|
344
|
-
};
|
|
345
|
-
name: {
|
|
346
|
-
keyword: 'name';
|
|
347
|
-
args: string;
|
|
348
|
-
};
|
|
349
|
-
catchall: {
|
|
350
|
-
keyword: 'catchall';
|
|
351
|
-
};
|
|
352
|
-
interface: {
|
|
353
|
-
keyword: 'interface';
|
|
354
|
-
};
|
|
355
|
-
};
|
|
356
|
-
type Schema = {
|
|
357
|
-
keyword: string;
|
|
358
|
-
} | SchemaKeywordMapper[keyof SchemaKeywordMapper];
|
|
359
|
-
//#endregion
|
|
360
|
-
//#region ../plugin-oas/src/SchemaGenerator.d.ts
|
|
361
|
-
type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
362
|
-
fabric: Fabric;
|
|
363
|
-
oas: Oas;
|
|
364
|
-
pluginManager: PluginManager;
|
|
365
|
-
events?: AsyncEventEmitter<KubbEvents>;
|
|
366
|
-
/**
|
|
367
|
-
* Current plugin
|
|
368
|
-
*/
|
|
369
|
-
plugin: Plugin<TPluginOptions>;
|
|
370
|
-
mode: KubbFile.Mode;
|
|
371
|
-
include?: Array<'schemas' | 'responses' | 'requestBodies'>;
|
|
372
|
-
override: Array<Override<TOptions>> | undefined;
|
|
373
|
-
contentType?: contentType;
|
|
374
|
-
output?: string;
|
|
375
|
-
};
|
|
376
|
-
type SchemaGeneratorOptions = {
|
|
377
|
-
dateType: false | 'string' | 'stringOffset' | 'stringLocal' | 'date';
|
|
378
|
-
integerType?: 'number' | 'bigint';
|
|
379
|
-
unknownType: 'any' | 'unknown' | 'void';
|
|
380
|
-
emptySchemaType: 'any' | 'unknown' | 'void';
|
|
381
|
-
enumType?: 'enum' | 'asConst' | 'asPascalConst' | 'constEnum' | 'literal' | 'inlineLiteral';
|
|
382
|
-
enumSuffix?: string;
|
|
383
|
-
/**
|
|
384
|
-
* @deprecated Will be removed in v5. Use `collisionDetection: true` instead to prevent enum name collisions.
|
|
385
|
-
* When `collisionDetection` is enabled, the rootName-based approach eliminates the need for numeric suffixes.
|
|
386
|
-
* @internal
|
|
387
|
-
*/
|
|
388
|
-
usedEnumNames?: Record<string, number>;
|
|
389
|
-
mapper?: Record<string, string>;
|
|
390
|
-
typed?: boolean;
|
|
391
|
-
transformers: {
|
|
392
|
-
/**
|
|
393
|
-
* Customize the names based on the type that is provided by the plugin.
|
|
394
|
-
*/
|
|
395
|
-
name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
396
|
-
/**
|
|
397
|
-
* Receive schema and name(propertyName) and return Schema array.
|
|
398
|
-
* Return `undefined` to fall through to default schema generation.
|
|
399
|
-
* @beta
|
|
400
|
-
*/
|
|
401
|
-
schema?: (schemaProps: SchemaProps$1, defaultSchemas: Schema[]) => Array<Schema> | undefined;
|
|
402
|
-
};
|
|
403
|
-
};
|
|
404
|
-
type SchemaProps$1 = {
|
|
405
|
-
schema: SchemaObject | null;
|
|
406
|
-
name: string | null;
|
|
407
|
-
parentName: string | null;
|
|
408
|
-
rootName?: string | null;
|
|
409
|
-
};
|
|
410
|
-
declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> {
|
|
411
|
-
#private;
|
|
412
|
-
constructor(options: TOptions, context: Context<TOptions, TPluginOptions>);
|
|
413
|
-
get options(): TOptions;
|
|
414
|
-
set options(options: TOptions);
|
|
415
|
-
get context(): Context<TOptions, TPluginOptions>;
|
|
416
|
-
refs: Refs;
|
|
417
|
-
/**
|
|
418
|
-
* Creates a type node from a given schema.
|
|
419
|
-
* Delegates to getBaseTypeFromSchema internally and
|
|
420
|
-
* optionally adds a union with null.
|
|
421
|
-
*/
|
|
422
|
-
parse(props: SchemaProps$1): Schema[];
|
|
423
|
-
static deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
|
|
424
|
-
static find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
425
|
-
static combineObjects(tree: Schema[] | undefined): Schema[];
|
|
426
|
-
build(...generators: Array<Generator<TPluginOptions, Version>>): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
427
|
-
}
|
|
428
|
-
//#endregion
|
|
429
|
-
//#region ../plugin-oas/src/generators/createGenerator.d.ts
|
|
430
|
-
type CoreGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version> = {
|
|
431
|
-
name: string;
|
|
432
|
-
type: 'core';
|
|
433
|
-
version: TVersion;
|
|
434
|
-
operations: (props: OperationsProps<TOptions, TVersion>) => Promise<KubbFile.File[]>;
|
|
435
|
-
operation: (props: OperationProps<TOptions, TVersion>) => Promise<KubbFile.File[]>;
|
|
436
|
-
schema: (props: SchemaProps<TOptions, TVersion>) => Promise<KubbFile.File[]>;
|
|
437
|
-
};
|
|
438
|
-
//#endregion
|
|
439
|
-
//#region ../plugin-oas/src/generators/types.d.ts
|
|
440
|
-
type Version = '1' | '2';
|
|
441
|
-
type OperationsV1Props<TOptions extends PluginFactoryOptions> = {
|
|
442
|
-
config: Config;
|
|
443
|
-
generator: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
444
|
-
plugin: Plugin<TOptions>;
|
|
445
|
-
operations: Array<Operation>;
|
|
446
|
-
};
|
|
447
|
-
type OperationsV2Props<TOptions extends PluginFactoryOptions> = {
|
|
448
|
-
config: Config;
|
|
449
|
-
plugin: Plugin<TOptions>;
|
|
450
|
-
nodes: Array<OperationNode>;
|
|
451
|
-
};
|
|
452
|
-
type OperationV1Props<TOptions extends PluginFactoryOptions> = {
|
|
453
|
-
config: Config;
|
|
454
|
-
generator: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
455
|
-
plugin: Plugin<TOptions>;
|
|
456
|
-
operation: Operation;
|
|
457
|
-
};
|
|
458
|
-
type OperationV2Props<TOptions extends PluginFactoryOptions> = {
|
|
459
|
-
config: Config;
|
|
460
|
-
plugin: Plugin<TOptions>;
|
|
461
|
-
node: OperationNode;
|
|
462
|
-
};
|
|
463
|
-
type OperationsProps<TOptions extends PluginFactoryOptions, TVersion extends Version = '1'> = TVersion extends '2' ? OperationsV2Props<TOptions> : OperationsV1Props<TOptions>;
|
|
464
|
-
type OperationProps<TOptions extends PluginFactoryOptions, TVersion extends Version = '1'> = TVersion extends '2' ? OperationV2Props<TOptions> : OperationV1Props<TOptions>;
|
|
465
|
-
type SchemaV1Props<TOptions extends PluginFactoryOptions> = {
|
|
466
|
-
config: Config;
|
|
467
|
-
generator: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>;
|
|
468
|
-
plugin: Plugin<TOptions>;
|
|
469
|
-
schema: {
|
|
470
|
-
name: string;
|
|
471
|
-
tree: Array<Schema>;
|
|
472
|
-
value: SchemaObject;
|
|
473
|
-
};
|
|
474
|
-
};
|
|
475
|
-
type SchemaV2Props<TOptions extends PluginFactoryOptions> = {
|
|
476
|
-
config: Config;
|
|
477
|
-
plugin: Plugin<TOptions>;
|
|
478
|
-
node: SchemaNode;
|
|
479
|
-
};
|
|
480
|
-
type SchemaProps<TOptions extends PluginFactoryOptions, TVersion extends Version = '1'> = TVersion extends '2' ? SchemaV2Props<TOptions> : SchemaV1Props<TOptions>;
|
|
481
|
-
type Generator<TOptions extends PluginFactoryOptions, TVersion extends Version = Version> = CoreGenerator<TOptions, TVersion> | ReactGenerator<TOptions, TVersion>;
|
|
482
|
-
//#endregion
|
|
483
|
-
//#region ../plugin-oas/src/generators/createReactGenerator.d.ts
|
|
484
|
-
type ReactGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version> = {
|
|
485
|
-
name: string;
|
|
486
|
-
type: 'react';
|
|
487
|
-
version: TVersion;
|
|
488
|
-
Operations: (props: OperationsProps<TOptions, TVersion>) => FabricReactNode;
|
|
489
|
-
Operation: (props: OperationProps<TOptions, TVersion>) => FabricReactNode;
|
|
490
|
-
Schema: (props: SchemaProps<TOptions, TVersion>) => FabricReactNode;
|
|
491
|
-
};
|
|
492
|
-
//#endregion
|
|
493
5
|
//#region src/generators/customHookOptionsFileGenerator.d.ts
|
|
494
|
-
declare const customHookOptionsFileGenerator: ReactGenerator<PluginReactQuery
|
|
6
|
+
declare const customHookOptionsFileGenerator: _kubb_plugin_oas_generators0.ReactGenerator<PluginReactQuery>;
|
|
495
7
|
//#endregion
|
|
496
8
|
//#region src/generators/hookOptionsGenerator.d.ts
|
|
497
|
-
declare const hookOptionsGenerator: ReactGenerator<PluginReactQuery
|
|
9
|
+
declare const hookOptionsGenerator: _kubb_plugin_oas_generators0.ReactGenerator<PluginReactQuery>;
|
|
498
10
|
//#endregion
|
|
499
11
|
//#region src/generators/infiniteQueryGenerator.d.ts
|
|
500
|
-
declare const infiniteQueryGenerator: ReactGenerator<PluginReactQuery
|
|
12
|
+
declare const infiniteQueryGenerator: _kubb_plugin_oas_generators0.ReactGenerator<PluginReactQuery>;
|
|
501
13
|
//#endregion
|
|
502
14
|
//#region src/generators/mutationGenerator.d.ts
|
|
503
|
-
declare const mutationGenerator: ReactGenerator<PluginReactQuery
|
|
15
|
+
declare const mutationGenerator: _kubb_plugin_oas_generators0.ReactGenerator<PluginReactQuery>;
|
|
504
16
|
//#endregion
|
|
505
17
|
//#region src/generators/queryGenerator.d.ts
|
|
506
|
-
declare const queryGenerator: ReactGenerator<PluginReactQuery
|
|
18
|
+
declare const queryGenerator: _kubb_plugin_oas_generators0.ReactGenerator<PluginReactQuery>;
|
|
507
19
|
//#endregion
|
|
508
20
|
//#region src/generators/suspenseInfiniteQueryGenerator.d.ts
|
|
509
|
-
declare const suspenseInfiniteQueryGenerator: ReactGenerator<PluginReactQuery
|
|
21
|
+
declare const suspenseInfiniteQueryGenerator: _kubb_plugin_oas_generators0.ReactGenerator<PluginReactQuery>;
|
|
510
22
|
//#endregion
|
|
511
23
|
//#region src/generators/suspenseQueryGenerator.d.ts
|
|
512
|
-
declare const suspenseQueryGenerator: ReactGenerator<PluginReactQuery
|
|
24
|
+
declare const suspenseQueryGenerator: _kubb_plugin_oas_generators0.ReactGenerator<PluginReactQuery>;
|
|
513
25
|
//#endregion
|
|
514
26
|
export { customHookOptionsFileGenerator, hookOptionsGenerator, infiniteQueryGenerator, mutationGenerator, queryGenerator, suspenseInfiniteQueryGenerator, suspenseQueryGenerator };
|
|
515
27
|
//# sourceMappingURL=generators.d.ts.map
|
package/dist/generators.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as infiniteQueryGenerator, i as mutationGenerator, n as suspenseInfiniteQueryGenerator, o as hookOptionsGenerator, r as queryGenerator, s as customHookOptionsFileGenerator, t as suspenseQueryGenerator } from "./generators-
|
|
1
|
+
import { a as infiniteQueryGenerator, i as mutationGenerator, n as suspenseInfiniteQueryGenerator, o as hookOptionsGenerator, r as queryGenerator, s as customHookOptionsFileGenerator, t as suspenseQueryGenerator } from "./generators-17bLNXlW.js";
|
|
2
2
|
export { customHookOptionsFileGenerator, hookOptionsGenerator, infiniteQueryGenerator, mutationGenerator, queryGenerator, suspenseInfiniteQueryGenerator, suspenseQueryGenerator };
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_components = require("./components-
|
|
3
|
-
const require_generators = require("./generators-
|
|
2
|
+
const require_components = require("./components-CyyBGYhf.cjs");
|
|
3
|
+
const require_generators = require("./generators-mEEW3Ihs.cjs");
|
|
4
4
|
let node_path = require("node:path");
|
|
5
5
|
node_path = require_components.__toESM(node_path);
|
|
6
6
|
let _kubb_core = require("@kubb/core");
|
|
@@ -13,7 +13,7 @@ let _kubb_plugin_ts = require("@kubb/plugin-ts");
|
|
|
13
13
|
let _kubb_plugin_zod = require("@kubb/plugin-zod");
|
|
14
14
|
//#region src/plugin.ts
|
|
15
15
|
const pluginReactQueryName = "plugin-react-query";
|
|
16
|
-
const pluginReactQuery = (0, _kubb_core.
|
|
16
|
+
const pluginReactQuery = (0, _kubb_core.createPlugin)((options) => {
|
|
17
17
|
const { output = {
|
|
18
18
|
path: "hooks",
|
|
19
19
|
barrelType: "named"
|
|
@@ -113,7 +113,7 @@ const pluginReactQuery = (0, _kubb_core.definePlugin)((options) => {
|
|
|
113
113
|
const oas = await this.getOas();
|
|
114
114
|
const baseURL = await this.getBaseURL();
|
|
115
115
|
if (baseURL) this.plugin.options.client.baseURL = baseURL;
|
|
116
|
-
const hasClientPlugin = !!this.
|
|
116
|
+
const hasClientPlugin = !!this.driver.getPluginByName(_kubb_plugin_client.pluginClientName);
|
|
117
117
|
if (this.plugin.options.client.bundle && !hasClientPlugin && !this.plugin.options.client.importPath) await this.upsertFile({
|
|
118
118
|
baseName: "fetch.ts",
|
|
119
119
|
path: node_path.default.resolve(root, ".kubb/fetch.ts"),
|
|
@@ -141,7 +141,7 @@ const pluginReactQuery = (0, _kubb_core.definePlugin)((options) => {
|
|
|
141
141
|
const files = await new _kubb_plugin_oas.OperationGenerator(this.plugin.options, {
|
|
142
142
|
fabric: this.fabric,
|
|
143
143
|
oas,
|
|
144
|
-
|
|
144
|
+
driver: this.driver,
|
|
145
145
|
events: this.events,
|
|
146
146
|
plugin: this.plugin,
|
|
147
147
|
contentType,
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["queryGenerator","suspenseQueryGenerator","infiniteQueryGenerator","suspenseInfiniteQueryGenerator","mutationGenerator","hookOptionsGenerator","customHookOptionsFileGenerator","MutationKey","QueryKey","pluginOasName","pluginTsName","pluginZodName","path","camelCase","pascalCase","pluginClientName","fetchClientSource","axiosClientSource","configSource","OperationGenerator"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { camelCase, pascalCase } from '@internals/utils'\nimport { definePlugin, type Group, getBarrelFiles, getMode } from '@kubb/core'\nimport { pluginClientName } from '@kubb/plugin-client'\nimport { source as axiosClientSource } from '@kubb/plugin-client/templates/clients/axios.source'\nimport { source as fetchClientSource } from '@kubb/plugin-client/templates/clients/fetch.source'\nimport { source as configSource } from '@kubb/plugin-client/templates/config.source'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { MutationKey } from './components'\nimport { QueryKey } from './components/QueryKey.tsx'\nimport {\n customHookOptionsFileGenerator,\n hookOptionsGenerator,\n infiniteQueryGenerator,\n mutationGenerator,\n queryGenerator,\n suspenseInfiniteQueryGenerator,\n suspenseQueryGenerator,\n} from './generators'\nimport type { PluginReactQuery } from './types.ts'\n\nexport const pluginReactQueryName = 'plugin-react-query' satisfies PluginReactQuery['name']\n\nexport const pluginReactQuery = definePlugin<PluginReactQuery>((options) => {\n const {\n output = { path: 'hooks', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n parser = 'client',\n suspense = {},\n infinite = false,\n transformers = {},\n paramsType = 'inline',\n pathParamsType = paramsType === 'object' ? 'object' : options.pathParamsType || 'inline',\n generators = [\n queryGenerator,\n suspenseQueryGenerator,\n infiniteQueryGenerator,\n suspenseInfiniteQueryGenerator,\n mutationGenerator,\n hookOptionsGenerator,\n customHookOptionsFileGenerator,\n ].filter(Boolean),\n mutation = {},\n query = {},\n mutationKey = MutationKey.getTransformer,\n queryKey = QueryKey.getTransformer,\n customOptions,\n paramsCasing,\n contentType,\n client,\n } = options\n\n const clientName = client?.client ?? 'axios'\n const clientImportPath = client?.importPath ?? (!client?.bundle ? `@kubb/plugin-client/clients/${clientName}` : undefined)\n\n return {\n name: pluginReactQueryName,\n options: {\n output,\n client: {\n bundle: client?.bundle,\n baseURL: client?.baseURL,\n client: clientName,\n clientType: client?.clientType ?? 'function',\n dataReturnType: client?.dataReturnType ?? 'data',\n pathParamsType,\n importPath: clientImportPath,\n paramsCasing,\n },\n infinite: infinite\n ? {\n queryParam: 'id',\n initialPageParam: 0,\n cursorParam: undefined,\n nextParam: undefined,\n previousParam: undefined,\n ...infinite,\n }\n : false,\n suspense,\n queryKey,\n query:\n query === false\n ? false\n : {\n methods: ['get'],\n importPath: '@tanstack/react-query',\n ...query,\n },\n mutationKey,\n mutation:\n mutation === false\n ? false\n : {\n methods: ['post', 'put', 'patch', 'delete'],\n importPath: '@tanstack/react-query',\n ...mutation,\n },\n customOptions: customOptions ? { name: 'useCustomHookOptions', ...customOptions } : undefined,\n paramsType,\n pathParamsType,\n parser,\n paramsCasing,\n group,\n },\n pre: [pluginOasName, pluginTsName, 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 ?? getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Controller`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n let resolvedName = camelCase(name)\n\n if (type === 'file' || type === 'function') {\n resolvedName = camelCase(name, {\n isFile: type === 'file',\n })\n }\n if (type === 'type') {\n resolvedName = pascalCase(name)\n }\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async install() {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = getMode(path.resolve(root, output.path))\n const oas = await this.getOas()\n const baseURL = await this.getBaseURL()\n\n if (baseURL) {\n this.plugin.options.client.baseURL = baseURL\n }\n\n const hasClientPlugin = !!this.pluginManager.getPluginByName(pluginClientName)\n\n if (this.plugin.options.client.bundle && !hasClientPlugin && !this.plugin.options.client.importPath) {\n // pre add bundled fetch\n await this.upsertFile({\n baseName: 'fetch.ts',\n path: path.resolve(root, '.kubb/fetch.ts'),\n sources: [\n {\n name: 'fetch',\n value: this.plugin.options.client.client === 'fetch' ? fetchClientSource : axiosClientSource,\n isExportable: true,\n isIndexable: true,\n },\n ],\n imports: [],\n exports: [],\n })\n }\n\n if (!hasClientPlugin) {\n await this.upsertFile({\n baseName: 'config.ts',\n path: path.resolve(root, '.kubb/config.ts'),\n sources: [\n {\n name: 'config',\n value: configSource,\n isExportable: false,\n isIndexable: false,\n },\n ],\n imports: [],\n exports: [],\n })\n }\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\n events: this.events,\n plugin: this.plugin,\n contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const files = await operationGenerator.build(...generators)\n await this.upsertFile(...files)\n\n const barrelFiles = await getBarrelFiles(this.fabric.files, {\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginName: this.plugin.name,\n },\n })\n\n await this.upsertFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;;;AAuBA,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AAY;;EAExC;EACD"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["queryGenerator","suspenseQueryGenerator","infiniteQueryGenerator","suspenseInfiniteQueryGenerator","mutationGenerator","hookOptionsGenerator","customHookOptionsFileGenerator","MutationKey","QueryKey","pluginOasName","pluginTsName","pluginZodName","path","camelCase","pascalCase","pluginClientName","fetchClientSource","axiosClientSource","configSource","OperationGenerator"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { camelCase, pascalCase } from '@internals/utils'\nimport { createPlugin, type Group, getBarrelFiles, getMode } from '@kubb/core'\nimport { pluginClientName } from '@kubb/plugin-client'\nimport { source as axiosClientSource } from '@kubb/plugin-client/templates/clients/axios.source'\nimport { source as fetchClientSource } from '@kubb/plugin-client/templates/clients/fetch.source'\nimport { source as configSource } from '@kubb/plugin-client/templates/config.source'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { MutationKey } from './components'\nimport { QueryKey } from './components/QueryKey.tsx'\nimport {\n customHookOptionsFileGenerator,\n hookOptionsGenerator,\n infiniteQueryGenerator,\n mutationGenerator,\n queryGenerator,\n suspenseInfiniteQueryGenerator,\n suspenseQueryGenerator,\n} from './generators'\nimport type { PluginReactQuery } from './types.ts'\n\nexport const pluginReactQueryName = 'plugin-react-query' satisfies PluginReactQuery['name']\n\nexport const pluginReactQuery = createPlugin<PluginReactQuery>((options) => {\n const {\n output = { path: 'hooks', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n parser = 'client',\n suspense = {},\n infinite = false,\n transformers = {},\n paramsType = 'inline',\n pathParamsType = paramsType === 'object' ? 'object' : options.pathParamsType || 'inline',\n generators = [\n queryGenerator,\n suspenseQueryGenerator,\n infiniteQueryGenerator,\n suspenseInfiniteQueryGenerator,\n mutationGenerator,\n hookOptionsGenerator,\n customHookOptionsFileGenerator,\n ].filter(Boolean),\n mutation = {},\n query = {},\n mutationKey = MutationKey.getTransformer,\n queryKey = QueryKey.getTransformer,\n customOptions,\n paramsCasing,\n contentType,\n client,\n } = options\n\n const clientName = client?.client ?? 'axios'\n const clientImportPath = client?.importPath ?? (!client?.bundle ? `@kubb/plugin-client/clients/${clientName}` : undefined)\n\n return {\n name: pluginReactQueryName,\n options: {\n output,\n client: {\n bundle: client?.bundle,\n baseURL: client?.baseURL,\n client: clientName,\n clientType: client?.clientType ?? 'function',\n dataReturnType: client?.dataReturnType ?? 'data',\n pathParamsType,\n importPath: clientImportPath,\n paramsCasing,\n },\n infinite: infinite\n ? {\n queryParam: 'id',\n initialPageParam: 0,\n cursorParam: undefined,\n nextParam: undefined,\n previousParam: undefined,\n ...infinite,\n }\n : false,\n suspense,\n queryKey,\n query:\n query === false\n ? false\n : {\n methods: ['get'],\n importPath: '@tanstack/react-query',\n ...query,\n },\n mutationKey,\n mutation:\n mutation === false\n ? false\n : {\n methods: ['post', 'put', 'patch', 'delete'],\n importPath: '@tanstack/react-query',\n ...mutation,\n },\n customOptions: customOptions ? { name: 'useCustomHookOptions', ...customOptions } : undefined,\n paramsType,\n pathParamsType,\n parser,\n paramsCasing,\n group,\n },\n pre: [pluginOasName, pluginTsName, 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 ?? getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Controller`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n let resolvedName = camelCase(name)\n\n if (type === 'file' || type === 'function') {\n resolvedName = camelCase(name, {\n isFile: type === 'file',\n })\n }\n if (type === 'type') {\n resolvedName = pascalCase(name)\n }\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async install() {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = getMode(path.resolve(root, output.path))\n const oas = await this.getOas()\n const baseURL = await this.getBaseURL()\n\n if (baseURL) {\n this.plugin.options.client.baseURL = baseURL\n }\n\n const hasClientPlugin = !!this.driver.getPluginByName(pluginClientName)\n\n if (this.plugin.options.client.bundle && !hasClientPlugin && !this.plugin.options.client.importPath) {\n // pre add bundled fetch\n await this.upsertFile({\n baseName: 'fetch.ts',\n path: path.resolve(root, '.kubb/fetch.ts'),\n sources: [\n {\n name: 'fetch',\n value: this.plugin.options.client.client === 'fetch' ? fetchClientSource : axiosClientSource,\n isExportable: true,\n isIndexable: true,\n },\n ],\n imports: [],\n exports: [],\n })\n }\n\n if (!hasClientPlugin) {\n await this.upsertFile({\n baseName: 'config.ts',\n path: path.resolve(root, '.kubb/config.ts'),\n sources: [\n {\n name: 'config',\n value: configSource,\n isExportable: false,\n isIndexable: false,\n },\n ],\n imports: [],\n exports: [],\n })\n }\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n driver: this.driver,\n events: this.events,\n plugin: this.plugin,\n contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const files = await operationGenerator.build(...generators)\n await this.upsertFile(...files)\n\n const barrelFiles = await getBarrelFiles(this.fabric.files, {\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginName: this.plugin.name,\n },\n })\n\n await this.upsertFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;;;AAuBA,MAAa,uBAAuB;AAEpC,MAAa,oBAAA,GAAA,WA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@ -1,8 +1,8 @@
|
|
|
1
1
|
import "./chunk--u3MIqq1.js";
|
|
2
|
-
import { d as MutationKey, f as camelCase, p as pascalCase, u as QueryKey } from "./components-
|
|
3
|
-
import { a as infiniteQueryGenerator, i as mutationGenerator, n as suspenseInfiniteQueryGenerator, o as hookOptionsGenerator, r as queryGenerator, s as customHookOptionsFileGenerator, t as suspenseQueryGenerator } from "./generators-
|
|
2
|
+
import { d as MutationKey, f as camelCase, p as pascalCase, u as QueryKey } from "./components-BMhCuuyw.js";
|
|
3
|
+
import { a as infiniteQueryGenerator, i as mutationGenerator, n as suspenseInfiniteQueryGenerator, o as hookOptionsGenerator, r as queryGenerator, s as customHookOptionsFileGenerator, t as suspenseQueryGenerator } from "./generators-17bLNXlW.js";
|
|
4
4
|
import path from "node:path";
|
|
5
|
-
import {
|
|
5
|
+
import { createPlugin, getBarrelFiles, getMode } from "@kubb/core";
|
|
6
6
|
import { pluginClientName } from "@kubb/plugin-client";
|
|
7
7
|
import { source } from "@kubb/plugin-client/templates/clients/axios.source";
|
|
8
8
|
import { source as source$1 } from "@kubb/plugin-client/templates/clients/fetch.source";
|
|
@@ -12,7 +12,7 @@ import { pluginTsName } from "@kubb/plugin-ts";
|
|
|
12
12
|
import { pluginZodName } from "@kubb/plugin-zod";
|
|
13
13
|
//#region src/plugin.ts
|
|
14
14
|
const pluginReactQueryName = "plugin-react-query";
|
|
15
|
-
const pluginReactQuery =
|
|
15
|
+
const pluginReactQuery = createPlugin((options) => {
|
|
16
16
|
const { output = {
|
|
17
17
|
path: "hooks",
|
|
18
18
|
barrelType: "named"
|
|
@@ -112,7 +112,7 @@ const pluginReactQuery = definePlugin((options) => {
|
|
|
112
112
|
const oas = await this.getOas();
|
|
113
113
|
const baseURL = await this.getBaseURL();
|
|
114
114
|
if (baseURL) this.plugin.options.client.baseURL = baseURL;
|
|
115
|
-
const hasClientPlugin = !!this.
|
|
115
|
+
const hasClientPlugin = !!this.driver.getPluginByName(pluginClientName);
|
|
116
116
|
if (this.plugin.options.client.bundle && !hasClientPlugin && !this.plugin.options.client.importPath) await this.upsertFile({
|
|
117
117
|
baseName: "fetch.ts",
|
|
118
118
|
path: path.resolve(root, ".kubb/fetch.ts"),
|
|
@@ -140,7 +140,7 @@ const pluginReactQuery = definePlugin((options) => {
|
|
|
140
140
|
const files = await new OperationGenerator(this.plugin.options, {
|
|
141
141
|
fabric: this.fabric,
|
|
142
142
|
oas,
|
|
143
|
-
|
|
143
|
+
driver: this.driver,
|
|
144
144
|
events: this.events,
|
|
145
145
|
plugin: this.plugin,
|
|
146
146
|
contentType,
|