@kubb/plugin-client 4.1.3 → 4.2.0
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/README.md +18 -16
- package/dist/{Operations-CRXqVhJN.cjs → Operations-CT9m1j9w.cjs} +2 -2
- package/dist/Operations-CT9m1j9w.cjs.map +1 -0
- package/dist/{Operations-v1XspnnY.js → Operations-ktPlsW1u.js} +3 -3
- package/dist/Operations-ktPlsW1u.js.map +1 -0
- package/dist/clients/axios.d.cts +4 -4
- package/dist/clients/axios.d.ts +4 -4
- package/dist/clients/fetch.d.cts +4 -4
- package/dist/clients/fetch.d.ts +4 -4
- package/dist/components.cjs +1 -1
- package/dist/components.d.cts +8 -5
- package/dist/components.d.ts +8 -5
- package/dist/components.js +1 -1
- package/dist/{generators-Ba5WL1X9.cjs → generators-BSxTToF6.cjs} +10 -5
- package/dist/generators-BSxTToF6.cjs.map +1 -0
- package/dist/{generators-DxMViNzn.js → generators-BqXV2IXC.js} +11 -7
- package/dist/generators-BqXV2IXC.js.map +1 -0
- package/dist/generators.cjs +2 -2
- package/dist/generators.d.cts +1 -1
- package/dist/generators.d.ts +1 -1
- package/dist/generators.js +2 -2
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/{types-Dff_FBev.d.ts → types-BO1JodPd.d.cts} +78 -123
- package/dist/{types-CX3qvh_y.d.cts → types-sBB-Ek3Z.d.ts} +78 -123
- package/package.json +8 -8
- package/src/components/Client.tsx +1 -1
- package/src/generators/clientGenerator.tsx +5 -6
- package/src/generators/groupedClientGenerator.tsx +6 -7
- package/src/generators/operationsGenerator.tsx +7 -7
- package/dist/Operations-CRXqVhJN.cjs.map +0 -1
- package/dist/Operations-v1XspnnY.js.map +0 -1
- package/dist/generators-Ba5WL1X9.cjs.map +0 -1
- package/dist/generators-DxMViNzn.js.map +0 -1
|
@@ -5,8 +5,9 @@ import { OpenAPIV3 } from "openapi-types";
|
|
|
5
5
|
import * as oas_normalize_lib_types0 from "oas-normalize/lib/types";
|
|
6
6
|
import BaseOas from "oas";
|
|
7
7
|
import { ConsolaInstance, LogLevel } from "consola";
|
|
8
|
-
import { ReactNode } from "react";
|
|
9
8
|
|
|
9
|
+
//#region rolldown:runtime
|
|
10
|
+
//#endregion
|
|
10
11
|
//#region ../oas/src/types.d.ts
|
|
11
12
|
type contentType = 'application/json' | (string & {});
|
|
12
13
|
type SchemaObject$1 = OasTypes.SchemaObject & {
|
|
@@ -15,7 +16,7 @@ type SchemaObject$1 = OasTypes.SchemaObject & {
|
|
|
15
16
|
};
|
|
16
17
|
//#endregion
|
|
17
18
|
//#region ../oas/src/Oas.d.ts
|
|
18
|
-
type Options$
|
|
19
|
+
type Options$3 = {
|
|
19
20
|
contentType?: contentType;
|
|
20
21
|
discriminator?: 'strict' | 'inherit';
|
|
21
22
|
};
|
|
@@ -29,8 +30,8 @@ declare class Oas<const TOAS = unknown> extends BaseOas {
|
|
|
29
30
|
oas: TOAS | OASDocument | string;
|
|
30
31
|
user?: User;
|
|
31
32
|
});
|
|
32
|
-
setOptions(options: Options$
|
|
33
|
-
get options(): Options$
|
|
33
|
+
setOptions(options: Options$3): void;
|
|
34
|
+
get options(): Options$3;
|
|
34
35
|
get($ref: string): any;
|
|
35
36
|
getKey($ref: string): string | undefined;
|
|
36
37
|
set($ref: string, value: unknown): false | undefined;
|
|
@@ -47,17 +48,17 @@ declare class Oas<const TOAS = unknown> extends BaseOas {
|
|
|
47
48
|
* Abstract class that contains the building blocks for plugins to create their own Generator
|
|
48
49
|
* @link idea based on https://github.com/colinhacks/zod/blob/master/src/types.ts#L137
|
|
49
50
|
*/
|
|
50
|
-
declare abstract class BaseGenerator<TOptions = unknown, TContext = unknown> {
|
|
51
|
+
declare abstract class BaseGenerator<TOptions$1 = unknown, TContext = unknown> {
|
|
51
52
|
#private;
|
|
52
|
-
constructor(options?: TOptions, context?: TContext);
|
|
53
|
-
get options(): TOptions;
|
|
53
|
+
constructor(options?: TOptions$1, context?: TContext);
|
|
54
|
+
get options(): TOptions$1;
|
|
54
55
|
get context(): TContext;
|
|
55
|
-
set options(options: TOptions);
|
|
56
|
+
set options(options: TOptions$1);
|
|
56
57
|
abstract build(...params: unknown[]): unknown;
|
|
57
58
|
}
|
|
58
59
|
//#endregion
|
|
59
60
|
//#region ../core/src/fs/types.d.ts
|
|
60
|
-
type BasePath<T extends string = string> = `${T}/`;
|
|
61
|
+
type BasePath<T$1 extends string = string> = `${T$1}/`;
|
|
61
62
|
type Import = {
|
|
62
63
|
/**
|
|
63
64
|
* Import name to be used
|
|
@@ -131,7 +132,7 @@ type BaseName = `${string}.${string}`;
|
|
|
131
132
|
* Path will be full qualified path to a specified file
|
|
132
133
|
*/
|
|
133
134
|
type Path = string;
|
|
134
|
-
type AdvancedPath<T extends BaseName = BaseName> = `${BasePath}${T}`;
|
|
135
|
+
type AdvancedPath<T$1 extends BaseName = BaseName> = `${BasePath}${T$1}`;
|
|
135
136
|
type OptionalPath = Path | undefined | null;
|
|
136
137
|
type File<TMeta extends object = object> = {
|
|
137
138
|
/**
|
|
@@ -220,9 +221,9 @@ type Logger = {
|
|
|
220
221
|
};
|
|
221
222
|
//#endregion
|
|
222
223
|
//#region ../core/src/utils/types.d.ts
|
|
223
|
-
type PossiblePromise<T> = Promise<T> | T;
|
|
224
|
-
type ArrayWithLength<T extends number, U extends any[] = []> = U['length'] extends T ? U : ArrayWithLength<T, [true, ...U]>;
|
|
225
|
-
type GreaterThan<T extends number, U extends number> = ArrayWithLength<U> extends [...ArrayWithLength<T>, ...infer _] ? false : true;
|
|
224
|
+
type PossiblePromise<T$1> = Promise<T$1> | T$1;
|
|
225
|
+
type ArrayWithLength<T$1 extends number, U extends any[] = []> = U['length'] extends T$1 ? U : ArrayWithLength<T$1, [true, ...U]>;
|
|
226
|
+
type GreaterThan<T$1 extends number, U extends number> = ArrayWithLength<U> extends [...ArrayWithLength<T$1>, ...infer _] ? false : true;
|
|
226
227
|
//#endregion
|
|
227
228
|
//#region ../core/src/types.d.ts
|
|
228
229
|
type InputPath = {
|
|
@@ -335,11 +336,11 @@ TName extends string = string,
|
|
|
335
336
|
/**
|
|
336
337
|
* Options of the plugin.
|
|
337
338
|
*/
|
|
338
|
-
TOptions extends object = object,
|
|
339
|
+
TOptions$1 extends object = object,
|
|
339
340
|
/**
|
|
340
341
|
* Options of the plugin that can be used later on, see `options` inside your plugin config.
|
|
341
342
|
*/
|
|
342
|
-
TResolvedOptions extends object = TOptions,
|
|
343
|
+
TResolvedOptions extends object = TOptions$1,
|
|
343
344
|
/**
|
|
344
345
|
* Context that you want to expose to other plugins.
|
|
345
346
|
*/
|
|
@@ -353,23 +354,23 @@ TResolvePathOptions extends object = object> = {
|
|
|
353
354
|
* Same behaviour like what has been done with `QueryKey` in `@tanstack/react-query`
|
|
354
355
|
*/
|
|
355
356
|
key: PluginKey<TName | string>;
|
|
356
|
-
options: TOptions;
|
|
357
|
+
options: TOptions$1;
|
|
357
358
|
resolvedOptions: TResolvedOptions;
|
|
358
359
|
context: TContext;
|
|
359
360
|
resolvePathOptions: TResolvePathOptions;
|
|
360
361
|
};
|
|
361
362
|
type PluginKey<TName> = [name: TName, identifier?: string | number];
|
|
362
|
-
type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
363
|
+
type UserPlugin<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
363
364
|
/**
|
|
364
365
|
* Unique name used for the plugin
|
|
365
366
|
* The name of the plugin follows the format scope:foo-bar or foo-bar, adding scope: can avoid naming conflicts with other plugins.
|
|
366
367
|
* @example @kubb/typescript
|
|
367
368
|
*/
|
|
368
|
-
name: TOptions['name'];
|
|
369
|
+
name: TOptions$1['name'];
|
|
369
370
|
/**
|
|
370
371
|
* Options set for a specific plugin(see kubb.config.js), passthrough of options.
|
|
371
372
|
*/
|
|
372
|
-
options: TOptions['resolvedOptions'];
|
|
373
|
+
options: TOptions$1['resolvedOptions'];
|
|
373
374
|
/**
|
|
374
375
|
* Specifies the preceding plugins for the current plugin. You can pass an array of preceding plugin names, and the current plugin will be executed after these plugins.
|
|
375
376
|
* Can be used to validate dependent plugins.
|
|
@@ -379,23 +380,23 @@ type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> =
|
|
|
379
380
|
* Specifies the succeeding plugins for the current plugin. You can pass an array of succeeding plugin names, and the current plugin will be executed before these plugins.
|
|
380
381
|
*/
|
|
381
382
|
post?: Array<string>;
|
|
382
|
-
} & (TOptions['context'] extends never ? {
|
|
383
|
+
} & (TOptions$1['context'] extends never ? {
|
|
383
384
|
context?: never;
|
|
384
385
|
} : {
|
|
385
|
-
context: (this: TOptions['name'] extends 'core' ? null : Omit<PluginContext<TOptions>, 'addFile'>) => TOptions['context'];
|
|
386
|
+
context: (this: TOptions$1['name'] extends 'core' ? null : Omit<PluginContext<TOptions$1>, 'addFile'>) => TOptions$1['context'];
|
|
386
387
|
});
|
|
387
|
-
type UserPluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = UserPlugin<TOptions> & PluginLifecycle<TOptions>;
|
|
388
|
-
type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
388
|
+
type UserPluginWithLifeCycle<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = UserPlugin<TOptions$1> & PluginLifecycle<TOptions$1>;
|
|
389
|
+
type Plugin<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
389
390
|
/**
|
|
390
391
|
* Unique name used for the plugin
|
|
391
392
|
* @example @kubb/typescript
|
|
392
393
|
*/
|
|
393
|
-
name: TOptions['name'];
|
|
394
|
+
name: TOptions$1['name'];
|
|
394
395
|
/**
|
|
395
396
|
* Internal key used when a developer uses more than one of the same plugin
|
|
396
397
|
* @private
|
|
397
398
|
*/
|
|
398
|
-
key: TOptions['key'];
|
|
399
|
+
key: TOptions$1['key'];
|
|
399
400
|
/**
|
|
400
401
|
* Specifies the preceding plugins for the current plugin. You can pass an array of preceding plugin names, and the current plugin will be executed after these plugins.
|
|
401
402
|
* Can be used to validate dependent plugins.
|
|
@@ -408,49 +409,49 @@ type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
|
408
409
|
/**
|
|
409
410
|
* Options set for a specific plugin(see kubb.config.js), passthrough of options.
|
|
410
411
|
*/
|
|
411
|
-
options: TOptions['resolvedOptions'];
|
|
412
|
-
} & (TOptions['context'] extends never ? {
|
|
412
|
+
options: TOptions$1['resolvedOptions'];
|
|
413
|
+
} & (TOptions$1['context'] extends never ? {
|
|
413
414
|
context?: never;
|
|
414
415
|
} : {
|
|
415
|
-
context: TOptions['context'];
|
|
416
|
+
context: TOptions$1['context'];
|
|
416
417
|
});
|
|
417
|
-
type PluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions> & PluginLifecycle<TOptions>;
|
|
418
|
-
type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
418
|
+
type PluginWithLifeCycle<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions$1> & PluginLifecycle<TOptions$1>;
|
|
419
|
+
type PluginLifecycle<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
419
420
|
/**
|
|
420
421
|
* Start of the lifecycle of a plugin.
|
|
421
422
|
* @type hookParallel
|
|
422
423
|
*/
|
|
423
|
-
buildStart?: (this: PluginContext<TOptions>, Config: Config) => PossiblePromise<void>;
|
|
424
|
+
buildStart?: (this: PluginContext<TOptions$1>, Config: Config) => PossiblePromise<void>;
|
|
424
425
|
/**
|
|
425
426
|
* Resolve to a Path based on a baseName(example: `./Pet.ts`) and directory(example: `./models`).
|
|
426
427
|
* Options can als be included.
|
|
427
428
|
* @type hookFirst
|
|
428
429
|
* @example ('./Pet.ts', './src/gen/') => '/src/gen/Pet.ts'
|
|
429
430
|
*/
|
|
430
|
-
resolvePath?: (this: PluginContext<TOptions>, baseName: BaseName, mode?: Mode, options?: TOptions['resolvePathOptions']) => OptionalPath;
|
|
431
|
+
resolvePath?: (this: PluginContext<TOptions$1>, baseName: BaseName, mode?: Mode, options?: TOptions$1['resolvePathOptions']) => OptionalPath;
|
|
431
432
|
/**
|
|
432
433
|
* Resolve to a name based on a string.
|
|
433
434
|
* Useful when converting to PascalCase or camelCase.
|
|
434
435
|
* @type hookFirst
|
|
435
436
|
* @example ('pet') => 'Pet'
|
|
436
437
|
*/
|
|
437
|
-
resolveName?: (this: PluginContext<TOptions>, name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
438
|
+
resolveName?: (this: PluginContext<TOptions$1>, name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
438
439
|
/**
|
|
439
440
|
* End of the plugin lifecycle.
|
|
440
441
|
* @type hookParallel
|
|
441
442
|
*/
|
|
442
|
-
buildEnd?: (this: PluginContext<TOptions>) => PossiblePromise<void>;
|
|
443
|
+
buildEnd?: (this: PluginContext<TOptions$1>) => PossiblePromise<void>;
|
|
443
444
|
};
|
|
444
445
|
type PluginLifecycleHooks = keyof PluginLifecycle;
|
|
445
|
-
type PluginParameter<H extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H]>;
|
|
446
|
-
type ResolvePathParams<TOptions = object> = {
|
|
446
|
+
type PluginParameter<H$1 extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H$1]>;
|
|
447
|
+
type ResolvePathParams<TOptions$1 = object> = {
|
|
447
448
|
pluginKey?: Plugin['key'];
|
|
448
449
|
baseName: BaseName;
|
|
449
450
|
mode?: Mode;
|
|
450
451
|
/**
|
|
451
452
|
* Options to be passed to 'resolvePath' 3th parameter
|
|
452
453
|
*/
|
|
453
|
-
options?: TOptions;
|
|
454
|
+
options?: TOptions$1;
|
|
454
455
|
};
|
|
455
456
|
type ResolveNameParams = {
|
|
456
457
|
name: string;
|
|
@@ -463,12 +464,12 @@ type ResolveNameParams = {
|
|
|
463
464
|
*/
|
|
464
465
|
type?: 'file' | 'function' | 'type' | 'const';
|
|
465
466
|
};
|
|
466
|
-
type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
467
|
+
type PluginContext<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
467
468
|
config: Config;
|
|
468
469
|
fileManager: FileManager;
|
|
469
470
|
pluginManager: PluginManager;
|
|
470
471
|
addFile: (...file: Array<File>) => Promise<Array<ResolvedFile>>;
|
|
471
|
-
resolvePath: (params: ResolvePathParams<TOptions['resolvePathOptions']>) => OptionalPath;
|
|
472
|
+
resolvePath: (params: ResolvePathParams<TOptions$1['resolvePathOptions']>) => OptionalPath;
|
|
472
473
|
resolveName: (params: ResolveNameParams) => string;
|
|
473
474
|
logger: Logger;
|
|
474
475
|
/**
|
|
@@ -478,12 +479,12 @@ type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions>
|
|
|
478
479
|
/**
|
|
479
480
|
* Current plugin
|
|
480
481
|
*/
|
|
481
|
-
plugin: Plugin<TOptions>;
|
|
482
|
+
plugin: Plugin<TOptions$1>;
|
|
482
483
|
};
|
|
483
484
|
/**
|
|
484
485
|
* Specify the export location for the files and define the behavior of the output
|
|
485
486
|
*/
|
|
486
|
-
type Output<TOptions> = {
|
|
487
|
+
type Output<TOptions$1> = {
|
|
487
488
|
/**
|
|
488
489
|
* Path to the output folder or file that will contain the generated code
|
|
489
490
|
*/
|
|
@@ -496,11 +497,11 @@ type Output<TOptions> = {
|
|
|
496
497
|
/**
|
|
497
498
|
* Add a banner text in the beginning of every file
|
|
498
499
|
*/
|
|
499
|
-
banner?: string | ((options: TOptions) => string);
|
|
500
|
+
banner?: string | ((options: TOptions$1) => string);
|
|
500
501
|
/**
|
|
501
502
|
* Add a footer text in the beginning of every file
|
|
502
503
|
*/
|
|
503
|
-
footer?: string | ((options: TOptions) => string);
|
|
504
|
+
footer?: string | ((options: TOptions$1) => string);
|
|
504
505
|
};
|
|
505
506
|
type GroupContext = {
|
|
506
507
|
group: string;
|
|
@@ -520,7 +521,7 @@ type Group = {
|
|
|
520
521
|
type FileMetaBase = {
|
|
521
522
|
pluginKey?: Plugin['key'];
|
|
522
523
|
};
|
|
523
|
-
type AddResult<T extends Array<File>> = Promise<Awaited<GreaterThan<T['length'], 1> extends true ? Promise<ResolvedFile[]> : Promise<ResolvedFile>>>;
|
|
524
|
+
type AddResult<T$1 extends Array<File>> = Promise<Awaited<GreaterThan<T$1['length'], 1> extends true ? Promise<ResolvedFile[]> : Promise<ResolvedFile>>>;
|
|
524
525
|
type AddIndexesProps = {
|
|
525
526
|
type: BarrelType | false | undefined;
|
|
526
527
|
/**
|
|
@@ -573,20 +574,20 @@ declare class FileManager {
|
|
|
573
574
|
//#region ../core/src/PluginManager.d.ts
|
|
574
575
|
type RequiredPluginLifecycle = Required<PluginLifecycle>;
|
|
575
576
|
type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
|
|
576
|
-
type Executer<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
577
|
+
type Executer<H$1 extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
577
578
|
message: string;
|
|
578
579
|
strategy: Strategy;
|
|
579
|
-
hookName: H;
|
|
580
|
+
hookName: H$1;
|
|
580
581
|
plugin: Plugin;
|
|
581
582
|
parameters?: unknown[] | undefined;
|
|
582
583
|
output?: unknown;
|
|
583
584
|
};
|
|
584
|
-
type ParseResult<H extends PluginLifecycleHooks> = RequiredPluginLifecycle[H];
|
|
585
|
-
type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {
|
|
585
|
+
type ParseResult<H$1 extends PluginLifecycleHooks> = RequiredPluginLifecycle[H$1];
|
|
586
|
+
type SafeParseResult<H$1 extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H$1>>> = {
|
|
586
587
|
result: Result;
|
|
587
588
|
plugin: Plugin;
|
|
588
589
|
};
|
|
589
|
-
type Options$
|
|
590
|
+
type Options$2 = {
|
|
590
591
|
logger: Logger;
|
|
591
592
|
/**
|
|
592
593
|
* @default Number.POSITIVE_INFINITY
|
|
@@ -598,12 +599,12 @@ type Events = {
|
|
|
598
599
|
executed: [executer: Executer];
|
|
599
600
|
error: [error: Error];
|
|
600
601
|
};
|
|
601
|
-
type GetFileProps<TOptions = object> = {
|
|
602
|
+
type GetFileProps<TOptions$1 = object> = {
|
|
602
603
|
name: string;
|
|
603
604
|
mode?: Mode;
|
|
604
605
|
extname: Extname;
|
|
605
606
|
pluginKey: Plugin['key'];
|
|
606
|
-
options?: TOptions;
|
|
607
|
+
options?: TOptions$1;
|
|
607
608
|
};
|
|
608
609
|
declare class PluginManager {
|
|
609
610
|
#private;
|
|
@@ -613,8 +614,8 @@ declare class PluginManager {
|
|
|
613
614
|
readonly config: Config;
|
|
614
615
|
readonly executed: Array<Executer>;
|
|
615
616
|
readonly logger: Logger;
|
|
616
|
-
readonly options: Options$
|
|
617
|
-
constructor(config: Config, options: Options$
|
|
617
|
+
readonly options: Options$2;
|
|
618
|
+
constructor(config: Config, options: Options$2);
|
|
618
619
|
getFile<TOptions = object>({
|
|
619
620
|
name,
|
|
620
621
|
mode,
|
|
@@ -715,53 +716,7 @@ declare class PluginManager {
|
|
|
715
716
|
static getDependedPlugins<T1 extends PluginFactoryOptions, T2 extends PluginFactoryOptions = never, T3 extends PluginFactoryOptions = never, TOutput = (T3 extends never ? (T2 extends never ? [T1: Plugin<T1>] : [T1: Plugin<T1>, T2: Plugin<T2>]) : [T1: Plugin<T1>, T2: Plugin<T2>, T3: Plugin<T3>])>(plugins: Array<Plugin>, dependedPluginNames: string | string[]): TOutput;
|
|
716
717
|
static get hooks(): readonly ["buildStart", "resolvePath", "resolveName", "buildEnd"];
|
|
717
718
|
}
|
|
718
|
-
|
|
719
|
-
//#region ../react/src/utils/getFunctionParams.d.ts
|
|
720
|
-
type Param = {
|
|
721
|
-
/**
|
|
722
|
-
* `object` will return the pathParams as an object.
|
|
723
|
-
*
|
|
724
|
-
* `inline` will return the pathParams as comma separated params.
|
|
725
|
-
* @default `'inline'`
|
|
726
|
-
* @private
|
|
727
|
-
*/
|
|
728
|
-
mode?: 'object' | 'inline' | 'inlineSpread';
|
|
729
|
-
type?: 'string' | 'number' | (string & {});
|
|
730
|
-
optional?: boolean;
|
|
731
|
-
/**
|
|
732
|
-
* @example test = "default"
|
|
733
|
-
*/
|
|
734
|
-
default?: string;
|
|
735
|
-
/**
|
|
736
|
-
* Used for no TypeScript(with mode object)
|
|
737
|
-
* @example test: "default"
|
|
738
|
-
*/
|
|
739
|
-
value?: string;
|
|
740
|
-
children?: Params;
|
|
741
|
-
};
|
|
742
|
-
type Params = Record<string, Param | undefined>;
|
|
743
|
-
type Options$2 = {
|
|
744
|
-
type: 'constructor' | 'call' | 'object' | 'objectValue';
|
|
745
|
-
transformName?: (name: string) => string;
|
|
746
|
-
transformType?: (type: string) => string;
|
|
747
|
-
};
|
|
748
|
-
declare class FunctionParams {
|
|
749
|
-
#private;
|
|
750
|
-
static factory(params: Params): FunctionParams;
|
|
751
|
-
constructor(params: Params);
|
|
752
|
-
get params(): Params;
|
|
753
|
-
get flatParams(): Params;
|
|
754
|
-
toCall({
|
|
755
|
-
transformName,
|
|
756
|
-
transformType
|
|
757
|
-
}?: Pick<Options$2, 'transformName' | 'transformType'>): string;
|
|
758
|
-
toObject(): string;
|
|
759
|
-
toObjectValue(): string;
|
|
760
|
-
toConstructor(): string;
|
|
761
|
-
}
|
|
762
|
-
//#endregion
|
|
763
|
-
//#region ../react/src/types.d.ts
|
|
764
|
-
type KubbNode = ReactNode;
|
|
719
|
+
import * as import___kubb_react_fabric_types from "@kubb/react-fabric/types";
|
|
765
720
|
//#endregion
|
|
766
721
|
//#region ../plugin-oas/src/SchemaMapper.d.ts
|
|
767
722
|
type SchemaKeywordMapper = {
|
|
@@ -1056,12 +1011,12 @@ type ByContentType = {
|
|
|
1056
1011
|
};
|
|
1057
1012
|
type Exclude$1 = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
|
|
1058
1013
|
type Include = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
|
|
1059
|
-
type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName | ByContentType) & {
|
|
1060
|
-
options: Partial<TOptions>;
|
|
1014
|
+
type Override<TOptions$1> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName | ByContentType) & {
|
|
1015
|
+
options: Partial<TOptions$1>;
|
|
1061
1016
|
};
|
|
1062
1017
|
//#endregion
|
|
1063
1018
|
//#region ../plugin-oas/src/SchemaGenerator.d.ts
|
|
1064
|
-
type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
1019
|
+
type Context$1<TOptions$1, TPluginOptions extends PluginFactoryOptions> = {
|
|
1065
1020
|
oas: Oas;
|
|
1066
1021
|
pluginManager: PluginManager;
|
|
1067
1022
|
/**
|
|
@@ -1070,7 +1025,7 @@ type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
|
1070
1025
|
plugin: Plugin<TPluginOptions>;
|
|
1071
1026
|
mode: Mode;
|
|
1072
1027
|
include?: Array<'schemas' | 'responses' | 'requestBodies'>;
|
|
1073
|
-
override: Array<Override<TOptions>> | undefined;
|
|
1028
|
+
override: Array<Override<TOptions$1>> | undefined;
|
|
1074
1029
|
contentType?: contentType;
|
|
1075
1030
|
output?: string;
|
|
1076
1031
|
};
|
|
@@ -1101,7 +1056,7 @@ type SchemaProps$1 = {
|
|
|
1101
1056
|
name?: string;
|
|
1102
1057
|
parentName?: string;
|
|
1103
1058
|
};
|
|
1104
|
-
declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions, Context$1<TOptions, TPluginOptions>> {
|
|
1059
|
+
declare class SchemaGenerator<TOptions$1 extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions$1, Context$1<TOptions$1, TPluginOptions>> {
|
|
1105
1060
|
#private;
|
|
1106
1061
|
refs: Refs;
|
|
1107
1062
|
/**
|
|
@@ -1120,39 +1075,39 @@ declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGe
|
|
|
1120
1075
|
}
|
|
1121
1076
|
//#endregion
|
|
1122
1077
|
//#region ../plugin-oas/src/generator.d.ts
|
|
1123
|
-
type OperationsProps<TOptions extends PluginFactoryOptions> = {
|
|
1124
|
-
instance: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
1125
|
-
options: TOptions['resolvedOptions'];
|
|
1078
|
+
type OperationsProps<TOptions$1 extends PluginFactoryOptions> = {
|
|
1079
|
+
instance: Omit<OperationGenerator<TOptions$1>, 'build'>;
|
|
1080
|
+
options: TOptions$1['resolvedOptions'];
|
|
1126
1081
|
operations: Array<Operation$1>;
|
|
1127
1082
|
};
|
|
1128
|
-
type OperationProps<TOptions extends PluginFactoryOptions> = {
|
|
1129
|
-
instance: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
1130
|
-
options: TOptions['resolvedOptions'];
|
|
1083
|
+
type OperationProps<TOptions$1 extends PluginFactoryOptions> = {
|
|
1084
|
+
instance: Omit<OperationGenerator<TOptions$1>, 'build'>;
|
|
1085
|
+
options: TOptions$1['resolvedOptions'];
|
|
1131
1086
|
operation: Operation$1;
|
|
1132
1087
|
};
|
|
1133
|
-
type SchemaProps<TOptions extends PluginFactoryOptions> = {
|
|
1134
|
-
instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>;
|
|
1135
|
-
options: TOptions['resolvedOptions'];
|
|
1088
|
+
type SchemaProps<TOptions$1 extends PluginFactoryOptions> = {
|
|
1089
|
+
instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions$1>, 'build'>;
|
|
1090
|
+
options: TOptions$1['resolvedOptions'];
|
|
1136
1091
|
schema: {
|
|
1137
1092
|
name: string;
|
|
1138
1093
|
tree: Array<Schema>;
|
|
1139
1094
|
value: SchemaObject$1;
|
|
1140
1095
|
};
|
|
1141
1096
|
};
|
|
1142
|
-
type GeneratorOptions<TOptions extends PluginFactoryOptions> = {
|
|
1097
|
+
type GeneratorOptions<TOptions$1 extends PluginFactoryOptions> = {
|
|
1143
1098
|
name: string;
|
|
1144
|
-
operations?: (this: GeneratorOptions<TOptions>, props: OperationsProps<TOptions>) => Promise<File[]>;
|
|
1145
|
-
operation?: (this: GeneratorOptions<TOptions>, props: OperationProps<TOptions>) => Promise<File[]>;
|
|
1146
|
-
schema?: (this: GeneratorOptions<TOptions>, props: SchemaProps<TOptions>) => Promise<File[]>;
|
|
1099
|
+
operations?: (this: GeneratorOptions<TOptions$1>, props: OperationsProps<TOptions$1>) => Promise<File[]>;
|
|
1100
|
+
operation?: (this: GeneratorOptions<TOptions$1>, props: OperationProps<TOptions$1>) => Promise<File[]>;
|
|
1101
|
+
schema?: (this: GeneratorOptions<TOptions$1>, props: SchemaProps<TOptions$1>) => Promise<File[]>;
|
|
1147
1102
|
};
|
|
1148
|
-
type Generator<TOptions extends PluginFactoryOptions> = GeneratorOptions<TOptions>;
|
|
1103
|
+
type Generator<TOptions$1 extends PluginFactoryOptions> = GeneratorOptions<TOptions$1>;
|
|
1149
1104
|
//#endregion
|
|
1150
1105
|
//#region ../plugin-oas/src/OperationGenerator.d.ts
|
|
1151
|
-
type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
1106
|
+
type Context<TOptions$1, TPluginOptions extends PluginFactoryOptions> = {
|
|
1152
1107
|
oas: Oas;
|
|
1153
1108
|
exclude: Array<Exclude$1> | undefined;
|
|
1154
1109
|
include: Array<Include> | undefined;
|
|
1155
|
-
override: Array<Override<TOptions>> | undefined;
|
|
1110
|
+
override: Array<Override<TOptions$1>> | undefined;
|
|
1156
1111
|
contentType: contentType | undefined;
|
|
1157
1112
|
pluginManager: PluginManager;
|
|
1158
1113
|
/**
|
|
@@ -1291,5 +1246,5 @@ type ResolvedOptions = {
|
|
|
1291
1246
|
};
|
|
1292
1247
|
type PluginClient = PluginFactoryOptions<'plugin-client', Options$1, ResolvedOptions, never, ResolvePathOptions>;
|
|
1293
1248
|
//#endregion
|
|
1294
|
-
export {
|
|
1295
|
-
//# sourceMappingURL=types-
|
|
1249
|
+
export { types_d_exports$1 as a, __reExport as c, OperationSchemas as i, PluginClient as n, UserPluginWithLifeCycle as o, Generator as r, Operation$1 as s, Options$1 as t };
|
|
1250
|
+
//# sourceMappingURL=types-sBB-Ek3Z.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-client",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.0",
|
|
4
4
|
"description": "API client generator plugin for Kubb, creating type-safe HTTP clients (Axios, Fetch) from OpenAPI specifications for making API requests.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"api-client",
|
|
@@ -77,16 +77,16 @@
|
|
|
77
77
|
"!/**/__tests__/**"
|
|
78
78
|
],
|
|
79
79
|
"dependencies": {
|
|
80
|
-
"@kubb/core": "4.
|
|
81
|
-
"@kubb/oas": "4.
|
|
82
|
-
"@kubb/plugin-oas": "4.
|
|
83
|
-
"@kubb/plugin-ts": "4.
|
|
84
|
-
"@kubb/plugin-zod": "4.
|
|
85
|
-
"@kubb/react": "4.
|
|
80
|
+
"@kubb/core": "4.2.0",
|
|
81
|
+
"@kubb/oas": "4.2.0",
|
|
82
|
+
"@kubb/plugin-oas": "4.2.0",
|
|
83
|
+
"@kubb/plugin-ts": "4.2.0",
|
|
84
|
+
"@kubb/plugin-zod": "4.2.0",
|
|
85
|
+
"@kubb/react": "4.2.0"
|
|
86
86
|
},
|
|
87
87
|
"devDependencies": {
|
|
88
88
|
"axios": "^1.12.2",
|
|
89
|
-
"tsdown": "^0.15.
|
|
89
|
+
"tsdown": "^0.15.9",
|
|
90
90
|
"typescript": "^5.9.3"
|
|
91
91
|
},
|
|
92
92
|
"peerDependencies": {
|
|
@@ -136,7 +136,7 @@ export function Client({
|
|
|
136
136
|
const contentType = operation.getContentType()
|
|
137
137
|
const isFormData = contentType === 'multipart/form-data'
|
|
138
138
|
const headers = [
|
|
139
|
-
contentType !== 'application/json' ? `'Content-Type': '${contentType}'` : undefined,
|
|
139
|
+
contentType !== 'application/json' && contentType !== 'multipart/form-data' ? `'Content-Type': '${contentType}'` : undefined,
|
|
140
140
|
typeSchemas.headerParams?.name ? '...headers' : undefined,
|
|
141
141
|
].filter(Boolean)
|
|
142
142
|
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { usePlugin, usePluginManager } from '@kubb/core/hooks'
|
|
1
2
|
import { createReactGenerator } from '@kubb/plugin-oas'
|
|
2
3
|
import { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'
|
|
3
4
|
import { getBanner, getFooter } from '@kubb/plugin-oas/utils'
|
|
4
5
|
import { pluginTsName } from '@kubb/plugin-ts'
|
|
5
6
|
import { pluginZodName } from '@kubb/plugin-zod'
|
|
6
|
-
import { File
|
|
7
|
+
import { File } from '@kubb/react'
|
|
7
8
|
import { Client } from '../components/Client'
|
|
8
9
|
import { Url } from '../components/Url.tsx'
|
|
9
10
|
import type { PluginClient } from '../types'
|
|
@@ -11,12 +12,10 @@ import type { PluginClient } from '../types'
|
|
|
11
12
|
export const clientGenerator = createReactGenerator<PluginClient>({
|
|
12
13
|
name: 'client',
|
|
13
14
|
Operation({ options, operation }) {
|
|
15
|
+
const pluginManager = usePluginManager()
|
|
14
16
|
const {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
},
|
|
18
|
-
pluginManager,
|
|
19
|
-
} = useApp<PluginClient>()
|
|
17
|
+
options: { output, urlType },
|
|
18
|
+
} = usePlugin<PluginClient>()
|
|
20
19
|
const oas = useOas()
|
|
21
20
|
const { getSchemas, getName, getFile } = useOperationManager()
|
|
22
21
|
|
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
import { camelCase } from '@kubb/core/transformers'
|
|
2
1
|
import type { KubbFile } from '@kubb/core/fs'
|
|
3
|
-
|
|
2
|
+
import { usePlugin, usePluginManager } from '@kubb/core/hooks'
|
|
3
|
+
import { camelCase } from '@kubb/core/transformers'
|
|
4
4
|
import { createReactGenerator } from '@kubb/plugin-oas'
|
|
5
5
|
import { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'
|
|
6
6
|
import { getBanner, getFooter } from '@kubb/plugin-oas/utils'
|
|
7
|
-
import { File, Function
|
|
7
|
+
import { File, Function } from '@kubb/react'
|
|
8
8
|
import type { PluginClient } from '../types'
|
|
9
9
|
|
|
10
10
|
export const groupedClientGenerator = createReactGenerator<PluginClient>({
|
|
11
11
|
name: 'groupedClient',
|
|
12
12
|
Operations({ operations }) {
|
|
13
|
-
const {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
} = useApp<PluginClient>()
|
|
13
|
+
const { options, key: pluginKey } = usePlugin<PluginClient>()
|
|
14
|
+
const pluginManager = usePluginManager()
|
|
15
|
+
|
|
17
16
|
const oas = useOas()
|
|
18
17
|
const { getName, getFile, getGroup } = useOperationManager()
|
|
19
18
|
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { usePlugin, usePluginManager } from '@kubb/core/hooks'
|
|
1
2
|
import { createReactGenerator } from '@kubb/plugin-oas'
|
|
2
3
|
import { useOas } from '@kubb/plugin-oas/hooks'
|
|
3
4
|
import { getBanner, getFooter } from '@kubb/plugin-oas/utils'
|
|
4
|
-
import { File
|
|
5
|
+
import { File } from '@kubb/react'
|
|
5
6
|
import { Operations } from '../components/Operations'
|
|
6
7
|
import type { PluginClient } from '../types'
|
|
7
8
|
|
|
@@ -9,12 +10,11 @@ export const operationsGenerator = createReactGenerator<PluginClient>({
|
|
|
9
10
|
name: 'client',
|
|
10
11
|
Operations({ operations }) {
|
|
11
12
|
const {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
} = useApp<PluginClient>()
|
|
13
|
+
key: pluginKey,
|
|
14
|
+
options: { output },
|
|
15
|
+
} = usePlugin<PluginClient>()
|
|
16
|
+
const pluginManager = usePluginManager()
|
|
17
|
+
|
|
18
18
|
const oas = useOas()
|
|
19
19
|
|
|
20
20
|
const name = 'operations'
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Operations-CRXqVhJN.cjs","names":["getParams","FunctionParams","URLPath","File","Function","Const","FunctionParams","URLPath","File","Function","operationsObject: Record<string, { path: string; method: HttpMethod }>","URLPath","File","Const"],"sources":["../src/components/Url.tsx","../src/components/Client.tsx","../src/components/Operations.tsx"],"sourcesContent":["import { URLPath } from '@kubb/core/utils'\n\nimport { isOptional, type Operation } from '@kubb/oas'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport { getPathParams } from '@kubb/plugin-oas/utils'\nimport { Const, File, Function, FunctionParams } from '@kubb/react'\nimport type { PluginClient } from '../types.ts'\n\ntype Props = {\n /**\n * Name of the function\n */\n name: string\n isExportable?: boolean\n isIndexable?: boolean\n\n baseURL: string | undefined\n paramsCasing: PluginClient['resolvedOptions']['paramsCasing']\n paramsType: PluginClient['resolvedOptions']['pathParamsType']\n pathParamsType: PluginClient['resolvedOptions']['pathParamsType']\n typeSchemas: OperationSchemas\n operation: Operation\n}\n\ntype GetParamsProps = {\n paramsCasing: PluginClient['resolvedOptions']['paramsCasing']\n paramsType: PluginClient['resolvedOptions']['paramsType']\n pathParamsType: PluginClient['resolvedOptions']['pathParamsType']\n typeSchemas: OperationSchemas\n}\n\nfunction getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas }: GetParamsProps) {\n if (paramsType === 'object') {\n return FunctionParams.factory({\n data: {\n mode: 'object',\n children: {\n ...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n },\n },\n })\n }\n\n return FunctionParams.factory({\n pathParams: typeSchemas.pathParams?.name\n ? {\n mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n optional: isOptional(typeSchemas.pathParams?.schema),\n }\n : undefined,\n })\n}\n\nexport function Url({ name, isExportable = true, isIndexable = true, typeSchemas, baseURL, paramsType, paramsCasing, pathParamsType, operation }: Props) {\n const path = new URLPath(operation.path, { casing: paramsCasing })\n const params = getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas })\n\n return (\n <File.Source name={name} isExportable={isExportable} isIndexable={isIndexable}>\n <Function name={name} export={isExportable} params={params.toConstructor()}>\n <Const name={'res'}>{`{ method: '${operation.method.toUpperCase()}', url: ${path.toTemplateString({ prefix: baseURL })} as const }`}</Const>\n <br />\n return res\n </Function>\n </File.Source>\n )\n}\n\nUrl.getParams = getParams\n","import { URLPath } from '@kubb/core/utils'\n\nimport { isOptional, type Operation } from '@kubb/oas'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport { getComments, getPathParams } from '@kubb/plugin-oas/utils'\nimport { File, Function, FunctionParams } from '@kubb/react'\nimport type { KubbNode } from '@kubb/react/types'\nimport type { PluginClient } from '../types.ts'\nimport { Url } from './Url.tsx'\n\ntype Props = {\n /**\n * Name of the function\n */\n name: string\n urlName?: string\n isExportable?: boolean\n isIndexable?: boolean\n isConfigurable?: boolean\n returnType?: string\n\n baseURL: string | undefined\n dataReturnType: PluginClient['resolvedOptions']['dataReturnType']\n paramsCasing: PluginClient['resolvedOptions']['paramsCasing']\n paramsType: PluginClient['resolvedOptions']['pathParamsType']\n pathParamsType: PluginClient['resolvedOptions']['pathParamsType']\n parser: PluginClient['resolvedOptions']['parser'] | undefined\n typeSchemas: OperationSchemas\n zodSchemas: OperationSchemas | undefined\n operation: Operation\n children?: KubbNode\n}\n\ntype GetParamsProps = {\n paramsCasing: PluginClient['resolvedOptions']['paramsCasing']\n paramsType: PluginClient['resolvedOptions']['paramsType']\n pathParamsType: PluginClient['resolvedOptions']['pathParamsType']\n typeSchemas: OperationSchemas\n isConfigurable: boolean\n}\n\nfunction getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas, isConfigurable }: GetParamsProps) {\n if (paramsType === 'object') {\n return FunctionParams.factory({\n data: {\n mode: 'object',\n children: {\n ...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n },\n },\n config: isConfigurable\n ? {\n type: typeSchemas.request?.name\n ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }`\n : 'Partial<RequestConfig> & { client?: typeof fetch }',\n default: '{}',\n }\n : undefined,\n })\n }\n\n return FunctionParams.factory({\n pathParams: typeSchemas.pathParams?.name\n ? {\n mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n optional: isOptional(typeSchemas.pathParams?.schema),\n }\n : undefined,\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n config: isConfigurable\n ? {\n type: typeSchemas.request?.name\n ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }`\n : 'Partial<RequestConfig> & { client?: typeof fetch }',\n default: '{}',\n }\n : undefined,\n })\n}\n\nexport function Client({\n name,\n isExportable = true,\n isIndexable = true,\n returnType,\n typeSchemas,\n baseURL,\n dataReturnType,\n parser,\n zodSchemas,\n paramsType,\n paramsCasing,\n pathParamsType,\n operation,\n urlName,\n children,\n isConfigurable = true,\n}: Props) {\n const path = new URLPath(operation.path, { casing: paramsCasing })\n const contentType = operation.getContentType()\n const isFormData = contentType === 'multipart/form-data'\n const headers = [\n contentType !== 'application/json' ? `'Content-Type': '${contentType}'` : undefined,\n typeSchemas.headerParams?.name ? '...headers' : undefined,\n ].filter(Boolean)\n\n const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'}>`\n\n const generics = [typeSchemas.response.name, TError, typeSchemas.request?.name || 'unknown'].filter(Boolean)\n const params = getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas, isConfigurable })\n const urlParams = Url.getParams({\n paramsType,\n paramsCasing,\n pathParamsType,\n typeSchemas,\n })\n const clientParams = FunctionParams.factory({\n config: {\n mode: 'object',\n children: {\n method: {\n value: JSON.stringify(operation.method.toUpperCase()),\n },\n url: {\n value: urlName ? `${urlName}(${urlParams.toCall()}).url.toString()` : path.template,\n },\n baseURL:\n baseURL && !urlName\n ? {\n value: JSON.stringify(baseURL),\n }\n : undefined,\n params: typeSchemas.queryParams?.name ? {} : undefined,\n data: typeSchemas.request?.name\n ? {\n value: isFormData ? 'formData' : 'requestData',\n }\n : undefined,\n requestConfig: isConfigurable\n ? {\n mode: 'inlineSpread',\n }\n : undefined,\n headers: headers.length\n ? {\n value: isConfigurable ? `{ ${headers.join(', ')}, ...requestConfig.headers }` : `{ ${headers.join(', ')} }`,\n }\n : undefined,\n },\n },\n })\n\n const formData = isFormData\n ? `\n const formData = new FormData()\n if (requestData) {\n Object.keys(requestData).forEach((key) => {\n const value = requestData[key as keyof typeof requestData];\n if (typeof value === 'string' || (value as unknown) instanceof Blob) {\n formData.append(key, value as unknown as string | Blob);\n } else {\n formData.append(key, JSON.stringify(value));\n }\n })\n }\n `\n : undefined\n\n const childrenElement = children ? (\n children\n ) : (\n <>\n {dataReturnType === 'full' && parser === 'zod' && zodSchemas && `return {...res, data: ${zodSchemas.response.name}.parse(res.data)}`}\n {dataReturnType === 'data' && parser === 'zod' && zodSchemas && `return ${zodSchemas.response.name}.parse(res.data)`}\n {dataReturnType === 'full' && parser === 'client' && 'return res'}\n {dataReturnType === 'data' && parser === 'client' && 'return res.data'}\n </>\n )\n\n return (\n <File.Source name={name} isExportable={isExportable} isIndexable={isIndexable}>\n <Function\n name={name}\n async\n export={isExportable}\n params={params.toConstructor()}\n JSDoc={{\n comments: getComments(operation),\n }}\n returnType={returnType}\n >\n {isConfigurable ? 'const { client: request = fetch, ...requestConfig } = config' : ''}\n <br />\n <br />\n {parser === 'zod' && zodSchemas?.request?.name && `const requestData = ${zodSchemas.request.name}.parse(data)`}\n {parser === 'client' && typeSchemas?.request?.name && 'const requestData = data'}\n <br />\n {formData}\n <br />\n {isConfigurable\n ? `const res = await request<${generics.join(', ')}>(${clientParams.toCall()})`\n : `const res = await fetch<${generics.join(', ')}>(${clientParams.toCall()})`}\n <br />\n {childrenElement}\n </Function>\n </File.Source>\n )\n}\n\nClient.getParams = getParams\n","import { URLPath } from '@kubb/core/utils'\nimport type { HttpMethod, Operation } from '@kubb/oas'\nimport { Const, File } from '@kubb/react'\n\ntype OperationsProps = {\n name: string\n operations: Array<Operation>\n}\n\nexport function Operations({ name, operations }: OperationsProps) {\n const operationsObject: Record<string, { path: string; method: HttpMethod }> = {}\n\n operations.forEach((operation) => {\n operationsObject[operation.getOperationId()] = {\n path: new URLPath(operation.path).URL,\n method: operation.method,\n }\n })\n\n return (\n <File.Source name={name} isExportable isIndexable>\n <Const name={name} export>\n {JSON.stringify(operationsObject, undefined, 2)}\n </Const>\n </File.Source>\n )\n}\n"],"mappings":";;;;;;;;;;;;;AA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