@kubb/plugin-ts 5.0.0-alpha.34 → 5.0.0-alpha.35
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/index.cjs +111 -176
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +20 -23
- package/dist/index.js +111 -176
- package/dist/index.js.map +1 -1
- package/package.json +5 -6
- package/src/components/Enum.tsx +3 -3
- package/src/components/Type.tsx +6 -8
- package/src/factory.ts +10 -8
- package/src/generators/typeGenerator.tsx +16 -17
- package/src/generators/typeGeneratorLegacy.tsx +48 -49
- package/src/plugin.ts +47 -81
- package/src/printers/functionPrinter.ts +13 -13
- package/src/printers/printerTs.ts +7 -8
- package/src/types.ts +11 -12
- package/src/utils.ts +30 -31
- package/src/presets.ts +0 -28
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
|
-
import * as _$_kubb_ast0 from "@kubb/ast";
|
|
3
|
-
import { OperationParamsResolver, Printer } from "@kubb/ast";
|
|
4
|
-
import ts from "typescript";
|
|
5
2
|
import * as _$_kubb_core0 from "@kubb/core";
|
|
6
|
-
import { CompatibilityPreset, Exclude, Generator, Group, Include, Output, Override, PluginFactoryOptions, PrinterFactoryOptions, PrinterPartial, ResolvePathOptions, Resolver, UserGroup } from "@kubb/core";
|
|
7
|
-
import
|
|
3
|
+
import { CompatibilityPreset, Exclude, Generator, Group, Include, Output, Override, PluginFactoryOptions, PrinterFactoryOptions, PrinterPartial, ResolvePathOptions, Resolver, UserGroup, ast } from "@kubb/core";
|
|
4
|
+
import ts from "typescript";
|
|
8
5
|
import { KubbReactNode } from "@kubb/renderer-jsx/types";
|
|
9
6
|
|
|
10
7
|
//#region src/printers/printerTs.d.ts
|
|
@@ -109,7 +106,7 @@ type PrinterTsFactory = PrinterFactoryOptions<'typescript', PrinterTsOptions, ts
|
|
|
109
106
|
* const declaration = printer.print(schemaNode) // ts.TypeAliasDeclaration | ts.InterfaceDeclaration
|
|
110
107
|
* ```
|
|
111
108
|
*/
|
|
112
|
-
declare const printerTs: (options?:
|
|
109
|
+
declare const printerTs: (options?: any) => ast.Printer<PrinterFactoryOptions<"typescript", PrinterTsOptions, ts.TypeNode, string>>;
|
|
113
110
|
//#endregion
|
|
114
111
|
//#region src/types.d.ts
|
|
115
112
|
/**
|
|
@@ -117,7 +114,7 @@ declare const printerTs: (options?: PrinterTsOptions | undefined) => _$_kubb_ast
|
|
|
117
114
|
* Extends the base `Resolver` (which provides `default` and `resolveOptions`) with
|
|
118
115
|
* plugin-specific naming helpers for operations, parameters, responses, and schemas.
|
|
119
116
|
*/
|
|
120
|
-
type ResolverTs = Resolver & OperationParamsResolver & {
|
|
117
|
+
type ResolverTs = Resolver & ast.OperationParamsResolver & {
|
|
121
118
|
/**
|
|
122
119
|
* Resolves the name for a given raw name (equivalent to `default(name, 'function')`).
|
|
123
120
|
* Since TypeScript only emits types, this is the canonical naming method.
|
|
@@ -136,7 +133,7 @@ type ResolverTs = Resolver & OperationParamsResolver & {
|
|
|
136
133
|
/**
|
|
137
134
|
* Resolves the request body type name for an operation (required on ResolverTs).
|
|
138
135
|
*/
|
|
139
|
-
resolveDataName(node: OperationNode): string;
|
|
136
|
+
resolveDataName(node: ast.OperationNode): string;
|
|
140
137
|
/**
|
|
141
138
|
* Resolves the name for an operation response by status code.
|
|
142
139
|
* Encapsulates the `<operationId> Status <statusCode>` template with PascalCase applied to the result.
|
|
@@ -144,28 +141,28 @@ type ResolverTs = Resolver & OperationParamsResolver & {
|
|
|
144
141
|
* @example
|
|
145
142
|
* resolver.resolveResponseStatusName(node, 200) // → 'ListPetsStatus200'
|
|
146
143
|
*/
|
|
147
|
-
resolveResponseStatusName(node: OperationNode, statusCode: StatusCode): string;
|
|
144
|
+
resolveResponseStatusName(node: ast.OperationNode, statusCode: ast.StatusCode): string;
|
|
148
145
|
/**
|
|
149
146
|
* Resolves the name for an operation's request config (`RequestConfig`).
|
|
150
147
|
*
|
|
151
148
|
* @example
|
|
152
149
|
* resolver.resolveRequestConfigName(node) // → 'ListPetsRequestConfig'
|
|
153
150
|
*/
|
|
154
|
-
resolveRequestConfigName(node: OperationNode): string;
|
|
151
|
+
resolveRequestConfigName(node: ast.OperationNode): string;
|
|
155
152
|
/**
|
|
156
153
|
* Resolves the name for the collection of all operation responses (`Responses`).
|
|
157
154
|
*
|
|
158
155
|
* @example
|
|
159
156
|
* resolver.resolveResponsesName(node) // → 'ListPetsResponses'
|
|
160
157
|
*/
|
|
161
|
-
resolveResponsesName(node: OperationNode): string;
|
|
158
|
+
resolveResponsesName(node: ast.OperationNode): string;
|
|
162
159
|
/**
|
|
163
160
|
* Resolves the name for the union of all operation responses (`Response`).
|
|
164
161
|
*
|
|
165
162
|
* @example
|
|
166
163
|
* resolver.resolveResponseName(node) // → 'ListPetsResponse'
|
|
167
164
|
*/
|
|
168
|
-
resolveResponseName(node: OperationNode): string;
|
|
165
|
+
resolveResponseName(node: ast.OperationNode): string;
|
|
169
166
|
/**
|
|
170
167
|
* Resolves the TypeScript type alias name for an enum schema's key variant.
|
|
171
168
|
* Appends `enumTypeSuffix` (default `'Key'`) after applying the default naming convention.
|
|
@@ -184,21 +181,21 @@ type ResolverTs = Resolver & OperationParamsResolver & {
|
|
|
184
181
|
* @example
|
|
185
182
|
* resolver.resolvePathParamsName(node, param) // → 'GetPetByIdPathParams'
|
|
186
183
|
*/
|
|
187
|
-
resolvePathParamsName(node: OperationNode, param: ParameterNode): string;
|
|
184
|
+
resolvePathParamsName(node: ast.OperationNode, param: ast.ParameterNode): string;
|
|
188
185
|
/**
|
|
189
186
|
* Resolves the name for an operation's grouped query parameters type.
|
|
190
187
|
*
|
|
191
188
|
* @example
|
|
192
189
|
* resolver.resolveQueryParamsName(node, param) // → 'FindPetsByStatusQueryParams'
|
|
193
190
|
*/
|
|
194
|
-
resolveQueryParamsName(node: OperationNode, param: ParameterNode): string;
|
|
191
|
+
resolveQueryParamsName(node: ast.OperationNode, param: ast.ParameterNode): string;
|
|
195
192
|
/**
|
|
196
193
|
* Resolves the name for an operation's grouped header parameters type.
|
|
197
194
|
*
|
|
198
195
|
* @example
|
|
199
196
|
* resolver.resolveHeaderParamsName(node, param) // → 'DeletePetHeaderParams'
|
|
200
197
|
*/
|
|
201
|
-
resolveHeaderParamsName(node: OperationNode, param: ParameterNode): string;
|
|
198
|
+
resolveHeaderParamsName(node: ast.OperationNode, param: ast.ParameterNode): string;
|
|
202
199
|
};
|
|
203
200
|
type EnumKeyCasing = 'screamingSnakeCase' | 'snakeCase' | 'pascalCase' | 'camelCase' | 'none';
|
|
204
201
|
/**
|
|
@@ -366,7 +363,7 @@ type Options = {
|
|
|
366
363
|
* }
|
|
367
364
|
* ```
|
|
368
365
|
*/
|
|
369
|
-
transformer?: Visitor;
|
|
366
|
+
transformer?: ast.Visitor;
|
|
370
367
|
/**
|
|
371
368
|
* Override individual printer node handlers to customize rendering of specific schema types.
|
|
372
369
|
*
|
|
@@ -417,7 +414,7 @@ declare global {
|
|
|
417
414
|
//#endregion
|
|
418
415
|
//#region src/components/Enum.d.ts
|
|
419
416
|
type Props$1 = {
|
|
420
|
-
node: EnumSchemaNode;
|
|
417
|
+
node: ast.EnumSchemaNode;
|
|
421
418
|
enumType: PluginTs['resolvedOptions']['enumType'];
|
|
422
419
|
enumTypeSuffix: PluginTs['resolvedOptions']['enumTypeSuffix'];
|
|
423
420
|
enumKeyCasing: PluginTs['resolvedOptions']['enumKeyCasing'];
|
|
@@ -452,12 +449,12 @@ declare function Enum({
|
|
|
452
449
|
//#region src/components/Type.d.ts
|
|
453
450
|
type Props = {
|
|
454
451
|
name: string;
|
|
455
|
-
node: SchemaNode;
|
|
452
|
+
node: ast.SchemaNode;
|
|
456
453
|
/**
|
|
457
454
|
* Pre-configured printer instance created by the generator.
|
|
458
455
|
* Created with `printerTs({ ..., nodes: options.printer?.nodes })`.
|
|
459
456
|
*/
|
|
460
|
-
printer: Printer<PrinterTsFactory>;
|
|
457
|
+
printer: ast.Printer<PrinterTsFactory>;
|
|
461
458
|
enumType: PluginTs['resolvedOptions']['enumType'];
|
|
462
459
|
enumTypeSuffix: PluginTs['resolvedOptions']['enumTypeSuffix'];
|
|
463
460
|
enumKeyCasing: PluginTs['resolvedOptions']['enumKeyCasing'];
|
|
@@ -474,7 +471,7 @@ declare function Type({
|
|
|
474
471
|
}: Props): KubbReactNode;
|
|
475
472
|
//#endregion
|
|
476
473
|
//#region src/generators/typeGenerator.d.ts
|
|
477
|
-
declare const typeGenerator: _$_kubb_core0.Generator<PluginTs>;
|
|
474
|
+
declare const typeGenerator: _$_kubb_core0.Generator<PluginTs, unknown>;
|
|
478
475
|
//#endregion
|
|
479
476
|
//#region src/plugin.d.ts
|
|
480
477
|
/**
|
|
@@ -497,7 +494,7 @@ declare const pluginTsName = "plugin-ts";
|
|
|
497
494
|
* })
|
|
498
495
|
* ```
|
|
499
496
|
*/
|
|
500
|
-
declare const pluginTs: (options?: Options | undefined) => _$_kubb_core0.
|
|
497
|
+
declare const pluginTs: (options?: Options | undefined) => _$_kubb_core0.HookStylePlugin<PluginTs>;
|
|
501
498
|
//#endregion
|
|
502
499
|
//#region src/printers/functionPrinter.d.ts
|
|
503
500
|
type FunctionPrinterOptions = {
|
|
@@ -542,8 +539,8 @@ type FunctionPrinterOptions = {
|
|
|
542
539
|
declare const functionPrinter: (options?: FunctionPrinterOptions | undefined) => {
|
|
543
540
|
name: "functionParameters";
|
|
544
541
|
options: FunctionPrinterOptions;
|
|
545
|
-
transform: (node: FunctionParamNode) => string | null | undefined;
|
|
546
|
-
print: (node: FunctionParamNode) => string | null | undefined;
|
|
542
|
+
transform: (node: ast.FunctionParamNode) => string | null | undefined;
|
|
543
|
+
print: (node: ast.FunctionParamNode) => string | null | undefined;
|
|
547
544
|
};
|
|
548
545
|
//#endregion
|
|
549
546
|
//#region src/resolvers/resolverTs.d.ts
|