@kubb/plugin-ts 5.0.0-alpha.3 → 5.0.0-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{components-CRjwjdyE.js → components-Cwn1rflQ.js} +9 -3
- package/dist/components-Cwn1rflQ.js.map +1 -0
- package/dist/{components-DI0aTIBg.cjs → components-CxTvawXI.cjs} +9 -3
- package/dist/components-CxTvawXI.cjs.map +1 -0
- package/dist/components.cjs +1 -1
- package/dist/components.d.ts +1 -1
- package/dist/components.js +1 -1
- package/dist/generators.cjs +1 -1
- package/dist/generators.d.ts +24 -47
- package/dist/generators.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/{plugin-DmwgRHK8.js → plugin-kdQ5D2cW.js} +302 -96
- package/dist/plugin-kdQ5D2cW.js.map +1 -0
- package/dist/{plugin-D5rCK1zO.cjs → plugin-meWNDVe7.cjs} +298 -92
- package/dist/plugin-meWNDVe7.cjs.map +1 -0
- package/dist/{types-BpeKGgCn.d.ts → types-eWhVEVgF.d.ts} +13 -3
- package/package.json +8 -8
- package/src/components/v2/Type.tsx +15 -2
- package/src/factory.ts +12 -16
- package/src/generators/typeGenerator.tsx +1 -2
- package/src/generators/v2/typeGenerator.tsx +77 -110
- package/src/generators/v2/utils.ts +145 -0
- package/src/plugin.ts +28 -4
- package/src/printer.ts +15 -1
- package/src/types.ts +10 -0
- package/dist/components-CRjwjdyE.js.map +0 -1
- package/dist/components-DI0aTIBg.cjs.map +0 -1
- package/dist/plugin-D5rCK1zO.cjs.map +0 -1
- package/dist/plugin-DmwgRHK8.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_components = require("./components-
|
|
1
|
+
const require_components = require("./components-CxTvawXI.cjs");
|
|
2
2
|
let node_path = require("node:path");
|
|
3
3
|
node_path = require_components.__toESM(node_path);
|
|
4
4
|
let _kubb_ast = require("@kubb/ast");
|
|
@@ -216,7 +216,6 @@ function printResponseSchema({ baseName, schemas, pluginManager, unknownType })
|
|
|
216
216
|
}
|
|
217
217
|
const typeGenerator$1 = (0, _kubb_plugin_oas_generators.createReactGenerator)({
|
|
218
218
|
name: "typescript",
|
|
219
|
-
version: "1",
|
|
220
219
|
Operation({ operation, generator, plugin }) {
|
|
221
220
|
const { options, options: { mapper, enumType, enumKeyCasing, syntaxType, optionalType, arrayType, unknownType, paramsCasing } } = plugin;
|
|
222
221
|
const mode = (0, _kubb_core_hooks.useMode)();
|
|
@@ -466,13 +465,17 @@ const printerTs = (0, _kubb_core.definePrinter)((options) => ({
|
|
|
466
465
|
any: () => require_components.keywordTypeNodes.any,
|
|
467
466
|
unknown: () => require_components.keywordTypeNodes.unknown,
|
|
468
467
|
void: () => require_components.keywordTypeNodes.void,
|
|
468
|
+
never: () => require_components.keywordTypeNodes.never,
|
|
469
469
|
boolean: () => require_components.keywordTypeNodes.boolean,
|
|
470
470
|
null: () => require_components.keywordTypeNodes.null,
|
|
471
471
|
blob: () => require_components.createTypeReferenceNode("Blob", []),
|
|
472
472
|
string: () => require_components.keywordTypeNodes.string,
|
|
473
473
|
uuid: () => require_components.keywordTypeNodes.string,
|
|
474
474
|
email: () => require_components.keywordTypeNodes.string,
|
|
475
|
-
url: () =>
|
|
475
|
+
url: (node) => {
|
|
476
|
+
if (node.path) return require_components.createUrlTemplateType(node.path);
|
|
477
|
+
return require_components.keywordTypeNodes.string;
|
|
478
|
+
},
|
|
476
479
|
datetime: () => require_components.keywordTypeNodes.string,
|
|
477
480
|
number: () => require_components.keywordTypeNodes.number,
|
|
478
481
|
integer: () => require_components.keywordTypeNodes.number,
|
|
@@ -537,6 +540,7 @@ const printerTs = (0, _kubb_core.definePrinter)((options) => ({
|
|
|
537
540
|
const addsQuestionToken = ["questionToken", "questionTokenAndUndefined"].includes(this.options.optionalType);
|
|
538
541
|
const { print } = this;
|
|
539
542
|
const propertyNodes = node.properties.map((prop) => {
|
|
543
|
+
if (this.options.mapper && Object.hasOwn(this.options.mapper, prop.name)) return this.options.mapper[prop.name];
|
|
540
544
|
const baseType = print(prop.schema) ?? require_components.keywordTypeNodes.unknown;
|
|
541
545
|
const type = buildPropertyType(prop.schema, baseType, this.options.optionalType);
|
|
542
546
|
const propertyNode = require_components.createPropertySignature({
|
|
@@ -558,7 +562,7 @@ const printerTs = (0, _kubb_core.definePrinter)((options) => ({
|
|
|
558
562
|
}));
|
|
559
563
|
//#endregion
|
|
560
564
|
//#region src/components/v2/Type.tsx
|
|
561
|
-
function Type({ name, typedName, node, keysToOmit, optionalType, arrayType, syntaxType, enumType, enumKeyCasing, ...rest }) {
|
|
565
|
+
function Type({ name, typedName, node, keysToOmit, optionalType, arrayType, syntaxType, enumType, enumKeyCasing, mapper, ...rest }) {
|
|
562
566
|
const typeNodes = [];
|
|
563
567
|
const description = rest.description || node?.description;
|
|
564
568
|
const enumSchemaNodes = (0, _kubb_ast.collect)(node, { schema(n) {
|
|
@@ -567,7 +571,8 @@ function Type({ name, typedName, node, keysToOmit, optionalType, arrayType, synt
|
|
|
567
571
|
let type = printerTs({
|
|
568
572
|
optionalType,
|
|
569
573
|
arrayType,
|
|
570
|
-
enumType
|
|
574
|
+
enumType,
|
|
575
|
+
mapper
|
|
571
576
|
}).print(node);
|
|
572
577
|
if (!type) return;
|
|
573
578
|
if (["asConst", "asPascalConst"].includes(enumType) && enumSchemaNodes.length > 0) {
|
|
@@ -658,29 +663,175 @@ function Type({ name, typedName, node, keysToOmit, optionalType, arrayType, synt
|
|
|
658
663
|
})] });
|
|
659
664
|
}
|
|
660
665
|
//#endregion
|
|
666
|
+
//#region src/generators/v2/utils.ts
|
|
667
|
+
/**
|
|
668
|
+
* Builds an `ObjectSchemaNode` for a group of parameters (path/query/header).
|
|
669
|
+
* Each property is a `ref` schema pointing to the individually-resolved parameter type.
|
|
670
|
+
*/
|
|
671
|
+
function buildParamsSchema({ params, operationId, resolveName }) {
|
|
672
|
+
return (0, _kubb_ast.createSchema)({
|
|
673
|
+
type: "object",
|
|
674
|
+
properties: params.map((param) => (0, _kubb_ast.createProperty)({
|
|
675
|
+
name: param.name,
|
|
676
|
+
schema: (0, _kubb_ast.createSchema)({
|
|
677
|
+
type: "ref",
|
|
678
|
+
name: resolveName({
|
|
679
|
+
name: `${operationId} ${param.name}`,
|
|
680
|
+
type: "function"
|
|
681
|
+
}),
|
|
682
|
+
optional: !param.required
|
|
683
|
+
})
|
|
684
|
+
}))
|
|
685
|
+
});
|
|
686
|
+
}
|
|
687
|
+
/**
|
|
688
|
+
* Builds an `ObjectSchemaNode` representing the `<OperationId>Data` type:
|
|
689
|
+
* - `data` → request body ref (optional) or `never`
|
|
690
|
+
* - `pathParams` → inline object of path param refs, or `never`
|
|
691
|
+
* - `queryParams` → inline object of query param refs (optional), or `never`
|
|
692
|
+
* - `headerParams` → inline object of header param refs (optional), or `never`
|
|
693
|
+
* - `url` → Express-style template literal (plugin-ts extension, handled by printer)
|
|
694
|
+
*/
|
|
695
|
+
function buildDataSchemaNode({ node, resolveName }) {
|
|
696
|
+
const pathParams = node.parameters.filter((p) => p.in === "path");
|
|
697
|
+
const queryParams = node.parameters.filter((p) => p.in === "query");
|
|
698
|
+
const headerParams = node.parameters.filter((p) => p.in === "header");
|
|
699
|
+
return (0, _kubb_ast.createSchema)({
|
|
700
|
+
type: "object",
|
|
701
|
+
properties: [
|
|
702
|
+
(0, _kubb_ast.createProperty)({
|
|
703
|
+
name: "data",
|
|
704
|
+
schema: node.requestBody ? (0, _kubb_ast.createSchema)({
|
|
705
|
+
type: "ref",
|
|
706
|
+
name: resolveName({
|
|
707
|
+
name: `${node.operationId} MutationRequest`,
|
|
708
|
+
type: "function"
|
|
709
|
+
}),
|
|
710
|
+
optional: true
|
|
711
|
+
}) : (0, _kubb_ast.createSchema)({
|
|
712
|
+
type: "never",
|
|
713
|
+
optional: true
|
|
714
|
+
})
|
|
715
|
+
}),
|
|
716
|
+
(0, _kubb_ast.createProperty)({
|
|
717
|
+
name: "pathParams",
|
|
718
|
+
schema: pathParams.length > 0 ? buildParamsSchema({
|
|
719
|
+
params: pathParams,
|
|
720
|
+
operationId: node.operationId,
|
|
721
|
+
resolveName
|
|
722
|
+
}) : (0, _kubb_ast.createSchema)({
|
|
723
|
+
type: "never",
|
|
724
|
+
optional: true
|
|
725
|
+
})
|
|
726
|
+
}),
|
|
727
|
+
(0, _kubb_ast.createProperty)({
|
|
728
|
+
name: "queryParams",
|
|
729
|
+
schema: queryParams.length > 0 ? (0, _kubb_ast.createSchema)({
|
|
730
|
+
...buildParamsSchema({
|
|
731
|
+
params: queryParams,
|
|
732
|
+
operationId: node.operationId,
|
|
733
|
+
resolveName
|
|
734
|
+
}),
|
|
735
|
+
optional: true
|
|
736
|
+
}) : (0, _kubb_ast.createSchema)({
|
|
737
|
+
type: "never",
|
|
738
|
+
optional: true
|
|
739
|
+
})
|
|
740
|
+
}),
|
|
741
|
+
(0, _kubb_ast.createProperty)({
|
|
742
|
+
name: "headerParams",
|
|
743
|
+
schema: headerParams.length > 0 ? (0, _kubb_ast.createSchema)({
|
|
744
|
+
...buildParamsSchema({
|
|
745
|
+
params: headerParams,
|
|
746
|
+
operationId: node.operationId,
|
|
747
|
+
resolveName
|
|
748
|
+
}),
|
|
749
|
+
optional: true
|
|
750
|
+
}) : (0, _kubb_ast.createSchema)({
|
|
751
|
+
type: "never",
|
|
752
|
+
optional: true
|
|
753
|
+
})
|
|
754
|
+
}),
|
|
755
|
+
(0, _kubb_ast.createProperty)({
|
|
756
|
+
name: "url",
|
|
757
|
+
schema: (0, _kubb_ast.createSchema)({
|
|
758
|
+
type: "url",
|
|
759
|
+
path: node.path
|
|
760
|
+
})
|
|
761
|
+
})
|
|
762
|
+
]
|
|
763
|
+
});
|
|
764
|
+
}
|
|
765
|
+
/**
|
|
766
|
+
* Builds an `ObjectSchemaNode` representing `<OperationId>Responses` — keyed by HTTP status code.
|
|
767
|
+
*
|
|
768
|
+
* Example output:
|
|
769
|
+
* ```ts
|
|
770
|
+
* export type PlaceOrderPatchResponses = { 200: PlaceOrderPatch200; 405: PlaceOrderPatch405 }
|
|
771
|
+
* ```
|
|
772
|
+
*/
|
|
773
|
+
function buildResponsesSchemaNode({ node, resolveName }) {
|
|
774
|
+
const responsesWithSchema = node.responses.filter((res) => res.schema);
|
|
775
|
+
if (responsesWithSchema.length === 0) return null;
|
|
776
|
+
return (0, _kubb_ast.createSchema)({
|
|
777
|
+
type: "object",
|
|
778
|
+
properties: responsesWithSchema.map((res) => (0, _kubb_ast.createProperty)({
|
|
779
|
+
name: String(res.statusCode),
|
|
780
|
+
schema: (0, _kubb_ast.createSchema)({
|
|
781
|
+
type: "ref",
|
|
782
|
+
name: resolveName({
|
|
783
|
+
name: `${node.operationId} ${res.statusCode}`,
|
|
784
|
+
type: "function"
|
|
785
|
+
})
|
|
786
|
+
})
|
|
787
|
+
}))
|
|
788
|
+
});
|
|
789
|
+
}
|
|
790
|
+
/**
|
|
791
|
+
* Builds a `UnionSchemaNode` representing `<OperationId>Response` — all response types in union format.
|
|
792
|
+
*
|
|
793
|
+
* Example output:
|
|
794
|
+
* ```ts
|
|
795
|
+
* export type PlaceOrderPatchResponse = PlaceOrderPatch200 | PlaceOrderPatch405
|
|
796
|
+
* ```
|
|
797
|
+
*/
|
|
798
|
+
function buildResponseUnionSchemaNode({ node, resolveName }) {
|
|
799
|
+
const responsesWithSchema = node.responses.filter((res) => res.schema);
|
|
800
|
+
if (responsesWithSchema.length === 0) return null;
|
|
801
|
+
return (0, _kubb_ast.createSchema)({
|
|
802
|
+
type: "union",
|
|
803
|
+
members: responsesWithSchema.map((res) => (0, _kubb_ast.createSchema)({
|
|
804
|
+
type: "ref",
|
|
805
|
+
name: resolveName({
|
|
806
|
+
name: `${node.operationId} ${res.statusCode}`,
|
|
807
|
+
type: "function"
|
|
808
|
+
})
|
|
809
|
+
}))
|
|
810
|
+
});
|
|
811
|
+
}
|
|
812
|
+
//#endregion
|
|
661
813
|
//#region src/generators/v2/typeGenerator.tsx
|
|
662
|
-
const typeGenerator = (0,
|
|
814
|
+
const typeGenerator = (0, _kubb_core.defineGenerator)({
|
|
663
815
|
name: "typescript",
|
|
664
|
-
|
|
816
|
+
type: "react",
|
|
665
817
|
Operation({ node, adapter, options }) {
|
|
666
|
-
const { enumType, enumKeyCasing, optionalType, arrayType, syntaxType } = options;
|
|
667
|
-
const {
|
|
818
|
+
const { enumType, enumKeyCasing, optionalType, arrayType, syntaxType, paramsCasing, mapper } = options;
|
|
819
|
+
const { mode, getFile, resolveName } = (0, _kubb_core_hooks.useKubb)();
|
|
668
820
|
const file = getFile({
|
|
669
821
|
name: node.operationId,
|
|
670
|
-
pluginName: plugin.name,
|
|
671
822
|
extname: ".ts",
|
|
672
823
|
mode
|
|
673
824
|
});
|
|
825
|
+
const params = (0, _kubb_ast.applyParamsCasing)(node.parameters, paramsCasing);
|
|
674
826
|
function renderSchemaType({ node: schemaNode, name, typedName, description }) {
|
|
827
|
+
if (!schemaNode) return null;
|
|
675
828
|
const imports = adapter.getImports(schemaNode, (schemaName) => ({
|
|
676
829
|
name: resolveName({
|
|
677
830
|
name: schemaName,
|
|
678
|
-
pluginName: plugin.name,
|
|
679
831
|
type: "type"
|
|
680
832
|
}),
|
|
681
833
|
path: getFile({
|
|
682
834
|
name: schemaName,
|
|
683
|
-
pluginName: plugin.name,
|
|
684
835
|
extname: ".ts",
|
|
685
836
|
mode
|
|
686
837
|
}).path
|
|
@@ -703,63 +854,90 @@ const typeGenerator = (0, _kubb_plugin_oas_generators.createReactGenerator)({
|
|
|
703
854
|
enumKeyCasing,
|
|
704
855
|
optionalType,
|
|
705
856
|
arrayType,
|
|
706
|
-
syntaxType
|
|
857
|
+
syntaxType,
|
|
858
|
+
mapper
|
|
707
859
|
})] });
|
|
708
860
|
}
|
|
709
|
-
const paramTypes =
|
|
710
|
-
|
|
861
|
+
const paramTypes = params.map((param) => renderSchemaType({
|
|
862
|
+
node: param.schema,
|
|
863
|
+
name: resolveName({
|
|
711
864
|
name: `${node.operationId} ${param.name}`,
|
|
712
|
-
pluginName: plugin.name,
|
|
713
865
|
type: "function"
|
|
714
|
-
})
|
|
715
|
-
|
|
866
|
+
}),
|
|
867
|
+
typedName: resolveName({
|
|
716
868
|
name: `${node.operationId} ${param.name}`,
|
|
717
|
-
pluginName: plugin.name,
|
|
718
869
|
type: "type"
|
|
719
|
-
})
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
870
|
+
})
|
|
871
|
+
}));
|
|
872
|
+
const responseTypes = node.responses.filter((res) => res.schema).map((res) => renderSchemaType({
|
|
873
|
+
node: res.schema,
|
|
874
|
+
name: resolveName({
|
|
875
|
+
name: `${node.operationId} ${res.statusCode}`,
|
|
876
|
+
type: "function"
|
|
877
|
+
}),
|
|
878
|
+
typedName: resolveName({
|
|
879
|
+
name: `${node.operationId} ${res.statusCode}`,
|
|
880
|
+
type: "type"
|
|
881
|
+
}),
|
|
882
|
+
description: res.description
|
|
883
|
+
}));
|
|
884
|
+
const requestType = node.requestBody ? renderSchemaType({
|
|
885
|
+
node: node.requestBody,
|
|
886
|
+
name: resolveName({
|
|
887
|
+
name: `${node.operationId} MutationRequest`,
|
|
888
|
+
type: "function"
|
|
889
|
+
}),
|
|
890
|
+
typedName: resolveName({
|
|
891
|
+
name: `${node.operationId} MutationRequest`,
|
|
892
|
+
type: "type"
|
|
893
|
+
}),
|
|
894
|
+
description: node.requestBody.description
|
|
895
|
+
}) : null;
|
|
896
|
+
const dataType = renderSchemaType({
|
|
897
|
+
node: buildDataSchemaNode({
|
|
898
|
+
node: {
|
|
899
|
+
...node,
|
|
900
|
+
parameters: params
|
|
901
|
+
},
|
|
902
|
+
resolveName
|
|
903
|
+
}),
|
|
904
|
+
name: resolveName({
|
|
905
|
+
name: `${node.operationId} Data`,
|
|
906
|
+
type: "function"
|
|
907
|
+
}),
|
|
908
|
+
typedName: resolveName({
|
|
909
|
+
name: `${node.operationId} Data`,
|
|
910
|
+
type: "type"
|
|
911
|
+
})
|
|
725
912
|
});
|
|
726
|
-
const
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
type: "type"
|
|
740
|
-
}),
|
|
741
|
-
description: res.description
|
|
742
|
-
});
|
|
913
|
+
const responsesType = renderSchemaType({
|
|
914
|
+
node: buildResponsesSchemaNode({
|
|
915
|
+
node,
|
|
916
|
+
resolveName
|
|
917
|
+
}),
|
|
918
|
+
name: resolveName({
|
|
919
|
+
name: `${node.operationId} Responses`,
|
|
920
|
+
type: "function"
|
|
921
|
+
}),
|
|
922
|
+
typedName: resolveName({
|
|
923
|
+
name: `${node.operationId} Responses`,
|
|
924
|
+
type: "type"
|
|
925
|
+
})
|
|
743
926
|
});
|
|
744
|
-
const
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
927
|
+
const responseType = renderSchemaType({
|
|
928
|
+
node: buildResponseUnionSchemaNode({
|
|
929
|
+
node,
|
|
930
|
+
resolveName
|
|
931
|
+
}),
|
|
932
|
+
name: resolveName({
|
|
933
|
+
name: `${node.operationId} Response`,
|
|
749
934
|
type: "function"
|
|
750
|
-
})
|
|
751
|
-
|
|
752
|
-
name:
|
|
753
|
-
pluginName: plugin.name,
|
|
935
|
+
}),
|
|
936
|
+
typedName: resolveName({
|
|
937
|
+
name: `${node.operationId} Response`,
|
|
754
938
|
type: "type"
|
|
755
|
-
})
|
|
756
|
-
|
|
757
|
-
node: node.requestBody,
|
|
758
|
-
name: resolvedName,
|
|
759
|
-
typedName,
|
|
760
|
-
description: node.requestBody.description
|
|
761
|
-
});
|
|
762
|
-
})() : null;
|
|
939
|
+
})
|
|
940
|
+
});
|
|
763
941
|
return /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsxs)(_kubb_react_fabric.File, {
|
|
764
942
|
baseName: file.baseName,
|
|
765
943
|
path: file.path,
|
|
@@ -767,23 +945,24 @@ const typeGenerator = (0, _kubb_plugin_oas_generators.createReactGenerator)({
|
|
|
767
945
|
children: [
|
|
768
946
|
paramTypes,
|
|
769
947
|
responseTypes,
|
|
770
|
-
requestType
|
|
948
|
+
requestType,
|
|
949
|
+
dataType,
|
|
950
|
+
responsesType,
|
|
951
|
+
responseType
|
|
771
952
|
]
|
|
772
953
|
});
|
|
773
954
|
},
|
|
774
955
|
Schema({ node, adapter, options }) {
|
|
775
|
-
const { enumType, enumKeyCasing, syntaxType, optionalType, arrayType } = options;
|
|
776
|
-
const {
|
|
956
|
+
const { enumType, enumKeyCasing, syntaxType, optionalType, arrayType, mapper } = options;
|
|
957
|
+
const { mode, resolveName, getFile } = (0, _kubb_core_hooks.useKubb)();
|
|
777
958
|
if (!node.name) return;
|
|
778
959
|
const imports = adapter.getImports(node, (schemaName) => ({
|
|
779
960
|
name: resolveName({
|
|
780
961
|
name: schemaName,
|
|
781
|
-
pluginName: plugin.name,
|
|
782
962
|
type: "type"
|
|
783
963
|
}),
|
|
784
964
|
path: getFile({
|
|
785
965
|
name: schemaName,
|
|
786
|
-
pluginName: plugin.name,
|
|
787
966
|
extname: ".ts",
|
|
788
967
|
mode
|
|
789
968
|
}).path
|
|
@@ -791,20 +970,17 @@ const typeGenerator = (0, _kubb_plugin_oas_generators.createReactGenerator)({
|
|
|
791
970
|
const isEnumSchema = node.type === "enum";
|
|
792
971
|
let typedName = resolveName({
|
|
793
972
|
name: node.name,
|
|
794
|
-
pluginName: plugin.name,
|
|
795
973
|
type: "type"
|
|
796
974
|
});
|
|
797
|
-
if (["asConst", "asPascalConst"].includes(enumType) && isEnumSchema) typedName
|
|
975
|
+
if (["asConst", "asPascalConst"].includes(enumType) && isEnumSchema) typedName += "Key";
|
|
798
976
|
const type = {
|
|
799
977
|
name: resolveName({
|
|
800
978
|
name: node.name,
|
|
801
|
-
pluginName: plugin.name,
|
|
802
979
|
type: "function"
|
|
803
980
|
}),
|
|
804
981
|
typedName,
|
|
805
982
|
file: getFile({
|
|
806
983
|
name: node.name,
|
|
807
|
-
pluginName: plugin.name,
|
|
808
984
|
extname: ".ts",
|
|
809
985
|
mode
|
|
810
986
|
})
|
|
@@ -830,7 +1006,8 @@ const typeGenerator = (0, _kubb_plugin_oas_generators.createReactGenerator)({
|
|
|
830
1006
|
enumKeyCasing,
|
|
831
1007
|
optionalType,
|
|
832
1008
|
arrayType,
|
|
833
|
-
syntaxType
|
|
1009
|
+
syntaxType,
|
|
1010
|
+
mapper
|
|
834
1011
|
})]
|
|
835
1012
|
});
|
|
836
1013
|
}
|
|
@@ -895,34 +1072,63 @@ const pluginTs = (0, _kubb_core.definePlugin)((options) => {
|
|
|
895
1072
|
await openInStudio({ ast: true });
|
|
896
1073
|
await (0, _kubb_ast.walk)(rootNode, {
|
|
897
1074
|
async schema(schemaNode) {
|
|
898
|
-
|
|
899
|
-
if (generator.type === "react" && generator.version === "2")
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
1075
|
+
const writeTasks = generators.map(async (generator) => {
|
|
1076
|
+
if (generator.type === "react" && generator.version === "2") {
|
|
1077
|
+
const options = (0, _kubb_core.resolveOptions)(schemaNode, {
|
|
1078
|
+
options: plugin.options,
|
|
1079
|
+
exclude,
|
|
1080
|
+
include,
|
|
1081
|
+
override
|
|
1082
|
+
});
|
|
1083
|
+
if (options === null) return;
|
|
1084
|
+
await (0, _kubb_plugin_oas.buildSchema)(schemaNode, {
|
|
1085
|
+
options,
|
|
1086
|
+
adapter,
|
|
1087
|
+
config,
|
|
1088
|
+
fabric,
|
|
1089
|
+
Component: generator.Schema,
|
|
1090
|
+
plugin,
|
|
1091
|
+
pluginManager,
|
|
1092
|
+
mode,
|
|
1093
|
+
version: generator.version
|
|
1094
|
+
});
|
|
1095
|
+
}
|
|
909
1096
|
});
|
|
1097
|
+
await Promise.all(writeTasks);
|
|
910
1098
|
},
|
|
911
1099
|
async operation(operationNode) {
|
|
912
|
-
|
|
913
|
-
if (generator.type === "react" && generator.version === "2")
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
1100
|
+
const writeTasks = generators.map(async (generator) => {
|
|
1101
|
+
if (generator.type === "react" && generator.version === "2") {
|
|
1102
|
+
const options = (0, _kubb_core.resolveOptions)(operationNode, {
|
|
1103
|
+
options: plugin.options,
|
|
1104
|
+
exclude,
|
|
1105
|
+
include,
|
|
1106
|
+
override
|
|
1107
|
+
});
|
|
1108
|
+
if (options === null) return;
|
|
1109
|
+
await (0, _kubb_plugin_oas.buildOperation)(operationNode, {
|
|
1110
|
+
options,
|
|
1111
|
+
adapter,
|
|
1112
|
+
config,
|
|
1113
|
+
fabric,
|
|
1114
|
+
Component: generator.Operation,
|
|
1115
|
+
plugin,
|
|
1116
|
+
pluginManager,
|
|
1117
|
+
mode,
|
|
1118
|
+
version: generator.version
|
|
1119
|
+
});
|
|
1120
|
+
}
|
|
923
1121
|
});
|
|
1122
|
+
await Promise.all(writeTasks);
|
|
924
1123
|
}
|
|
925
1124
|
}, { depth: "shallow" });
|
|
1125
|
+
const barrelFiles = await (0, _kubb_core.getBarrelFiles)(this.fabric.files, {
|
|
1126
|
+
type: output.barrelType ?? "named",
|
|
1127
|
+
root,
|
|
1128
|
+
output,
|
|
1129
|
+
meta: { pluginName: this.plugin.name }
|
|
1130
|
+
});
|
|
1131
|
+
await this.upsertFile(...barrelFiles);
|
|
926
1132
|
return;
|
|
927
1133
|
}
|
|
928
1134
|
const oas = await this.getOas();
|
|
@@ -989,4 +1195,4 @@ Object.defineProperty(exports, "typeGenerator$1", {
|
|
|
989
1195
|
}
|
|
990
1196
|
});
|
|
991
1197
|
|
|
992
|
-
//# sourceMappingURL=plugin-
|
|
1198
|
+
//# sourceMappingURL=plugin-meWNDVe7.cjs.map
|