@kubb/plugin-cypress 4.1.4 → 4.2.1

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.
@@ -5,6 +5,7 @@ import { OpenAPIV3 } from "openapi-types";
5
5
  import * as oas_normalize_lib_types0 from "oas-normalize/lib/types";
6
6
  import BaseOas from "oas";
7
7
  import { ConsolaInstance, LogLevel } from "consola";
8
+ import { FileManager } from "@kubb/fabric-core";
8
9
 
9
10
  //#region ../oas/src/types.d.ts
10
11
  type contentType = 'application/json' | (string & {});
@@ -46,17 +47,17 @@ declare class Oas<const TOAS = unknown> extends BaseOas {
46
47
  * Abstract class that contains the building blocks for plugins to create their own Generator
47
48
  * @link idea based on https://github.com/colinhacks/zod/blob/master/src/types.ts#L137
48
49
  */
49
- declare abstract class BaseGenerator<TOptions = unknown, TContext = unknown> {
50
+ declare abstract class BaseGenerator<TOptions$1 = unknown, TContext = unknown> {
50
51
  #private;
51
- constructor(options?: TOptions, context?: TContext);
52
- get options(): TOptions;
52
+ constructor(options?: TOptions$1, context?: TContext);
53
+ get options(): TOptions$1;
53
54
  get context(): TContext;
54
- set options(options: TOptions);
55
+ set options(options: TOptions$1);
55
56
  abstract build(...params: unknown[]): unknown;
56
57
  }
57
58
  //#endregion
58
59
  //#region ../core/src/fs/types.d.ts
59
- type BasePath<T extends string = string> = `${T}/`;
60
+ type BasePath<T$1 extends string = string> = `${T$1}/`;
60
61
  type Import = {
61
62
  /**
62
63
  * Import name to be used
@@ -130,7 +131,7 @@ type BaseName = `${string}.${string}`;
130
131
  * Path will be full qualified path to a specified file
131
132
  */
132
133
  type Path = string;
133
- type AdvancedPath<T extends BaseName = BaseName> = `${BasePath}${T}`;
134
+ type AdvancedPath<T$1 extends BaseName = BaseName> = `${BasePath}${T$1}`;
134
135
  type OptionalPath = Path | undefined | null;
135
136
  type File<TMeta extends object = object> = {
136
137
  /**
@@ -219,9 +220,7 @@ type Logger = {
219
220
  };
220
221
  //#endregion
221
222
  //#region ../core/src/utils/types.d.ts
222
- type PossiblePromise<T> = Promise<T> | T;
223
- type ArrayWithLength<T extends number, U extends any[] = []> = U['length'] extends T ? U : ArrayWithLength<T, [true, ...U]>;
224
- type GreaterThan<T extends number, U extends number> = ArrayWithLength<U> extends [...ArrayWithLength<T>, ...infer _] ? false : true;
223
+ type PossiblePromise<T$1> = Promise<T$1> | T$1;
225
224
  //#endregion
226
225
  //#region ../core/src/types.d.ts
227
226
  type InputPath = {
@@ -334,11 +333,11 @@ TName extends string = string,
334
333
  /**
335
334
  * Options of the plugin.
336
335
  */
337
- TOptions extends object = object,
336
+ TOptions$1 extends object = object,
338
337
  /**
339
338
  * Options of the plugin that can be used later on, see `options` inside your plugin config.
340
339
  */
341
- TResolvedOptions extends object = TOptions,
340
+ TResolvedOptions extends object = TOptions$1,
342
341
  /**
343
342
  * Context that you want to expose to other plugins.
344
343
  */
@@ -352,23 +351,23 @@ TResolvePathOptions extends object = object> = {
352
351
  * Same behaviour like what has been done with `QueryKey` in `@tanstack/react-query`
353
352
  */
354
353
  key: PluginKey<TName | string>;
355
- options: TOptions;
354
+ options: TOptions$1;
356
355
  resolvedOptions: TResolvedOptions;
357
356
  context: TContext;
358
357
  resolvePathOptions: TResolvePathOptions;
359
358
  };
360
359
  type PluginKey<TName> = [name: TName, identifier?: string | number];
361
- type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
360
+ type UserPlugin<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
362
361
  /**
363
362
  * Unique name used for the plugin
364
363
  * The name of the plugin follows the format scope:foo-bar or foo-bar, adding scope: can avoid naming conflicts with other plugins.
365
364
  * @example @kubb/typescript
366
365
  */
367
- name: TOptions['name'];
366
+ name: TOptions$1['name'];
368
367
  /**
369
368
  * Options set for a specific plugin(see kubb.config.js), passthrough of options.
370
369
  */
371
- options: TOptions['resolvedOptions'];
370
+ options: TOptions$1['resolvedOptions'];
372
371
  /**
373
372
  * 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.
374
373
  * Can be used to validate dependent plugins.
@@ -378,23 +377,23 @@ type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> =
378
377
  * 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.
379
378
  */
380
379
  post?: Array<string>;
381
- } & (TOptions['context'] extends never ? {
380
+ } & (TOptions$1['context'] extends never ? {
382
381
  context?: never;
383
382
  } : {
384
- context: (this: TOptions['name'] extends 'core' ? null : Omit<PluginContext<TOptions>, 'addFile'>) => TOptions['context'];
383
+ context: (this: TOptions$1['name'] extends 'core' ? null : Omit<PluginContext<TOptions$1>, 'addFile'>) => TOptions$1['context'];
385
384
  });
386
- type UserPluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = UserPlugin<TOptions> & PluginLifecycle<TOptions>;
387
- type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
385
+ type UserPluginWithLifeCycle<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = UserPlugin<TOptions$1> & PluginLifecycle<TOptions$1>;
386
+ type Plugin<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
388
387
  /**
389
388
  * Unique name used for the plugin
390
389
  * @example @kubb/typescript
391
390
  */
392
- name: TOptions['name'];
391
+ name: TOptions$1['name'];
393
392
  /**
394
393
  * Internal key used when a developer uses more than one of the same plugin
395
394
  * @private
396
395
  */
397
- key: TOptions['key'];
396
+ key: TOptions$1['key'];
398
397
  /**
399
398
  * 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.
400
399
  * Can be used to validate dependent plugins.
@@ -407,49 +406,49 @@ type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
407
406
  /**
408
407
  * Options set for a specific plugin(see kubb.config.js), passthrough of options.
409
408
  */
410
- options: TOptions['resolvedOptions'];
411
- } & (TOptions['context'] extends never ? {
409
+ options: TOptions$1['resolvedOptions'];
410
+ } & (TOptions$1['context'] extends never ? {
412
411
  context?: never;
413
412
  } : {
414
- context: TOptions['context'];
413
+ context: TOptions$1['context'];
415
414
  });
416
- type PluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions> & PluginLifecycle<TOptions>;
417
- type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
415
+ type PluginWithLifeCycle<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions$1> & PluginLifecycle<TOptions$1>;
416
+ type PluginLifecycle<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
418
417
  /**
419
418
  * Start of the lifecycle of a plugin.
420
419
  * @type hookParallel
421
420
  */
422
- buildStart?: (this: PluginContext<TOptions>, Config: Config) => PossiblePromise<void>;
421
+ buildStart?: (this: PluginContext<TOptions$1>, Config: Config) => PossiblePromise<void>;
423
422
  /**
424
423
  * Resolve to a Path based on a baseName(example: `./Pet.ts`) and directory(example: `./models`).
425
424
  * Options can als be included.
426
425
  * @type hookFirst
427
426
  * @example ('./Pet.ts', './src/gen/') => '/src/gen/Pet.ts'
428
427
  */
429
- resolvePath?: (this: PluginContext<TOptions>, baseName: BaseName, mode?: Mode, options?: TOptions['resolvePathOptions']) => OptionalPath;
428
+ resolvePath?: (this: PluginContext<TOptions$1>, baseName: BaseName, mode?: Mode, options?: TOptions$1['resolvePathOptions']) => OptionalPath;
430
429
  /**
431
430
  * Resolve to a name based on a string.
432
431
  * Useful when converting to PascalCase or camelCase.
433
432
  * @type hookFirst
434
433
  * @example ('pet') => 'Pet'
435
434
  */
436
- resolveName?: (this: PluginContext<TOptions>, name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
435
+ resolveName?: (this: PluginContext<TOptions$1>, name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
437
436
  /**
438
437
  * End of the plugin lifecycle.
439
438
  * @type hookParallel
440
439
  */
441
- buildEnd?: (this: PluginContext<TOptions>) => PossiblePromise<void>;
440
+ buildEnd?: (this: PluginContext<TOptions$1>) => PossiblePromise<void>;
442
441
  };
443
442
  type PluginLifecycleHooks = keyof PluginLifecycle;
444
- type PluginParameter<H extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H]>;
445
- type ResolvePathParams<TOptions = object> = {
443
+ type PluginParameter<H$1 extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H$1]>;
444
+ type ResolvePathParams<TOptions$1 = object> = {
446
445
  pluginKey?: Plugin['key'];
447
446
  baseName: BaseName;
448
447
  mode?: Mode;
449
448
  /**
450
449
  * Options to be passed to 'resolvePath' 3th parameter
451
450
  */
452
- options?: TOptions;
451
+ options?: TOptions$1;
453
452
  };
454
453
  type ResolveNameParams = {
455
454
  name: string;
@@ -462,12 +461,15 @@ type ResolveNameParams = {
462
461
  */
463
462
  type?: 'file' | 'function' | 'type' | 'const';
464
463
  };
465
- type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
464
+ type PluginContext<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
466
465
  config: Config;
466
+ /**
467
+ * @deprecated
468
+ */
467
469
  fileManager: FileManager;
468
470
  pluginManager: PluginManager;
469
471
  addFile: (...file: Array<File>) => Promise<Array<ResolvedFile>>;
470
- resolvePath: (params: ResolvePathParams<TOptions['resolvePathOptions']>) => OptionalPath;
472
+ resolvePath: (params: ResolvePathParams<TOptions$1['resolvePathOptions']>) => OptionalPath;
471
473
  resolveName: (params: ResolveNameParams) => string;
472
474
  logger: Logger;
473
475
  /**
@@ -477,12 +479,12 @@ type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions>
477
479
  /**
478
480
  * Current plugin
479
481
  */
480
- plugin: Plugin<TOptions>;
482
+ plugin: Plugin<TOptions$1>;
481
483
  };
482
484
  /**
483
485
  * Specify the export location for the files and define the behavior of the output
484
486
  */
485
- type Output<TOptions> = {
487
+ type Output<TOptions$1> = {
486
488
  /**
487
489
  * Path to the output folder or file that will contain the generated code
488
490
  */
@@ -495,11 +497,11 @@ type Output<TOptions> = {
495
497
  /**
496
498
  * Add a banner text in the beginning of every file
497
499
  */
498
- banner?: string | ((options: TOptions) => string);
500
+ banner?: string | ((options: TOptions$1) => string);
499
501
  /**
500
502
  * Add a footer text in the beginning of every file
501
503
  */
502
- footer?: string | ((options: TOptions) => string);
504
+ footer?: string | ((options: TOptions$1) => string);
503
505
  };
504
506
  type GroupContext = {
505
507
  group: string;
@@ -515,73 +517,19 @@ type Group = {
515
517
  name?: (context: GroupContext) => string;
516
518
  };
517
519
  //#endregion
518
- //#region ../core/src/FileManager.d.ts
519
- type FileMetaBase = {
520
- pluginKey?: Plugin['key'];
521
- };
522
- type AddResult<T extends Array<File>> = Promise<Awaited<GreaterThan<T['length'], 1> extends true ? Promise<ResolvedFile[]> : Promise<ResolvedFile>>>;
523
- type AddIndexesProps = {
524
- type: BarrelType | false | undefined;
525
- /**
526
- * Root based on root and output.path specified in the config
527
- */
528
- root: string;
529
- /**
530
- * Output for plugin
531
- */
532
- output: {
533
- path: string;
534
- };
535
- group?: {
536
- output: string;
537
- exportAs: string;
538
- };
539
- logger?: Logger;
540
- meta?: FileMetaBase;
541
- };
542
- type WriteFilesProps = {
543
- root: Config['root'];
544
- extension?: Record<Extname, Extname | ''>;
545
- logger?: Logger;
546
- dryRun?: boolean;
547
- };
548
- declare class FileManager {
549
- #private;
550
- constructor();
551
- add<T extends Array<File> = Array<File>>(...files: T): AddResult<T>;
552
- getByPath(path: Path): Promise<ResolvedFile | null>;
553
- deleteByPath(path: Path): Promise<void>;
554
- clear(): Promise<void>;
555
- getFiles(): Promise<Array<ResolvedFile>>;
556
- processFiles({
557
- dryRun,
558
- root,
559
- extension,
560
- logger
561
- }: WriteFilesProps): Promise<Array<ResolvedFile>>;
562
- getBarrelFiles({
563
- type,
564
- meta,
565
- root,
566
- output,
567
- logger
568
- }: AddIndexesProps): Promise<File[]>;
569
- static getMode(path: string | undefined | null): Mode;
570
- }
571
- //#endregion
572
520
  //#region ../core/src/PluginManager.d.ts
573
521
  type RequiredPluginLifecycle = Required<PluginLifecycle>;
574
522
  type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
575
- type Executer<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
523
+ type Executer<H$1 extends PluginLifecycleHooks = PluginLifecycleHooks> = {
576
524
  message: string;
577
525
  strategy: Strategy;
578
- hookName: H;
526
+ hookName: H$1;
579
527
  plugin: Plugin;
580
528
  parameters?: unknown[] | undefined;
581
529
  output?: unknown;
582
530
  };
583
- type ParseResult<H extends PluginLifecycleHooks> = RequiredPluginLifecycle[H];
584
- type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {
531
+ type ParseResult<H$1 extends PluginLifecycleHooks> = RequiredPluginLifecycle[H$1];
532
+ type SafeParseResult<H$1 extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H$1>>> = {
585
533
  result: Result;
586
534
  plugin: Plugin;
587
535
  };
@@ -597,16 +545,19 @@ type Events = {
597
545
  executed: [executer: Executer];
598
546
  error: [error: Error];
599
547
  };
600
- type GetFileProps<TOptions = object> = {
548
+ type GetFileProps<TOptions$1 = object> = {
601
549
  name: string;
602
550
  mode?: Mode;
603
551
  extname: Extname;
604
552
  pluginKey: Plugin['key'];
605
- options?: TOptions;
553
+ options?: TOptions$1;
606
554
  };
607
555
  declare class PluginManager {
608
556
  #private;
609
557
  readonly plugins: Set<Plugin<PluginFactoryOptions<string, object, object, any, object>>>;
558
+ /**
559
+ * @deprecated do not use from pluginManager
560
+ */
610
561
  readonly fileManager: FileManager;
611
562
  readonly events: EventEmitter<Events>;
612
563
  readonly config: Config;
@@ -715,6 +666,11 @@ declare class PluginManager {
715
666
  static get hooks(): readonly ["buildStart", "resolvePath", "resolveName", "buildEnd"];
716
667
  }
717
668
  //#endregion
669
+ //#region ../core/src/FileManager.d.ts
670
+ type FileMetaBase = {
671
+ pluginKey?: Plugin['key'];
672
+ };
673
+ //#endregion
718
674
  //#region ../plugin-oas/src/SchemaMapper.d.ts
719
675
  type SchemaKeywordMapper = {
720
676
  object: {
@@ -1008,12 +964,12 @@ type ByContentType = {
1008
964
  };
1009
965
  type Exclude$1 = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
1010
966
  type Include = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
1011
- type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName | ByContentType) & {
1012
- options: Partial<TOptions>;
967
+ type Override<TOptions$1> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName | ByContentType) & {
968
+ options: Partial<TOptions$1>;
1013
969
  };
1014
970
  //#endregion
1015
971
  //#region ../plugin-oas/src/SchemaGenerator.d.ts
1016
- type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
972
+ type Context$1<TOptions$1, TPluginOptions extends PluginFactoryOptions> = {
1017
973
  oas: Oas;
1018
974
  pluginManager: PluginManager;
1019
975
  /**
@@ -1022,7 +978,7 @@ type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
1022
978
  plugin: Plugin<TPluginOptions>;
1023
979
  mode: Mode;
1024
980
  include?: Array<'schemas' | 'responses' | 'requestBodies'>;
1025
- override: Array<Override<TOptions>> | undefined;
981
+ override: Array<Override<TOptions$1>> | undefined;
1026
982
  contentType?: contentType;
1027
983
  output?: string;
1028
984
  };
@@ -1053,7 +1009,7 @@ type SchemaProps$1 = {
1053
1009
  name?: string;
1054
1010
  parentName?: string;
1055
1011
  };
1056
- declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions, Context$1<TOptions, TPluginOptions>> {
1012
+ declare class SchemaGenerator<TOptions$1 extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions$1, Context$1<TOptions$1, TPluginOptions>> {
1057
1013
  #private;
1058
1014
  refs: Refs;
1059
1015
  /**
@@ -1072,39 +1028,39 @@ declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGe
1072
1028
  }
1073
1029
  //#endregion
1074
1030
  //#region ../plugin-oas/src/generator.d.ts
1075
- type OperationsProps<TOptions extends PluginFactoryOptions> = {
1076
- instance: Omit<OperationGenerator<TOptions>, 'build'>;
1077
- options: TOptions['resolvedOptions'];
1031
+ type OperationsProps<TOptions$1 extends PluginFactoryOptions> = {
1032
+ instance: Omit<OperationGenerator<TOptions$1>, 'build'>;
1033
+ options: TOptions$1['resolvedOptions'];
1078
1034
  operations: Array<Operation$1>;
1079
1035
  };
1080
- type OperationProps<TOptions extends PluginFactoryOptions> = {
1081
- instance: Omit<OperationGenerator<TOptions>, 'build'>;
1082
- options: TOptions['resolvedOptions'];
1036
+ type OperationProps<TOptions$1 extends PluginFactoryOptions> = {
1037
+ instance: Omit<OperationGenerator<TOptions$1>, 'build'>;
1038
+ options: TOptions$1['resolvedOptions'];
1083
1039
  operation: Operation$1;
1084
1040
  };
1085
- type SchemaProps<TOptions extends PluginFactoryOptions> = {
1086
- instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>;
1087
- options: TOptions['resolvedOptions'];
1041
+ type SchemaProps<TOptions$1 extends PluginFactoryOptions> = {
1042
+ instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions$1>, 'build'>;
1043
+ options: TOptions$1['resolvedOptions'];
1088
1044
  schema: {
1089
1045
  name: string;
1090
1046
  tree: Array<Schema>;
1091
1047
  value: SchemaObject$1;
1092
1048
  };
1093
1049
  };
1094
- type GeneratorOptions<TOptions extends PluginFactoryOptions> = {
1050
+ type GeneratorOptions<TOptions$1 extends PluginFactoryOptions> = {
1095
1051
  name: string;
1096
- operations?: (this: GeneratorOptions<TOptions>, props: OperationsProps<TOptions>) => Promise<File[]>;
1097
- operation?: (this: GeneratorOptions<TOptions>, props: OperationProps<TOptions>) => Promise<File[]>;
1098
- schema?: (this: GeneratorOptions<TOptions>, props: SchemaProps<TOptions>) => Promise<File[]>;
1052
+ operations?: (this: GeneratorOptions<TOptions$1>, props: OperationsProps<TOptions$1>) => Promise<File[]>;
1053
+ operation?: (this: GeneratorOptions<TOptions$1>, props: OperationProps<TOptions$1>) => Promise<File[]>;
1054
+ schema?: (this: GeneratorOptions<TOptions$1>, props: SchemaProps<TOptions$1>) => Promise<File[]>;
1099
1055
  };
1100
- type Generator<TOptions extends PluginFactoryOptions> = GeneratorOptions<TOptions>;
1056
+ type Generator<TOptions$1 extends PluginFactoryOptions> = GeneratorOptions<TOptions$1>;
1101
1057
  //#endregion
1102
1058
  //#region ../plugin-oas/src/OperationGenerator.d.ts
1103
- type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
1059
+ type Context<TOptions$1, TPluginOptions extends PluginFactoryOptions> = {
1104
1060
  oas: Oas;
1105
1061
  exclude: Array<Exclude$1> | undefined;
1106
1062
  include: Array<Include> | undefined;
1107
- override: Array<Override<TOptions>> | undefined;
1063
+ override: Array<Override<TOptions$1>> | undefined;
1108
1064
  contentType: contentType | undefined;
1109
1065
  pluginManager: PluginManager;
1110
1066
  /**
@@ -1183,5 +1139,5 @@ type ResolvedOptions = {
1183
1139
  };
1184
1140
  type PluginCypress = PluginFactoryOptions<'plugin-cypress', Options$1, ResolvedOptions, never, ResolvePathOptions>;
1185
1141
  //#endregion
1186
- export { Generator, type HttpMethod, OperationSchemas, Options$1 as Options, PluginCypress, UserPluginWithLifeCycle };
1187
- //# sourceMappingURL=types-rlD4akES.d.cts.map
1142
+ export { UserPluginWithLifeCycle as a, OperationSchemas as i, PluginCypress as n, HttpMethod as o, Generator as r, Options$1 as t };
1143
+ //# sourceMappingURL=types-BmCWqgDU.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-cypress",
3
- "version": "4.1.4",
3
+ "version": "4.2.1",
4
4
  "description": "Cypress test generator plugin for Kubb, creating end-to-end tests from OpenAPI specifications for automated API testing.",
5
5
  "keywords": [
6
6
  "cypress",
@@ -67,16 +67,14 @@
67
67
  "!/**/__tests__/**"
68
68
  ],
69
69
  "dependencies": {
70
- "@kubb/core": "4.1.4",
71
- "@kubb/oas": "4.1.4",
72
- "@kubb/plugin-oas": "4.1.4",
73
- "@kubb/plugin-ts": "4.1.4",
74
- "@kubb/react": "4.1.4"
70
+ "@kubb/core": "4.2.1",
71
+ "@kubb/oas": "4.2.1",
72
+ "@kubb/plugin-oas": "4.2.1",
73
+ "@kubb/plugin-ts": "4.2.1",
74
+ "@kubb/react": "4.2.1"
75
75
  },
76
76
  "devDependencies": {
77
- "@types/react": "^18.3.26",
78
- "react": "^18.3.1",
79
- "tsdown": "^0.14.2",
77
+ "tsdown": "^0.15.9",
80
78
  "typescript": "^5.9.3"
81
79
  },
82
80
  "peerDependencies": {
@@ -1,9 +1,8 @@
1
- import { File, Function, FunctionParams } from '@kubb/react'
1
+ import { URLPath } from '@kubb/core/utils'
2
2
 
3
3
  import { type HttpMethod, isOptional } from '@kubb/oas'
4
- import type { ReactNode } from 'react'
5
- import { URLPath } from '@kubb/core/utils'
6
4
  import type { OperationSchemas } from '@kubb/plugin-oas'
5
+ import { File, Function, FunctionParams } from '@kubb/react'
7
6
  import type { PluginCypress } from '../types.ts'
8
7
 
9
8
  type Props = {
@@ -18,7 +17,7 @@ type Props = {
18
17
  method: HttpMethod
19
18
  }
20
19
 
21
- export function Request({ baseURL = '', name, dataReturnType, typeSchemas, url, method }: Props): ReactNode {
20
+ export function Request({ baseURL = '', name, dataReturnType, typeSchemas, url, method }: Props) {
22
21
  const params = FunctionParams.factory({
23
22
  data: typeSchemas.request?.name
24
23
  ? {
@@ -1,9 +1,10 @@
1
+ import { usePlugin, usePluginManager } from '@kubb/core/hooks'
1
2
  import { URLPath } from '@kubb/core/utils'
2
3
  import { createReactGenerator } from '@kubb/plugin-oas'
3
4
  import { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'
4
5
  import { getBanner, getFooter } from '@kubb/plugin-oas/utils'
5
6
  import { pluginTsName } from '@kubb/plugin-ts'
6
- import { File, useApp } from '@kubb/react'
7
+ import { File } from '@kubb/react'
7
8
  import { Request } from '../components'
8
9
  import type { PluginCypress } from '../types'
9
10
 
@@ -11,11 +12,10 @@ export const cypressGenerator = createReactGenerator<PluginCypress>({
11
12
  name: 'cypress',
12
13
  Operation({ operation }) {
13
14
  const {
14
- pluginManager,
15
- plugin: {
16
- options: { output, baseURL, dataReturnType },
17
- },
18
- } = useApp<PluginCypress>()
15
+ options: { output, baseURL, dataReturnType },
16
+ } = usePlugin<PluginCypress>()
17
+ const pluginManager = usePluginManager()
18
+
19
19
  const oas = useOas()
20
20
  const { getSchemas, getName, getFile } = useOperationManager()
21
21
 
package/src/plugin.ts CHANGED
@@ -1,12 +1,9 @@
1
1
  import path from 'node:path'
2
-
3
- import { FileManager, type Group, PluginManager, createPlugin } from '@kubb/core'
2
+ import { createPlugin, type Group, getBarrelFiles, getMode, type Plugin, PluginManager } from '@kubb/core'
4
3
  import { camelCase } from '@kubb/core/transformers'
4
+ import type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'
5
5
  import { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'
6
6
  import { pluginTsName } from '@kubb/plugin-ts'
7
-
8
- import type { Plugin } from '@kubb/core'
9
- import type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'
10
7
  import { cypressGenerator } from './generators'
11
8
  import type { PluginCypress } from './types.ts'
12
9
 
@@ -37,7 +34,7 @@ export const pluginCypress = createPlugin<PluginCypress>((options) => {
37
34
  pre: [pluginOasName, pluginTsName].filter(Boolean),
38
35
  resolvePath(baseName, pathMode, options) {
39
36
  const root = path.resolve(this.config.root, this.config.output.path)
40
- const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path))
37
+ const mode = pathMode ?? getMode(path.resolve(root, output.path))
41
38
 
42
39
  if (mode === 'single') {
43
40
  /**
@@ -85,7 +82,7 @@ export const pluginCypress = createPlugin<PluginCypress>((options) => {
85
82
 
86
83
  const oas = await swaggerPlugin.context.getOas()
87
84
  const root = path.resolve(this.config.root, this.config.output.path)
88
- const mode = FileManager.getMode(path.resolve(root, output.path))
85
+ const mode = getMode(path.resolve(root, output.path))
89
86
 
90
87
  const operationGenerator = new OperationGenerator(this.plugin.options, {
91
88
  oas,
@@ -101,7 +98,7 @@ export const pluginCypress = createPlugin<PluginCypress>((options) => {
101
98
  const files = await operationGenerator.build(...generators)
102
99
  await this.addFile(...files)
103
100
 
104
- const barrelFiles = await this.fileManager.getBarrelFiles({
101
+ const barrelFiles = await getBarrelFiles(this.fileManager.files, {
105
102
  type: output.barrelType ?? 'named',
106
103
  root,
107
104
  output,
@@ -1 +0,0 @@
1
- {"version":3,"file":"components-jRFHC_sv.js","names":[],"sources":["../src/components/Request.tsx"],"sourcesContent":["import { File, Function, FunctionParams } from '@kubb/react'\n\nimport { type HttpMethod, isOptional } from '@kubb/oas'\nimport type { ReactNode } from 'react'\nimport { URLPath } from '@kubb/core/utils'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport type { PluginCypress } from '../types.ts'\n\ntype Props = {\n /**\n * Name of the function\n */\n name: string\n typeSchemas: OperationSchemas\n url: string\n baseURL: string | undefined\n dataReturnType: PluginCypress['resolvedOptions']['dataReturnType']\n method: HttpMethod\n}\n\nexport function Request({ baseURL = '', name, dataReturnType, typeSchemas, url, method }: Props): ReactNode {\n const params = FunctionParams.factory({\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n })\n\n const returnType =\n dataReturnType === 'data' ? `Cypress.Chainable<${typeSchemas.response.name}>` : `Cypress.Chainable<Cypress.Response<${typeSchemas.response.name}>>`\n\n const body = typeSchemas.request?.name ? 'data' : undefined\n\n return (\n <File.Source name={name} isIndexable isExportable>\n <Function name={name} export params={params.toConstructor()} returnType={returnType}>\n {dataReturnType === 'data' &&\n `return cy.request('${method}', '${baseURL ?? ''}${new URLPath(url).toURLPath().replace(/([^/]):/g, '$1\\\\\\\\:')}', ${body}).then((res: Cypress.Response<${typeSchemas.response.name}>) => res.body)`}\n {dataReturnType === 'full' && `return cy.request('${method}', '${new URLPath(`${baseURL ?? ''}${url}`).toURLPath()}', ${body})`}\n </Function>\n </File.Source>\n )\n}\n"],"mappings":";;;;;;AAoBA,SAAgB,QAAQ,EAAE,UAAU,IAAI,MAAM,gBAAgB,aAAa,KAAK,UAA4B;CAC1G,MAAM,SAAS,eAAe,QAAQ,EACpC,MAAM,YAAY,SAAS,OACvB;EACE,MAAM,YAAY,SAAS;EAC3B,UAAU,WAAW,YAAY,SAAS,OAAO;EAClD,GACD,QACL,CAAC;CAEF,MAAM,aACJ,mBAAmB,SAAS,qBAAqB,YAAY,SAAS,KAAK,KAAK,sCAAsC,YAAY,SAAS,KAAK;CAElJ,MAAM,OAAO,YAAY,SAAS,OAAO,SAAS;AAElD,QACE,oBAAC,KAAK;EAAa;EAAM;EAAY;YACnC,qBAAC;GAAe;GAAM;GAAO,QAAQ,OAAO,eAAe;GAAc;cACtE,mBAAmB,UAClB,sBAAsB,OAAO,MAAM,WAAW,KAAK,IAAI,QAAQ,IAAI,CAAC,WAAW,CAAC,QAAQ,YAAY,UAAU,CAAC,KAAK,KAAK,gCAAgC,YAAY,SAAS,KAAK,kBACpL,mBAAmB,UAAU,sBAAsB,OAAO,MAAM,IAAI,QAAQ,GAAG,WAAW,KAAK,MAAM,CAAC,WAAW,CAAC,KAAK,KAAK;IACpH;GACC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"generators-Dg1pCFZB.cjs","names":["pluginTsName","File","Request","URLPath"],"sources":["../src/generators/cypressGenerator.tsx"],"sourcesContent":["import { URLPath } from '@kubb/core/utils'\nimport { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { File, useApp } from '@kubb/react'\nimport { Request } from '../components'\nimport type { PluginCypress } from '../types'\n\nexport const cypressGenerator = createReactGenerator<PluginCypress>({\n name: 'cypress',\n Operation({ operation }) {\n const {\n pluginManager,\n plugin: {\n options: { output, baseURL, dataReturnType },\n },\n } = useApp<PluginCypress>()\n const oas = useOas()\n const { getSchemas, getName, getFile } = useOperationManager()\n\n const request = {\n name: getName(operation, { type: 'function' }),\n file: getFile(operation),\n }\n\n const type = {\n file: getFile(operation, { pluginKey: [pluginTsName] }),\n schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' }),\n }\n\n return (\n <File\n baseName={request.file.baseName}\n path={request.file.path}\n meta={request.file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n <File.Import\n name={[\n type.schemas.request?.name,\n type.schemas.response.name,\n type.schemas.pathParams?.name,\n type.schemas.queryParams?.name,\n type.schemas.headerParams?.name,\n ...(type.schemas.statusCodes?.map((item) => item.name) || []),\n ].filter(Boolean)}\n root={request.file.path}\n path={type.file.path}\n isTypeOnly\n />\n <Request\n name={request.name}\n dataReturnType={dataReturnType}\n typeSchemas={type.schemas}\n method={operation.method}\n baseURL={baseURL}\n url={new URLPath(operation.path).toURLPath()}\n />\n </File>\n )\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;AASA,MAAa,+DAAuD;CAClE,MAAM;CACN,UAAU,EAAE,aAAa;EACvB,MAAM,EACJ,eACA,QAAQ,EACN,SAAS,EAAE,QAAQ,SAAS,iDAEL;EAC3B,MAAM,2CAAc;EACpB,MAAM,EAAE,YAAY,SAAS,8DAAiC;EAE9D,MAAM,UAAU;GACd,MAAM,QAAQ,WAAW,EAAE,MAAM,YAAY,CAAC;GAC9C,MAAM,QAAQ,UAAU;GACzB;EAED,MAAM,OAAO;GACX,MAAM,QAAQ,WAAW,EAAE,WAAW,CAACA,8BAAa,EAAE,CAAC;GACvD,SAAS,WAAW,WAAW;IAAE,WAAW,CAACA,8BAAa;IAAE,MAAM;IAAQ,CAAC;GAC5E;AAED,SACE,mDAACC;GACC,UAAU,QAAQ,KAAK;GACvB,MAAM,QAAQ,KAAK;GACnB,MAAM,QAAQ,KAAK;GACnB,+CAAkB;IAAE;IAAK;IAAQ,QAAQ,cAAc;IAAQ,CAAC;GAChE,+CAAkB;IAAE;IAAK;IAAQ,CAAC;cAElC,kDAACA,kBAAK;IACJ,MAAM;KACJ,KAAK,QAAQ,SAAS;KACtB,KAAK,QAAQ,SAAS;KACtB,KAAK,QAAQ,YAAY;KACzB,KAAK,QAAQ,aAAa;KAC1B,KAAK,QAAQ,cAAc;KAC3B,GAAI,KAAK,QAAQ,aAAa,KAAK,SAAS,KAAK,KAAK,IAAI,EAAE;KAC7D,CAAC,OAAO,QAAQ;IACjB,MAAM,QAAQ,KAAK;IACnB,MAAM,KAAK,KAAK;IAChB;KACA,EACF,kDAACC;IACC,MAAM,QAAQ;IACE;IAChB,aAAa,KAAK;IAClB,QAAQ,UAAU;IACT;IACT,KAAK,IAAIC,0BAAQ,UAAU,KAAK,CAAC,WAAW;KAC5C;IACG;;CAGZ,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"generators-aYB5ZkVA.js","names":[],"sources":["../src/generators/cypressGenerator.tsx"],"sourcesContent":["import { URLPath } from '@kubb/core/utils'\nimport { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { File, useApp } from '@kubb/react'\nimport { Request } from '../components'\nimport type { PluginCypress } from '../types'\n\nexport const cypressGenerator = createReactGenerator<PluginCypress>({\n name: 'cypress',\n Operation({ operation }) {\n const {\n pluginManager,\n plugin: {\n options: { output, baseURL, dataReturnType },\n },\n } = useApp<PluginCypress>()\n const oas = useOas()\n const { getSchemas, getName, getFile } = useOperationManager()\n\n const request = {\n name: getName(operation, { type: 'function' }),\n file: getFile(operation),\n }\n\n const type = {\n file: getFile(operation, { pluginKey: [pluginTsName] }),\n schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' }),\n }\n\n return (\n <File\n baseName={request.file.baseName}\n path={request.file.path}\n meta={request.file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n <File.Import\n name={[\n type.schemas.request?.name,\n type.schemas.response.name,\n type.schemas.pathParams?.name,\n type.schemas.queryParams?.name,\n type.schemas.headerParams?.name,\n ...(type.schemas.statusCodes?.map((item) => item.name) || []),\n ].filter(Boolean)}\n root={request.file.path}\n path={type.file.path}\n isTypeOnly\n />\n <Request\n name={request.name}\n dataReturnType={dataReturnType}\n typeSchemas={type.schemas}\n method={operation.method}\n baseURL={baseURL}\n url={new URLPath(operation.path).toURLPath()}\n />\n </File>\n )\n },\n})\n"],"mappings":";;;;;;;;;;AASA,MAAa,mBAAmB,qBAAoC;CAClE,MAAM;CACN,UAAU,EAAE,aAAa;EACvB,MAAM,EACJ,eACA,QAAQ,EACN,SAAS,EAAE,QAAQ,SAAS,uBAE5B,QAAuB;EAC3B,MAAM,MAAM,QAAQ;EACpB,MAAM,EAAE,YAAY,SAAS,YAAY,qBAAqB;EAE9D,MAAM,UAAU;GACd,MAAM,QAAQ,WAAW,EAAE,MAAM,YAAY,CAAC;GAC9C,MAAM,QAAQ,UAAU;GACzB;EAED,MAAM,OAAO;GACX,MAAM,QAAQ,WAAW,EAAE,WAAW,CAAC,aAAa,EAAE,CAAC;GACvD,SAAS,WAAW,WAAW;IAAE,WAAW,CAAC,aAAa;IAAE,MAAM;IAAQ,CAAC;GAC5E;AAED,SACE,qBAAC;GACC,UAAU,QAAQ,KAAK;GACvB,MAAM,QAAQ,KAAK;GACnB,MAAM,QAAQ,KAAK;GACnB,QAAQ,UAAU;IAAE;IAAK;IAAQ,QAAQ,cAAc;IAAQ,CAAC;GAChE,QAAQ,UAAU;IAAE;IAAK;IAAQ,CAAC;cAElC,oBAAC,KAAK;IACJ,MAAM;KACJ,KAAK,QAAQ,SAAS;KACtB,KAAK,QAAQ,SAAS;KACtB,KAAK,QAAQ,YAAY;KACzB,KAAK,QAAQ,aAAa;KAC1B,KAAK,QAAQ,cAAc;KAC3B,GAAI,KAAK,QAAQ,aAAa,KAAK,SAAS,KAAK,KAAK,IAAI,EAAE;KAC7D,CAAC,OAAO,QAAQ;IACjB,MAAM,QAAQ,KAAK;IACnB,MAAM,KAAK,KAAK;IAChB;KACA,EACF,oBAAC;IACC,MAAM,QAAQ;IACE;IAChB,aAAa,KAAK;IAClB,QAAQ,UAAU;IACT;IACT,KAAK,IAAI,QAAQ,UAAU,KAAK,CAAC,WAAW;KAC5C;IACG;;CAGZ,CAAC"}