@kubb/plugin-ts 5.0.0-beta.81 → 5.0.0-beta.85
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 +243 -183
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +177 -146
- package/dist/index.js +191 -132
- package/dist/index.js.map +1 -1
- package/package.json +4 -6
package/dist/index.d.ts
CHANGED
|
@@ -1,56 +1,8 @@
|
|
|
1
1
|
import { n as __name } from "./rolldown-runtime-CNktS9qV.js";
|
|
2
|
+
import { KubbReactNode } from "kubb/jsx";
|
|
3
|
+
import { Exclude, Group, Include, Output, OutputOptions, Override, PluginFactoryOptions, Resolver, ResolverPatch, ast } from "kubb/kit";
|
|
2
4
|
import ts from "typescript";
|
|
3
|
-
import { Exclude, Group, Include, Output, OutputOptions, Override, PluginFactoryOptions, Resolver, ast } from "@kubb/core";
|
|
4
|
-
import { KubbReactNode } from "@kubb/renderer-jsx/types";
|
|
5
|
-
import { OperationNode } from "@kubb/ast";
|
|
6
5
|
|
|
7
|
-
//#region ../../internals/shared/src/operation.d.ts
|
|
8
|
-
/**
|
|
9
|
-
* Resolver interface for building operation parameters.
|
|
10
|
-
*
|
|
11
|
-
* `ResolverTs` from `@kubb/plugin-ts` satisfies this interface and can be passed directly.
|
|
12
|
-
*/
|
|
13
|
-
type OperationParamsResolver = {
|
|
14
|
-
/**
|
|
15
|
-
* Resolves the type name for an individual parameter.
|
|
16
|
-
*
|
|
17
|
-
* @example Individual path parameter name
|
|
18
|
-
* `resolver.resolveParamName(node, param) // → 'DeletePetPathPetId'`
|
|
19
|
-
*/
|
|
20
|
-
resolveParamName(node: ast.OperationNode, param: ast.ParameterNode): string;
|
|
21
|
-
/**
|
|
22
|
-
* Resolves the request body type name.
|
|
23
|
-
*
|
|
24
|
-
* @example Request body type name
|
|
25
|
-
* `resolver.resolveDataName(node) // → 'CreatePetData'`
|
|
26
|
-
*/
|
|
27
|
-
resolveDataName(node: ast.OperationNode): string;
|
|
28
|
-
/**
|
|
29
|
-
* Resolves the grouped path parameters type name.
|
|
30
|
-
* When the return value equals `resolveParamName`, no indexed access is emitted.
|
|
31
|
-
*
|
|
32
|
-
* @example Grouped path params type name
|
|
33
|
-
* `resolver.resolvePathParamsName(node, param) // → 'DeletePetPathParams'`
|
|
34
|
-
*/
|
|
35
|
-
resolvePathParamsName(node: ast.OperationNode, param: ast.ParameterNode): string;
|
|
36
|
-
/**
|
|
37
|
-
* Resolves the grouped query parameters type name.
|
|
38
|
-
* When the return value equals `resolveParamName`, an inline struct type is emitted instead.
|
|
39
|
-
*
|
|
40
|
-
* @example Grouped query params type name
|
|
41
|
-
* `resolver.resolveQueryParamsName(node, param) // → 'FindPetsByStatusQueryParams'`
|
|
42
|
-
*/
|
|
43
|
-
resolveQueryParamsName(node: ast.OperationNode, param: ast.ParameterNode): string;
|
|
44
|
-
/**
|
|
45
|
-
* Resolves the grouped header parameters type name.
|
|
46
|
-
* When the return value equals `resolveParamName`, an inline struct type is emitted instead.
|
|
47
|
-
*
|
|
48
|
-
* @example Grouped header params type name
|
|
49
|
-
* `resolver.resolveHeaderParamsName(node, param) // → 'DeletePetHeaderParams'`
|
|
50
|
-
*/
|
|
51
|
-
resolveHeaderParamsName(node: ast.OperationNode, param: ast.ParameterNode): string;
|
|
52
|
-
};
|
|
53
|
-
//#endregion
|
|
54
6
|
//#region src/printers/printerTs.d.ts
|
|
55
7
|
/**
|
|
56
8
|
* Partial map of node-type overrides for the TypeScript printer.
|
|
@@ -168,96 +120,105 @@ declare const printerTs: (options?: PrinterTsOptions | undefined) => ast.Printer
|
|
|
168
120
|
//#region src/types.d.ts
|
|
169
121
|
/**
|
|
170
122
|
* The concrete resolver type for `@kubb/plugin-ts`.
|
|
171
|
-
* Extends the base `Resolver` (which provides `default` and
|
|
172
|
-
* plugin-specific naming
|
|
123
|
+
* Extends the base `Resolver` (which provides `default` naming and option helpers, the top-level
|
|
124
|
+
* `name` casing, and the `file` builder) with plugin-specific naming namespaces for operation
|
|
125
|
+
* parameters, responses, and enum schemas.
|
|
173
126
|
*/
|
|
174
|
-
type ResolverTs = Resolver &
|
|
127
|
+
type ResolverTs = Resolver & {
|
|
175
128
|
/**
|
|
176
|
-
*
|
|
177
|
-
* Since TypeScript only emits types, this is the canonical naming method.
|
|
178
|
-
*
|
|
179
|
-
* @example Resolving type names
|
|
180
|
-
* `resolver.resolveName('list pets status 200') // → 'ListPetsStatus200'`
|
|
129
|
+
* Naming for an operation's parameters, grouped by location.
|
|
181
130
|
*/
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* Resolves the name for the collection of all operation responses (`Responses`).
|
|
214
|
-
*
|
|
215
|
-
* @example Responses collection names
|
|
216
|
-
* `resolver.resolveResponsesName(node) // → 'ListPetsResponses'`
|
|
217
|
-
*/
|
|
218
|
-
resolveResponsesName(node: ast.OperationNode): string;
|
|
219
|
-
/**
|
|
220
|
-
* Resolves the name for the union of all operation responses (`Response`).
|
|
221
|
-
*
|
|
222
|
-
* @example Response union names
|
|
223
|
-
* `resolver.resolveResponseName(node) // → 'ListPetsResponse'`
|
|
224
|
-
*/
|
|
225
|
-
resolveResponseName(node: ast.OperationNode): string;
|
|
226
|
-
/**
|
|
227
|
-
* Resolves the TypeScript type alias name for an enum schema's key variant.
|
|
228
|
-
* Appends `enumTypeSuffix` (default `'Key'`) after applying the default naming convention.
|
|
229
|
-
*
|
|
230
|
-
* @example Enum key names with different suffixes
|
|
231
|
-
* ```ts
|
|
232
|
-
* resolver.resolveEnumKeyName(node, 'Key') // → 'PetStatusKey'
|
|
233
|
-
* resolver.resolveEnumKeyName(node, 'Value') // → 'PetStatusValue'
|
|
234
|
-
* resolver.resolveEnumKeyName(node, '') // → 'PetStatus'
|
|
235
|
-
* ```
|
|
236
|
-
*/
|
|
237
|
-
resolveEnumKeyName(node: {
|
|
238
|
-
name?: string | null;
|
|
239
|
-
}, enumTypeSuffix: string): string;
|
|
240
|
-
/**
|
|
241
|
-
* Resolves the name for an operation's grouped path parameters type.
|
|
242
|
-
*
|
|
243
|
-
* @example Path parameters names
|
|
244
|
-
* `resolver.resolvePathParamsName(node, param) // → 'GetPetByIdPathParams'`
|
|
245
|
-
*/
|
|
246
|
-
resolvePathParamsName(node: ast.OperationNode, param: ast.ParameterNode): string;
|
|
131
|
+
param: {
|
|
132
|
+
/**
|
|
133
|
+
* Resolves the type name for an individual parameter.
|
|
134
|
+
*
|
|
135
|
+
* @example Individual parameter name
|
|
136
|
+
* `resolver.param.name(node, param) // → 'DeletePetPathPetId'`
|
|
137
|
+
*/
|
|
138
|
+
name(node: ast.OperationNode, param: ast.ParameterNode): string;
|
|
139
|
+
/**
|
|
140
|
+
* Resolves the name for an operation's grouped path parameters type.
|
|
141
|
+
*
|
|
142
|
+
* @example Path parameters names
|
|
143
|
+
* `resolver.param.path(node, param) // → 'GetPetByIdPath'`
|
|
144
|
+
*/
|
|
145
|
+
path(node: ast.OperationNode, param: ast.ParameterNode): string;
|
|
146
|
+
/**
|
|
147
|
+
* Resolves the name for an operation's grouped query parameters type.
|
|
148
|
+
*
|
|
149
|
+
* @example Query parameters names
|
|
150
|
+
* `resolver.param.query(node, param) // → 'FindPetsByStatusQuery'`
|
|
151
|
+
*/
|
|
152
|
+
query(node: ast.OperationNode, param: ast.ParameterNode): string;
|
|
153
|
+
/**
|
|
154
|
+
* Resolves the name for an operation's grouped header parameters type.
|
|
155
|
+
*
|
|
156
|
+
* @example Header parameters names
|
|
157
|
+
* `resolver.param.headers(node, param) // → 'DeletePetHeaders'`
|
|
158
|
+
*/
|
|
159
|
+
headers(node: ast.OperationNode, param: ast.ParameterNode): string;
|
|
160
|
+
};
|
|
247
161
|
/**
|
|
248
|
-
*
|
|
249
|
-
*
|
|
250
|
-
* @example Query parameters names
|
|
251
|
-
* `resolver.resolveQueryParamsName(node, param) // → 'FindPetsByStatusQueryParams'`
|
|
162
|
+
* Naming for an operation's request and response types.
|
|
252
163
|
*/
|
|
253
|
-
|
|
164
|
+
response: {
|
|
165
|
+
/**
|
|
166
|
+
* Resolves the name for an operation response by status code.
|
|
167
|
+
* Encapsulates the `<operationId> Status <statusCode>` template with PascalCase applied to the result.
|
|
168
|
+
*
|
|
169
|
+
* @example Response status names
|
|
170
|
+
* `resolver.response.status(node, 200) // → 'ListPetsStatus200'`
|
|
171
|
+
*/
|
|
172
|
+
status(node: ast.OperationNode, statusCode: ast.StatusCode): string;
|
|
173
|
+
/**
|
|
174
|
+
* Resolves the name for an operation's grouped request options type (`Options`), the
|
|
175
|
+
* `{ body, path, query, headers }` bag passed to call an operation.
|
|
176
|
+
*
|
|
177
|
+
* @example Options type names
|
|
178
|
+
* `resolver.response.options(node) // → 'ListPetsOptions'`
|
|
179
|
+
*/
|
|
180
|
+
options(node: ast.OperationNode): string;
|
|
181
|
+
/**
|
|
182
|
+
* Resolves the name for the collection of all operation responses (`Responses`).
|
|
183
|
+
*
|
|
184
|
+
* @example Responses collection names
|
|
185
|
+
* `resolver.response.responses(node) // → 'ListPetsResponses'`
|
|
186
|
+
*/
|
|
187
|
+
responses(node: ast.OperationNode): string;
|
|
188
|
+
/**
|
|
189
|
+
* Resolves the name for the union of all operation responses (`Response`).
|
|
190
|
+
*
|
|
191
|
+
* @example Response union names
|
|
192
|
+
* `resolver.response.response(node) // → 'ListPetsResponse'`
|
|
193
|
+
*/
|
|
194
|
+
response(node: ast.OperationNode): string;
|
|
195
|
+
/**
|
|
196
|
+
* Resolves the request body type name.
|
|
197
|
+
*
|
|
198
|
+
* @example Request body type name
|
|
199
|
+
* `resolver.response.body(node) // → 'CreatePetBody'`
|
|
200
|
+
*/
|
|
201
|
+
body(node: ast.OperationNode): string;
|
|
202
|
+
};
|
|
254
203
|
/**
|
|
255
|
-
*
|
|
256
|
-
*
|
|
257
|
-
* @example Header parameters names
|
|
258
|
-
* `resolver.resolveHeaderParamsName(node, param) // → 'DeletePetHeaderParams'`
|
|
204
|
+
* Naming for enum schemas.
|
|
259
205
|
*/
|
|
260
|
-
|
|
206
|
+
enum: {
|
|
207
|
+
/**
|
|
208
|
+
* Resolves the TypeScript type alias name for an enum schema's key variant.
|
|
209
|
+
* Appends `enumTypeSuffix` (default `'key'`) after applying the default naming convention.
|
|
210
|
+
*
|
|
211
|
+
* @example Enum key names with different suffixes
|
|
212
|
+
* ```ts
|
|
213
|
+
* resolver.enum.keyName(node, 'Key') // → 'PetStatusKey'
|
|
214
|
+
* resolver.enum.keyName(node, 'Value') // → 'PetStatusValue'
|
|
215
|
+
* resolver.enum.keyName(node, '') // → 'PetStatus'
|
|
216
|
+
* ```
|
|
217
|
+
*/
|
|
218
|
+
keyName(node: {
|
|
219
|
+
name?: string | null;
|
|
220
|
+
}, enumTypeSuffix?: string): string;
|
|
221
|
+
};
|
|
261
222
|
};
|
|
262
223
|
type EnumKeyCasing = 'screamingSnakeCase' | 'snakeCase' | 'pascalCase' | 'camelCase' | 'none';
|
|
263
224
|
type EnumConstCasing = 'camelCase' | 'pascalCase';
|
|
@@ -408,10 +369,9 @@ type Options = OutputOptions & {
|
|
|
408
369
|
/**
|
|
409
370
|
* Override how names and file paths are built for generated symbols.
|
|
410
371
|
* Methods you omit fall back to the default `resolverTs`. `this` is bound to the
|
|
411
|
-
* full resolver, so `this.default(name
|
|
412
|
-
* implementation.
|
|
372
|
+
* full resolver, so `this.default.name(name)` delegates to the built-in implementation.
|
|
413
373
|
*/
|
|
414
|
-
resolver?:
|
|
374
|
+
resolver?: ResolverPatch<ResolverTs>;
|
|
415
375
|
/**
|
|
416
376
|
* Macros applied to each schema or operation node before printing.
|
|
417
377
|
* Callbacks you omit fall back to the preset behavior.
|
|
@@ -545,7 +505,7 @@ declare function Type({
|
|
|
545
505
|
* types. Drop-replace with a custom `Generator<PluginTs>` to change how
|
|
546
506
|
* TypeScript output is produced.
|
|
547
507
|
*/
|
|
548
|
-
declare const typeGenerator: import("
|
|
508
|
+
declare const typeGenerator: import("kubb/kit").Generator<PluginTs, unknown>;
|
|
549
509
|
//#endregion
|
|
550
510
|
//#region src/plugin.d.ts
|
|
551
511
|
/**
|
|
@@ -561,7 +521,7 @@ declare const pluginTsName = "plugin-ts";
|
|
|
561
521
|
*
|
|
562
522
|
* @example
|
|
563
523
|
* ```ts
|
|
564
|
-
* import { defineConfig } from 'kubb'
|
|
524
|
+
* import { defineConfig } from 'kubb/config'
|
|
565
525
|
* import { pluginTs } from '@kubb/plugin-ts'
|
|
566
526
|
*
|
|
567
527
|
* export default defineConfig({
|
|
@@ -577,7 +537,7 @@ declare const pluginTsName = "plugin-ts";
|
|
|
577
537
|
* })
|
|
578
538
|
* ```
|
|
579
539
|
*/
|
|
580
|
-
declare const pluginTs: (options?: Options | undefined) => import("
|
|
540
|
+
declare const pluginTs: (options?: Options | undefined) => import("kubb/kit").Plugin<PluginTs>;
|
|
581
541
|
//#endregion
|
|
582
542
|
//#region src/printers/functionParams.d.ts
|
|
583
543
|
/**
|
|
@@ -835,6 +795,63 @@ declare function functionPrinter(options: FunctionPrinterOptions): {
|
|
|
835
795
|
print(node: FunctionParametersNode): string;
|
|
836
796
|
};
|
|
837
797
|
//#endregion
|
|
798
|
+
//#region ../../internals/shared/src/operation.d.ts
|
|
799
|
+
/**
|
|
800
|
+
* Resolver interface for building operation parameters.
|
|
801
|
+
*
|
|
802
|
+
* `ResolverTs` from `@kubb/plugin-ts` satisfies this interface and can be passed directly.
|
|
803
|
+
*/
|
|
804
|
+
type OperationParamsResolver = {
|
|
805
|
+
/**
|
|
806
|
+
* Naming for an operation's parameters, grouped by location.
|
|
807
|
+
*/
|
|
808
|
+
param: {
|
|
809
|
+
/**
|
|
810
|
+
* Resolves the type name for an individual parameter.
|
|
811
|
+
*
|
|
812
|
+
* @example Individual path parameter name
|
|
813
|
+
* `resolver.param.name(node, param) // → 'DeletePetPathPetId'`
|
|
814
|
+
*/
|
|
815
|
+
name(node: ast.OperationNode, param: ast.ParameterNode): string;
|
|
816
|
+
/**
|
|
817
|
+
* Resolves the grouped path parameters type name.
|
|
818
|
+
* When the return value equals `resolver.param.name`, no indexed access is emitted.
|
|
819
|
+
*
|
|
820
|
+
* @example Grouped path params type name
|
|
821
|
+
* `resolver.param.path(node, param) // → 'DeletePetPath'`
|
|
822
|
+
*/
|
|
823
|
+
path(node: ast.OperationNode, param: ast.ParameterNode): string;
|
|
824
|
+
/**
|
|
825
|
+
* Resolves the grouped query parameters type name.
|
|
826
|
+
* When the return value equals `resolver.param.name`, an inline struct type is emitted instead.
|
|
827
|
+
*
|
|
828
|
+
* @example Grouped query params type name
|
|
829
|
+
* `resolver.param.query(node, param) // → 'FindPetsByStatusQuery'`
|
|
830
|
+
*/
|
|
831
|
+
query(node: ast.OperationNode, param: ast.ParameterNode): string;
|
|
832
|
+
/**
|
|
833
|
+
* Resolves the grouped header parameters type name.
|
|
834
|
+
* When the return value equals `resolver.param.name`, an inline struct type is emitted instead.
|
|
835
|
+
*
|
|
836
|
+
* @example Grouped header params type name
|
|
837
|
+
* `resolver.param.headers(node, param) // → 'DeletePetHeaders'`
|
|
838
|
+
*/
|
|
839
|
+
headers(node: ast.OperationNode, param: ast.ParameterNode): string;
|
|
840
|
+
};
|
|
841
|
+
/**
|
|
842
|
+
* Naming for an operation's request and response types.
|
|
843
|
+
*/
|
|
844
|
+
response: {
|
|
845
|
+
/**
|
|
846
|
+
* Resolves the request body type name.
|
|
847
|
+
*
|
|
848
|
+
* @example Request body type name
|
|
849
|
+
* `resolver.response.body(node) // → 'CreatePetBody'`
|
|
850
|
+
*/
|
|
851
|
+
body(node: ast.OperationNode): string;
|
|
852
|
+
};
|
|
853
|
+
};
|
|
854
|
+
//#endregion
|
|
838
855
|
//#region src/printers/operationParams.d.ts
|
|
839
856
|
/**
|
|
840
857
|
* Options for {@link createOperationParams}.
|
|
@@ -923,7 +940,7 @@ type CreateOperationParamsOptions = {
|
|
|
923
940
|
* `pathParamsType` controls how path params render in inline mode. Provide a `resolver` for type
|
|
924
941
|
* name resolution and `extraParams` for plugin-specific trailing parameters such as an `options` object.
|
|
925
942
|
*/
|
|
926
|
-
declare function createOperationParams(node: OperationNode, options: CreateOperationParamsOptions): FunctionParametersNode;
|
|
943
|
+
declare function createOperationParams(node: ast.OperationNode, options: CreateOperationParamsOptions): FunctionParametersNode;
|
|
927
944
|
//#endregion
|
|
928
945
|
//#region src/resolvers/resolverTs.d.ts
|
|
929
946
|
/**
|
|
@@ -932,19 +949,33 @@ declare function createOperationParams(node: OperationNode, options: CreateOpera
|
|
|
932
949
|
* to reference the exact names `plugin-ts` produces without duplicating the
|
|
933
950
|
* casing/file-layout rules.
|
|
934
951
|
*
|
|
935
|
-
* The `default`
|
|
936
|
-
* type names and PascalCase file paths (dotted names
|
|
952
|
+
* The `default` helpers are supplied by `createResolver`. This plugin overrides the top-level `name`
|
|
953
|
+
* to use PascalCase for value and type names and `file` to write PascalCase file paths (dotted names
|
|
954
|
+
* become `/`-joined), and groups the operation-specific naming under the `param`, `response`, and
|
|
955
|
+
* `enum` namespaces.
|
|
937
956
|
*
|
|
938
957
|
* @example Resolve a type and file name
|
|
939
958
|
* ```ts
|
|
940
959
|
* import { resolverTs } from '@kubb/plugin-ts'
|
|
941
960
|
*
|
|
942
|
-
* resolverTs.
|
|
943
|
-
* resolverTs.
|
|
944
|
-
* resolverTs.resolveResponseStatusName(node, 200) // 'ListPetsStatus200'
|
|
961
|
+
* resolverTs.name('list pets') // 'ListPets'
|
|
962
|
+
* resolverTs.response.status(node, 200) // 'ListPetsStatus200'
|
|
945
963
|
* ```
|
|
946
964
|
*/
|
|
947
965
|
declare const resolverTs: ResolverTs;
|
|
948
966
|
//#endregion
|
|
949
|
-
|
|
967
|
+
//#region src/utils.d.ts
|
|
968
|
+
type BuildParamsSchemaOptions = {
|
|
969
|
+
params: Array<ast.ParameterNode>;
|
|
970
|
+
};
|
|
971
|
+
/**
|
|
972
|
+
* Builds the object schema for a group of parameters sharing one `in` location (path, query, or
|
|
973
|
+
* header), embedding each param's own schema (and JSDoc) directly rather than referencing a
|
|
974
|
+
* separate per-param type — the group itself is the only type these params get exported as.
|
|
975
|
+
*/
|
|
976
|
+
declare function buildParams({
|
|
977
|
+
params
|
|
978
|
+
}: BuildParamsSchemaOptions): ast.SchemaNode;
|
|
979
|
+
//#endregion
|
|
980
|
+
export { type CreateOperationParamsOptions, Enum, type FunctionParameterNode, type FunctionParametersNode, type IndexedAccessTypeNode, type ObjectBindingPatternNode, type PluginTs, type PrinterTsFactory, type PrinterTsNodes, type PrinterTsOptions, type ResolverTs, Type, type TypeExpression, type TypeLiteralNode, buildParams, createFunctionParameter, createFunctionParameters, createIndexedAccessType, createObjectBindingPattern, createOperationParams, createTypeLiteral, pluginTs as default, pluginTs, functionPrinter, pluginTsName, printerTs, renderType, resolverTs, typeGenerator };
|
|
950
981
|
//# sourceMappingURL=index.d.ts.map
|