@kubb/plugin-mcp 4.4.1 → 4.5.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/{SchemaGenerator-geilI4rJ.d.ts → OperationGenerator-Beq8iOZY.d.cts} +169 -175
- package/dist/components.d.cts +1 -1
- package/dist/components.d.ts +1 -1
- package/dist/{generators-8HowWmDg.cjs → generators-CSDgJv8G.cjs} +50 -23
- package/dist/generators-CSDgJv8G.cjs.map +1 -0
- package/dist/{generators-Bp0d1HbP.js → generators-DP6UAisL.js} +45 -19
- package/dist/generators-DP6UAisL.js.map +1 -0
- package/dist/generators.cjs +1 -1
- package/dist/generators.d.cts +2 -2
- package/dist/generators.d.ts +2 -2
- package/dist/generators.js +1 -1
- package/dist/{SchemaGenerator-Bu2D8QtI.d.cts → index-BlpJVG8h.d.ts} +169 -175
- package/dist/index.cjs +15 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +14 -2
- package/dist/index.js.map +1 -1
- package/dist/{types-DXH0aZQO.d.ts → types-B4xu5uHh.d.cts} +9 -10
- package/dist/{types-BPcoHHAu.d.cts → types-Cy3TnfH5.d.ts} +9 -10
- package/package.json +9 -9
- package/src/generators/mcpGenerator.tsx +27 -8
- package/src/generators/serverGenerator.tsx +5 -5
- package/src/plugin.ts +25 -1
- package/src/types.ts +4 -3
- package/dist/generators-8HowWmDg.cjs.map +0 -1
- package/dist/generators-Bp0d1HbP.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Fabric, FileManager } from "@kubb/react-fabric";
|
|
2
1
|
import { KubbFile } from "@kubb/fabric-core/types";
|
|
2
|
+
import { Fabric, FileManager } from "@kubb/react-fabric";
|
|
3
3
|
import { ConsolaInstance, LogLevel } from "consola";
|
|
4
4
|
import * as OasTypes from "oas/types";
|
|
5
5
|
import { HttpMethods as HttpMethod, OASDocument, SchemaObject, User } from "oas/types";
|
|
@@ -556,170 +556,6 @@ declare class Oas<const TOAS = unknown> extends BaseOas {
|
|
|
556
556
|
valdiate(): Promise<oas_normalize_lib_types0.ValidationResult>;
|
|
557
557
|
}
|
|
558
558
|
//#endregion
|
|
559
|
-
//#region ../plugin-oas/src/generators/createReactGenerator.d.ts
|
|
560
|
-
type ReactGenerator<TOptions extends PluginFactoryOptions> = {
|
|
561
|
-
name: string;
|
|
562
|
-
type: 'react';
|
|
563
|
-
Operations: (props: OperationsProps<TOptions>) => KubbNode;
|
|
564
|
-
Operation: (props: OperationProps<TOptions>) => KubbNode;
|
|
565
|
-
Schema: (props: SchemaProps$1<TOptions>) => KubbNode;
|
|
566
|
-
};
|
|
567
|
-
//#endregion
|
|
568
|
-
//#region ../plugin-oas/src/generators/types.d.ts
|
|
569
|
-
type OperationsProps<TOptions extends PluginFactoryOptions> = {
|
|
570
|
-
/**
|
|
571
|
-
* @deprecated
|
|
572
|
-
*/
|
|
573
|
-
instance: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
574
|
-
options: TOptions['resolvedOptions'];
|
|
575
|
-
operations: Array<Operation$1>;
|
|
576
|
-
};
|
|
577
|
-
type OperationProps<TOptions extends PluginFactoryOptions> = {
|
|
578
|
-
/**
|
|
579
|
-
* @deprecated
|
|
580
|
-
*/
|
|
581
|
-
instance: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
582
|
-
options: TOptions['resolvedOptions'];
|
|
583
|
-
operation: Operation$1;
|
|
584
|
-
};
|
|
585
|
-
type SchemaProps$1<TOptions extends PluginFactoryOptions> = {
|
|
586
|
-
instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>;
|
|
587
|
-
options: TOptions['resolvedOptions'];
|
|
588
|
-
schema: {
|
|
589
|
-
name: string;
|
|
590
|
-
tree: Array<Schema>;
|
|
591
|
-
value: SchemaObject$1;
|
|
592
|
-
};
|
|
593
|
-
};
|
|
594
|
-
type Generator<TOptions extends PluginFactoryOptions> = CoreGenerator<TOptions> | ReactGenerator<TOptions>;
|
|
595
|
-
//#endregion
|
|
596
|
-
//#region ../plugin-oas/src/generators/createGenerator.d.ts
|
|
597
|
-
type CoreGenerator<TOptions extends PluginFactoryOptions> = {
|
|
598
|
-
name: string;
|
|
599
|
-
type: 'core';
|
|
600
|
-
operations: (props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
601
|
-
operation: (props: OperationProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
602
|
-
schema: (props: SchemaProps$1<TOptions>) => Promise<KubbFile.File[]>;
|
|
603
|
-
};
|
|
604
|
-
//#endregion
|
|
605
|
-
//#region ../plugin-oas/src/types.d.ts
|
|
606
|
-
type ResolvePathOptions = {
|
|
607
|
-
pluginKey?: Plugin['key'];
|
|
608
|
-
group?: {
|
|
609
|
-
tag?: string;
|
|
610
|
-
path?: string;
|
|
611
|
-
};
|
|
612
|
-
type?: ResolveNameParams['type'];
|
|
613
|
-
};
|
|
614
|
-
/**
|
|
615
|
-
* `propertyName` is the ref name + resolved with the nameResolver
|
|
616
|
-
* @example import { Pet } from './Pet'
|
|
617
|
-
*
|
|
618
|
-
* `originalName` is the original name used(in PascalCase), only used to remove duplicates
|
|
619
|
-
*
|
|
620
|
-
* `pluginKey` can be used to override the current plugin being used, handy when you want to import a type/schema out of another plugin
|
|
621
|
-
* @example import a type(plugin-ts) for a mock file(swagger-faker)
|
|
622
|
-
*/
|
|
623
|
-
type Ref = {
|
|
624
|
-
propertyName: string;
|
|
625
|
-
originalName: string;
|
|
626
|
-
path: KubbFile.OptionalPath;
|
|
627
|
-
pluginKey?: Plugin['key'];
|
|
628
|
-
};
|
|
629
|
-
type Refs = Record<string, Ref>;
|
|
630
|
-
type OperationSchema = {
|
|
631
|
-
/**
|
|
632
|
-
* Converted name, contains already `PathParams`, `QueryParams`, ...
|
|
633
|
-
*/
|
|
634
|
-
name: string;
|
|
635
|
-
schema: SchemaObject$1;
|
|
636
|
-
operation?: Operation$1;
|
|
637
|
-
/**
|
|
638
|
-
* OperationName in PascalCase, only being used in OperationGenerator
|
|
639
|
-
*/
|
|
640
|
-
operationName: string;
|
|
641
|
-
description?: string;
|
|
642
|
-
statusCode?: number;
|
|
643
|
-
keys?: string[];
|
|
644
|
-
keysToOmit?: string[];
|
|
645
|
-
withData?: boolean;
|
|
646
|
-
};
|
|
647
|
-
type OperationSchemas = {
|
|
648
|
-
pathParams?: OperationSchema & {
|
|
649
|
-
keysToOmit?: never;
|
|
650
|
-
};
|
|
651
|
-
queryParams?: OperationSchema & {
|
|
652
|
-
keysToOmit?: never;
|
|
653
|
-
};
|
|
654
|
-
headerParams?: OperationSchema & {
|
|
655
|
-
keysToOmit?: never;
|
|
656
|
-
};
|
|
657
|
-
request?: OperationSchema;
|
|
658
|
-
response: OperationSchema;
|
|
659
|
-
responses: Array<OperationSchema>;
|
|
660
|
-
statusCodes?: Array<OperationSchema>;
|
|
661
|
-
errors?: Array<OperationSchema>;
|
|
662
|
-
};
|
|
663
|
-
type ByTag = {
|
|
664
|
-
type: 'tag';
|
|
665
|
-
pattern: string | RegExp;
|
|
666
|
-
};
|
|
667
|
-
type ByOperationId = {
|
|
668
|
-
type: 'operationId';
|
|
669
|
-
pattern: string | RegExp;
|
|
670
|
-
};
|
|
671
|
-
type ByPath = {
|
|
672
|
-
type: 'path';
|
|
673
|
-
pattern: string | RegExp;
|
|
674
|
-
};
|
|
675
|
-
type ByMethod = {
|
|
676
|
-
type: 'method';
|
|
677
|
-
pattern: HttpMethod | RegExp;
|
|
678
|
-
};
|
|
679
|
-
type BySchemaName = {
|
|
680
|
-
type: 'schemaName';
|
|
681
|
-
pattern: string | RegExp;
|
|
682
|
-
};
|
|
683
|
-
type ByContentType = {
|
|
684
|
-
type: 'contentType';
|
|
685
|
-
pattern: string | RegExp;
|
|
686
|
-
};
|
|
687
|
-
type Exclude$1 = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
|
|
688
|
-
type Include = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
|
|
689
|
-
type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName | ByContentType) & {
|
|
690
|
-
options: Partial<TOptions>;
|
|
691
|
-
};
|
|
692
|
-
//#endregion
|
|
693
|
-
//#region ../plugin-oas/src/OperationGenerator.d.ts
|
|
694
|
-
type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
695
|
-
fabric: Fabric;
|
|
696
|
-
oas: Oas;
|
|
697
|
-
exclude: Array<Exclude$1> | undefined;
|
|
698
|
-
include: Array<Include> | undefined;
|
|
699
|
-
override: Array<Override<TOptions>> | undefined;
|
|
700
|
-
contentType: contentType | undefined;
|
|
701
|
-
pluginManager: PluginManager;
|
|
702
|
-
/**
|
|
703
|
-
* Current plugin
|
|
704
|
-
*/
|
|
705
|
-
plugin: Plugin<TPluginOptions>;
|
|
706
|
-
mode: KubbFile.Mode;
|
|
707
|
-
};
|
|
708
|
-
declare class OperationGenerator<TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TPluginOptions['resolvedOptions'], Context$1<TPluginOptions['resolvedOptions'], TPluginOptions>> {
|
|
709
|
-
#private;
|
|
710
|
-
getSchemas(operation: Operation$1, {
|
|
711
|
-
resolveName
|
|
712
|
-
}?: {
|
|
713
|
-
resolveName?: (name: string) => string;
|
|
714
|
-
}): OperationSchemas;
|
|
715
|
-
getOperations(): Promise<Array<{
|
|
716
|
-
path: string;
|
|
717
|
-
method: HttpMethod;
|
|
718
|
-
operation: Operation$1;
|
|
719
|
-
}>>;
|
|
720
|
-
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
721
|
-
}
|
|
722
|
-
//#endregion
|
|
723
559
|
//#region ../plugin-oas/src/SchemaMapper.d.ts
|
|
724
560
|
type SchemaKeywordMapper = {
|
|
725
561
|
object: {
|
|
@@ -937,8 +773,96 @@ type Schema = {
|
|
|
937
773
|
keyword: string;
|
|
938
774
|
} | SchemaKeywordMapper[keyof SchemaKeywordMapper];
|
|
939
775
|
//#endregion
|
|
776
|
+
//#region ../plugin-oas/src/types.d.ts
|
|
777
|
+
type ResolvePathOptions = {
|
|
778
|
+
pluginKey?: Plugin['key'];
|
|
779
|
+
group?: {
|
|
780
|
+
tag?: string;
|
|
781
|
+
path?: string;
|
|
782
|
+
};
|
|
783
|
+
type?: ResolveNameParams['type'];
|
|
784
|
+
};
|
|
785
|
+
/**
|
|
786
|
+
* `propertyName` is the ref name + resolved with the nameResolver
|
|
787
|
+
* @example import { Pet } from './Pet'
|
|
788
|
+
*
|
|
789
|
+
* `originalName` is the original name used(in PascalCase), only used to remove duplicates
|
|
790
|
+
*
|
|
791
|
+
* `pluginKey` can be used to override the current plugin being used, handy when you want to import a type/schema out of another plugin
|
|
792
|
+
* @example import a type(plugin-ts) for a mock file(swagger-faker)
|
|
793
|
+
*/
|
|
794
|
+
type Ref = {
|
|
795
|
+
propertyName: string;
|
|
796
|
+
originalName: string;
|
|
797
|
+
path: KubbFile.OptionalPath;
|
|
798
|
+
pluginKey?: Plugin['key'];
|
|
799
|
+
};
|
|
800
|
+
type Refs = Record<string, Ref>;
|
|
801
|
+
type OperationSchema = {
|
|
802
|
+
/**
|
|
803
|
+
* Converted name, contains already `PathParams`, `QueryParams`, ...
|
|
804
|
+
*/
|
|
805
|
+
name: string;
|
|
806
|
+
schema: SchemaObject$1;
|
|
807
|
+
operation?: Operation$1;
|
|
808
|
+
/**
|
|
809
|
+
* OperationName in PascalCase, only being used in OperationGenerator
|
|
810
|
+
*/
|
|
811
|
+
operationName: string;
|
|
812
|
+
description?: string;
|
|
813
|
+
statusCode?: number;
|
|
814
|
+
keys?: string[];
|
|
815
|
+
keysToOmit?: string[];
|
|
816
|
+
withData?: boolean;
|
|
817
|
+
};
|
|
818
|
+
type OperationSchemas = {
|
|
819
|
+
pathParams?: OperationSchema & {
|
|
820
|
+
keysToOmit?: never;
|
|
821
|
+
};
|
|
822
|
+
queryParams?: OperationSchema & {
|
|
823
|
+
keysToOmit?: never;
|
|
824
|
+
};
|
|
825
|
+
headerParams?: OperationSchema & {
|
|
826
|
+
keysToOmit?: never;
|
|
827
|
+
};
|
|
828
|
+
request?: OperationSchema;
|
|
829
|
+
response: OperationSchema;
|
|
830
|
+
responses: Array<OperationSchema>;
|
|
831
|
+
statusCodes?: Array<OperationSchema>;
|
|
832
|
+
errors?: Array<OperationSchema>;
|
|
833
|
+
};
|
|
834
|
+
type ByTag = {
|
|
835
|
+
type: 'tag';
|
|
836
|
+
pattern: string | RegExp;
|
|
837
|
+
};
|
|
838
|
+
type ByOperationId = {
|
|
839
|
+
type: 'operationId';
|
|
840
|
+
pattern: string | RegExp;
|
|
841
|
+
};
|
|
842
|
+
type ByPath = {
|
|
843
|
+
type: 'path';
|
|
844
|
+
pattern: string | RegExp;
|
|
845
|
+
};
|
|
846
|
+
type ByMethod = {
|
|
847
|
+
type: 'method';
|
|
848
|
+
pattern: HttpMethod | RegExp;
|
|
849
|
+
};
|
|
850
|
+
type BySchemaName = {
|
|
851
|
+
type: 'schemaName';
|
|
852
|
+
pattern: string | RegExp;
|
|
853
|
+
};
|
|
854
|
+
type ByContentType = {
|
|
855
|
+
type: 'contentType';
|
|
856
|
+
pattern: string | RegExp;
|
|
857
|
+
};
|
|
858
|
+
type Exclude$1 = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
|
|
859
|
+
type Include = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
|
|
860
|
+
type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName | ByContentType) & {
|
|
861
|
+
options: Partial<TOptions>;
|
|
862
|
+
};
|
|
863
|
+
//#endregion
|
|
940
864
|
//#region ../plugin-oas/src/SchemaGenerator.d.ts
|
|
941
|
-
type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
865
|
+
type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
942
866
|
fabric: Fabric;
|
|
943
867
|
oas: Oas;
|
|
944
868
|
pluginManager: PluginManager;
|
|
@@ -971,15 +895,15 @@ type SchemaGeneratorOptions = {
|
|
|
971
895
|
* TODO TODO add docs
|
|
972
896
|
* @beta
|
|
973
897
|
*/
|
|
974
|
-
schema?: (schemaProps: SchemaProps, defaultSchemas: Schema[]) => Schema[] | undefined;
|
|
898
|
+
schema?: (schemaProps: SchemaProps$1, defaultSchemas: Schema[]) => Schema[] | undefined;
|
|
975
899
|
};
|
|
976
900
|
};
|
|
977
|
-
type SchemaProps = {
|
|
901
|
+
type SchemaProps$1 = {
|
|
978
902
|
schemaObject?: SchemaObject$1;
|
|
979
903
|
name?: string;
|
|
980
904
|
parentName?: string;
|
|
981
905
|
};
|
|
982
|
-
declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions, Context<TOptions, TPluginOptions>> {
|
|
906
|
+
declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions, Context$1<TOptions, TPluginOptions>> {
|
|
983
907
|
#private;
|
|
984
908
|
refs: Refs;
|
|
985
909
|
/**
|
|
@@ -987,15 +911,85 @@ declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGe
|
|
|
987
911
|
* Delegates to getBaseTypeFromSchema internally and
|
|
988
912
|
* optionally adds a union with null.
|
|
989
913
|
*/
|
|
990
|
-
parse(props: SchemaProps): Schema[];
|
|
991
|
-
deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
|
|
992
|
-
find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
914
|
+
parse(props: SchemaProps$1): Schema[];
|
|
993
915
|
static deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
|
|
994
|
-
static findInObject<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
995
916
|
static find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
996
917
|
static combineObjects(tree: Schema[] | undefined): Schema[];
|
|
997
918
|
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
998
919
|
}
|
|
999
920
|
//#endregion
|
|
1000
|
-
|
|
1001
|
-
|
|
921
|
+
//#region ../plugin-oas/src/generators/createGenerator.d.ts
|
|
922
|
+
type CoreGenerator<TOptions extends PluginFactoryOptions> = {
|
|
923
|
+
name: string;
|
|
924
|
+
type: 'core';
|
|
925
|
+
operations: (props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
926
|
+
operation: (props: OperationProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
927
|
+
schema: (props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
928
|
+
};
|
|
929
|
+
//#endregion
|
|
930
|
+
//#region ../plugin-oas/src/generators/createReactGenerator.d.ts
|
|
931
|
+
type ReactGenerator<TOptions extends PluginFactoryOptions> = {
|
|
932
|
+
name: string;
|
|
933
|
+
type: 'react';
|
|
934
|
+
Operations: (props: OperationsProps<TOptions>) => KubbNode;
|
|
935
|
+
Operation: (props: OperationProps<TOptions>) => KubbNode;
|
|
936
|
+
Schema: (props: SchemaProps<TOptions>) => KubbNode;
|
|
937
|
+
};
|
|
938
|
+
//#endregion
|
|
939
|
+
//#region ../plugin-oas/src/generators/types.d.ts
|
|
940
|
+
type OperationsProps<TOptions extends PluginFactoryOptions> = {
|
|
941
|
+
config: Config;
|
|
942
|
+
generator: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
943
|
+
plugin: Plugin<TOptions>;
|
|
944
|
+
operations: Array<Operation$1>;
|
|
945
|
+
};
|
|
946
|
+
type OperationProps<TOptions extends PluginFactoryOptions> = {
|
|
947
|
+
config: Config;
|
|
948
|
+
generator: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
949
|
+
plugin: Plugin<TOptions>;
|
|
950
|
+
operation: Operation$1;
|
|
951
|
+
};
|
|
952
|
+
type SchemaProps<TOptions extends PluginFactoryOptions> = {
|
|
953
|
+
config: Config;
|
|
954
|
+
generator: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>;
|
|
955
|
+
plugin: Plugin<TOptions>;
|
|
956
|
+
schema: {
|
|
957
|
+
name: string;
|
|
958
|
+
tree: Array<Schema>;
|
|
959
|
+
value: SchemaObject$1;
|
|
960
|
+
};
|
|
961
|
+
};
|
|
962
|
+
type Generator<TOptions extends PluginFactoryOptions> = CoreGenerator<TOptions> | ReactGenerator<TOptions>;
|
|
963
|
+
//#endregion
|
|
964
|
+
//#region ../plugin-oas/src/OperationGenerator.d.ts
|
|
965
|
+
type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
966
|
+
fabric: Fabric;
|
|
967
|
+
oas: Oas;
|
|
968
|
+
exclude: Array<Exclude$1> | undefined;
|
|
969
|
+
include: Array<Include> | undefined;
|
|
970
|
+
override: Array<Override<TOptions>> | undefined;
|
|
971
|
+
contentType: contentType | undefined;
|
|
972
|
+
pluginManager: PluginManager;
|
|
973
|
+
/**
|
|
974
|
+
* Current plugin
|
|
975
|
+
*/
|
|
976
|
+
plugin: Plugin<TPluginOptions>;
|
|
977
|
+
mode: KubbFile.Mode;
|
|
978
|
+
};
|
|
979
|
+
declare class OperationGenerator<TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TPluginOptions['resolvedOptions'], Context<TPluginOptions['resolvedOptions'], TPluginOptions>> {
|
|
980
|
+
#private;
|
|
981
|
+
getSchemas(operation: Operation$1, {
|
|
982
|
+
resolveName
|
|
983
|
+
}?: {
|
|
984
|
+
resolveName?: (name: string) => string;
|
|
985
|
+
}): OperationSchemas;
|
|
986
|
+
getOperations(): Promise<Array<{
|
|
987
|
+
path: string;
|
|
988
|
+
method: HttpMethod;
|
|
989
|
+
operation: Operation$1;
|
|
990
|
+
}>>;
|
|
991
|
+
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
992
|
+
}
|
|
993
|
+
//#endregion
|
|
994
|
+
export { OperationSchemas as a, Oas as c, Output as d, PluginFactoryOptions as f, Include as i, contentType as l, UserPluginWithLifeCycle as m, ReactGenerator as n, Override as o, ResolveNameParams as p, Exclude$1 as r, ResolvePathOptions as s, Generator as t, Group as u };
|
|
995
|
+
//# sourceMappingURL=OperationGenerator-Beq8iOZY.d.cts.map
|
package/dist/components.d.cts
CHANGED
package/dist/components.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
const require_Server = require('./Server-vKCXRjmg.cjs');
|
|
2
|
-
let
|
|
3
|
-
|
|
2
|
+
let node_path = require("node:path");
|
|
3
|
+
node_path = require_Server.__toESM(node_path);
|
|
4
4
|
let __kubb_plugin_ts = require("@kubb/plugin-ts");
|
|
5
5
|
__kubb_plugin_ts = require_Server.__toESM(__kubb_plugin_ts);
|
|
6
6
|
let __kubb_plugin_zod = require("@kubb/plugin-zod");
|
|
7
7
|
__kubb_plugin_zod = require_Server.__toESM(__kubb_plugin_zod);
|
|
8
|
-
let __kubb_core_hooks = require("@kubb/core/hooks");
|
|
9
|
-
__kubb_core_hooks = require_Server.__toESM(__kubb_core_hooks);
|
|
10
8
|
let __kubb_plugin_client_components = require("@kubb/plugin-client/components");
|
|
11
9
|
__kubb_plugin_client_components = require_Server.__toESM(__kubb_plugin_client_components);
|
|
10
|
+
let __kubb_plugin_oas_generators = require("@kubb/plugin-oas/generators");
|
|
11
|
+
__kubb_plugin_oas_generators = require_Server.__toESM(__kubb_plugin_oas_generators);
|
|
12
12
|
let __kubb_plugin_oas_hooks = require("@kubb/plugin-oas/hooks");
|
|
13
13
|
__kubb_plugin_oas_hooks = require_Server.__toESM(__kubb_plugin_oas_hooks);
|
|
14
14
|
let __kubb_plugin_oas_utils = require("@kubb/plugin-oas/utils");
|
|
@@ -17,14 +17,16 @@ let __kubb_react_fabric = require("@kubb/react-fabric");
|
|
|
17
17
|
__kubb_react_fabric = require_Server.__toESM(__kubb_react_fabric);
|
|
18
18
|
let __kubb_react_fabric_jsx_runtime = require("@kubb/react-fabric/jsx-runtime");
|
|
19
19
|
__kubb_react_fabric_jsx_runtime = require_Server.__toESM(__kubb_react_fabric_jsx_runtime);
|
|
20
|
+
let __kubb_core_hooks = require("@kubb/core/hooks");
|
|
21
|
+
__kubb_core_hooks = require_Server.__toESM(__kubb_core_hooks);
|
|
20
22
|
|
|
21
23
|
//#region src/generators/mcpGenerator.tsx
|
|
22
|
-
const mcpGenerator = (0,
|
|
24
|
+
const mcpGenerator = (0, __kubb_plugin_oas_generators.createReactGenerator)({
|
|
23
25
|
name: "mcp",
|
|
24
|
-
Operation({ operation }) {
|
|
25
|
-
const { options } =
|
|
26
|
+
Operation({ config, operation, generator, plugin }) {
|
|
27
|
+
const { options } = plugin;
|
|
26
28
|
const oas = (0, __kubb_plugin_oas_hooks.useOas)();
|
|
27
|
-
const { getSchemas, getName, getFile } = (0, __kubb_plugin_oas_hooks.useOperationManager)();
|
|
29
|
+
const { getSchemas, getName, getFile } = (0, __kubb_plugin_oas_hooks.useOperationManager)(generator);
|
|
28
30
|
const mcp = {
|
|
29
31
|
name: getName(operation, {
|
|
30
32
|
type: "function",
|
|
@@ -52,20 +54,45 @@ const mcpGenerator = (0, __kubb_plugin_oas.createReactGenerator)({
|
|
|
52
54
|
output: options.output
|
|
53
55
|
}),
|
|
54
56
|
children: [
|
|
57
|
+
options.client.importPath ? /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsxs)(__kubb_react_fabric_jsx_runtime.Fragment, { children: [
|
|
58
|
+
/* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
|
|
59
|
+
name: "fetch",
|
|
60
|
+
path: options.client.importPath
|
|
61
|
+
}),
|
|
62
|
+
/* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
|
|
63
|
+
name: ["RequestConfig", "ResponseErrorConfig"],
|
|
64
|
+
path: options.client.importPath,
|
|
65
|
+
isTypeOnly: true
|
|
66
|
+
}),
|
|
67
|
+
options.client.dataReturnType === "full" && /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
|
|
68
|
+
name: ["ResponseConfig"],
|
|
69
|
+
path: options.client.importPath,
|
|
70
|
+
isTypeOnly: true
|
|
71
|
+
})
|
|
72
|
+
] }) : /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsxs)(__kubb_react_fabric_jsx_runtime.Fragment, { children: [
|
|
73
|
+
/* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
|
|
74
|
+
name: "fetch",
|
|
75
|
+
root: mcp.file.path,
|
|
76
|
+
path: node_path.default.resolve(config.root, config.output.path, ".kubb/fetcher.ts")
|
|
77
|
+
}),
|
|
78
|
+
/* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
|
|
79
|
+
name: ["RequestConfig", "ResponseErrorConfig"],
|
|
80
|
+
root: mcp.file.path,
|
|
81
|
+
path: node_path.default.resolve(config.root, config.output.path, ".kubb/fetcher.ts"),
|
|
82
|
+
isTypeOnly: true
|
|
83
|
+
}),
|
|
84
|
+
options.client.dataReturnType === "full" && /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
|
|
85
|
+
name: ["ResponseConfig"],
|
|
86
|
+
root: mcp.file.path,
|
|
87
|
+
path: node_path.default.resolve(config.root, config.output.path, ".kubb/fetcher.ts"),
|
|
88
|
+
isTypeOnly: true
|
|
89
|
+
})
|
|
90
|
+
] }),
|
|
55
91
|
/* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
|
|
56
92
|
name: ["CallToolResult"],
|
|
57
93
|
path: "@modelcontextprotocol/sdk/types",
|
|
58
94
|
isTypeOnly: true
|
|
59
95
|
}),
|
|
60
|
-
/* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
|
|
61
|
-
name: "fetch",
|
|
62
|
-
path: options.client.importPath
|
|
63
|
-
}),
|
|
64
|
-
/* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
|
|
65
|
-
name: ["RequestConfig", "ResponseErrorConfig"],
|
|
66
|
-
path: options.client.importPath,
|
|
67
|
-
isTypeOnly: true
|
|
68
|
-
}),
|
|
69
96
|
/* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
|
|
70
97
|
name: [
|
|
71
98
|
type.schemas.request?.name,
|
|
@@ -87,7 +114,7 @@ const mcpGenerator = (0, __kubb_plugin_oas.createReactGenerator)({
|
|
|
87
114
|
operation,
|
|
88
115
|
typeSchemas: type.schemas,
|
|
89
116
|
zodSchemas: void 0,
|
|
90
|
-
dataReturnType: options.client.dataReturnType,
|
|
117
|
+
dataReturnType: options.client.dataReturnType || "data",
|
|
91
118
|
paramsType: "object",
|
|
92
119
|
paramsCasing: "camelcase",
|
|
93
120
|
pathParamsType: "object",
|
|
@@ -115,13 +142,13 @@ const mcpGenerator = (0, __kubb_plugin_oas.createReactGenerator)({
|
|
|
115
142
|
|
|
116
143
|
//#endregion
|
|
117
144
|
//#region src/generators/serverGenerator.tsx
|
|
118
|
-
const serverGenerator = (0,
|
|
145
|
+
const serverGenerator = (0, __kubb_plugin_oas_generators.createReactGenerator)({
|
|
119
146
|
name: "operations",
|
|
120
|
-
Operations({ operations,
|
|
121
|
-
const plugin = (0, __kubb_core_hooks.usePlugin)();
|
|
147
|
+
Operations({ operations, generator, plugin }) {
|
|
122
148
|
const pluginManager = (0, __kubb_core_hooks.usePluginManager)();
|
|
149
|
+
const { options } = plugin;
|
|
123
150
|
const oas = (0, __kubb_plugin_oas_hooks.useOas)();
|
|
124
|
-
const { getFile, getName, getSchemas } = (0, __kubb_plugin_oas_hooks.useOperationManager)();
|
|
151
|
+
const { getFile, getName, getSchemas } = (0, __kubb_plugin_oas_hooks.useOperationManager)(generator);
|
|
125
152
|
const name = "server";
|
|
126
153
|
const file = pluginManager.getFile({
|
|
127
154
|
name,
|
|
@@ -244,4 +271,4 @@ Object.defineProperty(exports, 'serverGenerator', {
|
|
|
244
271
|
return serverGenerator;
|
|
245
272
|
}
|
|
246
273
|
});
|
|
247
|
-
//# sourceMappingURL=generators-
|
|
274
|
+
//# sourceMappingURL=generators-CSDgJv8G.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generators-CSDgJv8G.cjs","names":["pluginTsName","File","path","Client","pluginZodName","pluginTsName","File","Server"],"sources":["../src/generators/mcpGenerator.tsx","../src/generators/serverGenerator.tsx"],"sourcesContent":["import path from 'node:path'\nimport { Client } from '@kubb/plugin-client/components'\nimport { createReactGenerator } from '@kubb/plugin-oas/generators'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { File } from '@kubb/react-fabric'\nimport type { PluginMcp } from '../types'\n\nexport const mcpGenerator = createReactGenerator<PluginMcp>({\n name: 'mcp',\n Operation({ config, operation, generator, plugin }) {\n const { options } = plugin\n const oas = useOas()\n\n const { getSchemas, getName, getFile } = useOperationManager(generator)\n\n const mcp = {\n name: getName(operation, { type: 'function', suffix: 'handler' }),\n file: getFile(operation),\n }\n\n const type = {\n file: getFile(operation, { pluginKey: [pluginTsName] }),\n schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' }),\n }\n\n return (\n <File\n baseName={mcp.file.baseName}\n path={mcp.file.path}\n meta={mcp.file.meta}\n banner={getBanner({ oas, output: options.output })}\n footer={getFooter({ oas, output: options.output })}\n >\n {options.client.importPath ? (\n <>\n <File.Import name={'fetch'} path={options.client.importPath} />\n <File.Import name={['RequestConfig', 'ResponseErrorConfig']} path={options.client.importPath} isTypeOnly />\n {options.client.dataReturnType === 'full' && <File.Import name={['ResponseConfig']} path={options.client.importPath} isTypeOnly />}\n </>\n ) : (\n <>\n <File.Import name={'fetch'} root={mcp.file.path} path={path.resolve(config.root, config.output.path, '.kubb/fetcher.ts')} />\n <File.Import\n name={['RequestConfig', 'ResponseErrorConfig']}\n root={mcp.file.path}\n path={path.resolve(config.root, config.output.path, '.kubb/fetcher.ts')}\n isTypeOnly\n />\n {options.client.dataReturnType === 'full' && (\n <File.Import name={['ResponseConfig']} root={mcp.file.path} path={path.resolve(config.root, config.output.path, '.kubb/fetcher.ts')} isTypeOnly />\n )}\n </>\n )}\n <File.Import name={['CallToolResult']} path={'@modelcontextprotocol/sdk/types'} isTypeOnly />\n <File.Import\n name={[\n type.schemas.request?.name,\n type.schemas.response.name,\n type.schemas.pathParams?.name,\n type.schemas.queryParams?.name,\n type.schemas.headerParams?.name,\n ...(type.schemas.statusCodes?.map((item) => item.name) || []),\n ].filter(Boolean)}\n root={mcp.file.path}\n path={type.file.path}\n isTypeOnly\n />\n\n <Client\n name={mcp.name}\n isConfigurable={false}\n returnType={'Promise<CallToolResult>'}\n baseURL={options.client.baseURL}\n operation={operation}\n typeSchemas={type.schemas}\n zodSchemas={undefined}\n dataReturnType={options.client.dataReturnType || 'data'}\n paramsType={'object'}\n paramsCasing={'camelcase'}\n pathParamsType={'object'}\n parser={'client'}\n >\n {options.client.dataReturnType === 'data' &&\n `return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(res.data)\n }\n ]\n }`}\n {options.client.dataReturnType === 'full' &&\n `return {\n content: [\n {\n type: 'text',\n text: JSON.stringify(res)\n }\n ]\n }`}\n </Client>\n </File>\n )\n },\n})\n","import { usePluginManager } from '@kubb/core/hooks'\nimport { createReactGenerator } from '@kubb/plugin-oas/generators'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { File } from '@kubb/react-fabric'\nimport { Server } from '../components/Server'\nimport type { PluginMcp } from '../types'\n\nexport const serverGenerator = createReactGenerator<PluginMcp>({\n name: 'operations',\n Operations({ operations, generator, plugin }) {\n const pluginManager = usePluginManager()\n const { options } = plugin\n\n const oas = useOas()\n const { getFile, getName, getSchemas } = useOperationManager(generator)\n\n const name = 'server'\n const file = pluginManager.getFile({ name, extname: '.ts', pluginKey: plugin.key })\n\n const jsonFile = pluginManager.getFile({ name: '.mcp', extname: '.json', pluginKey: plugin.key })\n\n const operationsMapped = operations.map((operation) => {\n return {\n tool: {\n name: operation.getOperationId() || operation.getSummary() || `${operation.method.toUpperCase()} ${operation.path}`,\n description: operation.getDescription() || `Make a ${operation.method.toUpperCase()} request to ${operation.path}`,\n },\n mcp: {\n name: getName(operation, {\n type: 'function',\n suffix: 'handler',\n }),\n file: getFile(operation),\n },\n zod: {\n name: getName(operation, {\n type: 'function',\n pluginKey: [pluginZodName],\n }),\n schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: 'function' }),\n file: getFile(operation, { pluginKey: [pluginZodName] }),\n },\n type: {\n schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' }),\n },\n }\n })\n\n const imports = operationsMapped.flatMap(({ mcp, zod }) => {\n return [\n <File.Import key={mcp.name} name={[mcp.name]} root={file.path} path={mcp.file.path} />,\n <File.Import\n key={zod.name}\n name={[zod.schemas.request?.name, zod.schemas.pathParams?.name, zod.schemas.queryParams?.name, zod.schemas.headerParams?.name].filter(Boolean)}\n root={file.path}\n path={zod.file.path}\n />,\n ]\n })\n\n return (\n <>\n <File\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={getBanner({ oas, output: options.output, config: pluginManager.config })}\n footer={getFooter({ oas, output: options.output })}\n >\n <File.Import name={['McpServer']} path={'@modelcontextprotocol/sdk/server/mcp'} />\n <File.Import name={['StdioServerTransport']} path={'@modelcontextprotocol/sdk/server/stdio'} />\n\n {imports}\n <Server name={name} serverName={oas.api.info?.title} serverVersion={oas.getVersion()} operations={operationsMapped} />\n </File>\n\n <File baseName={jsonFile.baseName} path={jsonFile.path} meta={jsonFile.meta}>\n <File.Source name={name}>\n {`\n {\n \"mcpServers\": {\n \"${oas.api.info?.title || 'server'}\": {\n \"type\": \"stdio\",\n \"command\": \"npx\",\n \"args\": [\"tsx\", \"${file.path}\"]\n }\n }\n }\n `}\n </File.Source>\n </File>\n </>\n )\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AASA,MAAa,sEAA+C;CAC1D,MAAM;CACN,UAAU,EAAE,QAAQ,WAAW,WAAW,UAAU;EAClD,MAAM,EAAE,YAAY;EACpB,MAAM,2CAAc;EAEpB,MAAM,EAAE,YAAY,SAAS,6DAAgC,UAAU;EAEvE,MAAM,MAAM;GACV,MAAM,QAAQ,WAAW;IAAE,MAAM;IAAY,QAAQ;IAAW,CAAC;GACjE,MAAM,QAAQ,UAAU;GACzB;EAED,MAAM,OAAO;GACX,MAAM,QAAQ,WAAW,EAAE,WAAW,CAACA,8BAAa,EAAE,CAAC;GACvD,SAAS,WAAW,WAAW;IAAE,WAAW,CAACA,8BAAa;IAAE,MAAM;IAAQ,CAAC;GAC5E;AAED,SACE,0DAACC;GACC,UAAU,IAAI,KAAK;GACnB,MAAM,IAAI,KAAK;GACf,MAAM,IAAI,KAAK;GACf,+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as Server } from "./Server-DMDo69md.js";
|
|
2
|
-
import
|
|
2
|
+
import path from "node:path";
|
|
3
3
|
import { pluginTsName } from "@kubb/plugin-ts";
|
|
4
4
|
import { pluginZodName } from "@kubb/plugin-zod";
|
|
5
|
-
import { usePlugin, usePluginManager } from "@kubb/core/hooks";
|
|
6
5
|
import { Client } from "@kubb/plugin-client/components";
|
|
6
|
+
import { createReactGenerator } from "@kubb/plugin-oas/generators";
|
|
7
7
|
import { useOas, useOperationManager } from "@kubb/plugin-oas/hooks";
|
|
8
8
|
import { getBanner, getFooter } from "@kubb/plugin-oas/utils";
|
|
9
9
|
import { File } from "@kubb/react-fabric";
|
|
10
10
|
import { Fragment, jsx, jsxs } from "@kubb/react-fabric/jsx-runtime";
|
|
11
|
+
import { usePluginManager } from "@kubb/core/hooks";
|
|
11
12
|
|
|
12
13
|
//#region src/generators/mcpGenerator.tsx
|
|
13
14
|
const mcpGenerator = createReactGenerator({
|
|
14
15
|
name: "mcp",
|
|
15
|
-
Operation({ operation }) {
|
|
16
|
-
const { options } =
|
|
16
|
+
Operation({ config, operation, generator, plugin }) {
|
|
17
|
+
const { options } = plugin;
|
|
17
18
|
const oas = useOas();
|
|
18
|
-
const { getSchemas, getName, getFile } = useOperationManager();
|
|
19
|
+
const { getSchemas, getName, getFile } = useOperationManager(generator);
|
|
19
20
|
const mcp = {
|
|
20
21
|
name: getName(operation, {
|
|
21
22
|
type: "function",
|
|
@@ -43,20 +44,45 @@ const mcpGenerator = createReactGenerator({
|
|
|
43
44
|
output: options.output
|
|
44
45
|
}),
|
|
45
46
|
children: [
|
|
47
|
+
options.client.importPath ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
48
|
+
/* @__PURE__ */ jsx(File.Import, {
|
|
49
|
+
name: "fetch",
|
|
50
|
+
path: options.client.importPath
|
|
51
|
+
}),
|
|
52
|
+
/* @__PURE__ */ jsx(File.Import, {
|
|
53
|
+
name: ["RequestConfig", "ResponseErrorConfig"],
|
|
54
|
+
path: options.client.importPath,
|
|
55
|
+
isTypeOnly: true
|
|
56
|
+
}),
|
|
57
|
+
options.client.dataReturnType === "full" && /* @__PURE__ */ jsx(File.Import, {
|
|
58
|
+
name: ["ResponseConfig"],
|
|
59
|
+
path: options.client.importPath,
|
|
60
|
+
isTypeOnly: true
|
|
61
|
+
})
|
|
62
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
63
|
+
/* @__PURE__ */ jsx(File.Import, {
|
|
64
|
+
name: "fetch",
|
|
65
|
+
root: mcp.file.path,
|
|
66
|
+
path: path.resolve(config.root, config.output.path, ".kubb/fetcher.ts")
|
|
67
|
+
}),
|
|
68
|
+
/* @__PURE__ */ jsx(File.Import, {
|
|
69
|
+
name: ["RequestConfig", "ResponseErrorConfig"],
|
|
70
|
+
root: mcp.file.path,
|
|
71
|
+
path: path.resolve(config.root, config.output.path, ".kubb/fetcher.ts"),
|
|
72
|
+
isTypeOnly: true
|
|
73
|
+
}),
|
|
74
|
+
options.client.dataReturnType === "full" && /* @__PURE__ */ jsx(File.Import, {
|
|
75
|
+
name: ["ResponseConfig"],
|
|
76
|
+
root: mcp.file.path,
|
|
77
|
+
path: path.resolve(config.root, config.output.path, ".kubb/fetcher.ts"),
|
|
78
|
+
isTypeOnly: true
|
|
79
|
+
})
|
|
80
|
+
] }),
|
|
46
81
|
/* @__PURE__ */ jsx(File.Import, {
|
|
47
82
|
name: ["CallToolResult"],
|
|
48
83
|
path: "@modelcontextprotocol/sdk/types",
|
|
49
84
|
isTypeOnly: true
|
|
50
85
|
}),
|
|
51
|
-
/* @__PURE__ */ jsx(File.Import, {
|
|
52
|
-
name: "fetch",
|
|
53
|
-
path: options.client.importPath
|
|
54
|
-
}),
|
|
55
|
-
/* @__PURE__ */ jsx(File.Import, {
|
|
56
|
-
name: ["RequestConfig", "ResponseErrorConfig"],
|
|
57
|
-
path: options.client.importPath,
|
|
58
|
-
isTypeOnly: true
|
|
59
|
-
}),
|
|
60
86
|
/* @__PURE__ */ jsx(File.Import, {
|
|
61
87
|
name: [
|
|
62
88
|
type.schemas.request?.name,
|
|
@@ -78,7 +104,7 @@ const mcpGenerator = createReactGenerator({
|
|
|
78
104
|
operation,
|
|
79
105
|
typeSchemas: type.schemas,
|
|
80
106
|
zodSchemas: void 0,
|
|
81
|
-
dataReturnType: options.client.dataReturnType,
|
|
107
|
+
dataReturnType: options.client.dataReturnType || "data",
|
|
82
108
|
paramsType: "object",
|
|
83
109
|
paramsCasing: "camelcase",
|
|
84
110
|
pathParamsType: "object",
|
|
@@ -108,11 +134,11 @@ const mcpGenerator = createReactGenerator({
|
|
|
108
134
|
//#region src/generators/serverGenerator.tsx
|
|
109
135
|
const serverGenerator = createReactGenerator({
|
|
110
136
|
name: "operations",
|
|
111
|
-
Operations({ operations,
|
|
112
|
-
const plugin = usePlugin();
|
|
137
|
+
Operations({ operations, generator, plugin }) {
|
|
113
138
|
const pluginManager = usePluginManager();
|
|
139
|
+
const { options } = plugin;
|
|
114
140
|
const oas = useOas();
|
|
115
|
-
const { getFile, getName, getSchemas } = useOperationManager();
|
|
141
|
+
const { getFile, getName, getSchemas } = useOperationManager(generator);
|
|
116
142
|
const name = "server";
|
|
117
143
|
const file = pluginManager.getFile({
|
|
118
144
|
name,
|
|
@@ -224,4 +250,4 @@ const serverGenerator = createReactGenerator({
|
|
|
224
250
|
|
|
225
251
|
//#endregion
|
|
226
252
|
export { mcpGenerator as n, serverGenerator as t };
|
|
227
|
-
//# sourceMappingURL=generators-
|
|
253
|
+
//# sourceMappingURL=generators-DP6UAisL.js.map
|