@kubb/plugin-msw 4.21.2 → 4.22.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.
@@ -1,554 +0,0 @@
1
- import { t as __name } from "./chunk-eQyhnF5A.js";
2
- import { a as contentType, i as SchemaObject, n as HttpMethod, r as Operation, t as Oas } from "./index-DquTBoXO.js";
3
- import { BaseGenerator, Config, FileMetaBase, Group, KubbEvents, Output, Plugin, PluginFactoryOptions, PluginManager, ResolveNameParams } from "@kubb/core";
4
- import { Fabric } from "@kubb/react-fabric";
5
- import { FabricReactNode } from "@kubb/react-fabric/types";
6
- import { KubbFile } from "@kubb/fabric-core/types";
7
-
8
- //#region ../core/src/utils/AsyncEventEmitter.d.ts
9
- declare class AsyncEventEmitter<TEvents extends Record<string, any>> {
10
- #private;
11
- constructor(maxListener?: number);
12
- emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArgs: TEvents[TEventName]): Promise<void>;
13
- on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
14
- onOnce<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArgs: TEvents[TEventName]) => void): void;
15
- off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
16
- removeAll(): void;
17
- }
18
- //#endregion
19
- //#region ../core/src/types.d.ts
20
- declare global {
21
- namespace Kubb {
22
- interface PluginContext {}
23
- }
24
- }
25
- /**
26
- * Config used in `kubb.config.ts`
27
- *
28
- * @example
29
- * import { defineConfig } from '@kubb/core'
30
- * export default defineConfig({
31
- * ...
32
- * })
33
- */
34
- //#endregion
35
- //#region ../plugin-oas/src/types.d.ts
36
- type GetOasOptions = {
37
- validate?: boolean;
38
- };
39
- type Context$2 = {
40
- getOas(options?: GetOasOptions): Promise<Oas>;
41
- getBaseURL(): Promise<string | undefined>;
42
- };
43
- declare global {
44
- namespace Kubb {
45
- interface PluginContext extends Context$2 {}
46
- }
47
- }
48
- type ResolvePathOptions = {
49
- pluginKey?: Plugin['key'];
50
- group?: {
51
- tag?: string;
52
- path?: string;
53
- };
54
- type?: ResolveNameParams['type'];
55
- };
56
- /**
57
- * `propertyName` is the ref name + resolved with the nameResolver
58
- * @example import { Pet } from './Pet'
59
- *
60
- * `originalName` is the original name used(in PascalCase), only used to remove duplicates
61
- *
62
- * `pluginKey` can be used to override the current plugin being used, handy when you want to import a type/schema out of another plugin
63
- * @example import a type(plugin-ts) for a mock file(swagger-faker)
64
- */
65
- type Ref = {
66
- propertyName: string;
67
- originalName: string;
68
- path: KubbFile.Path;
69
- pluginKey?: Plugin['key'];
70
- };
71
- type Refs = Record<string, Ref>;
72
- type OperationSchema = {
73
- /**
74
- * Converted name, contains already `PathParams`, `QueryParams`, ...
75
- */
76
- name: string;
77
- schema: SchemaObject;
78
- operation?: Operation;
79
- /**
80
- * OperationName in PascalCase, only being used in OperationGenerator
81
- */
82
- operationName: string;
83
- description?: string;
84
- statusCode?: number;
85
- keys?: string[];
86
- keysToOmit?: string[];
87
- withData?: boolean;
88
- };
89
- type OperationSchemas = {
90
- pathParams?: OperationSchema & {
91
- keysToOmit?: never;
92
- };
93
- queryParams?: OperationSchema & {
94
- keysToOmit?: never;
95
- };
96
- headerParams?: OperationSchema & {
97
- keysToOmit?: never;
98
- };
99
- request?: OperationSchema;
100
- response: OperationSchema;
101
- responses: Array<OperationSchema>;
102
- statusCodes?: Array<OperationSchema>;
103
- errors?: Array<OperationSchema>;
104
- };
105
- type ByTag = {
106
- type: 'tag';
107
- pattern: string | RegExp;
108
- };
109
- type ByOperationId = {
110
- type: 'operationId';
111
- pattern: string | RegExp;
112
- };
113
- type ByPath = {
114
- type: 'path';
115
- pattern: string | RegExp;
116
- };
117
- type ByMethod = {
118
- type: 'method';
119
- pattern: HttpMethod | RegExp;
120
- };
121
- type BySchemaName = {
122
- type: 'schemaName';
123
- pattern: string | RegExp;
124
- };
125
- type ByContentType = {
126
- type: 'contentType';
127
- pattern: string | RegExp;
128
- };
129
- type Exclude$1 = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
130
- type Include = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
131
- type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName | ByContentType) & {
132
- options: Partial<TOptions>;
133
- };
134
- //#endregion
135
- //#region ../plugin-oas/src/OperationGenerator.d.ts
136
- type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
137
- fabric: Fabric;
138
- oas: Oas;
139
- exclude: Array<Exclude$1> | undefined;
140
- include: Array<Include> | undefined;
141
- override: Array<Override<TOptions>> | undefined;
142
- contentType: contentType | undefined;
143
- pluginManager: PluginManager;
144
- events?: AsyncEventEmitter<KubbEvents>;
145
- /**
146
- * Current plugin
147
- */
148
- plugin: Plugin<TPluginOptions>;
149
- mode: KubbFile.Mode;
150
- UNSTABLE_NAMING?: true;
151
- };
152
- declare class OperationGenerator<TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TPluginOptions['resolvedOptions'], Context$1<TPluginOptions['resolvedOptions'], TPluginOptions>> {
153
- #private;
154
- getOptions(operation: Operation, method: HttpMethod): Partial<TPluginOptions['resolvedOptions']>;
155
- getSchemas(operation: Operation, {
156
- resolveName
157
- }?: {
158
- resolveName?: (name: string) => string;
159
- }): OperationSchemas;
160
- getOperations(): Promise<Array<{
161
- path: string;
162
- method: HttpMethod;
163
- operation: Operation;
164
- }>>;
165
- build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
166
- }
167
- //#endregion
168
- //#region ../plugin-oas/src/SchemaMapper.d.ts
169
- type SchemaKeywordMapper = {
170
- object: {
171
- keyword: 'object';
172
- args: {
173
- properties: {
174
- [x: string]: Schema[];
175
- };
176
- additionalProperties: Schema[];
177
- patternProperties?: Record<string, Schema[]>;
178
- strict?: boolean;
179
- };
180
- };
181
- url: {
182
- keyword: 'url';
183
- };
184
- readOnly: {
185
- keyword: 'readOnly';
186
- };
187
- writeOnly: {
188
- keyword: 'writeOnly';
189
- };
190
- uuid: {
191
- keyword: 'uuid';
192
- };
193
- email: {
194
- keyword: 'email';
195
- };
196
- firstName: {
197
- keyword: 'firstName';
198
- };
199
- lastName: {
200
- keyword: 'lastName';
201
- };
202
- phone: {
203
- keyword: 'phone';
204
- };
205
- password: {
206
- keyword: 'password';
207
- };
208
- date: {
209
- keyword: 'date';
210
- args: {
211
- type?: 'date' | 'string';
212
- };
213
- };
214
- time: {
215
- keyword: 'time';
216
- args: {
217
- type?: 'date' | 'string';
218
- };
219
- };
220
- datetime: {
221
- keyword: 'datetime';
222
- args: {
223
- offset?: boolean;
224
- local?: boolean;
225
- };
226
- };
227
- tuple: {
228
- keyword: 'tuple';
229
- args: {
230
- items: Schema[];
231
- min?: number;
232
- max?: number;
233
- rest?: Schema;
234
- };
235
- };
236
- array: {
237
- keyword: 'array';
238
- args: {
239
- items: Schema[];
240
- min?: number;
241
- max?: number;
242
- unique?: boolean;
243
- };
244
- };
245
- enum: {
246
- keyword: 'enum';
247
- args: {
248
- name: string;
249
- typeName: string;
250
- asConst: boolean;
251
- items: Array<{
252
- name: string | number;
253
- format: 'string' | 'number' | 'boolean';
254
- value?: string | number | boolean;
255
- }>;
256
- };
257
- };
258
- and: {
259
- keyword: 'and';
260
- args: Schema[];
261
- };
262
- const: {
263
- keyword: 'const';
264
- args: {
265
- name: string | number;
266
- format: 'string' | 'number' | 'boolean';
267
- value?: string | number | boolean;
268
- };
269
- };
270
- union: {
271
- keyword: 'union';
272
- args: Schema[];
273
- };
274
- ref: {
275
- keyword: 'ref';
276
- args: {
277
- name: string;
278
- $ref: string;
279
- /**
280
- * Full qualified path.
281
- */
282
- path: KubbFile.Path;
283
- /**
284
- * When true `File.Import` is used.
285
- * When false a reference is used inside the current file.
286
- */
287
- isImportable: boolean;
288
- };
289
- };
290
- matches: {
291
- keyword: 'matches';
292
- args?: string;
293
- };
294
- boolean: {
295
- keyword: 'boolean';
296
- };
297
- default: {
298
- keyword: 'default';
299
- args: string | number | boolean;
300
- };
301
- string: {
302
- keyword: 'string';
303
- };
304
- integer: {
305
- keyword: 'integer';
306
- };
307
- number: {
308
- keyword: 'number';
309
- };
310
- max: {
311
- keyword: 'max';
312
- args: number;
313
- };
314
- min: {
315
- keyword: 'min';
316
- args: number;
317
- };
318
- exclusiveMaximum: {
319
- keyword: 'exclusiveMaximum';
320
- args: number;
321
- };
322
- exclusiveMinimum: {
323
- keyword: 'exclusiveMinimum';
324
- args: number;
325
- };
326
- describe: {
327
- keyword: 'describe';
328
- args: string;
329
- };
330
- example: {
331
- keyword: 'example';
332
- args: string;
333
- };
334
- deprecated: {
335
- keyword: 'deprecated';
336
- };
337
- optional: {
338
- keyword: 'optional';
339
- };
340
- undefined: {
341
- keyword: 'undefined';
342
- };
343
- nullish: {
344
- keyword: 'nullish';
345
- };
346
- nullable: {
347
- keyword: 'nullable';
348
- };
349
- null: {
350
- keyword: 'null';
351
- };
352
- any: {
353
- keyword: 'any';
354
- };
355
- unknown: {
356
- keyword: 'unknown';
357
- };
358
- void: {
359
- keyword: 'void';
360
- };
361
- blob: {
362
- keyword: 'blob';
363
- };
364
- schema: {
365
- keyword: 'schema';
366
- args: {
367
- type: 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'object';
368
- format?: string;
369
- };
370
- };
371
- name: {
372
- keyword: 'name';
373
- args: string;
374
- };
375
- catchall: {
376
- keyword: 'catchall';
377
- };
378
- interface: {
379
- keyword: 'interface';
380
- };
381
- };
382
- type Schema = {
383
- keyword: string;
384
- } | SchemaKeywordMapper[keyof SchemaKeywordMapper];
385
- //#endregion
386
- //#region ../plugin-oas/src/SchemaGenerator.d.ts
387
- type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
388
- fabric: Fabric;
389
- oas: Oas;
390
- pluginManager: PluginManager;
391
- events?: AsyncEventEmitter<KubbEvents>;
392
- /**
393
- * Current plugin
394
- */
395
- plugin: Plugin<TPluginOptions>;
396
- mode: KubbFile.Mode;
397
- include?: Array<'schemas' | 'responses' | 'requestBodies'>;
398
- override: Array<Override<TOptions>> | undefined;
399
- contentType?: contentType;
400
- output?: string;
401
- };
402
- type SchemaGeneratorOptions = {
403
- dateType: false | 'string' | 'stringOffset' | 'stringLocal' | 'date';
404
- unknownType: 'any' | 'unknown' | 'void';
405
- emptySchemaType: 'any' | 'unknown' | 'void';
406
- enumType?: 'enum' | 'asConst' | 'asPascalConst' | 'constEnum' | 'literal' | 'inlineLiteral';
407
- enumSuffix?: string;
408
- /**
409
- * @deprecated Will be removed in v5. Use `collisionDetection: true` instead to prevent enum name collisions.
410
- * When `collisionDetection` is enabled, the rootName-based approach eliminates the need for numeric suffixes.
411
- * @internal
412
- */
413
- usedEnumNames?: Record<string, number>;
414
- mapper?: Record<string, string>;
415
- typed?: boolean;
416
- transformers: {
417
- /**
418
- * Customize the names based on the type that is provided by the plugin.
419
- */
420
- name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
421
- /**
422
- * Receive schema and name(propertyName) and return FakerMeta array
423
- * TODO TODO add docs
424
- * @beta
425
- */
426
- schema?: (schemaProps: SchemaProps$1, defaultSchemas: Schema[]) => Array<Schema> | undefined;
427
- };
428
- };
429
- type SchemaProps$1 = {
430
- schema: SchemaObject | null;
431
- name: string | null;
432
- parentName: string | null;
433
- rootName?: string | null;
434
- };
435
- declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions, Context<TOptions, TPluginOptions>> {
436
- #private;
437
- refs: Refs;
438
- /**
439
- * Creates a type node from a given schema.
440
- * Delegates to getBaseTypeFromSchema internally and
441
- * optionally adds a union with null.
442
- */
443
- parse(props: SchemaProps$1): Schema[];
444
- static deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
445
- static find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
446
- static combineObjects(tree: Schema[] | undefined): Schema[];
447
- build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
448
- }
449
- //#endregion
450
- //#region ../plugin-oas/src/generators/createGenerator.d.ts
451
- type CoreGenerator<TOptions extends PluginFactoryOptions> = {
452
- name: string;
453
- type: 'core';
454
- operations: (props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>;
455
- operation: (props: OperationProps<TOptions>) => Promise<KubbFile.File[]>;
456
- schema: (props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>;
457
- };
458
- //#endregion
459
- //#region ../plugin-oas/src/generators/types.d.ts
460
- type OperationsProps<TOptions extends PluginFactoryOptions> = {
461
- config: Config;
462
- generator: Omit<OperationGenerator<TOptions>, 'build'>;
463
- plugin: Plugin<TOptions>;
464
- operations: Array<Operation>;
465
- };
466
- type OperationProps<TOptions extends PluginFactoryOptions> = {
467
- config: Config;
468
- generator: Omit<OperationGenerator<TOptions>, 'build'>;
469
- plugin: Plugin<TOptions>;
470
- operation: Operation;
471
- };
472
- type SchemaProps<TOptions extends PluginFactoryOptions> = {
473
- config: Config;
474
- generator: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>;
475
- plugin: Plugin<TOptions>;
476
- schema: {
477
- name: string;
478
- tree: Array<Schema>;
479
- value: SchemaObject;
480
- };
481
- };
482
- type Generator<TOptions extends PluginFactoryOptions> = CoreGenerator<TOptions> | ReactGenerator<TOptions>;
483
- //#endregion
484
- //#region ../plugin-oas/src/generators/createReactGenerator.d.ts
485
- type ReactGenerator<TOptions extends PluginFactoryOptions> = {
486
- name: string;
487
- type: 'react';
488
- Operations: (props: OperationsProps<TOptions>) => FabricReactNode;
489
- Operation: (props: OperationProps<TOptions>) => FabricReactNode;
490
- Schema: (props: SchemaProps<TOptions>) => FabricReactNode;
491
- };
492
- //#endregion
493
- //#region src/types.d.ts
494
- type Options = {
495
- /**
496
- * Specify the export location for the files and define the behavior of the output
497
- * @default { path: 'mocks', barrelType: 'named' }
498
- */
499
- output?: Output<Oas>;
500
- /**
501
- * Define which contentType should be used.
502
- * By default, the first JSON valid mediaType is used
503
- */
504
- contentType?: contentType;
505
- baseURL?: string;
506
- /**
507
- * Group the MSW mocks based on the provided name.
508
- */
509
- group?: Group;
510
- /**
511
- * Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
512
- */
513
- exclude?: Array<Exclude$1>;
514
- /**
515
- * Array containing include parameters to include tags/operations/methods/paths.
516
- */
517
- include?: Array<Include>;
518
- /**
519
- * Array containing override parameters to override `options` based on tags/operations/methods/paths.
520
- */
521
- override?: Array<Override<ResolvedOptions>>;
522
- transformers?: {
523
- /**
524
- * Customize the names based on the type that is provided by the plugin.
525
- */
526
- name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
527
- };
528
- /**
529
- * Create `handlers.ts` file with all handlers grouped by methods.
530
- * @default false
531
- */
532
- handlers?: boolean;
533
- /**
534
- * Which parser should be used before returning the data to the Response of MSW.
535
- * - 'data' uses your custom data to generate the data for the response.
536
- * - 'faker' uses @kubb/plugin-faker to generate the data for the response.
537
- * @default 'data'
538
- */
539
- parser?: 'data' | 'faker';
540
- /**
541
- * Define some generators next to the msw generators
542
- */
543
- generators?: Array<Generator<PluginMsw>>;
544
- };
545
- type ResolvedOptions = {
546
- output: Output<Oas>;
547
- group: Options['group'];
548
- parser: NonNullable<Options['parser']>;
549
- baseURL: Options['baseURL'] | undefined;
550
- };
551
- type PluginMsw = PluginFactoryOptions<'plugin-msw', Options, ResolvedOptions, never, ResolvePathOptions>;
552
- //#endregion
553
- export { PluginMsw as n, ReactGenerator as r, Options as t };
554
- //# sourceMappingURL=types-CkkTxIj4.d.ts.map