@kubb/plugin-ts 4.18.4 → 4.18.5
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-BgXQceYE.js.map +1 -1
- package/dist/components-ORNo_nJW.cjs.map +1 -1
- package/dist/components.d.cts +1 -1
- package/dist/components.d.ts +1 -1
- package/dist/generators.d.cts +1 -1
- package/dist/generators.d.ts +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/{types-BmA-vXVc.d.cts → types-BMfQRWAb.d.cts} +82 -69
- package/dist/{types-e1TzqRgL.d.ts → types-DpL83O8r.d.ts} +82 -69
- package/package.json +4 -4
- package/src/parser.ts +1 -1
- package/src/types.ts +33 -23
|
@@ -39,7 +39,7 @@ declare class Oas extends BaseOas {
|
|
|
39
39
|
getResponseSchema(operation: Operation$1, statusCode: string | number): SchemaObject$1;
|
|
40
40
|
getRequestSchema(operation: Operation$1): SchemaObject$1 | undefined;
|
|
41
41
|
getParametersSchema(operation: Operation$1, inKey: 'path' | 'query' | 'header'): SchemaObject$1 | null;
|
|
42
|
-
|
|
42
|
+
validate(): Promise<oas_normalize_lib_types0.ValidationResult>;
|
|
43
43
|
flattenSchema(schema: SchemaObject$1 | null): SchemaObject$1 | null;
|
|
44
44
|
}
|
|
45
45
|
//#endregion
|
|
@@ -341,7 +341,7 @@ type Config<TInput = Input> = {
|
|
|
341
341
|
input: TInput;
|
|
342
342
|
output: {
|
|
343
343
|
/**
|
|
344
|
-
* The path where all generated files
|
|
344
|
+
* The path where all generated files receives exported.
|
|
345
345
|
* This can be an absolute path or a path relative to the specified root option.
|
|
346
346
|
*/
|
|
347
347
|
path: string;
|
|
@@ -356,41 +356,39 @@ type Config<TInput = Input> = {
|
|
|
356
356
|
write?: boolean;
|
|
357
357
|
/**
|
|
358
358
|
* Specifies the formatting tool to be used.
|
|
359
|
-
*
|
|
360
|
-
*
|
|
361
|
-
*
|
|
362
|
-
* - '
|
|
363
|
-
* -
|
|
364
|
-
*
|
|
365
|
-
*
|
|
359
|
+
* - 'auto' automatically detects and uses biome or prettier (in that order of preference).
|
|
360
|
+
* - 'prettier' uses Prettier for code formatting.
|
|
361
|
+
* - 'biome' uses Biome for code formatting.
|
|
362
|
+
* - 'oxfmt' uses Oxfmt for code formatting.
|
|
363
|
+
* - false disables code formatting.
|
|
364
|
+
* @default 'prettier'
|
|
366
365
|
*/
|
|
367
366
|
format?: 'auto' | 'prettier' | 'biome' | 'oxfmt' | false;
|
|
368
367
|
/**
|
|
369
368
|
* Specifies the linter that should be used to analyze the code.
|
|
370
|
-
*
|
|
371
|
-
*
|
|
372
|
-
*
|
|
373
|
-
* - '
|
|
374
|
-
* -
|
|
375
|
-
*
|
|
376
|
-
* - 'oxlint': Represents the Oxlint tool for linting purposes.
|
|
377
|
-
*
|
|
369
|
+
* - 'auto' automatically detects and uses biome, oxlint, or eslint (in that order of preference).
|
|
370
|
+
* - 'eslint' uses ESLint for linting.
|
|
371
|
+
* - 'biome' uses Biome for linting.
|
|
372
|
+
* - 'oxlint' uses Oxlint for linting.
|
|
373
|
+
* - false disables linting.
|
|
374
|
+
* @default 'auto'
|
|
378
375
|
*/
|
|
379
376
|
lint?: 'auto' | 'eslint' | 'biome' | 'oxlint' | false;
|
|
380
377
|
/**
|
|
381
|
-
*
|
|
378
|
+
* Overrides the extension for generated imports and exports. By default, each plugin adds an extension.
|
|
382
379
|
* @default { '.ts': '.ts'}
|
|
383
380
|
*/
|
|
384
381
|
extension?: Record<KubbFile.Extname, KubbFile.Extname | ''>;
|
|
385
382
|
/**
|
|
386
|
-
*
|
|
383
|
+
* 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`).
|
|
387
384
|
* @default 'named'
|
|
388
385
|
*/
|
|
389
386
|
barrelType?: Exclude<BarrelType, 'propagate'> | false;
|
|
390
387
|
/**
|
|
391
|
-
*
|
|
392
|
-
* - 'simple'
|
|
393
|
-
* - 'full'
|
|
388
|
+
* Adds a default banner to the start of every generated file indicating it was generated by Kubb.
|
|
389
|
+
* - 'simple' adds banner with link to Kubb.
|
|
390
|
+
* - 'full' adds source, title, description, and OpenAPI version.
|
|
391
|
+
* - false disables banner generation.
|
|
394
392
|
* @default 'simple'
|
|
395
393
|
*/
|
|
396
394
|
defaultBanner?: 'simple' | 'full' | false;
|
|
@@ -403,17 +401,17 @@ type Config<TInput = Input> = {
|
|
|
403
401
|
override?: boolean;
|
|
404
402
|
};
|
|
405
403
|
/**
|
|
406
|
-
* An array of Kubb plugins that
|
|
404
|
+
* An array of Kubb plugins that used in the generation.
|
|
407
405
|
* Each plugin may include additional configurable options(defined in the plugin itself).
|
|
408
|
-
* If a plugin depends on another plugin, an error
|
|
406
|
+
* If a plugin depends on another plugin, an error is returned if the required dependency is missing. See pre for more details.
|
|
409
407
|
*/
|
|
410
408
|
plugins?: Array<Plugin>;
|
|
411
409
|
/**
|
|
412
|
-
* Hooks
|
|
410
|
+
* Hooks triggered when a specific action occurs in Kubb.
|
|
413
411
|
*/
|
|
414
412
|
hooks?: {
|
|
415
413
|
/**
|
|
416
|
-
* Hook that
|
|
414
|
+
* Hook that triggers at the end of all executions.
|
|
417
415
|
* Useful for running Prettier or ESLint to format/lint your code.
|
|
418
416
|
*/
|
|
419
417
|
done?: string | Array<string>;
|
|
@@ -442,7 +440,7 @@ TContext = any,
|
|
|
442
440
|
TResolvePathOptions extends object = object> = {
|
|
443
441
|
name: TName;
|
|
444
442
|
/**
|
|
445
|
-
* Same
|
|
443
|
+
* Same behavior like what has been done with `QueryKey` in `@tanstack/react-query`
|
|
446
444
|
*/
|
|
447
445
|
key: PluginKey<TName | string>;
|
|
448
446
|
options: TOptions;
|
|
@@ -463,12 +461,12 @@ type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> =
|
|
|
463
461
|
*/
|
|
464
462
|
options: TOptions['resolvedOptions'];
|
|
465
463
|
/**
|
|
466
|
-
* Specifies the preceding plugins for the current plugin. You can pass an array of preceding plugin names, and the current plugin
|
|
464
|
+
* 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.
|
|
467
465
|
* Can be used to validate dependent plugins.
|
|
468
466
|
*/
|
|
469
467
|
pre?: Array<string>;
|
|
470
468
|
/**
|
|
471
|
-
* Specifies the succeeding plugins for the current plugin. You can pass an array of succeeding plugin names, and the current plugin
|
|
469
|
+
* 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.
|
|
472
470
|
*/
|
|
473
471
|
post?: Array<string>;
|
|
474
472
|
inject?: (this: PluginContext<TOptions>, context: PluginContext<TOptions>) => TOptions['context'];
|
|
@@ -486,12 +484,12 @@ type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
|
486
484
|
*/
|
|
487
485
|
key: TOptions['key'];
|
|
488
486
|
/**
|
|
489
|
-
* Specifies the preceding plugins for the current plugin. You can pass an array of preceding plugin names, and the current plugin
|
|
487
|
+
* 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.
|
|
490
488
|
* Can be used to validate dependent plugins.
|
|
491
489
|
*/
|
|
492
490
|
pre?: Array<string>;
|
|
493
491
|
/**
|
|
494
|
-
* Specifies the succeeding plugins for the current plugin. You can pass an array of succeeding plugin names, and the current plugin
|
|
492
|
+
* 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.
|
|
495
493
|
*/
|
|
496
494
|
post?: Array<string>;
|
|
497
495
|
/**
|
|
@@ -541,10 +539,12 @@ type ResolveNameParams = {
|
|
|
541
539
|
name: string;
|
|
542
540
|
pluginKey?: Plugin['key'];
|
|
543
541
|
/**
|
|
544
|
-
*
|
|
545
|
-
*
|
|
546
|
-
*
|
|
547
|
-
*
|
|
542
|
+
* Specifies the type of entity being named.
|
|
543
|
+
* - 'file' customizes the name of the created file (uses camelCase).
|
|
544
|
+
* - 'function' customizes the exported function names (uses camelCase).
|
|
545
|
+
* - 'type' customizes TypeScript types (uses PascalCase).
|
|
546
|
+
* - 'const' customizes variable names (uses camelCase).
|
|
547
|
+
* @default undefined
|
|
548
548
|
*/
|
|
549
549
|
type?: 'file' | 'function' | 'type' | 'const';
|
|
550
550
|
};
|
|
@@ -599,11 +599,14 @@ type GroupContext = {
|
|
|
599
599
|
};
|
|
600
600
|
type Group = {
|
|
601
601
|
/**
|
|
602
|
-
*
|
|
602
|
+
* Defines the type where to group the files.
|
|
603
|
+
* - 'tag' groups files by OpenAPI tags.
|
|
604
|
+
* - 'path' groups files by OpenAPI paths.
|
|
605
|
+
* @default undefined
|
|
603
606
|
*/
|
|
604
607
|
type: 'tag' | 'path';
|
|
605
608
|
/**
|
|
606
|
-
* Return the name of a group based on the group name, this
|
|
609
|
+
* Return the name of a group based on the group name, this used for the file and name generation
|
|
607
610
|
*/
|
|
608
611
|
name?: (context: GroupContext) => string;
|
|
609
612
|
};
|
|
@@ -675,7 +678,7 @@ declare class PluginManager {
|
|
|
675
678
|
parameters: PluginParameter<H>;
|
|
676
679
|
}): Array<ReturnType<ParseResult<H>>> | null;
|
|
677
680
|
/**
|
|
678
|
-
*
|
|
681
|
+
* Returns the first non-null result.
|
|
679
682
|
*/
|
|
680
683
|
hookFirst<H extends PluginLifecycleHooks>({
|
|
681
684
|
hookName,
|
|
@@ -687,7 +690,7 @@ declare class PluginManager {
|
|
|
687
690
|
skipped?: ReadonlySet<Plugin> | null;
|
|
688
691
|
}): Promise<SafeParseResult<H>>;
|
|
689
692
|
/**
|
|
690
|
-
*
|
|
693
|
+
* Returns the first non-null result.
|
|
691
694
|
*/
|
|
692
695
|
hookFirstSync<H extends PluginLifecycleHooks>({
|
|
693
696
|
hookName,
|
|
@@ -699,15 +702,15 @@ declare class PluginManager {
|
|
|
699
702
|
skipped?: ReadonlySet<Plugin> | null;
|
|
700
703
|
}): SafeParseResult<H>;
|
|
701
704
|
/**
|
|
702
|
-
*
|
|
705
|
+
* Runs all plugins in parallel based on `this.plugin` order and `pre`/`post` settings.
|
|
703
706
|
*/
|
|
704
|
-
hookParallel<H extends PluginLifecycleHooks,
|
|
707
|
+
hookParallel<H extends PluginLifecycleHooks, TOutput = void>({
|
|
705
708
|
hookName,
|
|
706
709
|
parameters
|
|
707
710
|
}: {
|
|
708
711
|
hookName: H;
|
|
709
712
|
parameters?: Parameters<RequiredPluginLifecycle[H]> | undefined;
|
|
710
|
-
}): Promise<Awaited<
|
|
713
|
+
}): Promise<Awaited<TOutput>[]>;
|
|
711
714
|
/**
|
|
712
715
|
* Chains plugins
|
|
713
716
|
*/
|
|
@@ -976,8 +979,8 @@ type SchemaKeywordMapper = {
|
|
|
976
979
|
*/
|
|
977
980
|
path: KubbFile.Path;
|
|
978
981
|
/**
|
|
979
|
-
* When true `File.Import`
|
|
980
|
-
* When false a reference
|
|
982
|
+
* When true `File.Import` is used.
|
|
983
|
+
* When false a reference is used inside the current file.
|
|
981
984
|
*/
|
|
982
985
|
isImportable: boolean;
|
|
983
986
|
};
|
|
@@ -1109,7 +1112,7 @@ type SchemaGeneratorOptions = {
|
|
|
1109
1112
|
*/
|
|
1110
1113
|
name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
1111
1114
|
/**
|
|
1112
|
-
* Receive schema and name(
|
|
1115
|
+
* Receive schema and name(propertyName) and return FakerMeta array
|
|
1113
1116
|
* TODO TODO add docs
|
|
1114
1117
|
* @beta
|
|
1115
1118
|
*/
|
|
@@ -1188,7 +1191,7 @@ type Options = {
|
|
|
1188
1191
|
output?: Output<Oas>;
|
|
1189
1192
|
/**
|
|
1190
1193
|
* Define which contentType should be used.
|
|
1191
|
-
* By default, the first
|
|
1194
|
+
* By default, uses the first valid JSON media type.
|
|
1192
1195
|
*/
|
|
1193
1196
|
contentType?: contentType;
|
|
1194
1197
|
/**
|
|
@@ -1208,29 +1211,31 @@ type Options = {
|
|
|
1208
1211
|
*/
|
|
1209
1212
|
override?: Array<Override<ResolvedOptions>>;
|
|
1210
1213
|
/**
|
|
1211
|
-
* Choose to use
|
|
1212
|
-
* -
|
|
1213
|
-
* -
|
|
1214
|
-
* -
|
|
1215
|
-
* -
|
|
1216
|
-
* -
|
|
1217
|
-
* -
|
|
1214
|
+
* Choose to use enum, asConst, asPascalConst, constEnum, literal, or inlineLiteral for enums.
|
|
1215
|
+
* - 'enum' generates TypeScript enum declarations.
|
|
1216
|
+
* - 'asConst' generates const objects with camelCase names and as const assertion.
|
|
1217
|
+
* - 'asPascalConst' generates const objects with PascalCase names and as const assertion.
|
|
1218
|
+
* - 'constEnum' generates TypeScript const enum declarations.
|
|
1219
|
+
* - 'literal' generates literal union types.
|
|
1220
|
+
* - 'inlineLiteral' inlines enum values directly into the type (default in v5).
|
|
1218
1221
|
* @default 'asConst'
|
|
1219
|
-
* @note In Kubb v5,
|
|
1222
|
+
* @note In Kubb v5, 'inlineLiteral' becomes the default.
|
|
1220
1223
|
*/
|
|
1221
1224
|
enumType?: 'enum' | 'asConst' | 'asPascalConst' | 'constEnum' | 'literal' | 'inlineLiteral';
|
|
1222
1225
|
/**
|
|
1223
1226
|
* Choose the casing for enum key names.
|
|
1224
|
-
* -
|
|
1225
|
-
* -
|
|
1226
|
-
* -
|
|
1227
|
-
* -
|
|
1228
|
-
* -
|
|
1227
|
+
* - 'screamingSnakeCase' generates keys in SCREAMING_SNAKE_CASE format.
|
|
1228
|
+
* - 'snakeCase' generates keys in snake_case format.
|
|
1229
|
+
* - 'pascalCase' generates keys in PascalCase format.
|
|
1230
|
+
* - 'camelCase' generates keys in camelCase format.
|
|
1231
|
+
* - 'none' uses the enum value as-is without transformation.
|
|
1229
1232
|
* @default 'none'
|
|
1230
1233
|
*/
|
|
1231
1234
|
enumKeyCasing?: 'screamingSnakeCase' | 'snakeCase' | 'pascalCase' | 'camelCase' | 'none';
|
|
1232
1235
|
/**
|
|
1233
|
-
* Switch between type or interface for creating TypeScript types
|
|
1236
|
+
* Switch between type or interface for creating TypeScript types.
|
|
1237
|
+
* - 'type' generates type alias declarations.
|
|
1238
|
+
* - 'interface' generates interface declarations.
|
|
1234
1239
|
* @default 'type'
|
|
1235
1240
|
*/
|
|
1236
1241
|
syntaxType?: 'type' | 'interface';
|
|
@@ -1240,32 +1245,40 @@ type Options = {
|
|
|
1240
1245
|
*/
|
|
1241
1246
|
enumSuffix?: string;
|
|
1242
1247
|
/**
|
|
1243
|
-
* Choose to use
|
|
1248
|
+
* Choose to use date or datetime as JavaScript Date instead of string.
|
|
1249
|
+
* - 'string' represents dates as string values.
|
|
1250
|
+
* - 'date' represents dates as JavaScript Date objects.
|
|
1244
1251
|
* @default 'string'
|
|
1245
1252
|
*/
|
|
1246
1253
|
dateType?: 'string' | 'date';
|
|
1247
1254
|
/**
|
|
1248
1255
|
* Which type to use when the Swagger/OpenAPI file is not providing more information.
|
|
1256
|
+
* - 'any' allows any value.
|
|
1257
|
+
* - 'unknown' requires type narrowing before use.
|
|
1258
|
+
* - 'void' represents no value.
|
|
1249
1259
|
* @default 'any'
|
|
1250
1260
|
*/
|
|
1251
1261
|
unknownType?: 'any' | 'unknown' | 'void';
|
|
1252
1262
|
/**
|
|
1253
|
-
* Which type to use for empty schema values
|
|
1263
|
+
* Which type to use for empty schema values.
|
|
1264
|
+
* - 'any' allows any value.
|
|
1265
|
+
* - 'unknown' requires type narrowing before use.
|
|
1266
|
+
* - 'void' represents no value.
|
|
1254
1267
|
* @default `unknownType`
|
|
1255
1268
|
*/
|
|
1256
1269
|
emptySchemaType?: 'any' | 'unknown' | 'void';
|
|
1257
1270
|
/**
|
|
1258
1271
|
* Choose what to use as mode for an optional value.
|
|
1259
|
-
*
|
|
1260
|
-
*
|
|
1261
|
-
*
|
|
1272
|
+
* - 'questionToken' marks the property as optional with ? (e.g., type?: string).
|
|
1273
|
+
* - 'undefined' adds undefined to the type union (e.g., type: string | undefined).
|
|
1274
|
+
* - 'questionTokenAndUndefined' combines both approaches (e.g., type?: string | undefined).
|
|
1262
1275
|
* @default 'questionToken'
|
|
1263
1276
|
*/
|
|
1264
1277
|
optionalType?: 'questionToken' | 'undefined' | 'questionTokenAndUndefined';
|
|
1265
1278
|
/**
|
|
1266
|
-
* Choose between
|
|
1267
|
-
* -
|
|
1268
|
-
* -
|
|
1279
|
+
* Choose between Array<string> or string[] for array types.
|
|
1280
|
+
* - 'generic' generates Array<Type> syntax.
|
|
1281
|
+
* - 'array' generates Type[] syntax.
|
|
1269
1282
|
* @default 'array'
|
|
1270
1283
|
*/
|
|
1271
1284
|
arrayType?: 'generic' | 'array';
|
|
@@ -1314,4 +1327,4 @@ type ResolvedOptions = {
|
|
|
1314
1327
|
type PluginTs = PluginFactoryOptions<'plugin-ts', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
1315
1328
|
//#endregion
|
|
1316
1329
|
export { UserPluginWithLifeCycle as a, Schema as i, PluginTs as n, SchemaObject$1 as o, ReactGenerator as r, __name as s, Options as t };
|
|
1317
|
-
//# sourceMappingURL=types-
|
|
1330
|
+
//# sourceMappingURL=types-BMfQRWAb.d.cts.map
|