@kubb/plugin-client 4.3.0 → 4.4.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/dist/{Operations-ktPlsW1u.js → Operations-CmHRmAdn.js} +3 -3
- package/dist/Operations-CmHRmAdn.js.map +1 -0
- package/dist/{Operations-CT9m1j9w.cjs → Operations-DXjVfmrY.cjs} +24 -24
- package/dist/Operations-DXjVfmrY.cjs.map +1 -0
- package/dist/chunk-DMmIE7y6.js +28 -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 +9 -13
- package/dist/components.d.ts +9 -13
- package/dist/components.js +1 -1
- package/dist/{generators-BqXV2IXC.js → generators-0Sc5zPfx.js} +4 -4
- package/dist/generators-0Sc5zPfx.js.map +1 -0
- package/dist/{generators-BSxTToF6.cjs → generators-C_ySk_ES.cjs} +19 -19
- package/dist/generators-C_ySk_ES.cjs.map +1 -0
- package/dist/generators.cjs +2 -2
- package/dist/generators.d.cts +4 -4
- package/dist/generators.d.ts +4 -4
- package/dist/generators.js +2 -2
- package/dist/index.cjs +3 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/{types-rIa1K280.d.cts → types-BtM-bA4L.d.ts} +225 -209
- package/dist/{types-BPLzP9R9.d.ts → types-CMiGIvE1.d.cts} +220 -204
- package/package.json +10 -10
- package/src/components/Client.tsx +3 -3
- package/src/components/Operations.tsx +3 -2
- package/src/components/Url.tsx +13 -2
- package/src/generators/clientGenerator.tsx +1 -1
- package/src/generators/groupedClientGenerator.tsx +1 -1
- package/src/generators/operationsGenerator.tsx +1 -1
- package/src/plugin.ts +1 -0
- package/src/types.ts +1 -1
- package/dist/Operations-CT9m1j9w.cjs.map +0 -1
- package/dist/Operations-ktPlsW1u.js.map +0 -1
- package/dist/generators-BSxTToF6.cjs.map +0 -1
- package/dist/generators-BqXV2IXC.js.map +0 -1
|
@@ -4,11 +4,10 @@ import { Operation, Operation as Operation$1 } from "oas/operation";
|
|
|
4
4
|
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
|
+
import { Fabric, FileManager } from "@kubb/react-fabric";
|
|
7
8
|
import { ConsolaInstance, LogLevel } from "consola";
|
|
8
|
-
import {
|
|
9
|
+
import { KubbNode } from "@kubb/react-fabric/types";
|
|
9
10
|
|
|
10
|
-
//#region rolldown:runtime
|
|
11
|
-
//#endregion
|
|
12
11
|
//#region ../oas/src/types.d.ts
|
|
13
12
|
type contentType = 'application/json' | (string & {});
|
|
14
13
|
type SchemaObject$1 = OasTypes.SchemaObject & {
|
|
@@ -49,17 +48,17 @@ declare class Oas<const TOAS = unknown> extends BaseOas {
|
|
|
49
48
|
* Abstract class that contains the building blocks for plugins to create their own Generator
|
|
50
49
|
* @link idea based on https://github.com/colinhacks/zod/blob/master/src/types.ts#L137
|
|
51
50
|
*/
|
|
52
|
-
declare abstract class BaseGenerator<TOptions
|
|
51
|
+
declare abstract class BaseGenerator<TOptions = unknown, TContext = unknown> {
|
|
53
52
|
#private;
|
|
54
|
-
constructor(options?: TOptions
|
|
55
|
-
get options(): TOptions
|
|
53
|
+
constructor(options?: TOptions, context?: TContext);
|
|
54
|
+
get options(): TOptions;
|
|
56
55
|
get context(): TContext;
|
|
57
|
-
set options(options: TOptions
|
|
56
|
+
set options(options: TOptions);
|
|
58
57
|
abstract build(...params: unknown[]): unknown;
|
|
59
58
|
}
|
|
60
59
|
//#endregion
|
|
61
60
|
//#region ../core/src/fs/types.d.ts
|
|
62
|
-
type BasePath<T
|
|
61
|
+
type BasePath<T extends string = string> = `${T}/`;
|
|
63
62
|
type Import = {
|
|
64
63
|
/**
|
|
65
64
|
* Import name to be used
|
|
@@ -133,7 +132,7 @@ type BaseName = `${string}.${string}`;
|
|
|
133
132
|
* Path will be full qualified path to a specified file
|
|
134
133
|
*/
|
|
135
134
|
type Path = string;
|
|
136
|
-
type AdvancedPath<T
|
|
135
|
+
type AdvancedPath<T extends BaseName = BaseName> = `${BasePath}${T}`;
|
|
137
136
|
type OptionalPath = Path | undefined | null;
|
|
138
137
|
type File<TMeta extends object = object> = {
|
|
139
138
|
/**
|
|
@@ -222,7 +221,7 @@ type Logger = {
|
|
|
222
221
|
};
|
|
223
222
|
//#endregion
|
|
224
223
|
//#region ../core/src/utils/types.d.ts
|
|
225
|
-
type PossiblePromise<T
|
|
224
|
+
type PossiblePromise<T> = Promise<T> | T;
|
|
226
225
|
//#endregion
|
|
227
226
|
//#region ../core/src/types.d.ts
|
|
228
227
|
type InputPath = {
|
|
@@ -335,11 +334,11 @@ TName extends string = string,
|
|
|
335
334
|
/**
|
|
336
335
|
* Options of the plugin.
|
|
337
336
|
*/
|
|
338
|
-
TOptions
|
|
337
|
+
TOptions extends object = object,
|
|
339
338
|
/**
|
|
340
339
|
* Options of the plugin that can be used later on, see `options` inside your plugin config.
|
|
341
340
|
*/
|
|
342
|
-
TResolvedOptions extends object = TOptions
|
|
341
|
+
TResolvedOptions extends object = TOptions,
|
|
343
342
|
/**
|
|
344
343
|
* Context that you want to expose to other plugins.
|
|
345
344
|
*/
|
|
@@ -353,23 +352,23 @@ TResolvePathOptions extends object = object> = {
|
|
|
353
352
|
* Same behaviour like what has been done with `QueryKey` in `@tanstack/react-query`
|
|
354
353
|
*/
|
|
355
354
|
key: PluginKey<TName | string>;
|
|
356
|
-
options: TOptions
|
|
355
|
+
options: TOptions;
|
|
357
356
|
resolvedOptions: TResolvedOptions;
|
|
358
357
|
context: TContext;
|
|
359
358
|
resolvePathOptions: TResolvePathOptions;
|
|
360
359
|
};
|
|
361
360
|
type PluginKey<TName> = [name: TName, identifier?: string | number];
|
|
362
|
-
type UserPlugin<TOptions
|
|
361
|
+
type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
363
362
|
/**
|
|
364
363
|
* Unique name used for the plugin
|
|
365
364
|
* The name of the plugin follows the format scope:foo-bar or foo-bar, adding scope: can avoid naming conflicts with other plugins.
|
|
366
365
|
* @example @kubb/typescript
|
|
367
366
|
*/
|
|
368
|
-
name: TOptions
|
|
367
|
+
name: TOptions['name'];
|
|
369
368
|
/**
|
|
370
369
|
* Options set for a specific plugin(see kubb.config.js), passthrough of options.
|
|
371
370
|
*/
|
|
372
|
-
options: TOptions
|
|
371
|
+
options: TOptions['resolvedOptions'];
|
|
373
372
|
/**
|
|
374
373
|
* 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
374
|
* Can be used to validate dependent plugins.
|
|
@@ -379,23 +378,23 @@ type UserPlugin<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions>
|
|
|
379
378
|
* 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
379
|
*/
|
|
381
380
|
post?: Array<string>;
|
|
382
|
-
} & (TOptions
|
|
381
|
+
} & (TOptions['context'] extends never ? {
|
|
383
382
|
context?: never;
|
|
384
383
|
} : {
|
|
385
|
-
context: (this: TOptions
|
|
384
|
+
context: (this: TOptions['name'] extends 'core' ? null : Omit<PluginContext<TOptions>, 'addFile'>) => TOptions['context'];
|
|
386
385
|
});
|
|
387
|
-
type UserPluginWithLifeCycle<TOptions
|
|
388
|
-
type Plugin<TOptions
|
|
386
|
+
type UserPluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = UserPlugin<TOptions> & PluginLifecycle<TOptions>;
|
|
387
|
+
type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
389
388
|
/**
|
|
390
389
|
* Unique name used for the plugin
|
|
391
390
|
* @example @kubb/typescript
|
|
392
391
|
*/
|
|
393
|
-
name: TOptions
|
|
392
|
+
name: TOptions['name'];
|
|
394
393
|
/**
|
|
395
394
|
* Internal key used when a developer uses more than one of the same plugin
|
|
396
395
|
* @private
|
|
397
396
|
*/
|
|
398
|
-
key: TOptions
|
|
397
|
+
key: TOptions['key'];
|
|
399
398
|
/**
|
|
400
399
|
* 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
400
|
* Can be used to validate dependent plugins.
|
|
@@ -408,49 +407,49 @@ type Plugin<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
|
408
407
|
/**
|
|
409
408
|
* Options set for a specific plugin(see kubb.config.js), passthrough of options.
|
|
410
409
|
*/
|
|
411
|
-
options: TOptions
|
|
412
|
-
} & (TOptions
|
|
410
|
+
options: TOptions['resolvedOptions'];
|
|
411
|
+
} & (TOptions['context'] extends never ? {
|
|
413
412
|
context?: never;
|
|
414
413
|
} : {
|
|
415
|
-
context: TOptions
|
|
414
|
+
context: TOptions['context'];
|
|
416
415
|
});
|
|
417
|
-
type PluginWithLifeCycle<TOptions
|
|
418
|
-
type PluginLifecycle<TOptions
|
|
416
|
+
type PluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions> & PluginLifecycle<TOptions>;
|
|
417
|
+
type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
419
418
|
/**
|
|
420
419
|
* Start of the lifecycle of a plugin.
|
|
421
420
|
* @type hookParallel
|
|
422
421
|
*/
|
|
423
|
-
buildStart?: (this: PluginContext<TOptions
|
|
422
|
+
buildStart?: (this: PluginContext<TOptions>, Config: Config) => PossiblePromise<void>;
|
|
424
423
|
/**
|
|
425
424
|
* Resolve to a Path based on a baseName(example: `./Pet.ts`) and directory(example: `./models`).
|
|
426
425
|
* Options can als be included.
|
|
427
426
|
* @type hookFirst
|
|
428
427
|
* @example ('./Pet.ts', './src/gen/') => '/src/gen/Pet.ts'
|
|
429
428
|
*/
|
|
430
|
-
resolvePath?: (this: PluginContext<TOptions
|
|
429
|
+
resolvePath?: (this: PluginContext<TOptions>, baseName: BaseName, mode?: Mode, options?: TOptions['resolvePathOptions']) => OptionalPath;
|
|
431
430
|
/**
|
|
432
431
|
* Resolve to a name based on a string.
|
|
433
432
|
* Useful when converting to PascalCase or camelCase.
|
|
434
433
|
* @type hookFirst
|
|
435
434
|
* @example ('pet') => 'Pet'
|
|
436
435
|
*/
|
|
437
|
-
resolveName?: (this: PluginContext<TOptions
|
|
436
|
+
resolveName?: (this: PluginContext<TOptions>, name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
438
437
|
/**
|
|
439
438
|
* End of the plugin lifecycle.
|
|
440
439
|
* @type hookParallel
|
|
441
440
|
*/
|
|
442
|
-
buildEnd?: (this: PluginContext<TOptions
|
|
441
|
+
buildEnd?: (this: PluginContext<TOptions>) => PossiblePromise<void>;
|
|
443
442
|
};
|
|
444
443
|
type PluginLifecycleHooks = keyof PluginLifecycle;
|
|
445
|
-
type PluginParameter<H
|
|
446
|
-
type ResolvePathParams<TOptions
|
|
444
|
+
type PluginParameter<H extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H]>;
|
|
445
|
+
type ResolvePathParams<TOptions = object> = {
|
|
447
446
|
pluginKey?: Plugin['key'];
|
|
448
447
|
baseName: BaseName;
|
|
449
448
|
mode?: Mode;
|
|
450
449
|
/**
|
|
451
450
|
* Options to be passed to 'resolvePath' 3th parameter
|
|
452
451
|
*/
|
|
453
|
-
options?: TOptions
|
|
452
|
+
options?: TOptions;
|
|
454
453
|
};
|
|
455
454
|
type ResolveNameParams = {
|
|
456
455
|
name: string;
|
|
@@ -463,7 +462,8 @@ type ResolveNameParams = {
|
|
|
463
462
|
*/
|
|
464
463
|
type?: 'file' | 'function' | 'type' | 'const';
|
|
465
464
|
};
|
|
466
|
-
type PluginContext<TOptions
|
|
465
|
+
type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
466
|
+
fabric: Fabric;
|
|
467
467
|
config: Config;
|
|
468
468
|
/**
|
|
469
469
|
* @deprecated
|
|
@@ -471,7 +471,7 @@ type PluginContext<TOptions$1 extends PluginFactoryOptions = PluginFactoryOption
|
|
|
471
471
|
fileManager: FileManager;
|
|
472
472
|
pluginManager: PluginManager;
|
|
473
473
|
addFile: (...file: Array<File>) => Promise<Array<ResolvedFile>>;
|
|
474
|
-
resolvePath: (params: ResolvePathParams<TOptions
|
|
474
|
+
resolvePath: (params: ResolvePathParams<TOptions['resolvePathOptions']>) => OptionalPath;
|
|
475
475
|
resolveName: (params: ResolveNameParams) => string;
|
|
476
476
|
logger: Logger;
|
|
477
477
|
/**
|
|
@@ -481,12 +481,12 @@ type PluginContext<TOptions$1 extends PluginFactoryOptions = PluginFactoryOption
|
|
|
481
481
|
/**
|
|
482
482
|
* Current plugin
|
|
483
483
|
*/
|
|
484
|
-
plugin: Plugin<TOptions
|
|
484
|
+
plugin: Plugin<TOptions>;
|
|
485
485
|
};
|
|
486
486
|
/**
|
|
487
487
|
* Specify the export location for the files and define the behavior of the output
|
|
488
488
|
*/
|
|
489
|
-
type Output<TOptions
|
|
489
|
+
type Output<TOptions> = {
|
|
490
490
|
/**
|
|
491
491
|
* Path to the output folder or file that will contain the generated code
|
|
492
492
|
*/
|
|
@@ -499,11 +499,11 @@ type Output<TOptions$1> = {
|
|
|
499
499
|
/**
|
|
500
500
|
* Add a banner text in the beginning of every file
|
|
501
501
|
*/
|
|
502
|
-
banner?: string | ((options: TOptions
|
|
502
|
+
banner?: string | ((options: TOptions) => string);
|
|
503
503
|
/**
|
|
504
504
|
* Add a footer text in the beginning of every file
|
|
505
505
|
*/
|
|
506
|
-
footer?: string | ((options: TOptions
|
|
506
|
+
footer?: string | ((options: TOptions) => string);
|
|
507
507
|
};
|
|
508
508
|
type GroupContext = {
|
|
509
509
|
group: string;
|
|
@@ -522,20 +522,21 @@ type Group = {
|
|
|
522
522
|
//#region ../core/src/PluginManager.d.ts
|
|
523
523
|
type RequiredPluginLifecycle = Required<PluginLifecycle>;
|
|
524
524
|
type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
|
|
525
|
-
type Executer<H
|
|
525
|
+
type Executer<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
526
526
|
message: string;
|
|
527
527
|
strategy: Strategy;
|
|
528
|
-
hookName: H
|
|
528
|
+
hookName: H;
|
|
529
529
|
plugin: Plugin;
|
|
530
530
|
parameters?: unknown[] | undefined;
|
|
531
531
|
output?: unknown;
|
|
532
532
|
};
|
|
533
|
-
type ParseResult<H
|
|
534
|
-
type SafeParseResult<H
|
|
533
|
+
type ParseResult<H extends PluginLifecycleHooks> = RequiredPluginLifecycle[H];
|
|
534
|
+
type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {
|
|
535
535
|
result: Result;
|
|
536
536
|
plugin: Plugin;
|
|
537
537
|
};
|
|
538
538
|
type Options$2 = {
|
|
539
|
+
fabric: Fabric;
|
|
539
540
|
logger: Logger;
|
|
540
541
|
/**
|
|
541
542
|
* @default Number.POSITIVE_INFINITY
|
|
@@ -547,20 +548,16 @@ type Events = {
|
|
|
547
548
|
executed: [executer: Executer];
|
|
548
549
|
error: [error: Error];
|
|
549
550
|
};
|
|
550
|
-
type GetFileProps<TOptions
|
|
551
|
+
type GetFileProps<TOptions = object> = {
|
|
551
552
|
name: string;
|
|
552
553
|
mode?: Mode;
|
|
553
554
|
extname: Extname;
|
|
554
555
|
pluginKey: Plugin['key'];
|
|
555
|
-
options?: TOptions
|
|
556
|
+
options?: TOptions;
|
|
556
557
|
};
|
|
557
558
|
declare class PluginManager {
|
|
558
559
|
#private;
|
|
559
560
|
readonly plugins: Set<Plugin<PluginFactoryOptions<string, object, object, any, object>>>;
|
|
560
|
-
/**
|
|
561
|
-
* @deprecated do not use from pluginManager
|
|
562
|
-
*/
|
|
563
|
-
readonly fileManager: FileManager;
|
|
564
561
|
readonly events: EventEmitter<Events>;
|
|
565
562
|
readonly config: Config;
|
|
566
563
|
readonly executed: Array<Executer>;
|
|
@@ -672,7 +669,170 @@ declare class PluginManager {
|
|
|
672
669
|
type FileMetaBase = {
|
|
673
670
|
pluginKey?: Plugin['key'];
|
|
674
671
|
};
|
|
675
|
-
|
|
672
|
+
//#endregion
|
|
673
|
+
//#region ../plugin-oas/src/generators/createReactGenerator.d.ts
|
|
674
|
+
type ReactGenerator<TOptions extends PluginFactoryOptions> = {
|
|
675
|
+
name: string;
|
|
676
|
+
type: 'react';
|
|
677
|
+
Operations: (props: OperationsProps<TOptions>) => KubbNode;
|
|
678
|
+
Operation: (props: OperationProps<TOptions>) => KubbNode;
|
|
679
|
+
Schema: (props: SchemaProps$1<TOptions>) => KubbNode;
|
|
680
|
+
};
|
|
681
|
+
//#endregion
|
|
682
|
+
//#region ../plugin-oas/src/generators/types.d.ts
|
|
683
|
+
type OperationsProps<TOptions extends PluginFactoryOptions> = {
|
|
684
|
+
/**
|
|
685
|
+
* @deprecated
|
|
686
|
+
*/
|
|
687
|
+
instance: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
688
|
+
options: TOptions['resolvedOptions'];
|
|
689
|
+
operations: Array<Operation$1>;
|
|
690
|
+
};
|
|
691
|
+
type OperationProps<TOptions extends PluginFactoryOptions> = {
|
|
692
|
+
/**
|
|
693
|
+
* @deprecated
|
|
694
|
+
*/
|
|
695
|
+
instance: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
696
|
+
options: TOptions['resolvedOptions'];
|
|
697
|
+
operation: Operation$1;
|
|
698
|
+
};
|
|
699
|
+
type SchemaProps$1<TOptions extends PluginFactoryOptions> = {
|
|
700
|
+
instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>;
|
|
701
|
+
options: TOptions['resolvedOptions'];
|
|
702
|
+
schema: {
|
|
703
|
+
name: string;
|
|
704
|
+
tree: Array<Schema>;
|
|
705
|
+
value: SchemaObject$1;
|
|
706
|
+
};
|
|
707
|
+
};
|
|
708
|
+
type Generator<TOptions extends PluginFactoryOptions> = CoreGenerator<TOptions> | ReactGenerator<TOptions>;
|
|
709
|
+
//#endregion
|
|
710
|
+
//#region ../plugin-oas/src/generators/createGenerator.d.ts
|
|
711
|
+
type CoreGenerator<TOptions extends PluginFactoryOptions> = {
|
|
712
|
+
name: string;
|
|
713
|
+
type: 'core';
|
|
714
|
+
operations: (props: OperationsProps<TOptions>) => Promise<File[]>;
|
|
715
|
+
operation: (props: OperationProps<TOptions>) => Promise<File[]>;
|
|
716
|
+
schema: (props: SchemaProps$1<TOptions>) => Promise<File[]>;
|
|
717
|
+
};
|
|
718
|
+
//#endregion
|
|
719
|
+
//#region ../plugin-oas/src/types.d.ts
|
|
720
|
+
type ResolvePathOptions = {
|
|
721
|
+
pluginKey?: Plugin['key'];
|
|
722
|
+
group?: {
|
|
723
|
+
tag?: string;
|
|
724
|
+
path?: string;
|
|
725
|
+
};
|
|
726
|
+
type?: ResolveNameParams['type'];
|
|
727
|
+
};
|
|
728
|
+
/**
|
|
729
|
+
* `propertyName` is the ref name + resolved with the nameResolver
|
|
730
|
+
* @example import { Pet } from './Pet'
|
|
731
|
+
*
|
|
732
|
+
* `originalName` is the original name used(in PascalCase), only used to remove duplicates
|
|
733
|
+
*
|
|
734
|
+
* `pluginKey` can be used to override the current plugin being used, handy when you want to import a type/schema out of another plugin
|
|
735
|
+
* @example import a type(plugin-ts) for a mock file(swagger-faker)
|
|
736
|
+
*/
|
|
737
|
+
type Ref = {
|
|
738
|
+
propertyName: string;
|
|
739
|
+
originalName: string;
|
|
740
|
+
path: OptionalPath;
|
|
741
|
+
pluginKey?: Plugin['key'];
|
|
742
|
+
};
|
|
743
|
+
type Refs = Record<string, Ref>;
|
|
744
|
+
type OperationSchema = {
|
|
745
|
+
/**
|
|
746
|
+
* Converted name, contains already `PathParams`, `QueryParams`, ...
|
|
747
|
+
*/
|
|
748
|
+
name: string;
|
|
749
|
+
schema: SchemaObject$1;
|
|
750
|
+
operation?: Operation$1;
|
|
751
|
+
/**
|
|
752
|
+
* OperationName in PascalCase, only being used in OperationGenerator
|
|
753
|
+
*/
|
|
754
|
+
operationName: string;
|
|
755
|
+
description?: string;
|
|
756
|
+
statusCode?: number;
|
|
757
|
+
keys?: string[];
|
|
758
|
+
keysToOmit?: string[];
|
|
759
|
+
withData?: boolean;
|
|
760
|
+
};
|
|
761
|
+
type OperationSchemas = {
|
|
762
|
+
pathParams?: OperationSchema & {
|
|
763
|
+
keysToOmit?: never;
|
|
764
|
+
};
|
|
765
|
+
queryParams?: OperationSchema & {
|
|
766
|
+
keysToOmit?: never;
|
|
767
|
+
};
|
|
768
|
+
headerParams?: OperationSchema & {
|
|
769
|
+
keysToOmit?: never;
|
|
770
|
+
};
|
|
771
|
+
request?: OperationSchema;
|
|
772
|
+
response: OperationSchema;
|
|
773
|
+
responses: Array<OperationSchema>;
|
|
774
|
+
statusCodes?: Array<OperationSchema>;
|
|
775
|
+
errors?: Array<OperationSchema>;
|
|
776
|
+
};
|
|
777
|
+
type ByTag = {
|
|
778
|
+
type: 'tag';
|
|
779
|
+
pattern: string | RegExp;
|
|
780
|
+
};
|
|
781
|
+
type ByOperationId = {
|
|
782
|
+
type: 'operationId';
|
|
783
|
+
pattern: string | RegExp;
|
|
784
|
+
};
|
|
785
|
+
type ByPath = {
|
|
786
|
+
type: 'path';
|
|
787
|
+
pattern: string | RegExp;
|
|
788
|
+
};
|
|
789
|
+
type ByMethod = {
|
|
790
|
+
type: 'method';
|
|
791
|
+
pattern: HttpMethod | RegExp;
|
|
792
|
+
};
|
|
793
|
+
type BySchemaName = {
|
|
794
|
+
type: 'schemaName';
|
|
795
|
+
pattern: string | RegExp;
|
|
796
|
+
};
|
|
797
|
+
type ByContentType = {
|
|
798
|
+
type: 'contentType';
|
|
799
|
+
pattern: string | RegExp;
|
|
800
|
+
};
|
|
801
|
+
type Exclude$1 = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
|
|
802
|
+
type Include = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
|
|
803
|
+
type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName | ByContentType) & {
|
|
804
|
+
options: Partial<TOptions>;
|
|
805
|
+
};
|
|
806
|
+
//#endregion
|
|
807
|
+
//#region ../plugin-oas/src/OperationGenerator.d.ts
|
|
808
|
+
type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
809
|
+
fabric: Fabric;
|
|
810
|
+
oas: Oas;
|
|
811
|
+
exclude: Array<Exclude$1> | undefined;
|
|
812
|
+
include: Array<Include> | undefined;
|
|
813
|
+
override: Array<Override<TOptions>> | undefined;
|
|
814
|
+
contentType: contentType | undefined;
|
|
815
|
+
pluginManager: PluginManager;
|
|
816
|
+
/**
|
|
817
|
+
* Current plugin
|
|
818
|
+
*/
|
|
819
|
+
plugin: Plugin<TPluginOptions>;
|
|
820
|
+
mode: Mode;
|
|
821
|
+
};
|
|
822
|
+
declare class OperationGenerator<TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TPluginOptions['resolvedOptions'], Context$1<TPluginOptions['resolvedOptions'], TPluginOptions>> {
|
|
823
|
+
#private;
|
|
824
|
+
getSchemas(operation: Operation$1, {
|
|
825
|
+
resolveName
|
|
826
|
+
}?: {
|
|
827
|
+
resolveName?: (name: string) => string;
|
|
828
|
+
}): OperationSchemas;
|
|
829
|
+
getOperations(): Promise<Array<{
|
|
830
|
+
path: string;
|
|
831
|
+
method: HttpMethod;
|
|
832
|
+
operation: Operation$1;
|
|
833
|
+
}>>;
|
|
834
|
+
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<File<TFileMeta>>>;
|
|
835
|
+
}
|
|
676
836
|
//#endregion
|
|
677
837
|
//#region ../plugin-oas/src/SchemaMapper.d.ts
|
|
678
838
|
type SchemaKeywordMapper = {
|
|
@@ -891,96 +1051,9 @@ type Schema = {
|
|
|
891
1051
|
keyword: string;
|
|
892
1052
|
} | SchemaKeywordMapper[keyof SchemaKeywordMapper];
|
|
893
1053
|
//#endregion
|
|
894
|
-
//#region ../plugin-oas/src/types.d.ts
|
|
895
|
-
type ResolvePathOptions = {
|
|
896
|
-
pluginKey?: Plugin['key'];
|
|
897
|
-
group?: {
|
|
898
|
-
tag?: string;
|
|
899
|
-
path?: string;
|
|
900
|
-
};
|
|
901
|
-
type?: ResolveNameParams['type'];
|
|
902
|
-
};
|
|
903
|
-
/**
|
|
904
|
-
* `propertyName` is the ref name + resolved with the nameResolver
|
|
905
|
-
* @example import { Pet } from './Pet'
|
|
906
|
-
*
|
|
907
|
-
* `originalName` is the original name used(in PascalCase), only used to remove duplicates
|
|
908
|
-
*
|
|
909
|
-
* `pluginKey` can be used to override the current plugin being used, handy when you want to import a type/schema out of another plugin
|
|
910
|
-
* @example import a type(plugin-ts) for a mock file(swagger-faker)
|
|
911
|
-
*/
|
|
912
|
-
type Ref = {
|
|
913
|
-
propertyName: string;
|
|
914
|
-
originalName: string;
|
|
915
|
-
path: OptionalPath;
|
|
916
|
-
pluginKey?: Plugin['key'];
|
|
917
|
-
};
|
|
918
|
-
type Refs = Record<string, Ref>;
|
|
919
|
-
type OperationSchema = {
|
|
920
|
-
/**
|
|
921
|
-
* Converted name, contains already `PathParams`, `QueryParams`, ...
|
|
922
|
-
*/
|
|
923
|
-
name: string;
|
|
924
|
-
schema: SchemaObject$1;
|
|
925
|
-
operation?: Operation$1;
|
|
926
|
-
/**
|
|
927
|
-
* OperationName in PascalCase, only being used in OperationGenerator
|
|
928
|
-
*/
|
|
929
|
-
operationName: string;
|
|
930
|
-
description?: string;
|
|
931
|
-
statusCode?: number;
|
|
932
|
-
keys?: string[];
|
|
933
|
-
keysToOmit?: string[];
|
|
934
|
-
withData?: boolean;
|
|
935
|
-
};
|
|
936
|
-
type OperationSchemas = {
|
|
937
|
-
pathParams?: OperationSchema & {
|
|
938
|
-
keysToOmit?: never;
|
|
939
|
-
};
|
|
940
|
-
queryParams?: OperationSchema & {
|
|
941
|
-
keysToOmit?: never;
|
|
942
|
-
};
|
|
943
|
-
headerParams?: OperationSchema & {
|
|
944
|
-
keysToOmit?: never;
|
|
945
|
-
};
|
|
946
|
-
request?: OperationSchema;
|
|
947
|
-
response: OperationSchema;
|
|
948
|
-
responses: Array<OperationSchema>;
|
|
949
|
-
statusCodes?: Array<OperationSchema>;
|
|
950
|
-
errors?: Array<OperationSchema>;
|
|
951
|
-
};
|
|
952
|
-
type ByTag = {
|
|
953
|
-
type: 'tag';
|
|
954
|
-
pattern: string | RegExp;
|
|
955
|
-
};
|
|
956
|
-
type ByOperationId = {
|
|
957
|
-
type: 'operationId';
|
|
958
|
-
pattern: string | RegExp;
|
|
959
|
-
};
|
|
960
|
-
type ByPath = {
|
|
961
|
-
type: 'path';
|
|
962
|
-
pattern: string | RegExp;
|
|
963
|
-
};
|
|
964
|
-
type ByMethod = {
|
|
965
|
-
type: 'method';
|
|
966
|
-
pattern: HttpMethod | RegExp;
|
|
967
|
-
};
|
|
968
|
-
type BySchemaName = {
|
|
969
|
-
type: 'schemaName';
|
|
970
|
-
pattern: string | RegExp;
|
|
971
|
-
};
|
|
972
|
-
type ByContentType = {
|
|
973
|
-
type: 'contentType';
|
|
974
|
-
pattern: string | RegExp;
|
|
975
|
-
};
|
|
976
|
-
type Exclude$1 = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
|
|
977
|
-
type Include = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
|
|
978
|
-
type Override<TOptions$1> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName | ByContentType) & {
|
|
979
|
-
options: Partial<TOptions$1>;
|
|
980
|
-
};
|
|
981
|
-
//#endregion
|
|
982
1054
|
//#region ../plugin-oas/src/SchemaGenerator.d.ts
|
|
983
|
-
type Context
|
|
1055
|
+
type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
1056
|
+
fabric: Fabric;
|
|
984
1057
|
oas: Oas;
|
|
985
1058
|
pluginManager: PluginManager;
|
|
986
1059
|
/**
|
|
@@ -989,7 +1062,7 @@ type Context$1<TOptions$1, TPluginOptions extends PluginFactoryOptions> = {
|
|
|
989
1062
|
plugin: Plugin<TPluginOptions>;
|
|
990
1063
|
mode: Mode;
|
|
991
1064
|
include?: Array<'schemas' | 'responses' | 'requestBodies'>;
|
|
992
|
-
override: Array<Override<TOptions
|
|
1065
|
+
override: Array<Override<TOptions>> | undefined;
|
|
993
1066
|
contentType?: contentType;
|
|
994
1067
|
output?: string;
|
|
995
1068
|
};
|
|
@@ -1012,15 +1085,15 @@ type SchemaGeneratorOptions = {
|
|
|
1012
1085
|
* TODO TODO add docs
|
|
1013
1086
|
* @beta
|
|
1014
1087
|
*/
|
|
1015
|
-
schema?: (schemaProps: SchemaProps
|
|
1088
|
+
schema?: (schemaProps: SchemaProps, defaultSchemas: Schema[]) => Schema[] | undefined;
|
|
1016
1089
|
};
|
|
1017
1090
|
};
|
|
1018
|
-
type SchemaProps
|
|
1091
|
+
type SchemaProps = {
|
|
1019
1092
|
schemaObject?: SchemaObject$1;
|
|
1020
1093
|
name?: string;
|
|
1021
1094
|
parentName?: string;
|
|
1022
1095
|
};
|
|
1023
|
-
declare class SchemaGenerator<TOptions
|
|
1096
|
+
declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions, Context<TOptions, TPluginOptions>> {
|
|
1024
1097
|
#private;
|
|
1025
1098
|
refs: Refs;
|
|
1026
1099
|
/**
|
|
@@ -1028,7 +1101,7 @@ declare class SchemaGenerator<TOptions$1 extends SchemaGeneratorOptions = Schema
|
|
|
1028
1101
|
* Delegates to getBaseTypeFromSchema internally and
|
|
1029
1102
|
* optionally adds a union with null.
|
|
1030
1103
|
*/
|
|
1031
|
-
parse(props: SchemaProps
|
|
1104
|
+
parse(props: SchemaProps): Schema[];
|
|
1032
1105
|
deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
|
|
1033
1106
|
find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
1034
1107
|
static deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
|
|
@@ -1038,63 +1111,6 @@ declare class SchemaGenerator<TOptions$1 extends SchemaGeneratorOptions = Schema
|
|
|
1038
1111
|
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<File<TFileMeta>>>;
|
|
1039
1112
|
}
|
|
1040
1113
|
//#endregion
|
|
1041
|
-
//#region ../plugin-oas/src/generator.d.ts
|
|
1042
|
-
type OperationsProps<TOptions$1 extends PluginFactoryOptions> = {
|
|
1043
|
-
instance: Omit<OperationGenerator<TOptions$1>, 'build'>;
|
|
1044
|
-
options: TOptions$1['resolvedOptions'];
|
|
1045
|
-
operations: Array<Operation$1>;
|
|
1046
|
-
};
|
|
1047
|
-
type OperationProps<TOptions$1 extends PluginFactoryOptions> = {
|
|
1048
|
-
instance: Omit<OperationGenerator<TOptions$1>, 'build'>;
|
|
1049
|
-
options: TOptions$1['resolvedOptions'];
|
|
1050
|
-
operation: Operation$1;
|
|
1051
|
-
};
|
|
1052
|
-
type SchemaProps<TOptions$1 extends PluginFactoryOptions> = {
|
|
1053
|
-
instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions$1>, 'build'>;
|
|
1054
|
-
options: TOptions$1['resolvedOptions'];
|
|
1055
|
-
schema: {
|
|
1056
|
-
name: string;
|
|
1057
|
-
tree: Array<Schema>;
|
|
1058
|
-
value: SchemaObject$1;
|
|
1059
|
-
};
|
|
1060
|
-
};
|
|
1061
|
-
type GeneratorOptions<TOptions$1 extends PluginFactoryOptions> = {
|
|
1062
|
-
name: string;
|
|
1063
|
-
operations?: (this: GeneratorOptions<TOptions$1>, props: OperationsProps<TOptions$1>) => Promise<File[]>;
|
|
1064
|
-
operation?: (this: GeneratorOptions<TOptions$1>, props: OperationProps<TOptions$1>) => Promise<File[]>;
|
|
1065
|
-
schema?: (this: GeneratorOptions<TOptions$1>, props: SchemaProps<TOptions$1>) => Promise<File[]>;
|
|
1066
|
-
};
|
|
1067
|
-
type Generator<TOptions$1 extends PluginFactoryOptions> = GeneratorOptions<TOptions$1>;
|
|
1068
|
-
//#endregion
|
|
1069
|
-
//#region ../plugin-oas/src/OperationGenerator.d.ts
|
|
1070
|
-
type Context<TOptions$1, TPluginOptions extends PluginFactoryOptions> = {
|
|
1071
|
-
oas: Oas;
|
|
1072
|
-
exclude: Array<Exclude$1> | undefined;
|
|
1073
|
-
include: Array<Include> | undefined;
|
|
1074
|
-
override: Array<Override<TOptions$1>> | undefined;
|
|
1075
|
-
contentType: contentType | undefined;
|
|
1076
|
-
pluginManager: PluginManager;
|
|
1077
|
-
/**
|
|
1078
|
-
* Current plugin
|
|
1079
|
-
*/
|
|
1080
|
-
plugin: Plugin<TPluginOptions>;
|
|
1081
|
-
mode: Mode;
|
|
1082
|
-
};
|
|
1083
|
-
declare class OperationGenerator<TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TPluginOptions['resolvedOptions'], Context<TPluginOptions['resolvedOptions'], TPluginOptions>> {
|
|
1084
|
-
#private;
|
|
1085
|
-
getSchemas(operation: Operation$1, {
|
|
1086
|
-
resolveName
|
|
1087
|
-
}?: {
|
|
1088
|
-
resolveName?: (name: string) => string;
|
|
1089
|
-
}): OperationSchemas;
|
|
1090
|
-
getOperations(): Promise<Array<{
|
|
1091
|
-
path: string;
|
|
1092
|
-
method: HttpMethod;
|
|
1093
|
-
operation: Operation$1;
|
|
1094
|
-
}>>;
|
|
1095
|
-
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<File<TFileMeta>>>;
|
|
1096
|
-
}
|
|
1097
|
-
//#endregion
|
|
1098
1114
|
//#region src/types.d.ts
|
|
1099
1115
|
type Options$1 = {
|
|
1100
1116
|
/**
|
|
@@ -1210,5 +1226,5 @@ type ResolvedOptions = {
|
|
|
1210
1226
|
};
|
|
1211
1227
|
type PluginClient = PluginFactoryOptions<'plugin-client', Options$1, ResolvedOptions, never, ResolvePathOptions>;
|
|
1212
1228
|
//#endregion
|
|
1213
|
-
export {
|
|
1214
|
-
//# sourceMappingURL=types-
|
|
1229
|
+
export { UserPluginWithLifeCycle as a, ReactGenerator as i, PluginClient as n, Operation$1 as o, OperationSchemas as r, Options$1 as t };
|
|
1230
|
+
//# sourceMappingURL=types-CMiGIvE1.d.cts.map
|