@kubb/plugin-msw 5.0.0-alpha.8 → 5.0.0-beta.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.
- package/LICENSE +17 -10
- package/README.md +1 -3
- package/dist/components-CLQ77DVn.cjs +584 -0
- package/dist/components-CLQ77DVn.cjs.map +1 -0
- package/dist/components-vO0FIb2i.js +519 -0
- package/dist/components-vO0FIb2i.js.map +1 -0
- package/dist/components.cjs +1 -1
- package/dist/components.d.ts +17 -21
- package/dist/components.js +1 -1
- package/dist/generators-BPJCs1x1.js +176 -0
- package/dist/generators-BPJCs1x1.js.map +1 -0
- package/dist/generators-CrmMwWE4.cjs +186 -0
- package/dist/generators-CrmMwWE4.cjs.map +1 -0
- package/dist/generators.cjs +1 -1
- package/dist/generators.d.ts +4 -471
- package/dist/generators.js +1 -1
- package/dist/index.cjs +54 -65
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +51 -65
- package/dist/index.js.map +1 -1
- package/dist/types-Dxu0KMQ4.d.ts +89 -0
- package/package.json +59 -57
- package/src/components/Handlers.tsx +3 -3
- package/src/components/Mock.tsx +36 -28
- package/src/components/MockWithFaker.tsx +36 -24
- package/src/components/Response.tsx +23 -17
- package/src/generators/handlersGenerator.tsx +18 -18
- package/src/generators/mswGenerator.tsx +49 -60
- package/src/index.ts +1 -1
- package/src/plugin.ts +48 -85
- package/src/resolvers/resolverMsw.ts +19 -0
- package/src/types.ts +45 -22
- package/src/utils.ts +109 -0
- package/dist/components-8XBwMbFa.cjs +0 -343
- package/dist/components-8XBwMbFa.cjs.map +0 -1
- package/dist/components-DgtTZkWX.js +0 -277
- package/dist/components-DgtTZkWX.js.map +0 -1
- package/dist/generators-CY1SNd5X.cjs +0 -171
- package/dist/generators-CY1SNd5X.cjs.map +0 -1
- package/dist/generators-CvyZTxOm.js +0 -161
- package/dist/generators-CvyZTxOm.js.map +0 -1
- package/dist/types-MdHRNpgi.d.ts +0 -68
package/dist/generators.d.ts
CHANGED
|
@@ -1,479 +1,12 @@
|
|
|
1
1
|
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
|
-
import { n as PluginMsw } from "./types-
|
|
3
|
-
import
|
|
4
|
-
import { FabricReactNode } from "@kubb/react-fabric/types";
|
|
5
|
-
import { HttpMethod, Oas, Operation, SchemaObject, contentType } from "@kubb/oas";
|
|
6
|
-
import { Fabric, KubbFile } from "@kubb/fabric-core/types";
|
|
2
|
+
import { n as PluginMsw } from "./types-Dxu0KMQ4.js";
|
|
3
|
+
import * as _$_kubb_core0 from "@kubb/core";
|
|
7
4
|
|
|
8
|
-
//#region ../plugin-oas/src/types.d.ts
|
|
9
|
-
type GetOasOptions = {
|
|
10
|
-
validate?: boolean;
|
|
11
|
-
};
|
|
12
|
-
type Context$2 = {
|
|
13
|
-
getOas(options?: GetOasOptions): Promise<Oas>;
|
|
14
|
-
getBaseURL(): Promise<string | undefined>;
|
|
15
|
-
};
|
|
16
|
-
declare global {
|
|
17
|
-
namespace Kubb {
|
|
18
|
-
interface PluginContext extends Context$2 {}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* `propertyName` is the ref name + resolved with the nameResolver
|
|
23
|
-
* @example import { Pet } from './Pet'
|
|
24
|
-
*
|
|
25
|
-
* `originalName` is the original name used(in PascalCase), only used to remove duplicates
|
|
26
|
-
*
|
|
27
|
-
* `pluginName` can be used to override the current plugin being used, handy when you want to import a type/schema out of another plugin
|
|
28
|
-
* @example import a type(plugin-ts) for a mock file(swagger-faker)
|
|
29
|
-
*/
|
|
30
|
-
type Ref = {
|
|
31
|
-
propertyName: string;
|
|
32
|
-
originalName: string;
|
|
33
|
-
path: KubbFile.Path;
|
|
34
|
-
pluginName?: string;
|
|
35
|
-
};
|
|
36
|
-
type Refs = Record<string, Ref>;
|
|
37
|
-
type OperationSchema = {
|
|
38
|
-
/**
|
|
39
|
-
* Converted name, contains already `PathParams`, `QueryParams`, ...
|
|
40
|
-
*/
|
|
41
|
-
name: string;
|
|
42
|
-
schema: SchemaObject;
|
|
43
|
-
operation?: Operation;
|
|
44
|
-
/**
|
|
45
|
-
* OperationName in PascalCase, only being used in OperationGenerator
|
|
46
|
-
*/
|
|
47
|
-
operationName: string;
|
|
48
|
-
description?: string;
|
|
49
|
-
statusCode?: number;
|
|
50
|
-
keys?: string[];
|
|
51
|
-
keysToOmit?: string[];
|
|
52
|
-
withData?: boolean;
|
|
53
|
-
};
|
|
54
|
-
type OperationSchemas = {
|
|
55
|
-
pathParams?: OperationSchema & {
|
|
56
|
-
keysToOmit?: never;
|
|
57
|
-
};
|
|
58
|
-
queryParams?: OperationSchema & {
|
|
59
|
-
keysToOmit?: never;
|
|
60
|
-
};
|
|
61
|
-
headerParams?: OperationSchema & {
|
|
62
|
-
keysToOmit?: never;
|
|
63
|
-
};
|
|
64
|
-
request?: OperationSchema;
|
|
65
|
-
response: OperationSchema;
|
|
66
|
-
responses: Array<OperationSchema>;
|
|
67
|
-
statusCodes?: Array<OperationSchema>;
|
|
68
|
-
errors?: Array<OperationSchema>;
|
|
69
|
-
};
|
|
70
|
-
type ByTag = {
|
|
71
|
-
type: 'tag';
|
|
72
|
-
pattern: string | RegExp;
|
|
73
|
-
};
|
|
74
|
-
type ByOperationId = {
|
|
75
|
-
type: 'operationId';
|
|
76
|
-
pattern: string | RegExp;
|
|
77
|
-
};
|
|
78
|
-
type ByPath = {
|
|
79
|
-
type: 'path';
|
|
80
|
-
pattern: string | RegExp;
|
|
81
|
-
};
|
|
82
|
-
type ByMethod = {
|
|
83
|
-
type: 'method';
|
|
84
|
-
pattern: HttpMethod | RegExp;
|
|
85
|
-
};
|
|
86
|
-
type BySchemaName = {
|
|
87
|
-
type: 'schemaName';
|
|
88
|
-
pattern: string | RegExp;
|
|
89
|
-
};
|
|
90
|
-
type ByContentType = {
|
|
91
|
-
type: 'contentType';
|
|
92
|
-
pattern: string | RegExp;
|
|
93
|
-
};
|
|
94
|
-
type Exclude = ByTag | ByOperationId | ByPath | ByMethod | ByContentType | BySchemaName;
|
|
95
|
-
type Include = ByTag | ByOperationId | ByPath | ByMethod | ByContentType | BySchemaName;
|
|
96
|
-
type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName | ByContentType) & {
|
|
97
|
-
options: Partial<TOptions>;
|
|
98
|
-
};
|
|
99
|
-
//#endregion
|
|
100
|
-
//#region ../plugin-oas/src/OperationGenerator.d.ts
|
|
101
|
-
type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
102
|
-
fabric: Fabric;
|
|
103
|
-
oas: Oas;
|
|
104
|
-
exclude: Array<Exclude> | undefined;
|
|
105
|
-
include: Array<Include> | undefined;
|
|
106
|
-
override: Array<Override<TOptions>> | undefined;
|
|
107
|
-
contentType: contentType | undefined;
|
|
108
|
-
driver: PluginDriver;
|
|
109
|
-
events?: AsyncEventEmitter<KubbEvents>;
|
|
110
|
-
/**
|
|
111
|
-
* Current plugin
|
|
112
|
-
*/
|
|
113
|
-
plugin: Plugin<TPluginOptions>;
|
|
114
|
-
mode: KubbFile.Mode;
|
|
115
|
-
UNSTABLE_NAMING?: true;
|
|
116
|
-
};
|
|
117
|
-
declare class OperationGenerator<TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> {
|
|
118
|
-
#private;
|
|
119
|
-
constructor(options: TPluginOptions['resolvedOptions'], context: Context$1<TPluginOptions['resolvedOptions'], TPluginOptions>);
|
|
120
|
-
get options(): TPluginOptions['resolvedOptions'];
|
|
121
|
-
set options(options: TPluginOptions['resolvedOptions']);
|
|
122
|
-
get context(): Context$1<TPluginOptions['resolvedOptions'], TPluginOptions>;
|
|
123
|
-
getOptions(operation: Operation, method: HttpMethod): Partial<TPluginOptions['resolvedOptions']>;
|
|
124
|
-
getSchemas(operation: Operation, {
|
|
125
|
-
resolveName
|
|
126
|
-
}?: {
|
|
127
|
-
resolveName?: (name: string) => string;
|
|
128
|
-
}): OperationSchemas;
|
|
129
|
-
getOperations(): Promise<Array<{
|
|
130
|
-
path: string;
|
|
131
|
-
method: HttpMethod;
|
|
132
|
-
operation: Operation;
|
|
133
|
-
}>>;
|
|
134
|
-
build(...generators: Array<Generator$1<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
135
|
-
}
|
|
136
|
-
//#endregion
|
|
137
|
-
//#region ../plugin-oas/src/SchemaMapper.d.ts
|
|
138
|
-
type SchemaKeywordMapper = {
|
|
139
|
-
object: {
|
|
140
|
-
keyword: 'object';
|
|
141
|
-
args: {
|
|
142
|
-
properties: {
|
|
143
|
-
[x: string]: Schema[];
|
|
144
|
-
};
|
|
145
|
-
additionalProperties: Schema[];
|
|
146
|
-
patternProperties?: Record<string, Schema[]>;
|
|
147
|
-
strict?: boolean;
|
|
148
|
-
};
|
|
149
|
-
};
|
|
150
|
-
url: {
|
|
151
|
-
keyword: 'url';
|
|
152
|
-
};
|
|
153
|
-
readOnly: {
|
|
154
|
-
keyword: 'readOnly';
|
|
155
|
-
};
|
|
156
|
-
writeOnly: {
|
|
157
|
-
keyword: 'writeOnly';
|
|
158
|
-
};
|
|
159
|
-
uuid: {
|
|
160
|
-
keyword: 'uuid';
|
|
161
|
-
};
|
|
162
|
-
email: {
|
|
163
|
-
keyword: 'email';
|
|
164
|
-
};
|
|
165
|
-
firstName: {
|
|
166
|
-
keyword: 'firstName';
|
|
167
|
-
};
|
|
168
|
-
lastName: {
|
|
169
|
-
keyword: 'lastName';
|
|
170
|
-
};
|
|
171
|
-
phone: {
|
|
172
|
-
keyword: 'phone';
|
|
173
|
-
};
|
|
174
|
-
password: {
|
|
175
|
-
keyword: 'password';
|
|
176
|
-
};
|
|
177
|
-
date: {
|
|
178
|
-
keyword: 'date';
|
|
179
|
-
args: {
|
|
180
|
-
type?: 'date' | 'string';
|
|
181
|
-
};
|
|
182
|
-
};
|
|
183
|
-
time: {
|
|
184
|
-
keyword: 'time';
|
|
185
|
-
args: {
|
|
186
|
-
type?: 'date' | 'string';
|
|
187
|
-
};
|
|
188
|
-
};
|
|
189
|
-
datetime: {
|
|
190
|
-
keyword: 'datetime';
|
|
191
|
-
args: {
|
|
192
|
-
offset?: boolean;
|
|
193
|
-
local?: boolean;
|
|
194
|
-
};
|
|
195
|
-
};
|
|
196
|
-
tuple: {
|
|
197
|
-
keyword: 'tuple';
|
|
198
|
-
args: {
|
|
199
|
-
items: Schema[];
|
|
200
|
-
min?: number;
|
|
201
|
-
max?: number;
|
|
202
|
-
rest?: Schema;
|
|
203
|
-
};
|
|
204
|
-
};
|
|
205
|
-
array: {
|
|
206
|
-
keyword: 'array';
|
|
207
|
-
args: {
|
|
208
|
-
items: Schema[];
|
|
209
|
-
min?: number;
|
|
210
|
-
max?: number;
|
|
211
|
-
unique?: boolean;
|
|
212
|
-
};
|
|
213
|
-
};
|
|
214
|
-
enum: {
|
|
215
|
-
keyword: 'enum';
|
|
216
|
-
args: {
|
|
217
|
-
name: string;
|
|
218
|
-
typeName: string;
|
|
219
|
-
asConst: boolean;
|
|
220
|
-
items: Array<{
|
|
221
|
-
name: string | number;
|
|
222
|
-
format: 'string' | 'number' | 'boolean';
|
|
223
|
-
value?: string | number | boolean;
|
|
224
|
-
}>;
|
|
225
|
-
};
|
|
226
|
-
};
|
|
227
|
-
and: {
|
|
228
|
-
keyword: 'and';
|
|
229
|
-
args: Schema[];
|
|
230
|
-
};
|
|
231
|
-
const: {
|
|
232
|
-
keyword: 'const';
|
|
233
|
-
args: {
|
|
234
|
-
name: string | number;
|
|
235
|
-
format: 'string' | 'number' | 'boolean';
|
|
236
|
-
value?: string | number | boolean;
|
|
237
|
-
};
|
|
238
|
-
};
|
|
239
|
-
union: {
|
|
240
|
-
keyword: 'union';
|
|
241
|
-
args: Schema[];
|
|
242
|
-
};
|
|
243
|
-
ref: {
|
|
244
|
-
keyword: 'ref';
|
|
245
|
-
args: {
|
|
246
|
-
name: string;
|
|
247
|
-
$ref: string;
|
|
248
|
-
/**
|
|
249
|
-
* Full qualified path.
|
|
250
|
-
*/
|
|
251
|
-
path: KubbFile.Path;
|
|
252
|
-
/**
|
|
253
|
-
* When true `File.Import` is used.
|
|
254
|
-
* When false a reference is used inside the current file.
|
|
255
|
-
*/
|
|
256
|
-
isImportable: boolean;
|
|
257
|
-
};
|
|
258
|
-
};
|
|
259
|
-
matches: {
|
|
260
|
-
keyword: 'matches';
|
|
261
|
-
args?: string;
|
|
262
|
-
};
|
|
263
|
-
boolean: {
|
|
264
|
-
keyword: 'boolean';
|
|
265
|
-
};
|
|
266
|
-
default: {
|
|
267
|
-
keyword: 'default';
|
|
268
|
-
args: string | number | boolean;
|
|
269
|
-
};
|
|
270
|
-
string: {
|
|
271
|
-
keyword: 'string';
|
|
272
|
-
};
|
|
273
|
-
integer: {
|
|
274
|
-
keyword: 'integer';
|
|
275
|
-
};
|
|
276
|
-
bigint: {
|
|
277
|
-
keyword: 'bigint';
|
|
278
|
-
};
|
|
279
|
-
number: {
|
|
280
|
-
keyword: 'number';
|
|
281
|
-
};
|
|
282
|
-
max: {
|
|
283
|
-
keyword: 'max';
|
|
284
|
-
args: number;
|
|
285
|
-
};
|
|
286
|
-
min: {
|
|
287
|
-
keyword: 'min';
|
|
288
|
-
args: number;
|
|
289
|
-
};
|
|
290
|
-
exclusiveMaximum: {
|
|
291
|
-
keyword: 'exclusiveMaximum';
|
|
292
|
-
args: number;
|
|
293
|
-
};
|
|
294
|
-
exclusiveMinimum: {
|
|
295
|
-
keyword: 'exclusiveMinimum';
|
|
296
|
-
args: number;
|
|
297
|
-
};
|
|
298
|
-
describe: {
|
|
299
|
-
keyword: 'describe';
|
|
300
|
-
args: string;
|
|
301
|
-
};
|
|
302
|
-
example: {
|
|
303
|
-
keyword: 'example';
|
|
304
|
-
args: string;
|
|
305
|
-
};
|
|
306
|
-
deprecated: {
|
|
307
|
-
keyword: 'deprecated';
|
|
308
|
-
};
|
|
309
|
-
optional: {
|
|
310
|
-
keyword: 'optional';
|
|
311
|
-
};
|
|
312
|
-
undefined: {
|
|
313
|
-
keyword: 'undefined';
|
|
314
|
-
};
|
|
315
|
-
nullish: {
|
|
316
|
-
keyword: 'nullish';
|
|
317
|
-
};
|
|
318
|
-
nullable: {
|
|
319
|
-
keyword: 'nullable';
|
|
320
|
-
};
|
|
321
|
-
null: {
|
|
322
|
-
keyword: 'null';
|
|
323
|
-
};
|
|
324
|
-
any: {
|
|
325
|
-
keyword: 'any';
|
|
326
|
-
};
|
|
327
|
-
unknown: {
|
|
328
|
-
keyword: 'unknown';
|
|
329
|
-
};
|
|
330
|
-
void: {
|
|
331
|
-
keyword: 'void';
|
|
332
|
-
};
|
|
333
|
-
blob: {
|
|
334
|
-
keyword: 'blob';
|
|
335
|
-
};
|
|
336
|
-
schema: {
|
|
337
|
-
keyword: 'schema';
|
|
338
|
-
args: {
|
|
339
|
-
type: 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'object';
|
|
340
|
-
format?: string;
|
|
341
|
-
};
|
|
342
|
-
};
|
|
343
|
-
name: {
|
|
344
|
-
keyword: 'name';
|
|
345
|
-
args: string;
|
|
346
|
-
};
|
|
347
|
-
catchall: {
|
|
348
|
-
keyword: 'catchall';
|
|
349
|
-
};
|
|
350
|
-
interface: {
|
|
351
|
-
keyword: 'interface';
|
|
352
|
-
};
|
|
353
|
-
};
|
|
354
|
-
type Schema = {
|
|
355
|
-
keyword: string;
|
|
356
|
-
} | SchemaKeywordMapper[keyof SchemaKeywordMapper];
|
|
357
|
-
//#endregion
|
|
358
|
-
//#region ../plugin-oas/src/SchemaGenerator.d.ts
|
|
359
|
-
type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
360
|
-
fabric: Fabric;
|
|
361
|
-
oas: Oas;
|
|
362
|
-
driver: PluginDriver;
|
|
363
|
-
events?: AsyncEventEmitter<KubbEvents>;
|
|
364
|
-
/**
|
|
365
|
-
* Current plugin
|
|
366
|
-
*/
|
|
367
|
-
plugin: Plugin<TPluginOptions>;
|
|
368
|
-
mode: KubbFile.Mode;
|
|
369
|
-
include?: Array<'schemas' | 'responses' | 'requestBodies'>;
|
|
370
|
-
override: Array<Override<TOptions>> | undefined;
|
|
371
|
-
contentType?: contentType;
|
|
372
|
-
output?: string;
|
|
373
|
-
};
|
|
374
|
-
type SchemaGeneratorOptions = {
|
|
375
|
-
dateType: false | 'string' | 'stringOffset' | 'stringLocal' | 'date';
|
|
376
|
-
integerType?: 'number' | 'bigint';
|
|
377
|
-
unknownType: 'any' | 'unknown' | 'void';
|
|
378
|
-
emptySchemaType: 'any' | 'unknown' | 'void';
|
|
379
|
-
enumType?: 'enum' | 'asConst' | 'asPascalConst' | 'constEnum' | 'literal' | 'inlineLiteral';
|
|
380
|
-
enumSuffix?: string;
|
|
381
|
-
/**
|
|
382
|
-
* @deprecated Will be removed in v5. Use `collisionDetection: true` instead to prevent enum name collisions.
|
|
383
|
-
* When `collisionDetection` is enabled, the rootName-based approach eliminates the need for numeric suffixes.
|
|
384
|
-
* @internal
|
|
385
|
-
*/
|
|
386
|
-
usedEnumNames?: Record<string, number>;
|
|
387
|
-
mapper?: Record<string, string>;
|
|
388
|
-
typed?: boolean;
|
|
389
|
-
transformers: {
|
|
390
|
-
/**
|
|
391
|
-
* Customize the names based on the type that is provided by the plugin.
|
|
392
|
-
*/
|
|
393
|
-
name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
394
|
-
/**
|
|
395
|
-
* Receive schema and name(propertyName) and return Schema array.
|
|
396
|
-
* Return `undefined` to fall through to default schema generation.
|
|
397
|
-
* @beta
|
|
398
|
-
*/
|
|
399
|
-
schema?: (schemaProps: SchemaProps$1, defaultSchemas: Schema[]) => Array<Schema> | undefined;
|
|
400
|
-
};
|
|
401
|
-
};
|
|
402
|
-
type SchemaProps$1 = {
|
|
403
|
-
schema: SchemaObject | null;
|
|
404
|
-
name: string | null;
|
|
405
|
-
parentName: string | null;
|
|
406
|
-
rootName?: string | null;
|
|
407
|
-
};
|
|
408
|
-
declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> {
|
|
409
|
-
#private;
|
|
410
|
-
constructor(options: TOptions, context: Context<TOptions, TPluginOptions>);
|
|
411
|
-
get options(): TOptions;
|
|
412
|
-
set options(options: TOptions);
|
|
413
|
-
get context(): Context<TOptions, TPluginOptions>;
|
|
414
|
-
refs: Refs;
|
|
415
|
-
/**
|
|
416
|
-
* Creates a type node from a given schema.
|
|
417
|
-
* Delegates to getBaseTypeFromSchema internally and
|
|
418
|
-
* optionally adds a union with null.
|
|
419
|
-
*/
|
|
420
|
-
parse(props: SchemaProps$1): Schema[];
|
|
421
|
-
static deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
|
|
422
|
-
static find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
423
|
-
static combineObjects(tree: Schema[] | undefined): Schema[];
|
|
424
|
-
build(...generators: Array<Generator$1<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
425
|
-
}
|
|
426
|
-
//#endregion
|
|
427
|
-
//#region ../plugin-oas/src/generators/createGenerator.d.ts
|
|
428
|
-
type CoreGenerator<TOptions extends PluginFactoryOptions> = {
|
|
429
|
-
name: string;
|
|
430
|
-
type: 'core';
|
|
431
|
-
version: '1';
|
|
432
|
-
operations: (props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
433
|
-
operation: (props: OperationProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
434
|
-
schema: (props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
435
|
-
};
|
|
436
|
-
//#endregion
|
|
437
|
-
//#region ../plugin-oas/src/generators/types.d.ts
|
|
438
|
-
type OperationsProps<TOptions extends PluginFactoryOptions> = {
|
|
439
|
-
config: Config;
|
|
440
|
-
generator: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
441
|
-
plugin: Plugin<TOptions>;
|
|
442
|
-
operations: Array<Operation>;
|
|
443
|
-
};
|
|
444
|
-
type OperationProps<TOptions extends PluginFactoryOptions> = {
|
|
445
|
-
config: Config;
|
|
446
|
-
generator: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
447
|
-
plugin: Plugin<TOptions>;
|
|
448
|
-
operation: Operation;
|
|
449
|
-
};
|
|
450
|
-
type SchemaProps<TOptions extends PluginFactoryOptions> = {
|
|
451
|
-
config: Config;
|
|
452
|
-
generator: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>;
|
|
453
|
-
plugin: Plugin<TOptions>;
|
|
454
|
-
schema: {
|
|
455
|
-
name: string;
|
|
456
|
-
tree: Array<Schema>;
|
|
457
|
-
value: SchemaObject;
|
|
458
|
-
};
|
|
459
|
-
};
|
|
460
|
-
type Generator$1<TOptions extends PluginFactoryOptions> = CoreGenerator<TOptions> | ReactGenerator<TOptions> | Generator<TOptions>;
|
|
461
|
-
//#endregion
|
|
462
|
-
//#region ../plugin-oas/src/generators/createReactGenerator.d.ts
|
|
463
|
-
type ReactGenerator<TOptions extends PluginFactoryOptions> = {
|
|
464
|
-
name: string;
|
|
465
|
-
type: 'react';
|
|
466
|
-
version: '1';
|
|
467
|
-
Operations: (props: OperationsProps<TOptions>) => FabricReactNode;
|
|
468
|
-
Operation: (props: OperationProps<TOptions>) => FabricReactNode;
|
|
469
|
-
Schema: (props: SchemaProps<TOptions>) => FabricReactNode;
|
|
470
|
-
};
|
|
471
|
-
//#endregion
|
|
472
5
|
//#region src/generators/handlersGenerator.d.ts
|
|
473
|
-
declare const handlersGenerator:
|
|
6
|
+
declare const handlersGenerator: _$_kubb_core0.Generator<PluginMsw, unknown>;
|
|
474
7
|
//#endregion
|
|
475
8
|
//#region src/generators/mswGenerator.d.ts
|
|
476
|
-
declare const mswGenerator:
|
|
9
|
+
declare const mswGenerator: _$_kubb_core0.Generator<PluginMsw, unknown>;
|
|
477
10
|
//#endregion
|
|
478
11
|
export { handlersGenerator, mswGenerator };
|
|
479
12
|
//# sourceMappingURL=generators.d.ts.map
|
package/dist/generators.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as handlersGenerator, t as mswGenerator } from "./generators-
|
|
1
|
+
import { n as handlersGenerator, t as mswGenerator } from "./generators-BPJCs1x1.js";
|
|
2
2
|
export { handlersGenerator, mswGenerator };
|
package/dist/index.cjs
CHANGED
|
@@ -1,85 +1,74 @@
|
|
|
1
|
-
Object.
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
+
});
|
|
5
|
+
const require_components = require("./components-CLQ77DVn.cjs");
|
|
6
|
+
const require_generators = require("./generators-CrmMwWE4.cjs");
|
|
6
7
|
let _kubb_core = require("@kubb/core");
|
|
7
8
|
let _kubb_plugin_faker = require("@kubb/plugin-faker");
|
|
8
|
-
let _kubb_plugin_oas = require("@kubb/plugin-oas");
|
|
9
9
|
let _kubb_plugin_ts = require("@kubb/plugin-ts");
|
|
10
|
+
//#region src/resolvers/resolverMsw.ts
|
|
11
|
+
/**
|
|
12
|
+
* Naming convention resolver for MSW plugin.
|
|
13
|
+
*
|
|
14
|
+
* Provides default naming helpers using camelCase with a `handler` suffix.
|
|
15
|
+
*/
|
|
16
|
+
const resolverMsw = (0, _kubb_core.defineResolver)((_ctx) => ({
|
|
17
|
+
name: "default",
|
|
18
|
+
pluginName: "plugin-msw",
|
|
19
|
+
default(name, type) {
|
|
20
|
+
return require_components.camelCase(name, { isFile: type === "file" });
|
|
21
|
+
},
|
|
22
|
+
resolveName(name) {
|
|
23
|
+
return require_components.camelCase(name, { suffix: "handler" });
|
|
24
|
+
}
|
|
25
|
+
}));
|
|
26
|
+
//#endregion
|
|
10
27
|
//#region src/plugin.ts
|
|
11
28
|
const pluginMswName = "plugin-msw";
|
|
12
|
-
const pluginMsw = (0, _kubb_core.
|
|
29
|
+
const pluginMsw = (0, _kubb_core.definePlugin)((options) => {
|
|
13
30
|
const { output = {
|
|
14
31
|
path: "handlers",
|
|
15
32
|
barrelType: "named"
|
|
16
|
-
}, group, exclude = [], include, override = [], transformers = {}, handlers = false, parser = "data",
|
|
33
|
+
}, group, exclude = [], include, override = [], transformers = {}, handlers = false, parser = "data", baseURL, resolver: userResolver, transformer: userTransformer, generators: userGenerators = [] } = options;
|
|
34
|
+
const groupConfig = group ? {
|
|
35
|
+
...group,
|
|
36
|
+
name: group.name ? group.name : (ctx) => {
|
|
37
|
+
if (group.type === "path") return `${ctx.group.split("/")[1]}`;
|
|
38
|
+
return `${require_components.camelCase(ctx.group)}Controller`;
|
|
39
|
+
}
|
|
40
|
+
} : void 0;
|
|
17
41
|
return {
|
|
18
42
|
name: pluginMswName,
|
|
19
|
-
options
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const root = node_path.default.resolve(this.config.root, this.config.output.path);
|
|
32
|
-
if ((pathMode ?? (0, _kubb_core.getMode)(node_path.default.resolve(root, output.path))) === "single")
|
|
33
|
-
/**
|
|
34
|
-
* when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend
|
|
35
|
-
* Other plugins then need to call addOrAppend instead of just add from the fileManager class
|
|
36
|
-
*/
|
|
37
|
-
return node_path.default.resolve(root, output.path);
|
|
38
|
-
if (group && (options?.group?.path || options?.group?.tag)) {
|
|
39
|
-
const groupName = group?.name ? group.name : (ctx) => {
|
|
40
|
-
if (group?.type === "path") return `${ctx.group.split("/")[1]}`;
|
|
41
|
-
return `${require_components.camelCase(ctx.group)}Controller`;
|
|
42
|
-
};
|
|
43
|
-
return node_path.default.resolve(root, output.path, groupName({ group: group.type === "path" ? options.group.path : options.group.tag }), baseName);
|
|
44
|
-
}
|
|
45
|
-
return node_path.default.resolve(root, output.path, baseName);
|
|
46
|
-
},
|
|
47
|
-
resolveName(name, type) {
|
|
48
|
-
const resolvedName = require_components.camelCase(name, {
|
|
49
|
-
suffix: type ? "handler" : void 0,
|
|
50
|
-
isFile: type === "file"
|
|
51
|
-
});
|
|
52
|
-
if (type) return transformers?.name?.(resolvedName, type) || resolvedName;
|
|
53
|
-
return resolvedName;
|
|
54
|
-
},
|
|
55
|
-
async install() {
|
|
56
|
-
const root = node_path.default.resolve(this.config.root, this.config.output.path);
|
|
57
|
-
const mode = (0, _kubb_core.getMode)(node_path.default.resolve(root, output.path));
|
|
58
|
-
const oas = await this.getOas();
|
|
59
|
-
const files = await new _kubb_plugin_oas.OperationGenerator(this.plugin.options, {
|
|
60
|
-
fabric: this.fabric,
|
|
61
|
-
oas,
|
|
62
|
-
driver: this.driver,
|
|
63
|
-
events: this.events,
|
|
64
|
-
plugin: this.plugin,
|
|
65
|
-
contentType,
|
|
43
|
+
options,
|
|
44
|
+
dependencies: [_kubb_plugin_ts.pluginTsName, parser === "faker" ? _kubb_plugin_faker.pluginFakerName : void 0].filter(Boolean),
|
|
45
|
+
hooks: { "kubb:plugin:setup"(ctx) {
|
|
46
|
+
const resolver = userResolver ? {
|
|
47
|
+
...resolverMsw,
|
|
48
|
+
...userResolver
|
|
49
|
+
} : resolverMsw;
|
|
50
|
+
ctx.setOptions({
|
|
51
|
+
output,
|
|
52
|
+
parser,
|
|
53
|
+
baseURL,
|
|
54
|
+
group: groupConfig,
|
|
66
55
|
exclude,
|
|
67
56
|
include,
|
|
68
57
|
override,
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const barrelFiles = await (0, _kubb_core.getBarrelFiles)(this.fabric.files, {
|
|
73
|
-
type: output.barrelType ?? "named",
|
|
74
|
-
root,
|
|
75
|
-
output,
|
|
76
|
-
meta: { pluginName: this.plugin.name }
|
|
58
|
+
handlers,
|
|
59
|
+
transformers,
|
|
60
|
+
resolver
|
|
77
61
|
});
|
|
78
|
-
|
|
79
|
-
|
|
62
|
+
ctx.setResolver(resolver);
|
|
63
|
+
if (userTransformer) ctx.setTransformer(userTransformer);
|
|
64
|
+
ctx.addGenerator(require_generators.mswGenerator);
|
|
65
|
+
if (handlers) ctx.addGenerator(require_generators.handlersGenerator);
|
|
66
|
+
for (const gen of userGenerators) ctx.addGenerator(gen);
|
|
67
|
+
} }
|
|
80
68
|
};
|
|
81
69
|
});
|
|
82
70
|
//#endregion
|
|
71
|
+
exports.default = pluginMsw;
|
|
83
72
|
exports.pluginMsw = pluginMsw;
|
|
84
73
|
exports.pluginMswName = pluginMswName;
|
|
85
74
|
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["camelCase","camelCase","pluginTsName","pluginFakerName","mswGenerator","handlersGenerator"],"sources":["../src/resolvers/resolverMsw.ts","../src/plugin.ts"],"sourcesContent":["import { camelCase } from '@internals/utils'\nimport { defineResolver } from '@kubb/core'\nimport type { PluginMsw } from '../types.ts'\n\n/**\n * Naming convention resolver for MSW plugin.\n *\n * Provides default naming helpers using camelCase with a `handler` suffix.\n */\nexport const resolverMsw = defineResolver<PluginMsw>((_ctx) => ({\n name: 'default',\n pluginName: 'plugin-msw',\n default(name, type) {\n return camelCase(name, { isFile: type === 'file' })\n },\n resolveName(name) {\n return camelCase(name, { suffix: 'handler' })\n },\n}))\n","import { camelCase } from '@internals/utils'\nimport { definePlugin, type Group } from '@kubb/core'\nimport { pluginFakerName } from '@kubb/plugin-faker'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { handlersGenerator, mswGenerator } from './generators'\nimport { resolverMsw } from './resolvers/resolverMsw.ts'\nimport type { PluginMsw } from './types.ts'\n\nexport const pluginMswName = 'plugin-msw' satisfies PluginMsw['name']\n\nexport const pluginMsw = definePlugin<PluginMsw>((options) => {\n const {\n output = { path: 'handlers', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n transformers = {},\n handlers = false,\n parser = 'data',\n baseURL,\n resolver: userResolver,\n transformer: userTransformer,\n generators: userGenerators = [],\n } = options\n\n const groupConfig = group\n ? ({\n ...group,\n name: group.name\n ? group.name\n : (ctx: { group: string }) => {\n if (group.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Controller`\n },\n } satisfies Group)\n : undefined\n\n return {\n name: pluginMswName,\n options,\n dependencies: [pluginTsName, parser === 'faker' ? pluginFakerName : undefined].filter(Boolean),\n hooks: {\n 'kubb:plugin:setup'(ctx) {\n const resolver = userResolver ? { ...resolverMsw, ...userResolver } : resolverMsw\n\n ctx.setOptions({\n output,\n parser,\n baseURL,\n group: groupConfig,\n exclude,\n include,\n override,\n handlers,\n transformers,\n resolver,\n })\n ctx.setResolver(resolver)\n if (userTransformer) {\n ctx.setTransformer(userTransformer)\n }\n\n ctx.addGenerator(mswGenerator)\n if (handlers) {\n ctx.addGenerator(handlersGenerator)\n }\n for (const gen of userGenerators) {\n ctx.addGenerator(gen)\n }\n },\n },\n }\n})\n\nexport default pluginMsw\n"],"mappings":";;;;;;;;;;;;;;;AASA,MAAa,eAAA,GAAA,WAAA,iBAAyC,UAAU;CAC9D,MAAM;CACN,YAAY;CACZ,QAAQ,MAAM,MAAM;AAClB,SAAOA,mBAAAA,UAAU,MAAM,EAAE,QAAQ,SAAS,QAAQ,CAAC;;CAErD,YAAY,MAAM;AAChB,SAAOA,mBAAAA,UAAU,MAAM,EAAE,QAAQ,WAAW,CAAC;;CAEhD,EAAE;;;ACVH,MAAa,gBAAgB;AAE7B,MAAa,aAAA,GAAA,WAAA,eAAqC,YAAY;CAC5D,MAAM,EACJ,SAAS;EAAE,MAAM;EAAY,YAAY;EAAS,EAClD,OACA,UAAU,EAAE,EACZ,SACA,WAAW,EAAE,EACb,eAAe,EAAE,EACjB,WAAW,OACX,SAAS,QACT,SACA,UAAU,cACV,aAAa,iBACb,YAAY,iBAAiB,EAAE,KAC7B;CAEJ,MAAM,cAAc,QACf;EACC,GAAG;EACH,MAAM,MAAM,OACR,MAAM,QACL,QAA2B;AAC1B,OAAI,MAAM,SAAS,OACjB,QAAO,GAAG,IAAI,MAAM,MAAM,IAAI,CAAC;AAEjC,UAAO,GAAGC,mBAAAA,UAAU,IAAI,MAAM,CAAC;;EAEtC,GACD,KAAA;AAEJ,QAAO;EACL,MAAM;EACN;EACA,cAAc,CAACC,gBAAAA,cAAc,WAAW,UAAUC,mBAAAA,kBAAkB,KAAA,EAAU,CAAC,OAAO,QAAQ;EAC9F,OAAO,EACL,oBAAoB,KAAK;GACvB,MAAM,WAAW,eAAe;IAAE,GAAG;IAAa,GAAG;IAAc,GAAG;AAEtE,OAAI,WAAW;IACb;IACA;IACA;IACA,OAAO;IACP;IACA;IACA;IACA;IACA;IACA;IACD,CAAC;AACF,OAAI,YAAY,SAAS;AACzB,OAAI,gBACF,KAAI,eAAe,gBAAgB;AAGrC,OAAI,aAAaC,mBAAAA,aAAa;AAC9B,OAAI,SACF,KAAI,aAAaC,mBAAAA,kBAAkB;AAErC,QAAK,MAAM,OAAO,eAChB,KAAI,aAAa,IAAI;KAG1B;EACF;EACD"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
|
-
import { n as PluginMsw, t as Options } from "./types-
|
|
3
|
-
import * as _kubb_core0 from "@kubb/core";
|
|
2
|
+
import { n as PluginMsw, t as Options } from "./types-Dxu0KMQ4.js";
|
|
3
|
+
import * as _$_kubb_core0 from "@kubb/core";
|
|
4
4
|
|
|
5
5
|
//#region src/plugin.d.ts
|
|
6
6
|
declare const pluginMswName = "plugin-msw";
|
|
7
|
-
declare const pluginMsw: (options?: Options | undefined) => _kubb_core0.
|
|
7
|
+
declare const pluginMsw: (options?: Options | undefined) => _$_kubb_core0.Plugin<PluginMsw>;
|
|
8
8
|
//#endregion
|
|
9
|
-
export { type PluginMsw, pluginMsw, pluginMswName };
|
|
9
|
+
export { type PluginMsw, pluginMsw as default, pluginMsw, pluginMswName };
|
|
10
10
|
//# sourceMappingURL=index.d.ts.map
|