@kubb/plugin-ts 5.0.0-beta.84 → 5.0.0-beta.86

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.d.ts CHANGED
@@ -1,55 +1,8 @@
1
1
  import { n as __name } from "./rolldown-runtime-CNktS9qV.js";
2
- import { Exclude, Group, Include, Output, OutputOptions, Override, PluginFactoryOptions, Resolver, ast } from "kubb/kit";
3
2
  import { KubbReactNode } from "kubb/jsx";
3
+ import { Exclude, Group, Include, Output, OutputOptions, Override, PluginFactoryOptions, Resolver, ResolverPatch, ast } from "kubb/kit";
4
4
  import ts from "typescript";
5
5
 
6
- //#region ../../internals/shared/src/operation.d.ts
7
- /**
8
- * Resolver interface for building operation parameters.
9
- *
10
- * `ResolverTs` from `@kubb/plugin-ts` satisfies this interface and can be passed directly.
11
- */
12
- type OperationParamsResolver = {
13
- /**
14
- * Resolves the type name for an individual parameter.
15
- *
16
- * @example Individual path parameter name
17
- * `resolver.resolveParamName(node, param) // → 'DeletePetPathPetId'`
18
- */
19
- resolveParamName(node: ast.OperationNode, param: ast.ParameterNode): string;
20
- /**
21
- * Resolves the request body type name.
22
- *
23
- * @example Request body type name
24
- * `resolver.resolveDataName(node) // → 'CreatePetData'`
25
- */
26
- resolveDataName(node: ast.OperationNode): string;
27
- /**
28
- * Resolves the grouped path parameters type name.
29
- * When the return value equals `resolveParamName`, no indexed access is emitted.
30
- *
31
- * @example Grouped path params type name
32
- * `resolver.resolvePathParamsName(node, param) // → 'DeletePetPathParams'`
33
- */
34
- resolvePathParamsName(node: ast.OperationNode, param: ast.ParameterNode): string;
35
- /**
36
- * Resolves the grouped query parameters type name.
37
- * When the return value equals `resolveParamName`, an inline struct type is emitted instead.
38
- *
39
- * @example Grouped query params type name
40
- * `resolver.resolveQueryParamsName(node, param) // → 'FindPetsByStatusQueryParams'`
41
- */
42
- resolveQueryParamsName(node: ast.OperationNode, param: ast.ParameterNode): string;
43
- /**
44
- * Resolves the grouped header parameters type name.
45
- * When the return value equals `resolveParamName`, an inline struct type is emitted instead.
46
- *
47
- * @example Grouped header params type name
48
- * `resolver.resolveHeaderParamsName(node, param) // → 'DeletePetHeaderParams'`
49
- */
50
- resolveHeaderParamsName(node: ast.OperationNode, param: ast.ParameterNode): string;
51
- };
52
- //#endregion
53
6
  //#region src/printers/printerTs.d.ts
54
7
  /**
55
8
  * Partial map of node-type overrides for the TypeScript printer.
@@ -167,96 +120,105 @@ declare const printerTs: (options?: PrinterTsOptions | undefined) => ast.Printer
167
120
  //#region src/types.d.ts
168
121
  /**
169
122
  * The concrete resolver type for `@kubb/plugin-ts`.
170
- * Extends the base `Resolver` (which provides `default` and `resolveOptions`) with
171
- * plugin-specific naming helpers for operations, parameters, responses, and schemas.
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.
172
126
  */
173
- type ResolverTs = Resolver & OperationParamsResolver & {
127
+ type ResolverTs = Resolver & {
174
128
  /**
175
- * Resolves the name for a given raw name (equivalent to `default(name, 'function')`).
176
- * Since TypeScript only emits types, this is the canonical naming method.
177
- *
178
- * @example Resolving type names
179
- * `resolver.resolveName('list pets status 200') // → 'ListPetsStatus200'`
129
+ * Naming for an operation's parameters, grouped by location.
180
130
  */
181
- resolveTypeName(name: string): string;
182
- /**
183
- * Resolves the file/path name for a given identifier using PascalCase.
184
- *
185
- * @example Resolving path names
186
- * `resolver.resolvePathName('list pets', 'file') // → 'ListPets'`
187
- */
188
- resolvePathName(name: string, type?: 'file' | 'function' | 'type' | 'const'): string;
189
- /**
190
- * Resolves the request body type name for an operation (required on ResolverTs).
191
- */
192
- resolveDataName(node: ast.OperationNode): string;
193
- /**
194
- * Resolves the name for an operation response by status code.
195
- * Encapsulates the `<operationId> Status <statusCode>` template with PascalCase applied to the result.
196
- *
197
- * @example Response status names
198
- * `resolver.resolveResponseStatusName(node, 200) // → 'ListPetsStatus200'`
199
- */
200
- resolveResponseStatusName(node: ast.OperationNode, statusCode: ast.StatusCode): string;
201
- /**
202
- * Resolves the name for an operation's request config (`RequestConfig`).
203
- *
204
- * The `RequestConfig` suffix is kept through the v5 beta to avoid churn, but it overlaps with the
205
- * runtime client's `RequestConfig`. Renaming to `Request` is on the table before stable.
206
- *
207
- * @example Request config names
208
- * `resolver.resolveRequestConfigName(node) // → 'ListPetsRequestConfig'`
209
- */
210
- resolveRequestConfigName(node: ast.OperationNode): string;
211
- /**
212
- * Resolves the name for the collection of all operation responses (`Responses`).
213
- *
214
- * @example Responses collection names
215
- * `resolver.resolveResponsesName(node) // → 'ListPetsResponses'`
216
- */
217
- resolveResponsesName(node: ast.OperationNode): string;
218
- /**
219
- * Resolves the name for the union of all operation responses (`Response`).
220
- *
221
- * @example Response union names
222
- * `resolver.resolveResponseName(node) // → 'ListPetsResponse'`
223
- */
224
- resolveResponseName(node: ast.OperationNode): string;
225
- /**
226
- * Resolves the TypeScript type alias name for an enum schema's key variant.
227
- * Appends `enumTypeSuffix` (default `'Key'`) after applying the default naming convention.
228
- *
229
- * @example Enum key names with different suffixes
230
- * ```ts
231
- * resolver.resolveEnumKeyName(node, 'Key') // → 'PetStatusKey'
232
- * resolver.resolveEnumKeyName(node, 'Value') // → 'PetStatusValue'
233
- * resolver.resolveEnumKeyName(node, '') // → 'PetStatus'
234
- * ```
235
- */
236
- resolveEnumKeyName(node: {
237
- name?: string | null;
238
- }, enumTypeSuffix: string): string;
239
- /**
240
- * Resolves the name for an operation's grouped path parameters type.
241
- *
242
- * @example Path parameters names
243
- * `resolver.resolvePathParamsName(node, param) // → 'GetPetByIdPathParams'`
244
- */
245
- 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
+ };
246
161
  /**
247
- * Resolves the name for an operation's grouped query parameters type.
248
- *
249
- * @example Query parameters names
250
- * `resolver.resolveQueryParamsName(node, param) // → 'FindPetsByStatusQueryParams'`
162
+ * Naming for an operation's request and response types.
251
163
  */
252
- resolveQueryParamsName(node: ast.OperationNode, param: ast.ParameterNode): string;
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
+ };
253
203
  /**
254
- * Resolves the name for an operation's grouped header parameters type.
255
- *
256
- * @example Header parameters names
257
- * `resolver.resolveHeaderParamsName(node, param) // → 'DeletePetHeaderParams'`
204
+ * Naming for enum schemas.
258
205
  */
259
- resolveHeaderParamsName(node: ast.OperationNode, param: ast.ParameterNode): string;
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
+ };
260
222
  };
261
223
  type EnumKeyCasing = 'screamingSnakeCase' | 'snakeCase' | 'pascalCase' | 'camelCase' | 'none';
262
224
  type EnumConstCasing = 'camelCase' | 'pascalCase';
@@ -407,10 +369,9 @@ type Options = OutputOptions & {
407
369
  /**
408
370
  * Override how names and file paths are built for generated symbols.
409
371
  * Methods you omit fall back to the default `resolverTs`. `this` is bound to the
410
- * full resolver, so `this.default(name, 'function')` delegates to the built-in
411
- * implementation.
372
+ * full resolver, so `this.default.name(name)` delegates to the built-in implementation.
412
373
  */
413
- resolver?: Partial<ResolverTs> & ThisType<ResolverTs>;
374
+ resolver?: ResolverPatch<ResolverTs>;
414
375
  /**
415
376
  * Macros applied to each schema or operation node before printing.
416
377
  * Callbacks you omit fall back to the preset behavior.
@@ -834,6 +795,63 @@ declare function functionPrinter(options: FunctionPrinterOptions): {
834
795
  print(node: FunctionParametersNode): string;
835
796
  };
836
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
837
855
  //#region src/printers/operationParams.d.ts
838
856
  /**
839
857
  * Options for {@link createOperationParams}.
@@ -931,19 +949,33 @@ declare function createOperationParams(node: ast.OperationNode, options: CreateO
931
949
  * to reference the exact names `plugin-ts` produces without duplicating the
932
950
  * casing/file-layout rules.
933
951
  *
934
- * The `default` method is supplied by `defineResolver`. It uses PascalCase for
935
- * type names and PascalCase file paths (dotted names become `/`-joined) for files.
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.
936
956
  *
937
957
  * @example Resolve a type and file name
938
958
  * ```ts
939
959
  * import { resolverTs } from '@kubb/plugin-ts'
940
960
  *
941
- * resolverTs.default('list pets', 'type') // 'ListPets'
942
- * resolverTs.resolvePathName('list pets', 'file') // 'ListPets'
943
- * resolverTs.resolveResponseStatusName(node, 200) // 'ListPetsStatus200'
961
+ * resolverTs.name('list pets') // 'ListPets'
962
+ * resolverTs.response.status(node, 200) // 'ListPetsStatus200'
944
963
  * ```
945
964
  */
946
965
  declare const resolverTs: ResolverTs;
947
966
  //#endregion
948
- 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, createFunctionParameter, createFunctionParameters, createIndexedAccessType, createObjectBindingPattern, createOperationParams, createTypeLiteral, pluginTs as default, pluginTs, functionPrinter, pluginTsName, printerTs, renderType, resolverTs, typeGenerator };
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 };
949
981
  //# sourceMappingURL=index.d.ts.map