@kubb/plugin-cypress 3.16.2 → 3.16.3

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.
Files changed (38) hide show
  1. package/dist/components-C8-e6KqF.cjs +64 -0
  2. package/dist/components-C8-e6KqF.cjs.map +1 -0
  3. package/dist/components-jRFHC_sv.js +30 -0
  4. package/dist/components-jRFHC_sv.js.map +1 -0
  5. package/dist/components.cjs +2 -11
  6. package/dist/components.d.cts +22 -16
  7. package/dist/components.d.ts +22 -16
  8. package/dist/components.js +3 -3
  9. package/dist/generators-Ct16r8RK.cjs +72 -0
  10. package/dist/{chunk-PIJKOKJD.js.map → generators-Ct16r8RK.cjs.map} +1 -1
  11. package/dist/generators-aYB5ZkVA.js +67 -0
  12. package/dist/generators-aYB5ZkVA.js.map +1 -0
  13. package/dist/generators.cjs +3 -12
  14. package/dist/generators.d.cts +5 -6
  15. package/dist/generators.d.ts +5 -6
  16. package/dist/generators.js +4 -4
  17. package/dist/index.cjs +74 -99
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.d.cts +6 -7
  20. package/dist/index.d.ts +6 -7
  21. package/dist/index.js +74 -93
  22. package/dist/index.js.map +1 -1
  23. package/dist/types-BNTHk264.d.ts +1166 -0
  24. package/dist/types-Rl0-mzsN.d.cts +1166 -0
  25. package/package.json +18 -33
  26. package/dist/chunk-AQ3NKEYB.cjs +0 -75
  27. package/dist/chunk-AQ3NKEYB.cjs.map +0 -1
  28. package/dist/chunk-LJ3OQYCX.cjs +0 -26
  29. package/dist/chunk-LJ3OQYCX.cjs.map +0 -1
  30. package/dist/chunk-NEMUYKDD.js +0 -24
  31. package/dist/chunk-NEMUYKDD.js.map +0 -1
  32. package/dist/chunk-PIJKOKJD.js +0 -73
  33. package/dist/components.cjs.map +0 -1
  34. package/dist/components.js.map +0 -1
  35. package/dist/generators.cjs.map +0 -1
  36. package/dist/generators.js.map +0 -1
  37. package/dist/types-C2ke2hnU.d.cts +0 -59
  38. package/dist/types-C2ke2hnU.d.ts +0 -59
@@ -0,0 +1,1166 @@
1
+ import * as OasTypes from "oas/types";
2
+ import { HttpMethods as HttpMethod, OASDocument, SchemaObject, User } from "oas/types";
3
+ import { Operation, Operation as Operation$1 } from "oas/operation";
4
+ import { OpenAPIV3 } from "openapi-types";
5
+ import * as oas_normalize_lib_types0 from "oas-normalize/lib/types";
6
+ import BaseOas from "oas";
7
+ import { ConsolaInstance, LogLevel } from "consola";
8
+
9
+ //#region ../oas/src/types.d.ts
10
+ type contentType = 'application/json' | (string & {});
11
+ type SchemaObject$1 = OasTypes.SchemaObject & {
12
+ 'x-nullable'?: boolean;
13
+ $ref?: string;
14
+ };
15
+ //#endregion
16
+ //#region ../oas/src/Oas.d.ts
17
+ type Options$3 = {
18
+ contentType?: contentType;
19
+ discriminator?: 'strict' | 'inherit';
20
+ };
21
+ declare class Oas<const TOAS = unknown> extends BaseOas {
22
+ #private;
23
+ document: TOAS;
24
+ constructor({
25
+ oas,
26
+ user
27
+ }: {
28
+ oas: TOAS | OASDocument | string;
29
+ user?: User;
30
+ });
31
+ setOptions(options: Options$3): void;
32
+ get options(): Options$3;
33
+ get($ref: string): any;
34
+ getKey($ref: string): string | undefined;
35
+ set($ref: string, value: unknown): false | undefined;
36
+ getDiscriminator(schema: OasTypes.SchemaObject): OpenAPIV3.DiscriminatorObject | undefined;
37
+ dereferenceWithRef(schema?: unknown): any;
38
+ getResponseSchema(operation: Operation, statusCode: string | number): SchemaObject;
39
+ getRequestSchema(operation: Operation): SchemaObject | undefined;
40
+ getParametersSchema(operation: Operation, inKey: 'path' | 'query' | 'header'): SchemaObject | null;
41
+ valdiate(): Promise<oas_normalize_lib_types0.ValidationResult>;
42
+ }
43
+ //#endregion
44
+ //#region ../core/src/BaseGenerator.d.ts
45
+ /**
46
+ * Abstract class that contains the building blocks for plugins to create their own Generator
47
+ * @link idea based on https://github.com/colinhacks/zod/blob/master/src/types.ts#L137
48
+ */
49
+ declare abstract class BaseGenerator<TOptions = unknown, TContext = unknown> {
50
+ #private;
51
+ constructor(options?: TOptions, context?: TContext);
52
+ get options(): TOptions;
53
+ get context(): TContext;
54
+ set options(options: TOptions);
55
+ abstract build(...params: unknown[]): unknown;
56
+ }
57
+ //#endregion
58
+ //#region ../core/src/fs/types.d.ts
59
+ type BasePath<T extends string = string> = `${T}/`;
60
+ type Import = {
61
+ /**
62
+ * Import name to be used
63
+ * @example ["useState"]
64
+ * @example "React"
65
+ */
66
+ name: string | Array<string | {
67
+ propertyName: string;
68
+ name?: string;
69
+ }>;
70
+ /**
71
+ * Path for the import
72
+ * @example '@kubb/core'
73
+ */
74
+ path: string;
75
+ /**
76
+ * Add `type` prefix to the import, this will result in: `import type { Type } from './path'`.
77
+ */
78
+ isTypeOnly?: boolean;
79
+ isNameSpace?: boolean;
80
+ /**
81
+ * When root is set it will get the path with relative getRelativePath(root, path).
82
+ */
83
+ root?: string;
84
+ };
85
+ type Source = {
86
+ name?: string;
87
+ value?: string;
88
+ isTypeOnly?: boolean;
89
+ /**
90
+ * Has const or type 'export'
91
+ * @default false
92
+ */
93
+ isExportable?: boolean;
94
+ /**
95
+ * When set, barrel generation will add this
96
+ * @default false
97
+ */
98
+ isIndexable?: boolean;
99
+ };
100
+ type Export = {
101
+ /**
102
+ * Export name to be used.
103
+ * @example ["useState"]
104
+ * @example "React"
105
+ */
106
+ name?: string | Array<string>;
107
+ /**
108
+ * Path for the import.
109
+ * @example '@kubb/core'
110
+ */
111
+ path: string;
112
+ /**
113
+ * Add `type` prefix to the export, this will result in: `export type { Type } from './path'`.
114
+ */
115
+ isTypeOnly?: boolean;
116
+ /**
117
+ * Make it possible to override the name, this will result in: `export * as aliasName from './path'`.
118
+ */
119
+ asAlias?: boolean;
120
+ };
121
+ type Extname = '.ts' | '.js' | '.tsx' | '.json' | `.${string}`;
122
+ type Mode = 'single' | 'split';
123
+ /**
124
+ * Name to be used to dynamicly create the baseName(based on input.path)
125
+ * Based on UNIX basename
126
+ * @link https://nodejs.org/api/path.html#pathbasenamepath-suffix
127
+ */
128
+ type BaseName = `${string}.${string}`;
129
+ /**
130
+ * Path will be full qualified path to a specified file
131
+ */
132
+ type Path = string;
133
+ type AdvancedPath<T extends BaseName = BaseName> = `${BasePath}${T}`;
134
+ type OptionalPath = Path | undefined | null;
135
+ type File<TMeta extends object = object> = {
136
+ /**
137
+ * Name to be used to create the path
138
+ * Based on UNIX basename, `${name}.extname`
139
+ * @link https://nodejs.org/api/path.html#pathbasenamepath-suffix
140
+ */
141
+ baseName: BaseName;
142
+ /**
143
+ * Path will be full qualified path to a specified file
144
+ */
145
+ path: AdvancedPath<BaseName> | Path;
146
+ sources: Array<Source>;
147
+ imports?: Array<Import>;
148
+ exports?: Array<Export>;
149
+ /**
150
+ * Use extra meta, this is getting used to generate the barrel/index files.
151
+ */
152
+ meta?: TMeta;
153
+ banner?: string;
154
+ footer?: string;
155
+ };
156
+ type ResolvedImport = Import;
157
+ type ResolvedExport = Export;
158
+ type ResolvedFile<TMeta extends object = object> = File<TMeta> & {
159
+ /**
160
+ * @default object-hash
161
+ */
162
+ id: string;
163
+ /**
164
+ * Contains the first part of the baseName, generated based on baseName
165
+ * @link https://nodejs.org/api/path.html#pathformatpathobject
166
+ */
167
+ name: string;
168
+ extname: Extname;
169
+ imports: Array<ResolvedImport>;
170
+ exports: Array<ResolvedExport>;
171
+ };
172
+ //#endregion
173
+ //#region ../core/src/utils/EventEmitter.d.ts
174
+ declare class EventEmitter<TEvents extends Record<string, any>> {
175
+ #private;
176
+ constructor();
177
+ emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArg: TEvents[TEventName]): void;
178
+ on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
179
+ off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
180
+ removeAll(): void;
181
+ }
182
+ //#endregion
183
+ //#region ../core/src/logger.d.ts
184
+ type DebugEvent = {
185
+ date: Date;
186
+ logs: string[];
187
+ fileName?: string;
188
+ };
189
+ type Events$1 = {
190
+ start: [message: string];
191
+ success: [message: string];
192
+ error: [message: string, cause: Error];
193
+ warning: [message: string];
194
+ debug: [DebugEvent];
195
+ info: [message: string];
196
+ progress_start: [{
197
+ id: string;
198
+ size: number;
199
+ message?: string;
200
+ }];
201
+ progressed: [{
202
+ id: string;
203
+ message?: string;
204
+ }];
205
+ progress_stop: [{
206
+ id: string;
207
+ }];
208
+ };
209
+ type Logger = {
210
+ /**
211
+ * Optional config name to show in CLI output
212
+ */
213
+ name?: string;
214
+ logLevel: LogLevel;
215
+ consola?: ConsolaInstance;
216
+ on: EventEmitter<Events$1>['on'];
217
+ emit: EventEmitter<Events$1>['emit'];
218
+ writeLogs: () => Promise<string[]>;
219
+ };
220
+ //#endregion
221
+ //#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;
225
+ //#endregion
226
+ //#region ../core/src/types.d.ts
227
+ type InputPath = {
228
+ /**
229
+ * Specify your Swagger/OpenAPI file, either as an absolute path or a path relative to the root.
230
+ */
231
+ path: string;
232
+ };
233
+ type InputData = {
234
+ /**
235
+ * A `string` or `object` that contains your Swagger/OpenAPI data.
236
+ */
237
+ data: string | unknown;
238
+ };
239
+ type Input = InputPath | InputData | Array<InputPath>;
240
+ type BarrelType = 'all' | 'named' | 'propagate';
241
+ /**
242
+ * @private
243
+ */
244
+ type Config<TInput = Input> = {
245
+ /**
246
+ * The name to display in the CLI output.
247
+ */
248
+ name?: string;
249
+ /**
250
+ * The project root directory, which can be either an absolute path or a path relative to the location of your `kubb.config.ts` file.
251
+ * @default process.cwd()
252
+ */
253
+ root: string;
254
+ /**
255
+ * You can use either `input.path` or `input.data`, depending on your specific needs.
256
+ */
257
+ input: TInput;
258
+ output: {
259
+ /**
260
+ * The path where all generated files will be exported.
261
+ * This can be an absolute path or a path relative to the specified root option.
262
+ */
263
+ path: string;
264
+ /**
265
+ * Clean the output directory before each build.
266
+ */
267
+ clean?: boolean;
268
+ /**
269
+ * Save files to the file system.
270
+ * @default true
271
+ */
272
+ write?: boolean;
273
+ /**
274
+ * Override the extension to the generated imports and exports, by default each plugin will add an extension
275
+ * @default { '.ts': '.ts'}
276
+ */
277
+ extension?: Record<Extname, Extname | ''>;
278
+ /**
279
+ * 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`.
280
+ * @default 'named'
281
+ */
282
+ barrelType?: Exclude<BarrelType, 'propagate'> | false;
283
+ /**
284
+ * Add a default banner to the beginning of every generated file. This makes it clear that the file was generated by Kubb.
285
+ * - 'simple': will only add banner with link to Kubb
286
+ * - 'full': will add source, title, description and the OpenAPI version used
287
+ * @default 'simple'
288
+ */
289
+ defaultBanner?: 'simple' | 'full' | false;
290
+ };
291
+ /**
292
+ * An array of Kubb plugins that will be used in the generation.
293
+ * Each plugin may include additional configurable options(defined in the plugin itself).
294
+ * If a plugin depends on another plugin, an error will be returned if the required dependency is missing. See pre for more details.
295
+ */
296
+ plugins?: Array<Plugin>;
297
+ /**
298
+ * Hooks that will be called when a specific action is triggered in Kubb.
299
+ */
300
+ hooks?: {
301
+ /**
302
+ * Hook that will be triggered at the end of all executions.
303
+ * Useful for running Prettier or ESLint to format/lint your code.
304
+ */
305
+ done?: string | Array<string>;
306
+ };
307
+ };
308
+ type PluginFactoryOptions<
309
+ /**
310
+ * Name to be used for the plugin, this will also be used for they key.
311
+ */
312
+ TName extends string = string,
313
+ /**
314
+ * Options of the plugin.
315
+ */
316
+ TOptions extends object = object,
317
+ /**
318
+ * Options of the plugin that can be used later on, see `options` inside your plugin config.
319
+ */
320
+ TResolvedOptions extends object = TOptions,
321
+ /**
322
+ * Context that you want to expose to other plugins.
323
+ */
324
+ TContext = any,
325
+ /**
326
+ * When calling `resolvePath` you can specify better types.
327
+ */
328
+ TResolvePathOptions extends object = object> = {
329
+ name: TName;
330
+ /**
331
+ * Same behaviour like what has been done with `QueryKey` in `@tanstack/react-query`
332
+ */
333
+ key: PluginKey<TName | string>;
334
+ options: TOptions;
335
+ resolvedOptions: TResolvedOptions;
336
+ context: TContext;
337
+ resolvePathOptions: TResolvePathOptions;
338
+ };
339
+ type PluginKey<TName> = [name: TName, identifier?: string | number];
340
+ type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
341
+ /**
342
+ * Unique name used for the plugin
343
+ * The name of the plugin follows the format scope:foo-bar or foo-bar, adding scope: can avoid naming conflicts with other plugins.
344
+ * @example @kubb/typescript
345
+ */
346
+ name: TOptions['name'];
347
+ /**
348
+ * Options set for a specific plugin(see kubb.config.js), passthrough of options.
349
+ */
350
+ options: TOptions['resolvedOptions'];
351
+ /**
352
+ * 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.
353
+ * Can be used to validate dependent plugins.
354
+ */
355
+ pre?: Array<string>;
356
+ /**
357
+ * 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.
358
+ */
359
+ post?: Array<string>;
360
+ } & (TOptions['context'] extends never ? {
361
+ context?: never;
362
+ } : {
363
+ context: (this: TOptions['name'] extends 'core' ? null : Omit<PluginContext<TOptions>, 'addFile'>) => TOptions['context'];
364
+ });
365
+ type UserPluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = UserPlugin<TOptions> & PluginLifecycle<TOptions>;
366
+ type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
367
+ /**
368
+ * Unique name used for the plugin
369
+ * @example @kubb/typescript
370
+ */
371
+ name: TOptions['name'];
372
+ /**
373
+ * Internal key used when a developer uses more than one of the same plugin
374
+ * @private
375
+ */
376
+ key: TOptions['key'];
377
+ /**
378
+ * 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.
379
+ * Can be used to validate dependent plugins.
380
+ */
381
+ pre?: Array<string>;
382
+ /**
383
+ * 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.
384
+ */
385
+ post?: Array<string>;
386
+ /**
387
+ * Options set for a specific plugin(see kubb.config.js), passthrough of options.
388
+ */
389
+ options: TOptions['resolvedOptions'];
390
+ } & (TOptions['context'] extends never ? {
391
+ context?: never;
392
+ } : {
393
+ context: TOptions['context'];
394
+ });
395
+ type PluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions> & PluginLifecycle<TOptions>;
396
+ type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
397
+ /**
398
+ * Start of the lifecycle of a plugin.
399
+ * @type hookParallel
400
+ */
401
+ buildStart?: (this: PluginContext<TOptions>, Config: Config) => PossiblePromise<void>;
402
+ /**
403
+ * Resolve to a Path based on a baseName(example: `./Pet.ts`) and directory(example: `./models`).
404
+ * Options can als be included.
405
+ * @type hookFirst
406
+ * @example ('./Pet.ts', './src/gen/') => '/src/gen/Pet.ts'
407
+ */
408
+ resolvePath?: (this: PluginContext<TOptions>, baseName: BaseName, mode?: Mode, options?: TOptions['resolvePathOptions']) => OptionalPath;
409
+ /**
410
+ * Resolve to a name based on a string.
411
+ * Useful when converting to PascalCase or camelCase.
412
+ * @type hookFirst
413
+ * @example ('pet') => 'Pet'
414
+ */
415
+ resolveName?: (this: PluginContext<TOptions>, name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
416
+ /**
417
+ * End of the plugin lifecycle.
418
+ * @type hookParallel
419
+ */
420
+ buildEnd?: (this: PluginContext<TOptions>) => PossiblePromise<void>;
421
+ };
422
+ type PluginLifecycleHooks = keyof PluginLifecycle;
423
+ type PluginParameter<H extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H]>;
424
+ type ResolvePathParams<TOptions = object> = {
425
+ pluginKey?: Plugin['key'];
426
+ baseName: BaseName;
427
+ mode?: Mode;
428
+ /**
429
+ * Options to be passed to 'resolvePath' 3th parameter
430
+ */
431
+ options?: TOptions;
432
+ };
433
+ type ResolveNameParams = {
434
+ name: string;
435
+ pluginKey?: Plugin['key'];
436
+ /**
437
+ * `file` will be used to customize the name of the created file(use of camelCase)
438
+ * `function` can be used to customize the exported functions(use of camelCase)
439
+ * `type` is a special type for TypeScript(use of PascalCase)
440
+ * `const` can be used for variables(use of camelCase)
441
+ */
442
+ type?: 'file' | 'function' | 'type' | 'const';
443
+ };
444
+ type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
445
+ config: Config;
446
+ fileManager: FileManager;
447
+ pluginManager: PluginManager;
448
+ addFile: (...file: Array<File>) => Promise<Array<ResolvedFile>>;
449
+ resolvePath: (params: ResolvePathParams<TOptions['resolvePathOptions']>) => OptionalPath;
450
+ resolveName: (params: ResolveNameParams) => string;
451
+ logger: Logger;
452
+ /**
453
+ * All plugins
454
+ */
455
+ plugins: Plugin[];
456
+ /**
457
+ * Current plugin
458
+ */
459
+ plugin: Plugin<TOptions>;
460
+ };
461
+ /**
462
+ * Specify the export location for the files and define the behavior of the output
463
+ */
464
+ type Output<TOptions> = {
465
+ /**
466
+ * Path to the output folder or file that will contain the generated code
467
+ */
468
+ path: string;
469
+ /**
470
+ * Define what needs to be exported, here you can also disable the export of barrel files
471
+ * @default 'named'
472
+ */
473
+ barrelType?: BarrelType | false;
474
+ /**
475
+ * Add a banner text in the beginning of every file
476
+ */
477
+ banner?: string | ((options: TOptions) => string);
478
+ /**
479
+ * Add a footer text in the beginning of every file
480
+ */
481
+ footer?: string | ((options: TOptions) => string);
482
+ };
483
+ type GroupContext = {
484
+ group: string;
485
+ };
486
+ type Group = {
487
+ /**
488
+ * Define a type where to group the files on
489
+ */
490
+ type: 'tag' | 'path';
491
+ /**
492
+ * Return the name of a group based on the group name, this will be used for the file and name generation
493
+ */
494
+ name?: (context: GroupContext) => string;
495
+ };
496
+ //#endregion
497
+ //#region ../core/src/FileManager.d.ts
498
+ type FileMetaBase = {
499
+ pluginKey?: Plugin['key'];
500
+ };
501
+ type AddResult<T extends Array<File>> = Promise<Awaited<GreaterThan<T['length'], 1> extends true ? Promise<ResolvedFile[]> : Promise<ResolvedFile>>>;
502
+ type AddIndexesProps = {
503
+ type: BarrelType | false | undefined;
504
+ /**
505
+ * Root based on root and output.path specified in the config
506
+ */
507
+ root: string;
508
+ /**
509
+ * Output for plugin
510
+ */
511
+ output: {
512
+ path: string;
513
+ };
514
+ group?: {
515
+ output: string;
516
+ exportAs: string;
517
+ };
518
+ logger?: Logger;
519
+ meta?: FileMetaBase;
520
+ };
521
+ type WriteFilesProps = {
522
+ root: Config['root'];
523
+ extension?: Record<Extname, Extname | ''>;
524
+ logger?: Logger;
525
+ dryRun?: boolean;
526
+ };
527
+ declare class FileManager {
528
+ #private;
529
+ constructor();
530
+ add<T extends Array<File> = Array<File>>(...files: T): AddResult<T>;
531
+ getByPath(path: Path): Promise<ResolvedFile | null>;
532
+ deleteByPath(path: Path): Promise<void>;
533
+ clear(): Promise<void>;
534
+ getFiles(): Promise<Array<ResolvedFile>>;
535
+ processFiles({
536
+ dryRun,
537
+ root,
538
+ extension,
539
+ logger
540
+ }: WriteFilesProps): Promise<Array<ResolvedFile>>;
541
+ getBarrelFiles({
542
+ type,
543
+ meta,
544
+ root,
545
+ output,
546
+ logger
547
+ }: AddIndexesProps): Promise<File[]>;
548
+ static getMode(path: string | undefined | null): Mode;
549
+ }
550
+ //#endregion
551
+ //#region ../core/src/PluginManager.d.ts
552
+ type RequiredPluginLifecycle = Required<PluginLifecycle>;
553
+ type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
554
+ type Executer<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
555
+ message: string;
556
+ strategy: Strategy;
557
+ hookName: H;
558
+ plugin: Plugin;
559
+ parameters?: unknown[] | undefined;
560
+ output?: unknown;
561
+ };
562
+ type ParseResult<H extends PluginLifecycleHooks> = RequiredPluginLifecycle[H];
563
+ type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {
564
+ result: Result;
565
+ plugin: Plugin;
566
+ };
567
+ type Options$2 = {
568
+ logger: Logger;
569
+ /**
570
+ * @default Number.POSITIVE_INFINITY
571
+ */
572
+ concurrency?: number;
573
+ };
574
+ type Events = {
575
+ executing: [executer: Executer];
576
+ executed: [executer: Executer];
577
+ error: [error: Error];
578
+ };
579
+ type GetFileProps<TOptions = object> = {
580
+ name: string;
581
+ mode?: Mode;
582
+ extname: Extname;
583
+ pluginKey: Plugin['key'];
584
+ options?: TOptions;
585
+ };
586
+ declare class PluginManager {
587
+ #private;
588
+ readonly plugins: Set<Plugin<PluginFactoryOptions<string, object, object, any, object>>>;
589
+ readonly fileManager: FileManager;
590
+ readonly events: EventEmitter<Events>;
591
+ readonly config: Config;
592
+ readonly executed: Array<Executer>;
593
+ readonly logger: Logger;
594
+ readonly options: Options$2;
595
+ constructor(config: Config, options: Options$2);
596
+ getFile<TOptions = object>({
597
+ name,
598
+ mode,
599
+ extname,
600
+ pluginKey,
601
+ options
602
+ }: GetFileProps<TOptions>): File<{
603
+ pluginKey: Plugin['key'];
604
+ }>;
605
+ resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => OptionalPath;
606
+ resolveName: (params: ResolveNameParams) => string;
607
+ /**
608
+ * Instead of calling `pluginManager.events.on` you can use `pluginManager.on`. This one also has better types.
609
+ */
610
+ on<TEventName extends keyof Events & string>(eventName: TEventName, handler: (...eventArg: Events[TEventName]) => void): void;
611
+ /**
612
+ * Run a specific hookName for plugin x.
613
+ */
614
+ hookForPlugin<H extends PluginLifecycleHooks>({
615
+ pluginKey,
616
+ hookName,
617
+ parameters,
618
+ message
619
+ }: {
620
+ pluginKey: Plugin['key'];
621
+ hookName: H;
622
+ parameters: PluginParameter<H>;
623
+ message: string;
624
+ }): Promise<Array<ReturnType<ParseResult<H>> | null>>;
625
+ /**
626
+ * Run a specific hookName for plugin x.
627
+ */
628
+ hookForPluginSync<H extends PluginLifecycleHooks>({
629
+ pluginKey,
630
+ hookName,
631
+ parameters,
632
+ message
633
+ }: {
634
+ pluginKey: Plugin['key'];
635
+ hookName: H;
636
+ parameters: PluginParameter<H>;
637
+ message: string;
638
+ }): Array<ReturnType<ParseResult<H>>> | null;
639
+ /**
640
+ * First non-null result stops and will return it's value.
641
+ */
642
+ hookFirst<H extends PluginLifecycleHooks>({
643
+ hookName,
644
+ parameters,
645
+ skipped,
646
+ message
647
+ }: {
648
+ hookName: H;
649
+ parameters: PluginParameter<H>;
650
+ skipped?: ReadonlySet<Plugin> | null;
651
+ message: string;
652
+ }): Promise<SafeParseResult<H>>;
653
+ /**
654
+ * First non-null result stops and will return it's value.
655
+ */
656
+ hookFirstSync<H extends PluginLifecycleHooks>({
657
+ hookName,
658
+ parameters,
659
+ skipped,
660
+ message
661
+ }: {
662
+ hookName: H;
663
+ parameters: PluginParameter<H>;
664
+ skipped?: ReadonlySet<Plugin> | null;
665
+ message: string;
666
+ }): SafeParseResult<H>;
667
+ /**
668
+ * Run all plugins in parallel(order will be based on `this.plugin` and if `pre` or `post` is set).
669
+ */
670
+ hookParallel<H extends PluginLifecycleHooks, TOuput = void>({
671
+ hookName,
672
+ parameters,
673
+ message
674
+ }: {
675
+ hookName: H;
676
+ parameters?: Parameters<RequiredPluginLifecycle[H]> | undefined;
677
+ message: string;
678
+ }): Promise<Awaited<TOuput>[]>;
679
+ /**
680
+ * Chains plugins
681
+ */
682
+ hookSeq<H extends PluginLifecycleHooks>({
683
+ hookName,
684
+ parameters,
685
+ message
686
+ }: {
687
+ hookName: H;
688
+ parameters?: PluginParameter<H>;
689
+ message: string;
690
+ }): Promise<void>;
691
+ getPluginByKey(pluginKey: Plugin['key']): Plugin | undefined;
692
+ getPluginsByKey(hookName: keyof PluginWithLifeCycle, pluginKey: Plugin['key']): Plugin[];
693
+ static getDependedPlugins<T1 extends PluginFactoryOptions, T2 extends PluginFactoryOptions = never, T3 extends PluginFactoryOptions = never, TOutput = (T3 extends never ? (T2 extends never ? [T1: Plugin<T1>] : [T1: Plugin<T1>, T2: Plugin<T2>]) : [T1: Plugin<T1>, T2: Plugin<T2>, T3: Plugin<T3>])>(plugins: Array<Plugin>, dependedPluginNames: string | string[]): TOutput;
694
+ static get hooks(): readonly ["buildStart", "resolvePath", "resolveName", "buildEnd"];
695
+ }
696
+ //#endregion
697
+ //#region ../plugin-oas/src/SchemaMapper.d.ts
698
+ type SchemaKeywordMapper = {
699
+ object: {
700
+ keyword: 'object';
701
+ args: {
702
+ properties: {
703
+ [x: string]: Schema[];
704
+ };
705
+ additionalProperties: Schema[];
706
+ strict?: boolean;
707
+ };
708
+ };
709
+ url: {
710
+ keyword: 'url';
711
+ };
712
+ readOnly: {
713
+ keyword: 'readOnly';
714
+ };
715
+ writeOnly: {
716
+ keyword: 'writeOnly';
717
+ };
718
+ uuid: {
719
+ keyword: 'uuid';
720
+ };
721
+ email: {
722
+ keyword: 'email';
723
+ };
724
+ firstName: {
725
+ keyword: 'firstName';
726
+ };
727
+ lastName: {
728
+ keyword: 'lastName';
729
+ };
730
+ phone: {
731
+ keyword: 'phone';
732
+ };
733
+ password: {
734
+ keyword: 'password';
735
+ };
736
+ date: {
737
+ keyword: 'date';
738
+ args: {
739
+ type?: 'date' | 'string';
740
+ };
741
+ };
742
+ time: {
743
+ keyword: 'time';
744
+ args: {
745
+ type?: 'date' | 'string';
746
+ };
747
+ };
748
+ datetime: {
749
+ keyword: 'datetime';
750
+ args: {
751
+ offset?: boolean;
752
+ local?: boolean;
753
+ };
754
+ };
755
+ tuple: {
756
+ keyword: 'tuple';
757
+ args: {
758
+ items: Schema[];
759
+ min?: number;
760
+ max?: number;
761
+ rest?: Schema;
762
+ };
763
+ };
764
+ array: {
765
+ keyword: 'array';
766
+ args: {
767
+ items: Schema[];
768
+ min?: number;
769
+ max?: number;
770
+ unique?: boolean;
771
+ };
772
+ };
773
+ enum: {
774
+ keyword: 'enum';
775
+ args: {
776
+ name: string;
777
+ typeName: string;
778
+ asConst: boolean;
779
+ items: Array<{
780
+ name: string | number;
781
+ format: 'string' | 'number' | 'boolean';
782
+ value?: string | number | boolean;
783
+ }>;
784
+ };
785
+ };
786
+ and: {
787
+ keyword: 'and';
788
+ args: Schema[];
789
+ };
790
+ const: {
791
+ keyword: 'const';
792
+ args: {
793
+ name: string | number;
794
+ format: 'string' | 'number' | 'boolean';
795
+ value?: string | number | boolean;
796
+ };
797
+ };
798
+ union: {
799
+ keyword: 'union';
800
+ args: Schema[];
801
+ };
802
+ ref: {
803
+ keyword: 'ref';
804
+ args: {
805
+ name: string;
806
+ $ref: string;
807
+ /**
808
+ * Full qualified path.
809
+ */
810
+ path: OptionalPath;
811
+ /**
812
+ * When true `File.Import` will be used.
813
+ * When false a reference will be used inside the current file.
814
+ */
815
+ isImportable: boolean;
816
+ };
817
+ };
818
+ matches: {
819
+ keyword: 'matches';
820
+ args?: string;
821
+ };
822
+ boolean: {
823
+ keyword: 'boolean';
824
+ };
825
+ default: {
826
+ keyword: 'default';
827
+ args: string | number | boolean;
828
+ };
829
+ string: {
830
+ keyword: 'string';
831
+ };
832
+ integer: {
833
+ keyword: 'integer';
834
+ };
835
+ number: {
836
+ keyword: 'number';
837
+ };
838
+ max: {
839
+ keyword: 'max';
840
+ args: number;
841
+ };
842
+ min: {
843
+ keyword: 'min';
844
+ args: number;
845
+ };
846
+ describe: {
847
+ keyword: 'describe';
848
+ args: string;
849
+ };
850
+ example: {
851
+ keyword: 'example';
852
+ args: string;
853
+ };
854
+ deprecated: {
855
+ keyword: 'deprecated';
856
+ };
857
+ optional: {
858
+ keyword: 'optional';
859
+ };
860
+ undefined: {
861
+ keyword: 'undefined';
862
+ };
863
+ nullish: {
864
+ keyword: 'nullish';
865
+ };
866
+ nullable: {
867
+ keyword: 'nullable';
868
+ };
869
+ null: {
870
+ keyword: 'null';
871
+ };
872
+ any: {
873
+ keyword: 'any';
874
+ };
875
+ unknown: {
876
+ keyword: 'unknown';
877
+ };
878
+ void: {
879
+ keyword: 'void';
880
+ };
881
+ blob: {
882
+ keyword: 'blob';
883
+ };
884
+ schema: {
885
+ keyword: 'schema';
886
+ args: {
887
+ type: 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'object';
888
+ format?: string;
889
+ };
890
+ };
891
+ name: {
892
+ keyword: 'name';
893
+ args: string;
894
+ };
895
+ catchall: {
896
+ keyword: 'catchall';
897
+ };
898
+ interface: {
899
+ keyword: 'interface';
900
+ };
901
+ };
902
+ type Schema = {
903
+ keyword: string;
904
+ } | SchemaKeywordMapper[keyof SchemaKeywordMapper];
905
+ //#endregion
906
+ //#region ../plugin-oas/src/types.d.ts
907
+ type ResolvePathOptions = {
908
+ pluginKey?: Plugin['key'];
909
+ group?: {
910
+ tag?: string;
911
+ path?: string;
912
+ };
913
+ type?: ResolveNameParams['type'];
914
+ };
915
+ /**
916
+ * `propertyName` is the ref name + resolved with the nameResolver
917
+ * @example import { Pet } from './Pet'
918
+ *
919
+ * `originalName` is the original name used(in PascalCase), only used to remove duplicates
920
+ *
921
+ * `pluginKey` can be used to override the current plugin being used, handy when you want to import a type/schema out of another plugin
922
+ * @example import a type(plugin-ts) for a mock file(swagger-faker)
923
+ */
924
+ type Ref = {
925
+ propertyName: string;
926
+ originalName: string;
927
+ path: OptionalPath;
928
+ pluginKey?: Plugin['key'];
929
+ };
930
+ type Refs = Record<string, Ref>;
931
+ type OperationSchema = {
932
+ /**
933
+ * Converted name, contains already `PathParams`, `QueryParams`, ...
934
+ */
935
+ name: string;
936
+ schema: SchemaObject$1;
937
+ operation?: Operation$1;
938
+ /**
939
+ * OperationName in PascalCase, only being used in OperationGenerator
940
+ */
941
+ operationName: string;
942
+ description?: string;
943
+ statusCode?: number;
944
+ keys?: string[];
945
+ keysToOmit?: string[];
946
+ withData?: boolean;
947
+ };
948
+ type OperationSchemas = {
949
+ pathParams?: OperationSchema & {
950
+ keysToOmit?: never;
951
+ };
952
+ queryParams?: OperationSchema & {
953
+ keysToOmit?: never;
954
+ };
955
+ headerParams?: OperationSchema & {
956
+ keysToOmit?: never;
957
+ };
958
+ request?: OperationSchema;
959
+ response: OperationSchema;
960
+ responses: Array<OperationSchema>;
961
+ statusCodes?: Array<OperationSchema>;
962
+ errors?: Array<OperationSchema>;
963
+ };
964
+ type ByTag = {
965
+ type: 'tag';
966
+ pattern: string | RegExp;
967
+ };
968
+ type ByOperationId = {
969
+ type: 'operationId';
970
+ pattern: string | RegExp;
971
+ };
972
+ type ByPath = {
973
+ type: 'path';
974
+ pattern: string | RegExp;
975
+ };
976
+ type ByMethod = {
977
+ type: 'method';
978
+ pattern: HttpMethod | RegExp;
979
+ };
980
+ type BySchemaName = {
981
+ type: 'schemaName';
982
+ pattern: string | RegExp;
983
+ };
984
+ type ByContentType = {
985
+ type: 'contentType';
986
+ pattern: string | RegExp;
987
+ };
988
+ type Exclude$1 = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
989
+ type Include = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
990
+ type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName | ByContentType) & {
991
+ options: Partial<TOptions>;
992
+ };
993
+ //#endregion
994
+ //#region ../plugin-oas/src/SchemaGenerator.d.ts
995
+ type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
996
+ oas: Oas;
997
+ pluginManager: PluginManager;
998
+ /**
999
+ * Current plugin
1000
+ */
1001
+ plugin: Plugin<TPluginOptions>;
1002
+ mode: Mode;
1003
+ include?: Array<'schemas' | 'responses' | 'requestBodies'>;
1004
+ override: Array<Override<TOptions>> | undefined;
1005
+ contentType?: contentType;
1006
+ output?: string;
1007
+ };
1008
+ type SchemaGeneratorOptions = {
1009
+ dateType: false | 'string' | 'stringOffset' | 'stringLocal' | 'date';
1010
+ unknownType: 'any' | 'unknown' | 'void';
1011
+ emptySchemaType: 'any' | 'unknown' | 'void';
1012
+ enumType?: 'enum' | 'asConst' | 'asPascalConst' | 'constEnum' | 'literal';
1013
+ enumSuffix?: string;
1014
+ usedEnumNames?: Record<string, number>;
1015
+ mapper?: Record<string, string>;
1016
+ typed?: boolean;
1017
+ transformers: {
1018
+ /**
1019
+ * Customize the names based on the type that is provided by the plugin.
1020
+ */
1021
+ name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
1022
+ /**
1023
+ * Receive schema and name(propertName) and return FakerMeta array
1024
+ * TODO TODO add docs
1025
+ * @beta
1026
+ */
1027
+ schema?: (schemaProps: SchemaProps$1, defaultSchemas: Schema[]) => Schema[] | undefined;
1028
+ };
1029
+ };
1030
+ type SchemaProps$1 = {
1031
+ schemaObject?: SchemaObject$1;
1032
+ name?: string;
1033
+ parentName?: string;
1034
+ };
1035
+ declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions, Context$1<TOptions, TPluginOptions>> {
1036
+ #private;
1037
+ refs: Refs;
1038
+ /**
1039
+ * Creates a type node from a given schema.
1040
+ * Delegates to getBaseTypeFromSchema internally and
1041
+ * optionally adds a union with null.
1042
+ */
1043
+ parse(props: SchemaProps$1): Schema[];
1044
+ deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
1045
+ find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
1046
+ static deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
1047
+ static findInObject<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
1048
+ static find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
1049
+ static combineObjects(tree: Schema[] | undefined): Schema[];
1050
+ build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<File<TFileMeta>>>;
1051
+ }
1052
+ //#endregion
1053
+ //#region ../plugin-oas/src/generator.d.ts
1054
+ type OperationsProps<TOptions extends PluginFactoryOptions> = {
1055
+ instance: Omit<OperationGenerator<TOptions>, 'build'>;
1056
+ options: TOptions['resolvedOptions'];
1057
+ operations: Array<Operation$1>;
1058
+ };
1059
+ type OperationProps<TOptions extends PluginFactoryOptions> = {
1060
+ instance: Omit<OperationGenerator<TOptions>, 'build'>;
1061
+ options: TOptions['resolvedOptions'];
1062
+ operation: Operation$1;
1063
+ };
1064
+ type SchemaProps<TOptions extends PluginFactoryOptions> = {
1065
+ instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>;
1066
+ options: TOptions['resolvedOptions'];
1067
+ schema: {
1068
+ name: string;
1069
+ tree: Array<Schema>;
1070
+ value: SchemaObject$1;
1071
+ };
1072
+ };
1073
+ type GeneratorOptions<TOptions extends PluginFactoryOptions> = {
1074
+ name: string;
1075
+ operations?: (this: GeneratorOptions<TOptions>, props: OperationsProps<TOptions>) => Promise<File[]>;
1076
+ operation?: (this: GeneratorOptions<TOptions>, props: OperationProps<TOptions>) => Promise<File[]>;
1077
+ schema?: (this: GeneratorOptions<TOptions>, props: SchemaProps<TOptions>) => Promise<File[]>;
1078
+ };
1079
+ type Generator<TOptions extends PluginFactoryOptions> = GeneratorOptions<TOptions>;
1080
+ //#endregion
1081
+ //#region ../plugin-oas/src/OperationGenerator.d.ts
1082
+ type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
1083
+ oas: Oas;
1084
+ exclude: Array<Exclude$1> | undefined;
1085
+ include: Array<Include> | undefined;
1086
+ override: Array<Override<TOptions>> | undefined;
1087
+ contentType: contentType | undefined;
1088
+ pluginManager: PluginManager;
1089
+ /**
1090
+ * Current plugin
1091
+ */
1092
+ plugin: Plugin<TPluginOptions>;
1093
+ mode: Mode;
1094
+ };
1095
+ declare class OperationGenerator<TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TPluginOptions['resolvedOptions'], Context<TPluginOptions['resolvedOptions'], TPluginOptions>> {
1096
+ #private;
1097
+ getSchemas(operation: Operation$1, {
1098
+ resolveName
1099
+ }?: {
1100
+ resolveName?: (name: string) => string;
1101
+ }): OperationSchemas;
1102
+ getOperations(): Promise<Array<{
1103
+ path: string;
1104
+ method: HttpMethod;
1105
+ operation: Operation$1;
1106
+ }>>;
1107
+ build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<File<TFileMeta>>>;
1108
+ }
1109
+ //#endregion
1110
+ //#region src/types.d.ts
1111
+ type Options$1 = {
1112
+ /**
1113
+ * Specify the export location for the files and define the behavior of the output
1114
+ * @default { path: 'cypress', barrelType: 'named' }
1115
+ */
1116
+ output?: Output<Oas>;
1117
+ /**
1118
+ * Define which contentType should be used.
1119
+ * By default, the first JSON valid mediaType will be used
1120
+ */
1121
+ contentType?: contentType;
1122
+ /**
1123
+ * ReturnType that will be used when calling cy.request.
1124
+ * - 'data' will return ResponseConfig[data].
1125
+ * - 'full' will return ResponseConfig.
1126
+ * @default 'data'
1127
+ */
1128
+ dataReturnType?: 'data' | 'full';
1129
+ baseURL?: string;
1130
+ /**
1131
+ * Group the Cypress requests based on the provided name.
1132
+ */
1133
+ group?: Group;
1134
+ /**
1135
+ * Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
1136
+ */
1137
+ exclude?: Array<Exclude$1>;
1138
+ /**
1139
+ * Array containing include parameters to include tags/operations/methods/paths.
1140
+ */
1141
+ include?: Array<Include>;
1142
+ /**
1143
+ * Array containing override parameters to override `options` based on tags/operations/methods/paths.
1144
+ */
1145
+ override?: Array<Override<ResolvedOptions>>;
1146
+ transformers?: {
1147
+ /**
1148
+ * Customize the names based on the type that is provided by the plugin.
1149
+ */
1150
+ name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
1151
+ };
1152
+ /**
1153
+ * Define some generators next to the Cypress generators.
1154
+ */
1155
+ generators?: Array<Generator<PluginCypress>>;
1156
+ };
1157
+ type ResolvedOptions = {
1158
+ output: Output<Oas>;
1159
+ group: Options$1['group'];
1160
+ baseURL: Options$1['baseURL'] | undefined;
1161
+ dataReturnType: NonNullable<Options$1['dataReturnType']>;
1162
+ };
1163
+ type PluginCypress = PluginFactoryOptions<'plugin-cypress', Options$1, ResolvedOptions, never, ResolvePathOptions>;
1164
+ //#endregion
1165
+ export { Generator, type HttpMethod, OperationSchemas, Options$1 as Options, PluginCypress, UserPluginWithLifeCycle };
1166
+ //# sourceMappingURL=types-BNTHk264.d.ts.map