@kubb/plugin-ts 5.0.0-alpha.8 → 5.0.0-alpha.9
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.d.ts +1 -1
- package/dist/generators.cjs +1 -1
- package/dist/generators.d.ts +31 -2
- package/dist/generators.js +1 -1
- package/dist/index.cjs +2 -1
- package/dist/index.d.ts +41 -2
- package/dist/index.js +2 -2
- package/dist/{plugin-D5NGPj0v.js → plugin-BZkBwnEA.js} +108 -71
- package/dist/plugin-BZkBwnEA.js.map +1 -0
- package/dist/{plugin-MLTxoa8p.cjs → plugin-Bunz1oGa.cjs} +112 -69
- package/dist/plugin-Bunz1oGa.cjs.map +1 -0
- package/dist/{types-CsvB6X5Y.d.ts → types-mSXmB8WU.d.ts} +134 -3
- package/package.json +5 -5
- package/src/constants.ts +5 -5
- package/src/generators/v2/typeGenerator.tsx +28 -32
- package/src/generators/v2/utils.ts +4 -4
- package/src/index.ts +1 -0
- package/src/plugin.ts +6 -5
- package/src/printer.ts +1 -1
- package/src/resolverTs.ts +77 -0
- package/src/types.ts +134 -2
- package/dist/plugin-D5NGPj0v.js.map +0 -1
- package/dist/plugin-MLTxoa8p.cjs.map +0 -1
package/dist/components.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
|
-
import { n as PluginTs } from "./types-
|
|
2
|
+
import { n as PluginTs } from "./types-mSXmB8WU.js";
|
|
3
3
|
import { Schema } from "@kubb/plugin-oas";
|
|
4
4
|
import { SchemaObject } from "@kubb/oas";
|
|
5
5
|
import { FabricReactNode } from "@kubb/react-fabric/types";
|
package/dist/generators.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_plugin = require("./plugin-
|
|
2
|
+
const require_plugin = require("./plugin-Bunz1oGa.cjs");
|
|
3
3
|
exports.typeGenerator = require_plugin.typeGenerator$1;
|
|
4
4
|
exports.typeGeneratorV2 = require_plugin.typeGenerator;
|
package/dist/generators.d.ts
CHANGED
|
@@ -1,11 +1,40 @@
|
|
|
1
1
|
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
|
-
import { n as PluginTs } from "./types-
|
|
2
|
+
import { n as PluginTs } from "./types-mSXmB8WU.js";
|
|
3
3
|
import * as _kubb_core0 from "@kubb/core";
|
|
4
|
-
import {
|
|
4
|
+
import { Config, FileMetaBase, Generator, Group, KubbEvents, Output, Plugin, PluginDriver, PluginFactoryOptions, ResolveNameParams } from "@kubb/core";
|
|
5
5
|
import { HttpMethod, Oas, Operation, SchemaObject, contentType } from "@kubb/oas";
|
|
6
6
|
import { FabricReactNode } from "@kubb/react-fabric/types";
|
|
7
7
|
import { Fabric, KubbFile } from "@kubb/fabric-core/types";
|
|
8
8
|
|
|
9
|
+
//#region ../../internals/utils/src/asyncEventEmitter.d.ts
|
|
10
|
+
/** A function that can be registered as an event listener, synchronous or async. */
|
|
11
|
+
type AsyncListener<TArgs extends unknown[]> = (...args: TArgs) => void | Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* A typed EventEmitter that awaits all async listeners before resolving.
|
|
14
|
+
* Wraps Node's `EventEmitter` with full TypeScript event-map inference.
|
|
15
|
+
*/
|
|
16
|
+
declare class AsyncEventEmitter<TEvents extends { [K in keyof TEvents]: unknown[] }> {
|
|
17
|
+
#private;
|
|
18
|
+
/**
|
|
19
|
+
* `maxListener` controls the maximum number of listeners per event before Node emits a memory-leak warning.
|
|
20
|
+
* @default 10
|
|
21
|
+
*/
|
|
22
|
+
constructor(maxListener?: number);
|
|
23
|
+
/**
|
|
24
|
+
* Emits an event and awaits all registered listeners in parallel.
|
|
25
|
+
* Throws if any listener rejects, wrapping the cause with the event name and serialized arguments.
|
|
26
|
+
*/
|
|
27
|
+
emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArgs: TEvents[TEventName]): Promise<void>;
|
|
28
|
+
/** Registers a persistent listener for the given event. */
|
|
29
|
+
on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: AsyncListener<TEvents[TEventName]>): void;
|
|
30
|
+
/** Registers a one-shot listener that removes itself after the first invocation. */
|
|
31
|
+
onOnce<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: AsyncListener<TEvents[TEventName]>): void;
|
|
32
|
+
/** Removes a previously registered listener. */
|
|
33
|
+
off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: AsyncListener<TEvents[TEventName]>): void;
|
|
34
|
+
/** Removes all listeners from every event channel. */
|
|
35
|
+
removeAll(): void;
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
9
38
|
//#region ../plugin-oas/src/types.d.ts
|
|
10
39
|
type GetOasOptions = {
|
|
11
40
|
validate?: boolean;
|
package/dist/generators.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as typeGenerator, r as typeGenerator$1 } from "./plugin-BZkBwnEA.js";
|
|
2
2
|
export { typeGenerator, typeGenerator$1 as typeGeneratorV2 };
|
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_plugin = require("./plugin-
|
|
2
|
+
const require_plugin = require("./plugin-Bunz1oGa.cjs");
|
|
3
3
|
exports.pluginTs = require_plugin.pluginTs;
|
|
4
4
|
exports.pluginTsName = require_plugin.pluginTsName;
|
|
5
|
+
exports.resolverTs = require_plugin.resolverTs;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,49 @@
|
|
|
1
1
|
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
|
-
import { n as PluginTs, t as Options } from "./types-
|
|
2
|
+
import { n as PluginTs, t as Options } from "./types-mSXmB8WU.js";
|
|
3
3
|
import * as _kubb_core0 from "@kubb/core";
|
|
4
|
+
import * as _kubb_ast_types0 from "@kubb/ast/types";
|
|
4
5
|
|
|
5
6
|
//#region src/plugin.d.ts
|
|
6
7
|
declare const pluginTsName = "plugin-ts";
|
|
7
8
|
declare const pluginTs: (options?: Options | undefined) => _kubb_core0.UserPluginWithLifeCycle<PluginTs>;
|
|
8
9
|
//#endregion
|
|
9
|
-
|
|
10
|
+
//#region src/resolverTs.d.ts
|
|
11
|
+
/**
|
|
12
|
+
* Resolver for `@kubb/plugin-ts` that provides the default naming and path-resolution
|
|
13
|
+
* helpers used by the plugin. Import this in other plugins to resolve the exact names and
|
|
14
|
+
* paths that `plugin-ts` generates without hardcoding the conventions.
|
|
15
|
+
*
|
|
16
|
+
* The `default` method is automatically injected by `defineResolver` — it uses `camelCase`
|
|
17
|
+
* for identifiers/files and `pascalCase` for type names.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* import { resolver } from '@kubb/plugin-ts'
|
|
22
|
+
*
|
|
23
|
+
* resolver.default('list pets', 'type') // → 'ListPets'
|
|
24
|
+
* resolver.resolveName('list pets status 200') // → 'listPetsStatus200'
|
|
25
|
+
* resolver.resolveTypedName('list pets status 200') // → 'ListPetsStatus200'
|
|
26
|
+
* resolver.resolvePathName('list pets', 'file') // → 'listPets'
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
declare const resolverTs: _kubb_core0.Resolver & {
|
|
30
|
+
resolveName(name: string): string;
|
|
31
|
+
resolveTypedName(name: string): string;
|
|
32
|
+
resolvePathName(name: string, type?: "file" | "function" | "type" | "const"): string;
|
|
33
|
+
resolveParamName(node: _kubb_ast_types0.OperationNode, param: _kubb_ast_types0.ParameterNode): string;
|
|
34
|
+
resolveParamTypedName(node: _kubb_ast_types0.OperationNode, param: _kubb_ast_types0.ParameterNode): string;
|
|
35
|
+
resolveResponseStatusName(node: _kubb_ast_types0.OperationNode, statusCode: _kubb_ast_types0.StatusCode): string;
|
|
36
|
+
resolveResponseStatusTypedName(node: _kubb_ast_types0.OperationNode, statusCode: _kubb_ast_types0.StatusCode): string;
|
|
37
|
+
resolveDataName(node: _kubb_ast_types0.OperationNode): string;
|
|
38
|
+
resolveDataTypedName(node: _kubb_ast_types0.OperationNode): string;
|
|
39
|
+
resolveRequestConfigName(node: _kubb_ast_types0.OperationNode): string;
|
|
40
|
+
resolveRequestConfigTypedName(node: _kubb_ast_types0.OperationNode): string;
|
|
41
|
+
resolveResponsesName(node: _kubb_ast_types0.OperationNode): string;
|
|
42
|
+
resolveResponsesTypedName(node: _kubb_ast_types0.OperationNode): string;
|
|
43
|
+
resolveResponseName(node: _kubb_ast_types0.OperationNode): string;
|
|
44
|
+
resolveResponseTypedName(node: _kubb_ast_types0.OperationNode): string;
|
|
45
|
+
resolveEnumKeyTypedName(node: _kubb_ast_types0.SchemaNode): string;
|
|
46
|
+
};
|
|
47
|
+
//#endregion
|
|
48
|
+
export { type PluginTs, pluginTs, pluginTsName, resolverTs };
|
|
10
49
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as pluginTsName, t as pluginTs } from "./plugin-
|
|
2
|
-
export { pluginTs, pluginTsName };
|
|
1
|
+
import { i as resolverTs, n as pluginTsName, t as pluginTs } from "./plugin-BZkBwnEA.js";
|
|
2
|
+
export { pluginTs, pluginTsName, resolverTs };
|
|
@@ -2,7 +2,7 @@ import "./chunk--u3MIqq1.js";
|
|
|
2
2
|
import { A as keywordTypeNodes, C as createTypeDeclaration, D as createUnionDeclaration, E as createTypeReferenceNode, F as camelCase, I as pascalCase, M as syntaxKind, N as jsStringEscape, O as createUrlTemplateType, P as trimQuotes, S as createTypeAliasDeclaration, T as createTypeOperatorNode, _ as createPropertySignature, a as createArrayTypeNode, b as createTrue, c as createIdentifier, d as createIntersectionDeclaration, f as createLiteralTypeNode, g as createPrefixUnaryExpression, h as createOptionalTypeNode, i as createArrayDeclaration, j as modifiers, k as getUnknownType, l as createIndexSignature, m as createOmitDeclaration, n as SyntaxKind, o as createEnumDeclaration, p as createNumericLiteral, r as appendJSDocToNode, s as createFalse, t as Type$1, u as createIndexedAccessTypeNode, v as createRestTypeNode, w as createTypeLiteralNode, x as createTupleTypeNode, y as createStringLiteral } from "./components-CRu8IKY3.js";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { applyParamsCasing, collect, createProperty, createSchema, isPlainStringType, walk } from "@kubb/ast";
|
|
5
|
-
import {
|
|
5
|
+
import { createPlugin, defineGenerator, definePrinter, defineResolver, getBarrelFiles, getMode } from "@kubb/core";
|
|
6
6
|
import { OperationGenerator, SchemaGenerator, buildOperation, buildSchema, isKeyword, pluginOasName, schemaKeywords } from "@kubb/plugin-oas";
|
|
7
7
|
import { useKubb, useMode, usePluginDriver } from "@kubb/core/hooks";
|
|
8
8
|
import { safePrint } from "@kubb/fabric-core/parsers/typescript";
|
|
@@ -555,7 +555,7 @@ const printerTs = definePrinter((options) => {
|
|
|
555
555
|
},
|
|
556
556
|
union(node) {
|
|
557
557
|
const members = node.members ?? [];
|
|
558
|
-
const hasStringLiteral = members.some((m) => m.type === "enum" && m.enumType === "string");
|
|
558
|
+
const hasStringLiteral = members.some((m) => m.type === "enum" && (m.enumType === "string" || m.primitive === "string"));
|
|
559
559
|
const hasPlainString = members.some((m) => isPlainStringType(m));
|
|
560
560
|
if (hasStringLiteral && hasPlainString) return createUnionDeclaration({
|
|
561
561
|
withParentheses: true,
|
|
@@ -727,6 +727,81 @@ function Type({ name, typedName, node, keysToOmit, optionalType, arrayType, synt
|
|
|
727
727
|
})] });
|
|
728
728
|
}
|
|
729
729
|
//#endregion
|
|
730
|
+
//#region src/resolverTs.ts
|
|
731
|
+
/**
|
|
732
|
+
* Resolver for `@kubb/plugin-ts` that provides the default naming and path-resolution
|
|
733
|
+
* helpers used by the plugin. Import this in other plugins to resolve the exact names and
|
|
734
|
+
* paths that `plugin-ts` generates without hardcoding the conventions.
|
|
735
|
+
*
|
|
736
|
+
* The `default` method is automatically injected by `defineResolver` — it uses `camelCase`
|
|
737
|
+
* for identifiers/files and `pascalCase` for type names.
|
|
738
|
+
*
|
|
739
|
+
* @example
|
|
740
|
+
* ```ts
|
|
741
|
+
* import { resolver } from '@kubb/plugin-ts'
|
|
742
|
+
*
|
|
743
|
+
* resolver.default('list pets', 'type') // → 'ListPets'
|
|
744
|
+
* resolver.resolveName('list pets status 200') // → 'listPetsStatus200'
|
|
745
|
+
* resolver.resolveTypedName('list pets status 200') // → 'ListPetsStatus200'
|
|
746
|
+
* resolver.resolvePathName('list pets', 'file') // → 'listPets'
|
|
747
|
+
* ```
|
|
748
|
+
*/
|
|
749
|
+
const resolverTs = defineResolver(() => {
|
|
750
|
+
return {
|
|
751
|
+
default(name, type) {
|
|
752
|
+
return pascalCase(name, { isFile: type === "file" });
|
|
753
|
+
},
|
|
754
|
+
resolveName(name) {
|
|
755
|
+
return this.default(name, "function");
|
|
756
|
+
},
|
|
757
|
+
resolveTypedName(name) {
|
|
758
|
+
return this.default(name, "type");
|
|
759
|
+
},
|
|
760
|
+
resolvePathName(name, type) {
|
|
761
|
+
return this.default(name, type);
|
|
762
|
+
},
|
|
763
|
+
resolveParamName(node, param) {
|
|
764
|
+
return this.resolveName(`${node.operationId} ${this.default(param.in)} ${param.name}`);
|
|
765
|
+
},
|
|
766
|
+
resolveParamTypedName(node, param) {
|
|
767
|
+
return this.resolveTypedName(`${node.operationId} ${this.default(param.in)} ${param.name}`);
|
|
768
|
+
},
|
|
769
|
+
resolveResponseStatusName(node, statusCode) {
|
|
770
|
+
return this.resolveName(`${node.operationId} Status ${statusCode}`);
|
|
771
|
+
},
|
|
772
|
+
resolveResponseStatusTypedName(node, statusCode) {
|
|
773
|
+
return this.resolveTypedName(`${node.operationId} Status ${statusCode}`);
|
|
774
|
+
},
|
|
775
|
+
resolveDataName(node) {
|
|
776
|
+
return this.resolveName(`${node.operationId} Data`);
|
|
777
|
+
},
|
|
778
|
+
resolveDataTypedName(node) {
|
|
779
|
+
return this.resolveTypedName(`${node.operationId} Data`);
|
|
780
|
+
},
|
|
781
|
+
resolveRequestConfigName(node) {
|
|
782
|
+
return this.resolveName(`${node.operationId} RequestConfig`);
|
|
783
|
+
},
|
|
784
|
+
resolveRequestConfigTypedName(node) {
|
|
785
|
+
return this.resolveTypedName(`${node.operationId} RequestConfig`);
|
|
786
|
+
},
|
|
787
|
+
resolveResponsesName(node) {
|
|
788
|
+
return this.resolveName(`${node.operationId} Responses`);
|
|
789
|
+
},
|
|
790
|
+
resolveResponsesTypedName(node) {
|
|
791
|
+
return this.resolveTypedName(`${node.operationId} Responses`);
|
|
792
|
+
},
|
|
793
|
+
resolveResponseName(node) {
|
|
794
|
+
return this.resolveName(`${node.operationId} Response`);
|
|
795
|
+
},
|
|
796
|
+
resolveResponseTypedName(node) {
|
|
797
|
+
return this.resolveTypedName(`${node.operationId} Response`);
|
|
798
|
+
},
|
|
799
|
+
resolveEnumKeyTypedName(node) {
|
|
800
|
+
return `${this.resolveTypedName(node.name ?? "")}Key`;
|
|
801
|
+
}
|
|
802
|
+
};
|
|
803
|
+
});
|
|
804
|
+
//#endregion
|
|
730
805
|
//#region src/generators/v2/utils.ts
|
|
731
806
|
/**
|
|
732
807
|
* Builds an `ObjectSchemaNode` for a group of parameters (path/query/header).
|
|
@@ -764,6 +839,7 @@ function buildDataSchemaNode({ node, resolveName }) {
|
|
|
764
839
|
const headerParams = node.parameters.filter((p) => p.in === "header");
|
|
765
840
|
return createSchema({
|
|
766
841
|
type: "object",
|
|
842
|
+
deprecated: node.deprecated,
|
|
767
843
|
properties: [
|
|
768
844
|
createProperty({
|
|
769
845
|
name: "data",
|
|
@@ -831,13 +907,13 @@ function buildDataSchemaNode({ node, resolveName }) {
|
|
|
831
907
|
/**
|
|
832
908
|
* Builds an `ObjectSchemaNode` representing `<OperationId>Responses` — keyed by HTTP status code.
|
|
833
909
|
* Numeric status codes produce unquoted numeric keys (e.g. `200:`).
|
|
910
|
+
* All responses are included; those without a schema are represented as a ref to a `never` type.
|
|
834
911
|
*/
|
|
835
912
|
function buildResponsesSchemaNode({ node, resolveName }) {
|
|
836
|
-
|
|
837
|
-
if (responsesWithSchema.length === 0) return null;
|
|
913
|
+
if (node.responses.length === 0) return null;
|
|
838
914
|
return createSchema({
|
|
839
915
|
type: "object",
|
|
840
|
-
properties:
|
|
916
|
+
properties: node.responses.map((res) => createProperty({
|
|
841
917
|
name: String(res.statusCode),
|
|
842
918
|
schema: createSchema({
|
|
843
919
|
type: "ref",
|
|
@@ -869,12 +945,12 @@ function buildResponseUnionSchemaNode({ node, resolveName }) {
|
|
|
869
945
|
}
|
|
870
946
|
//#endregion
|
|
871
947
|
//#region src/generators/v2/typeGenerator.tsx
|
|
872
|
-
const typeGenerator =
|
|
948
|
+
const typeGenerator = defineGenerator({
|
|
873
949
|
name: "typescript",
|
|
874
950
|
type: "react",
|
|
875
951
|
Operation({ node, adapter, options }) {
|
|
876
952
|
const { enumType, enumKeyCasing, optionalType, arrayType, syntaxType, paramsCasing, group } = options;
|
|
877
|
-
const { mode, getFile, resolveName } = useKubb();
|
|
953
|
+
const { mode, getFile, resolveName, resolveBanner, resolveFooter } = useKubb();
|
|
878
954
|
const file = getFile({
|
|
879
955
|
name: node.operationId,
|
|
880
956
|
extname: ".ts",
|
|
@@ -918,37 +994,19 @@ const typeGenerator = createGenerator({
|
|
|
918
994
|
}
|
|
919
995
|
const paramTypes = params.map((param) => renderSchemaType({
|
|
920
996
|
node: param.schema,
|
|
921
|
-
name:
|
|
922
|
-
|
|
923
|
-
type: "function"
|
|
924
|
-
}),
|
|
925
|
-
typedName: resolveName({
|
|
926
|
-
name: `${node.operationId} ${pascalCase(param.in)} ${param.name}`,
|
|
927
|
-
type: "type"
|
|
928
|
-
})
|
|
997
|
+
name: resolverTs.resolveParamName(node, param),
|
|
998
|
+
typedName: resolverTs.resolveParamTypedName(node, param)
|
|
929
999
|
}));
|
|
930
|
-
const responseTypes = node.responses.
|
|
1000
|
+
const responseTypes = node.responses.map((res) => renderSchemaType({
|
|
931
1001
|
node: res.schema,
|
|
932
|
-
name:
|
|
933
|
-
|
|
934
|
-
type: "function"
|
|
935
|
-
}),
|
|
936
|
-
typedName: resolveName({
|
|
937
|
-
name: `${node.operationId} Status ${res.statusCode}`,
|
|
938
|
-
type: "type"
|
|
939
|
-
}),
|
|
1002
|
+
name: resolverTs.resolveResponseStatusName(node, res.statusCode),
|
|
1003
|
+
typedName: resolverTs.resolveResponseStatusTypedName(node, res.statusCode),
|
|
940
1004
|
description: res.description
|
|
941
1005
|
}));
|
|
942
1006
|
const requestType = node.requestBody ? renderSchemaType({
|
|
943
1007
|
node: node.requestBody,
|
|
944
|
-
name:
|
|
945
|
-
|
|
946
|
-
type: "function"
|
|
947
|
-
}),
|
|
948
|
-
typedName: resolveName({
|
|
949
|
-
name: `${node.operationId} Data`,
|
|
950
|
-
type: "type"
|
|
951
|
-
}),
|
|
1008
|
+
name: resolverTs.resolveDataName(node),
|
|
1009
|
+
typedName: resolverTs.resolveDataTypedName(node),
|
|
952
1010
|
description: node.requestBody.description
|
|
953
1011
|
}) : null;
|
|
954
1012
|
const dataType = renderSchemaType({
|
|
@@ -959,48 +1017,32 @@ const typeGenerator = createGenerator({
|
|
|
959
1017
|
},
|
|
960
1018
|
resolveName
|
|
961
1019
|
}),
|
|
962
|
-
name:
|
|
963
|
-
|
|
964
|
-
type: "function"
|
|
965
|
-
}),
|
|
966
|
-
typedName: resolveName({
|
|
967
|
-
name: `${node.operationId} RequestConfig`,
|
|
968
|
-
type: "type"
|
|
969
|
-
})
|
|
1020
|
+
name: resolverTs.resolveRequestConfigName(node),
|
|
1021
|
+
typedName: resolverTs.resolveRequestConfigTypedName(node)
|
|
970
1022
|
});
|
|
971
1023
|
const responsesType = renderSchemaType({
|
|
972
1024
|
node: buildResponsesSchemaNode({
|
|
973
1025
|
node,
|
|
974
1026
|
resolveName
|
|
975
1027
|
}),
|
|
976
|
-
name:
|
|
977
|
-
|
|
978
|
-
type: "function"
|
|
979
|
-
}),
|
|
980
|
-
typedName: resolveName({
|
|
981
|
-
name: `${node.operationId} Responses`,
|
|
982
|
-
type: "type"
|
|
983
|
-
})
|
|
1028
|
+
name: resolverTs.resolveResponsesName(node),
|
|
1029
|
+
typedName: resolverTs.resolveResponsesTypedName(node)
|
|
984
1030
|
});
|
|
985
1031
|
const responseType = renderSchemaType({
|
|
986
1032
|
node: buildResponseUnionSchemaNode({
|
|
987
1033
|
node,
|
|
988
1034
|
resolveName
|
|
989
1035
|
}),
|
|
990
|
-
name:
|
|
991
|
-
|
|
992
|
-
type: "function"
|
|
993
|
-
}),
|
|
994
|
-
typedName: resolveName({
|
|
995
|
-
name: `${node.operationId} Response`,
|
|
996
|
-
type: "type"
|
|
997
|
-
}),
|
|
1036
|
+
name: resolverTs.resolveResponseName(node),
|
|
1037
|
+
typedName: resolverTs.resolveResponseTypedName(node),
|
|
998
1038
|
description: "Union of all possible responses"
|
|
999
1039
|
});
|
|
1000
1040
|
return /* @__PURE__ */ jsxs(File, {
|
|
1001
1041
|
baseName: file.baseName,
|
|
1002
1042
|
path: file.path,
|
|
1003
1043
|
meta: file.meta,
|
|
1044
|
+
banner: resolveBanner(),
|
|
1045
|
+
footer: resolveFooter(),
|
|
1004
1046
|
children: [
|
|
1005
1047
|
paramTypes,
|
|
1006
1048
|
responseTypes,
|
|
@@ -1013,7 +1055,7 @@ const typeGenerator = createGenerator({
|
|
|
1013
1055
|
},
|
|
1014
1056
|
Schema({ node, adapter, options }) {
|
|
1015
1057
|
const { enumType, enumKeyCasing, syntaxType, optionalType, arrayType } = options;
|
|
1016
|
-
const { mode, resolveName, getFile } = useKubb();
|
|
1058
|
+
const { mode, resolveName, getFile, resolveBanner, resolveFooter } = useKubb();
|
|
1017
1059
|
if (!node.name) return;
|
|
1018
1060
|
const imports = adapter.getImports(node, (schemaName) => ({
|
|
1019
1061
|
name: resolveName({
|
|
@@ -1027,16 +1069,9 @@ const typeGenerator = createGenerator({
|
|
|
1027
1069
|
}).path
|
|
1028
1070
|
}));
|
|
1029
1071
|
const isEnumSchema = node.type === "enum";
|
|
1030
|
-
|
|
1031
|
-
name: node.name,
|
|
1032
|
-
type: "type"
|
|
1033
|
-
});
|
|
1034
|
-
if (ENUM_TYPES_WITH_KEY_SUFFIX.has(enumType) && isEnumSchema) typedName += "Key";
|
|
1072
|
+
const typedName = ENUM_TYPES_WITH_KEY_SUFFIX.has(enumType) && isEnumSchema ? resolverTs.resolveEnumKeyTypedName(node) : resolverTs.resolveTypedName(node.name);
|
|
1035
1073
|
const type = {
|
|
1036
|
-
name: resolveName(
|
|
1037
|
-
name: node.name,
|
|
1038
|
-
type: "function"
|
|
1039
|
-
}),
|
|
1074
|
+
name: resolverTs.resolveName(node.name),
|
|
1040
1075
|
typedName,
|
|
1041
1076
|
file: getFile({
|
|
1042
1077
|
name: node.name,
|
|
@@ -1048,6 +1083,8 @@ const typeGenerator = createGenerator({
|
|
|
1048
1083
|
baseName: type.file.baseName,
|
|
1049
1084
|
path: type.file.path,
|
|
1050
1085
|
meta: type.file.meta,
|
|
1086
|
+
banner: resolveBanner(),
|
|
1087
|
+
footer: resolveFooter(),
|
|
1051
1088
|
children: [mode === "split" && imports.map((imp) => /* @__PURE__ */ jsx(File.Import, {
|
|
1052
1089
|
root: type.file.path,
|
|
1053
1090
|
path: imp.path,
|
|
@@ -1117,7 +1154,7 @@ const pluginTs = createPlugin((options) => {
|
|
|
1117
1154
|
return path.resolve(root, output.path, baseName);
|
|
1118
1155
|
},
|
|
1119
1156
|
resolveName(name, type) {
|
|
1120
|
-
const resolvedName =
|
|
1157
|
+
const resolvedName = resolverTs.default(name, type);
|
|
1121
1158
|
if (type) return transformers?.name?.(resolvedName, type) || resolvedName;
|
|
1122
1159
|
return resolvedName;
|
|
1123
1160
|
},
|
|
@@ -1131,7 +1168,7 @@ const pluginTs = createPlugin((options) => {
|
|
|
1131
1168
|
async schema(schemaNode) {
|
|
1132
1169
|
const writeTasks = generators.map(async (generator) => {
|
|
1133
1170
|
if (generator.type === "react" && generator.version === "2") {
|
|
1134
|
-
const options = resolveOptions(schemaNode, {
|
|
1171
|
+
const options = resolverTs.resolveOptions(schemaNode, {
|
|
1135
1172
|
options: plugin.options,
|
|
1136
1173
|
exclude,
|
|
1137
1174
|
include,
|
|
@@ -1156,7 +1193,7 @@ const pluginTs = createPlugin((options) => {
|
|
|
1156
1193
|
async operation(operationNode) {
|
|
1157
1194
|
const writeTasks = generators.map(async (generator) => {
|
|
1158
1195
|
if (generator.type === "react" && generator.version === "2") {
|
|
1159
|
-
const options = resolveOptions(operationNode, {
|
|
1196
|
+
const options = resolverTs.resolveOptions(operationNode, {
|
|
1160
1197
|
options: plugin.options,
|
|
1161
1198
|
exclude,
|
|
1162
1199
|
include,
|
|
@@ -1227,6 +1264,6 @@ const pluginTs = createPlugin((options) => {
|
|
|
1227
1264
|
};
|
|
1228
1265
|
});
|
|
1229
1266
|
//#endregion
|
|
1230
|
-
export { typeGenerator$1 as i, pluginTsName as n, typeGenerator as r, pluginTs as t };
|
|
1267
|
+
export { typeGenerator$1 as a, resolverTs as i, pluginTsName as n, typeGenerator as r, pluginTs as t };
|
|
1231
1268
|
|
|
1232
|
-
//# sourceMappingURL=plugin-
|
|
1269
|
+
//# sourceMappingURL=plugin-BZkBwnEA.js.map
|