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