@kubb/plugin-ts 4.18.4 → 4.19.0

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.
@@ -20,16 +20,21 @@ type Operation$1 = Operation;
20
20
  type DiscriminatorObject$1 = DiscriminatorObject;
21
21
  //#endregion
22
22
  //#region ../oas/src/Oas.d.ts
23
- type Options$2 = {
23
+ type OasOptions = {
24
24
  contentType?: contentType;
25
25
  discriminator?: 'strict' | 'inherit';
26
+ /**
27
+ * Resolve name collisions when schemas from different components share the same name (case-insensitive).
28
+ * @default false
29
+ */
30
+ collisionDetection?: boolean;
26
31
  };
27
32
  declare class Oas extends BaseOas {
28
33
  #private;
29
34
  document: Document;
30
35
  constructor(document: Document);
31
- setOptions(options: Options$2): void;
32
- get options(): Options$2;
36
+ setOptions(options: OasOptions): void;
37
+ get options(): OasOptions;
33
38
  get<T = unknown>($ref: string): T | null;
34
39
  getKey($ref: string): string | undefined;
35
40
  set($ref: string, value: unknown): false | undefined;
@@ -38,8 +43,20 @@ declare class Oas extends BaseOas {
38
43
  getResponseSchema(operation: Operation$1, statusCode: string | number): SchemaObject$1;
39
44
  getRequestSchema(operation: Operation$1): SchemaObject$1 | undefined;
40
45
  getParametersSchema(operation: Operation$1, inKey: 'path' | 'query' | 'header'): SchemaObject$1 | null;
41
- valdiate(): Promise<oas_normalize_lib_types0.ValidationResult>;
46
+ validate(): Promise<oas_normalize_lib_types0.ValidationResult>;
42
47
  flattenSchema(schema: SchemaObject$1 | null): SchemaObject$1 | null;
48
+ /**
49
+ * Get schemas from OpenAPI components (schemas, responses, requestBodies).
50
+ * Returns schemas in dependency order along with name mapping for collision resolution.
51
+ */
52
+ getSchemas(options?: {
53
+ contentType?: contentType;
54
+ includes?: Array<'schemas' | 'responses' | 'requestBodies'>;
55
+ collisionDetection?: boolean;
56
+ }): {
57
+ schemas: Record<string, SchemaObject$1>;
58
+ nameMapping: Map<string, string>;
59
+ };
43
60
  }
44
61
  //#endregion
45
62
  //#region ../core/src/BaseGenerator.d.ts
@@ -340,7 +357,7 @@ type Config<TInput = Input> = {
340
357
  input: TInput;
341
358
  output: {
342
359
  /**
343
- * The path where all generated files will be exported.
360
+ * The path where all generated files receives exported.
344
361
  * This can be an absolute path or a path relative to the specified root option.
345
362
  */
346
363
  path: string;
@@ -355,41 +372,39 @@ type Config<TInput = Input> = {
355
372
  write?: boolean;
356
373
  /**
357
374
  * Specifies the formatting tool to be used.
358
- * @default prettier
359
- *
360
- * Possible values:
361
- * - 'auto': Automatically detects and uses biome or prettier (in that order of preference).
362
- * - 'prettier': Uses Prettier for code formatting.
363
- * - 'biome': Uses Biome for code formatting.
364
- *
375
+ * - 'auto' automatically detects and uses biome or prettier (in that order of preference).
376
+ * - 'prettier' uses Prettier for code formatting.
377
+ * - 'biome' uses Biome for code formatting.
378
+ * - 'oxfmt' uses Oxfmt for code formatting.
379
+ * - false disables code formatting.
380
+ * @default 'prettier'
365
381
  */
366
382
  format?: 'auto' | 'prettier' | 'biome' | 'oxfmt' | false;
367
383
  /**
368
384
  * Specifies the linter that should be used to analyze the code.
369
- * The accepted values indicate different linting tools.
370
- *
371
- * Possible values:
372
- * - 'auto': Automatically detects and uses biome, oxlint, or eslint (in that order of preference).
373
- * - 'eslint': Represents the use of ESLint, a widely used JavaScript linter.
374
- * - 'biome': Represents the Biome linter, a modern tool for code scanning.
375
- * - 'oxlint': Represents the Oxlint tool for linting purposes.
376
- *
385
+ * - 'auto' automatically detects and uses biome, oxlint, or eslint (in that order of preference).
386
+ * - 'eslint' uses ESLint for linting.
387
+ * - 'biome' uses Biome for linting.
388
+ * - 'oxlint' uses Oxlint for linting.
389
+ * - false disables linting.
390
+ * @default 'auto'
377
391
  */
378
392
  lint?: 'auto' | 'eslint' | 'biome' | 'oxlint' | false;
379
393
  /**
380
- * Override the extension to the generated imports and exports, by default each plugin will add an extension
394
+ * Overrides the extension for generated imports and exports. By default, each plugin adds an extension.
381
395
  * @default { '.ts': '.ts'}
382
396
  */
383
397
  extension?: Record<KubbFile.Extname, KubbFile.Extname | ''>;
384
398
  /**
385
- * Specify how `index.ts` files should be created. You can also disable the generation of barrel files here. While each plugin has its own `barrelType` option, this setting controls the creation of the root barrel file, such as` src/gen/index.ts`.
399
+ * Configures how `index.ts` files are created, including disabling barrel file generation. Each plugin has its own `barrelType` option; this setting controls the root barrel file (e.g., `src/gen/index.ts`).
386
400
  * @default 'named'
387
401
  */
388
402
  barrelType?: Exclude<BarrelType, 'propagate'> | false;
389
403
  /**
390
- * Add a default banner to the beginning of every generated file. This makes it clear that the file was generated by Kubb.
391
- * - 'simple': will only add banner with link to Kubb
392
- * - 'full': will add source, title, description and the OpenAPI version used
404
+ * Adds a default banner to the start of every generated file indicating it was generated by Kubb.
405
+ * - 'simple' adds banner with link to Kubb.
406
+ * - 'full' adds source, title, description, and OpenAPI version.
407
+ * - false disables banner generation.
393
408
  * @default 'simple'
394
409
  */
395
410
  defaultBanner?: 'simple' | 'full' | false;
@@ -402,17 +417,17 @@ type Config<TInput = Input> = {
402
417
  override?: boolean;
403
418
  };
404
419
  /**
405
- * An array of Kubb plugins that will be used in the generation.
420
+ * An array of Kubb plugins that used in the generation.
406
421
  * Each plugin may include additional configurable options(defined in the plugin itself).
407
- * If a plugin depends on another plugin, an error will be returned if the required dependency is missing. See pre for more details.
422
+ * If a plugin depends on another plugin, an error is returned if the required dependency is missing. See pre for more details.
408
423
  */
409
424
  plugins?: Array<Plugin>;
410
425
  /**
411
- * Hooks that will be called when a specific action is triggered in Kubb.
426
+ * Hooks triggered when a specific action occurs in Kubb.
412
427
  */
413
428
  hooks?: {
414
429
  /**
415
- * Hook that will be triggered at the end of all executions.
430
+ * Hook that triggers at the end of all executions.
416
431
  * Useful for running Prettier or ESLint to format/lint your code.
417
432
  */
418
433
  done?: string | Array<string>;
@@ -441,7 +456,7 @@ TContext = any,
441
456
  TResolvePathOptions extends object = object> = {
442
457
  name: TName;
443
458
  /**
444
- * Same behaviour like what has been done with `QueryKey` in `@tanstack/react-query`
459
+ * Same behavior like what has been done with `QueryKey` in `@tanstack/react-query`
445
460
  */
446
461
  key: PluginKey<TName | string>;
447
462
  options: TOptions;
@@ -462,12 +477,12 @@ type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> =
462
477
  */
463
478
  options: TOptions['resolvedOptions'];
464
479
  /**
465
- * Specifies the preceding plugins for the current plugin. You can pass an array of preceding plugin names, and the current plugin will be executed after these plugins.
480
+ * Specifies the preceding plugins for the current plugin. You can pass an array of preceding plugin names, and the current plugin is executed after these plugins.
466
481
  * Can be used to validate dependent plugins.
467
482
  */
468
483
  pre?: Array<string>;
469
484
  /**
470
- * Specifies the succeeding plugins for the current plugin. You can pass an array of succeeding plugin names, and the current plugin will be executed before these plugins.
485
+ * Specifies the succeeding plugins for the current plugin. You can pass an array of succeeding plugin names, and the current plugin is executed before these plugins.
471
486
  */
472
487
  post?: Array<string>;
473
488
  inject?: (this: PluginContext<TOptions>, context: PluginContext<TOptions>) => TOptions['context'];
@@ -485,12 +500,12 @@ type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
485
500
  */
486
501
  key: TOptions['key'];
487
502
  /**
488
- * Specifies the preceding plugins for the current plugin. You can pass an array of preceding plugin names, and the current plugin will be executed after these plugins.
503
+ * Specifies the preceding plugins for the current plugin. You can pass an array of preceding plugin names, and the current plugin is executed after these plugins.
489
504
  * Can be used to validate dependent plugins.
490
505
  */
491
506
  pre?: Array<string>;
492
507
  /**
493
- * Specifies the succeeding plugins for the current plugin. You can pass an array of succeeding plugin names, and the current plugin will be executed before these plugins.
508
+ * Specifies the succeeding plugins for the current plugin. You can pass an array of succeeding plugin names, and the current plugin is executed before these plugins.
494
509
  */
495
510
  post?: Array<string>;
496
511
  /**
@@ -540,10 +555,12 @@ type ResolveNameParams = {
540
555
  name: string;
541
556
  pluginKey?: Plugin['key'];
542
557
  /**
543
- * `file` will be used to customize the name of the created file(use of camelCase)
544
- * `function` can be used to customize the exported functions(use of camelCase)
545
- * `type` is a special type for TypeScript(use of PascalCase)
546
- * `const` can be used for variables(use of camelCase)
558
+ * Specifies the type of entity being named.
559
+ * - 'file' customizes the name of the created file (uses camelCase).
560
+ * - 'function' customizes the exported function names (uses camelCase).
561
+ * - 'type' customizes TypeScript types (uses PascalCase).
562
+ * - 'const' customizes variable names (uses camelCase).
563
+ * @default undefined
547
564
  */
548
565
  type?: 'file' | 'function' | 'type' | 'const';
549
566
  };
@@ -598,11 +615,14 @@ type GroupContext = {
598
615
  };
599
616
  type Group = {
600
617
  /**
601
- * Define a type where to group the files on
618
+ * Defines the type where to group the files.
619
+ * - 'tag' groups files by OpenAPI tags.
620
+ * - 'path' groups files by OpenAPI paths.
621
+ * @default undefined
602
622
  */
603
623
  type: 'tag' | 'path';
604
624
  /**
605
- * Return the name of a group based on the group name, this will be used for the file and name generation
625
+ * Return the name of a group based on the group name, this used for the file and name generation
606
626
  */
607
627
  name?: (context: GroupContext) => string;
608
628
  };
@@ -674,7 +694,7 @@ declare class PluginManager {
674
694
  parameters: PluginParameter<H>;
675
695
  }): Array<ReturnType<ParseResult<H>>> | null;
676
696
  /**
677
- * First non-null result stops and will return it's value.
697
+ * Returns the first non-null result.
678
698
  */
679
699
  hookFirst<H extends PluginLifecycleHooks>({
680
700
  hookName,
@@ -686,7 +706,7 @@ declare class PluginManager {
686
706
  skipped?: ReadonlySet<Plugin> | null;
687
707
  }): Promise<SafeParseResult<H>>;
688
708
  /**
689
- * First non-null result stops and will return it's value.
709
+ * Returns the first non-null result.
690
710
  */
691
711
  hookFirstSync<H extends PluginLifecycleHooks>({
692
712
  hookName,
@@ -698,15 +718,15 @@ declare class PluginManager {
698
718
  skipped?: ReadonlySet<Plugin> | null;
699
719
  }): SafeParseResult<H>;
700
720
  /**
701
- * Run all plugins in parallel(order will be based on `this.plugin` and if `pre` or `post` is set).
721
+ * Runs all plugins in parallel based on `this.plugin` order and `pre`/`post` settings.
702
722
  */
703
- hookParallel<H extends PluginLifecycleHooks, TOuput = void>({
723
+ hookParallel<H extends PluginLifecycleHooks, TOutput = void>({
704
724
  hookName,
705
725
  parameters
706
726
  }: {
707
727
  hookName: H;
708
728
  parameters?: Parameters<RequiredPluginLifecycle[H]> | undefined;
709
- }): Promise<Awaited<TOuput>[]>;
729
+ }): Promise<Awaited<TOutput>[]>;
710
730
  /**
711
731
  * Chains plugins
712
732
  */
@@ -975,8 +995,8 @@ type SchemaKeywordMapper = {
975
995
  */
976
996
  path: KubbFile.Path;
977
997
  /**
978
- * When true `File.Import` will be used.
979
- * When false a reference will be used inside the current file.
998
+ * When true `File.Import` is used.
999
+ * When false a reference is used inside the current file.
980
1000
  */
981
1001
  isImportable: boolean;
982
1002
  };
@@ -1108,7 +1128,7 @@ type SchemaGeneratorOptions = {
1108
1128
  */
1109
1129
  name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
1110
1130
  /**
1111
- * Receive schema and name(propertName) and return FakerMeta array
1131
+ * Receive schema and name(propertyName) and return FakerMeta array
1112
1132
  * TODO TODO add docs
1113
1133
  * @beta
1114
1134
  */
@@ -1187,7 +1207,7 @@ type Options = {
1187
1207
  output?: Output<Oas>;
1188
1208
  /**
1189
1209
  * Define which contentType should be used.
1190
- * By default, the first JSON valid mediaType will be used
1210
+ * By default, uses the first valid JSON media type.
1191
1211
  */
1192
1212
  contentType?: contentType;
1193
1213
  /**
@@ -1207,29 +1227,31 @@ type Options = {
1207
1227
  */
1208
1228
  override?: Array<Override<ResolvedOptions>>;
1209
1229
  /**
1210
- * Choose to use `enum`, `asConst`, `asPascalConst`, `constEnum`, `literal`, or `inlineLiteral` for enums.
1211
- * - `enum`: TypeScript enum
1212
- * - `asConst`: const with camelCase name (e.g., `petType`)
1213
- * - `asPascalConst`: const with PascalCase name (e.g., `PetType`)
1214
- * - `constEnum`: const enum
1215
- * - `literal`: literal union type
1216
- * - `inlineLiteral`: inline enum values directly into the type (default in v5)
1230
+ * Choose to use enum, asConst, asPascalConst, constEnum, literal, or inlineLiteral for enums.
1231
+ * - 'enum' generates TypeScript enum declarations.
1232
+ * - 'asConst' generates const objects with camelCase names and as const assertion.
1233
+ * - 'asPascalConst' generates const objects with PascalCase names and as const assertion.
1234
+ * - 'constEnum' generates TypeScript const enum declarations.
1235
+ * - 'literal' generates literal union types.
1236
+ * - 'inlineLiteral' inlines enum values directly into the type (default in v5).
1217
1237
  * @default 'asConst'
1218
- * @note In Kubb v5, `inlineLiteral` will become the default.
1238
+ * @note In Kubb v5, 'inlineLiteral' becomes the default.
1219
1239
  */
1220
1240
  enumType?: 'enum' | 'asConst' | 'asPascalConst' | 'constEnum' | 'literal' | 'inlineLiteral';
1221
1241
  /**
1222
1242
  * Choose the casing for enum key names.
1223
- * - `'screamingSnakeCase'`: ENUM_VALUE
1224
- * - `'snakeCase'`: enum_value
1225
- * - `'pascalCase'`: EnumValue
1226
- * - `'camelCase'`: enumValue
1227
- * - `'none'`: Uses the enum value as-is
1243
+ * - 'screamingSnakeCase' generates keys in SCREAMING_SNAKE_CASE format.
1244
+ * - 'snakeCase' generates keys in snake_case format.
1245
+ * - 'pascalCase' generates keys in PascalCase format.
1246
+ * - 'camelCase' generates keys in camelCase format.
1247
+ * - 'none' uses the enum value as-is without transformation.
1228
1248
  * @default 'none'
1229
1249
  */
1230
1250
  enumKeyCasing?: 'screamingSnakeCase' | 'snakeCase' | 'pascalCase' | 'camelCase' | 'none';
1231
1251
  /**
1232
- * Switch between type or interface for creating TypeScript types
1252
+ * Switch between type or interface for creating TypeScript types.
1253
+ * - 'type' generates type alias declarations.
1254
+ * - 'interface' generates interface declarations.
1233
1255
  * @default 'type'
1234
1256
  */
1235
1257
  syntaxType?: 'type' | 'interface';
@@ -1239,32 +1261,40 @@ type Options = {
1239
1261
  */
1240
1262
  enumSuffix?: string;
1241
1263
  /**
1242
- * Choose to use `date` or `datetime` as JavaScript `Date` instead of `string`.
1264
+ * Choose to use date or datetime as JavaScript Date instead of string.
1265
+ * - 'string' represents dates as string values.
1266
+ * - 'date' represents dates as JavaScript Date objects.
1243
1267
  * @default 'string'
1244
1268
  */
1245
1269
  dateType?: 'string' | 'date';
1246
1270
  /**
1247
1271
  * Which type to use when the Swagger/OpenAPI file is not providing more information.
1272
+ * - 'any' allows any value.
1273
+ * - 'unknown' requires type narrowing before use.
1274
+ * - 'void' represents no value.
1248
1275
  * @default 'any'
1249
1276
  */
1250
1277
  unknownType?: 'any' | 'unknown' | 'void';
1251
1278
  /**
1252
- * Which type to use for empty schema values
1279
+ * Which type to use for empty schema values.
1280
+ * - 'any' allows any value.
1281
+ * - 'unknown' requires type narrowing before use.
1282
+ * - 'void' represents no value.
1253
1283
  * @default `unknownType`
1254
1284
  */
1255
1285
  emptySchemaType?: 'any' | 'unknown' | 'void';
1256
1286
  /**
1257
1287
  * Choose what to use as mode for an optional value.
1258
- * @examples 'questionToken': type?: string
1259
- * @examples 'undefined': type: string | undefined
1260
- * @examples 'questionTokenAndUndefined': type?: string | undefined
1288
+ * - 'questionToken' marks the property as optional with ? (e.g., type?: string).
1289
+ * - 'undefined' adds undefined to the type union (e.g., type: string | undefined).
1290
+ * - 'questionTokenAndUndefined' combines both approaches (e.g., type?: string | undefined).
1261
1291
  * @default 'questionToken'
1262
1292
  */
1263
1293
  optionalType?: 'questionToken' | 'undefined' | 'questionTokenAndUndefined';
1264
1294
  /**
1265
- * Choose between `Array<string>` or `string[]` for array types.
1266
- * - `generic`: Array<Type>
1267
- * - `array`: Type[]
1295
+ * Choose between Array<string> or string[] for array types.
1296
+ * - 'generic' generates Array<Type> syntax.
1297
+ * - 'array' generates Type[] syntax.
1268
1298
  * @default 'array'
1269
1299
  */
1270
1300
  arrayType?: 'generic' | 'array';
@@ -1313,4 +1343,4 @@ type ResolvedOptions = {
1313
1343
  type PluginTs = PluginFactoryOptions<'plugin-ts', Options, ResolvedOptions, never, ResolvePathOptions>;
1314
1344
  //#endregion
1315
1345
  export { UserPluginWithLifeCycle as a, Schema as i, PluginTs as n, SchemaObject$1 as o, ReactGenerator as r, Options as t };
1316
- //# sourceMappingURL=types-e1TzqRgL.d.ts.map
1346
+ //# sourceMappingURL=types-C6zMTrNH.d.ts.map