@kubb/plugin-faker 5.0.0-alpha.3 → 5.0.0-alpha.30
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/dist/{components-BkBIov4R.js → components-CRVgxJhG.js} +6 -1
- package/dist/components-CRVgxJhG.js.map +1 -0
- package/dist/{components-IdP8GXXX.cjs → components-Cmw1Lygb.cjs} +6 -1
- package/dist/components-Cmw1Lygb.cjs.map +1 -0
- package/dist/components.cjs +1 -1
- package/dist/components.d.ts +1 -1
- package/dist/components.js +1 -1
- package/dist/{fakerGenerator-BuATcfwD.js → fakerGenerator-BviedIXa.js} +8 -8
- package/dist/fakerGenerator-BviedIXa.js.map +1 -0
- package/dist/{fakerGenerator-CMgWxvK8.cjs → fakerGenerator-Cqs2pBO4.cjs} +7 -7
- package/dist/fakerGenerator-Cqs2pBO4.cjs.map +1 -0
- package/dist/generators.cjs +1 -1
- package/dist/generators.d.ts +3 -494
- package/dist/generators.js +1 -1
- package/dist/index.cjs +20 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +20 -11
- package/dist/index.js.map +1 -1
- package/dist/{types-WKLWEptG.d.ts → types--Cz1mk4t.d.ts} +12 -3
- package/package.json +6 -6
- package/src/generators/fakerGenerator.tsx +6 -6
- package/src/plugin.ts +14 -10
- package/src/types.ts +12 -2
- package/dist/components-BkBIov4R.js.map +0 -1
- package/dist/components-IdP8GXXX.cjs.map +0 -1
- package/dist/fakerGenerator-BuATcfwD.js.map +0 -1
- package/dist/fakerGenerator-CMgWxvK8.cjs.map +0 -1
package/dist/generators.d.ts
CHANGED
|
@@ -1,500 +1,9 @@
|
|
|
1
1
|
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
|
-
import { n as PluginFaker } from "./types
|
|
3
|
-
import
|
|
4
|
-
import { Fabric } from "@kubb/react-fabric";
|
|
5
|
-
import { FabricReactNode } from "@kubb/react-fabric/types";
|
|
6
|
-
import { HttpMethod, Oas, Operation, SchemaObject, contentType } from "@kubb/oas";
|
|
7
|
-
import { OperationNode, SchemaNode } from "@kubb/ast/types";
|
|
8
|
-
import { KubbFile } from "@kubb/fabric-core/types";
|
|
2
|
+
import { n as PluginFaker } from "./types--Cz1mk4t.js";
|
|
3
|
+
import * as _$_kubb_plugin_oas_generators0 from "@kubb/plugin-oas/generators";
|
|
9
4
|
|
|
10
|
-
//#region ../plugin-oas/src/types.d.ts
|
|
11
|
-
type GetOasOptions = {
|
|
12
|
-
validate?: boolean;
|
|
13
|
-
};
|
|
14
|
-
type Context$2 = {
|
|
15
|
-
getOas(options?: GetOasOptions): Promise<Oas>;
|
|
16
|
-
getBaseURL(): Promise<string | undefined>;
|
|
17
|
-
};
|
|
18
|
-
declare global {
|
|
19
|
-
namespace Kubb {
|
|
20
|
-
interface PluginContext extends Context$2 {}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* `propertyName` is the ref name + resolved with the nameResolver
|
|
25
|
-
* @example import { Pet } from './Pet'
|
|
26
|
-
*
|
|
27
|
-
* `originalName` is the original name used(in PascalCase), only used to remove duplicates
|
|
28
|
-
*
|
|
29
|
-
* `pluginName` can be used to override the current plugin being used, handy when you want to import a type/schema out of another plugin
|
|
30
|
-
* @example import a type(plugin-ts) for a mock file(swagger-faker)
|
|
31
|
-
*/
|
|
32
|
-
type Ref = {
|
|
33
|
-
propertyName: string;
|
|
34
|
-
originalName: string;
|
|
35
|
-
path: KubbFile.Path;
|
|
36
|
-
pluginName?: string;
|
|
37
|
-
};
|
|
38
|
-
type Refs = Record<string, Ref>;
|
|
39
|
-
type OperationSchema = {
|
|
40
|
-
/**
|
|
41
|
-
* Converted name, contains already `PathParams`, `QueryParams`, ...
|
|
42
|
-
*/
|
|
43
|
-
name: string;
|
|
44
|
-
schema: SchemaObject;
|
|
45
|
-
operation?: Operation;
|
|
46
|
-
/**
|
|
47
|
-
* OperationName in PascalCase, only being used in OperationGenerator
|
|
48
|
-
*/
|
|
49
|
-
operationName: string;
|
|
50
|
-
description?: string;
|
|
51
|
-
statusCode?: number;
|
|
52
|
-
keys?: string[];
|
|
53
|
-
keysToOmit?: string[];
|
|
54
|
-
withData?: boolean;
|
|
55
|
-
};
|
|
56
|
-
type OperationSchemas = {
|
|
57
|
-
pathParams?: OperationSchema & {
|
|
58
|
-
keysToOmit?: never;
|
|
59
|
-
};
|
|
60
|
-
queryParams?: OperationSchema & {
|
|
61
|
-
keysToOmit?: never;
|
|
62
|
-
};
|
|
63
|
-
headerParams?: OperationSchema & {
|
|
64
|
-
keysToOmit?: never;
|
|
65
|
-
};
|
|
66
|
-
request?: OperationSchema;
|
|
67
|
-
response: OperationSchema;
|
|
68
|
-
responses: Array<OperationSchema>;
|
|
69
|
-
statusCodes?: Array<OperationSchema>;
|
|
70
|
-
errors?: Array<OperationSchema>;
|
|
71
|
-
};
|
|
72
|
-
type ByTag = {
|
|
73
|
-
type: 'tag';
|
|
74
|
-
pattern: string | RegExp;
|
|
75
|
-
};
|
|
76
|
-
type ByOperationId = {
|
|
77
|
-
type: 'operationId';
|
|
78
|
-
pattern: string | RegExp;
|
|
79
|
-
};
|
|
80
|
-
type ByPath = {
|
|
81
|
-
type: 'path';
|
|
82
|
-
pattern: string | RegExp;
|
|
83
|
-
};
|
|
84
|
-
type ByMethod = {
|
|
85
|
-
type: 'method';
|
|
86
|
-
pattern: HttpMethod | RegExp;
|
|
87
|
-
};
|
|
88
|
-
type BySchemaName = {
|
|
89
|
-
type: 'schemaName';
|
|
90
|
-
pattern: string | RegExp;
|
|
91
|
-
};
|
|
92
|
-
type ByContentType = {
|
|
93
|
-
type: 'contentType';
|
|
94
|
-
pattern: string | RegExp;
|
|
95
|
-
};
|
|
96
|
-
type Exclude = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
|
|
97
|
-
type Include = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
|
|
98
|
-
type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName | ByContentType) & {
|
|
99
|
-
options: Partial<TOptions>;
|
|
100
|
-
};
|
|
101
|
-
//#endregion
|
|
102
|
-
//#region ../plugin-oas/src/OperationGenerator.d.ts
|
|
103
|
-
type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
104
|
-
fabric: Fabric;
|
|
105
|
-
oas: Oas;
|
|
106
|
-
exclude: Array<Exclude> | undefined;
|
|
107
|
-
include: Array<Include> | undefined;
|
|
108
|
-
override: Array<Override<TOptions>> | undefined;
|
|
109
|
-
contentType: contentType | undefined;
|
|
110
|
-
pluginManager: PluginManager;
|
|
111
|
-
events?: AsyncEventEmitter<KubbEvents>;
|
|
112
|
-
/**
|
|
113
|
-
* Current plugin
|
|
114
|
-
*/
|
|
115
|
-
plugin: Plugin<TPluginOptions>;
|
|
116
|
-
mode: KubbFile.Mode;
|
|
117
|
-
UNSTABLE_NAMING?: true;
|
|
118
|
-
};
|
|
119
|
-
declare class OperationGenerator<TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> {
|
|
120
|
-
#private;
|
|
121
|
-
constructor(options: TPluginOptions['resolvedOptions'], context: Context$1<TPluginOptions['resolvedOptions'], TPluginOptions>);
|
|
122
|
-
get options(): TPluginOptions['resolvedOptions'];
|
|
123
|
-
set options(options: TPluginOptions['resolvedOptions']);
|
|
124
|
-
get context(): Context$1<TPluginOptions['resolvedOptions'], TPluginOptions>;
|
|
125
|
-
getOptions(operation: Operation, method: HttpMethod): Partial<TPluginOptions['resolvedOptions']>;
|
|
126
|
-
getSchemas(operation: Operation, {
|
|
127
|
-
resolveName
|
|
128
|
-
}?: {
|
|
129
|
-
resolveName?: (name: string) => string;
|
|
130
|
-
}): OperationSchemas;
|
|
131
|
-
getOperations(): Promise<Array<{
|
|
132
|
-
path: string;
|
|
133
|
-
method: HttpMethod;
|
|
134
|
-
operation: Operation;
|
|
135
|
-
}>>;
|
|
136
|
-
build(...generators: Array<Generator<TPluginOptions, Version>>): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
137
|
-
}
|
|
138
|
-
//#endregion
|
|
139
|
-
//#region ../plugin-oas/src/SchemaMapper.d.ts
|
|
140
|
-
type SchemaKeywordMapper = {
|
|
141
|
-
object: {
|
|
142
|
-
keyword: 'object';
|
|
143
|
-
args: {
|
|
144
|
-
properties: {
|
|
145
|
-
[x: string]: Schema[];
|
|
146
|
-
};
|
|
147
|
-
additionalProperties: Schema[];
|
|
148
|
-
patternProperties?: Record<string, Schema[]>;
|
|
149
|
-
strict?: boolean;
|
|
150
|
-
};
|
|
151
|
-
};
|
|
152
|
-
url: {
|
|
153
|
-
keyword: 'url';
|
|
154
|
-
};
|
|
155
|
-
readOnly: {
|
|
156
|
-
keyword: 'readOnly';
|
|
157
|
-
};
|
|
158
|
-
writeOnly: {
|
|
159
|
-
keyword: 'writeOnly';
|
|
160
|
-
};
|
|
161
|
-
uuid: {
|
|
162
|
-
keyword: 'uuid';
|
|
163
|
-
};
|
|
164
|
-
email: {
|
|
165
|
-
keyword: 'email';
|
|
166
|
-
};
|
|
167
|
-
firstName: {
|
|
168
|
-
keyword: 'firstName';
|
|
169
|
-
};
|
|
170
|
-
lastName: {
|
|
171
|
-
keyword: 'lastName';
|
|
172
|
-
};
|
|
173
|
-
phone: {
|
|
174
|
-
keyword: 'phone';
|
|
175
|
-
};
|
|
176
|
-
password: {
|
|
177
|
-
keyword: 'password';
|
|
178
|
-
};
|
|
179
|
-
date: {
|
|
180
|
-
keyword: 'date';
|
|
181
|
-
args: {
|
|
182
|
-
type?: 'date' | 'string';
|
|
183
|
-
};
|
|
184
|
-
};
|
|
185
|
-
time: {
|
|
186
|
-
keyword: 'time';
|
|
187
|
-
args: {
|
|
188
|
-
type?: 'date' | 'string';
|
|
189
|
-
};
|
|
190
|
-
};
|
|
191
|
-
datetime: {
|
|
192
|
-
keyword: 'datetime';
|
|
193
|
-
args: {
|
|
194
|
-
offset?: boolean;
|
|
195
|
-
local?: boolean;
|
|
196
|
-
};
|
|
197
|
-
};
|
|
198
|
-
tuple: {
|
|
199
|
-
keyword: 'tuple';
|
|
200
|
-
args: {
|
|
201
|
-
items: Schema[];
|
|
202
|
-
min?: number;
|
|
203
|
-
max?: number;
|
|
204
|
-
rest?: Schema;
|
|
205
|
-
};
|
|
206
|
-
};
|
|
207
|
-
array: {
|
|
208
|
-
keyword: 'array';
|
|
209
|
-
args: {
|
|
210
|
-
items: Schema[];
|
|
211
|
-
min?: number;
|
|
212
|
-
max?: number;
|
|
213
|
-
unique?: boolean;
|
|
214
|
-
};
|
|
215
|
-
};
|
|
216
|
-
enum: {
|
|
217
|
-
keyword: 'enum';
|
|
218
|
-
args: {
|
|
219
|
-
name: string;
|
|
220
|
-
typeName: string;
|
|
221
|
-
asConst: boolean;
|
|
222
|
-
items: Array<{
|
|
223
|
-
name: string | number;
|
|
224
|
-
format: 'string' | 'number' | 'boolean';
|
|
225
|
-
value?: string | number | boolean;
|
|
226
|
-
}>;
|
|
227
|
-
};
|
|
228
|
-
};
|
|
229
|
-
and: {
|
|
230
|
-
keyword: 'and';
|
|
231
|
-
args: Schema[];
|
|
232
|
-
};
|
|
233
|
-
const: {
|
|
234
|
-
keyword: 'const';
|
|
235
|
-
args: {
|
|
236
|
-
name: string | number;
|
|
237
|
-
format: 'string' | 'number' | 'boolean';
|
|
238
|
-
value?: string | number | boolean;
|
|
239
|
-
};
|
|
240
|
-
};
|
|
241
|
-
union: {
|
|
242
|
-
keyword: 'union';
|
|
243
|
-
args: Schema[];
|
|
244
|
-
};
|
|
245
|
-
ref: {
|
|
246
|
-
keyword: 'ref';
|
|
247
|
-
args: {
|
|
248
|
-
name: string;
|
|
249
|
-
$ref: string;
|
|
250
|
-
/**
|
|
251
|
-
* Full qualified path.
|
|
252
|
-
*/
|
|
253
|
-
path: KubbFile.Path;
|
|
254
|
-
/**
|
|
255
|
-
* When true `File.Import` is used.
|
|
256
|
-
* When false a reference is used inside the current file.
|
|
257
|
-
*/
|
|
258
|
-
isImportable: boolean;
|
|
259
|
-
};
|
|
260
|
-
};
|
|
261
|
-
matches: {
|
|
262
|
-
keyword: 'matches';
|
|
263
|
-
args?: string;
|
|
264
|
-
};
|
|
265
|
-
boolean: {
|
|
266
|
-
keyword: 'boolean';
|
|
267
|
-
};
|
|
268
|
-
default: {
|
|
269
|
-
keyword: 'default';
|
|
270
|
-
args: string | number | boolean;
|
|
271
|
-
};
|
|
272
|
-
string: {
|
|
273
|
-
keyword: 'string';
|
|
274
|
-
};
|
|
275
|
-
integer: {
|
|
276
|
-
keyword: 'integer';
|
|
277
|
-
};
|
|
278
|
-
bigint: {
|
|
279
|
-
keyword: 'bigint';
|
|
280
|
-
};
|
|
281
|
-
number: {
|
|
282
|
-
keyword: 'number';
|
|
283
|
-
};
|
|
284
|
-
max: {
|
|
285
|
-
keyword: 'max';
|
|
286
|
-
args: number;
|
|
287
|
-
};
|
|
288
|
-
min: {
|
|
289
|
-
keyword: 'min';
|
|
290
|
-
args: number;
|
|
291
|
-
};
|
|
292
|
-
exclusiveMaximum: {
|
|
293
|
-
keyword: 'exclusiveMaximum';
|
|
294
|
-
args: number;
|
|
295
|
-
};
|
|
296
|
-
exclusiveMinimum: {
|
|
297
|
-
keyword: 'exclusiveMinimum';
|
|
298
|
-
args: number;
|
|
299
|
-
};
|
|
300
|
-
describe: {
|
|
301
|
-
keyword: 'describe';
|
|
302
|
-
args: string;
|
|
303
|
-
};
|
|
304
|
-
example: {
|
|
305
|
-
keyword: 'example';
|
|
306
|
-
args: string;
|
|
307
|
-
};
|
|
308
|
-
deprecated: {
|
|
309
|
-
keyword: 'deprecated';
|
|
310
|
-
};
|
|
311
|
-
optional: {
|
|
312
|
-
keyword: 'optional';
|
|
313
|
-
};
|
|
314
|
-
undefined: {
|
|
315
|
-
keyword: 'undefined';
|
|
316
|
-
};
|
|
317
|
-
nullish: {
|
|
318
|
-
keyword: 'nullish';
|
|
319
|
-
};
|
|
320
|
-
nullable: {
|
|
321
|
-
keyword: 'nullable';
|
|
322
|
-
};
|
|
323
|
-
null: {
|
|
324
|
-
keyword: 'null';
|
|
325
|
-
};
|
|
326
|
-
any: {
|
|
327
|
-
keyword: 'any';
|
|
328
|
-
};
|
|
329
|
-
unknown: {
|
|
330
|
-
keyword: 'unknown';
|
|
331
|
-
};
|
|
332
|
-
void: {
|
|
333
|
-
keyword: 'void';
|
|
334
|
-
};
|
|
335
|
-
blob: {
|
|
336
|
-
keyword: 'blob';
|
|
337
|
-
};
|
|
338
|
-
schema: {
|
|
339
|
-
keyword: 'schema';
|
|
340
|
-
args: {
|
|
341
|
-
type: 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'object';
|
|
342
|
-
format?: string;
|
|
343
|
-
};
|
|
344
|
-
};
|
|
345
|
-
name: {
|
|
346
|
-
keyword: 'name';
|
|
347
|
-
args: string;
|
|
348
|
-
};
|
|
349
|
-
catchall: {
|
|
350
|
-
keyword: 'catchall';
|
|
351
|
-
};
|
|
352
|
-
interface: {
|
|
353
|
-
keyword: 'interface';
|
|
354
|
-
};
|
|
355
|
-
};
|
|
356
|
-
type Schema = {
|
|
357
|
-
keyword: string;
|
|
358
|
-
} | SchemaKeywordMapper[keyof SchemaKeywordMapper];
|
|
359
|
-
//#endregion
|
|
360
|
-
//#region ../plugin-oas/src/SchemaGenerator.d.ts
|
|
361
|
-
type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
362
|
-
fabric: Fabric;
|
|
363
|
-
oas: Oas;
|
|
364
|
-
pluginManager: PluginManager;
|
|
365
|
-
events?: AsyncEventEmitter<KubbEvents>;
|
|
366
|
-
/**
|
|
367
|
-
* Current plugin
|
|
368
|
-
*/
|
|
369
|
-
plugin: Plugin<TPluginOptions>;
|
|
370
|
-
mode: KubbFile.Mode;
|
|
371
|
-
include?: Array<'schemas' | 'responses' | 'requestBodies'>;
|
|
372
|
-
override: Array<Override<TOptions>> | undefined;
|
|
373
|
-
contentType?: contentType;
|
|
374
|
-
output?: string;
|
|
375
|
-
};
|
|
376
|
-
type SchemaGeneratorOptions = {
|
|
377
|
-
dateType: false | 'string' | 'stringOffset' | 'stringLocal' | 'date';
|
|
378
|
-
integerType?: 'number' | 'bigint';
|
|
379
|
-
unknownType: 'any' | 'unknown' | 'void';
|
|
380
|
-
emptySchemaType: 'any' | 'unknown' | 'void';
|
|
381
|
-
enumType?: 'enum' | 'asConst' | 'asPascalConst' | 'constEnum' | 'literal' | 'inlineLiteral';
|
|
382
|
-
enumSuffix?: string;
|
|
383
|
-
/**
|
|
384
|
-
* @deprecated Will be removed in v5. Use `collisionDetection: true` instead to prevent enum name collisions.
|
|
385
|
-
* When `collisionDetection` is enabled, the rootName-based approach eliminates the need for numeric suffixes.
|
|
386
|
-
* @internal
|
|
387
|
-
*/
|
|
388
|
-
usedEnumNames?: Record<string, number>;
|
|
389
|
-
mapper?: Record<string, string>;
|
|
390
|
-
typed?: boolean;
|
|
391
|
-
transformers: {
|
|
392
|
-
/**
|
|
393
|
-
* Customize the names based on the type that is provided by the plugin.
|
|
394
|
-
*/
|
|
395
|
-
name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
396
|
-
/**
|
|
397
|
-
* Receive schema and name(propertyName) and return Schema array.
|
|
398
|
-
* Return `undefined` to fall through to default schema generation.
|
|
399
|
-
* @beta
|
|
400
|
-
*/
|
|
401
|
-
schema?: (schemaProps: SchemaProps$1, defaultSchemas: Schema[]) => Array<Schema> | undefined;
|
|
402
|
-
};
|
|
403
|
-
};
|
|
404
|
-
type SchemaProps$1 = {
|
|
405
|
-
schema: SchemaObject | null;
|
|
406
|
-
name: string | null;
|
|
407
|
-
parentName: string | null;
|
|
408
|
-
rootName?: string | null;
|
|
409
|
-
};
|
|
410
|
-
declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> {
|
|
411
|
-
#private;
|
|
412
|
-
constructor(options: TOptions, context: Context<TOptions, TPluginOptions>);
|
|
413
|
-
get options(): TOptions;
|
|
414
|
-
set options(options: TOptions);
|
|
415
|
-
get context(): Context<TOptions, TPluginOptions>;
|
|
416
|
-
refs: Refs;
|
|
417
|
-
/**
|
|
418
|
-
* Creates a type node from a given schema.
|
|
419
|
-
* Delegates to getBaseTypeFromSchema internally and
|
|
420
|
-
* optionally adds a union with null.
|
|
421
|
-
*/
|
|
422
|
-
parse(props: SchemaProps$1): Schema[];
|
|
423
|
-
static deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
|
|
424
|
-
static find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
425
|
-
static combineObjects(tree: Schema[] | undefined): Schema[];
|
|
426
|
-
build(...generators: Array<Generator<TPluginOptions, Version>>): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
427
|
-
}
|
|
428
|
-
//#endregion
|
|
429
|
-
//#region ../plugin-oas/src/generators/createGenerator.d.ts
|
|
430
|
-
type CoreGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version> = {
|
|
431
|
-
name: string;
|
|
432
|
-
type: 'core';
|
|
433
|
-
version: TVersion;
|
|
434
|
-
operations: (props: OperationsProps<TOptions, TVersion>) => Promise<KubbFile.File[]>;
|
|
435
|
-
operation: (props: OperationProps<TOptions, TVersion>) => Promise<KubbFile.File[]>;
|
|
436
|
-
schema: (props: SchemaProps<TOptions, TVersion>) => Promise<KubbFile.File[]>;
|
|
437
|
-
};
|
|
438
|
-
//#endregion
|
|
439
|
-
//#region ../plugin-oas/src/generators/types.d.ts
|
|
440
|
-
type Version = '1' | '2';
|
|
441
|
-
type OperationsV1Props<TOptions extends PluginFactoryOptions> = {
|
|
442
|
-
config: Config;
|
|
443
|
-
generator: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
444
|
-
plugin: Plugin<TOptions>;
|
|
445
|
-
operations: Array<Operation>;
|
|
446
|
-
};
|
|
447
|
-
type OperationsV2Props<TOptions extends PluginFactoryOptions> = {
|
|
448
|
-
config: Config;
|
|
449
|
-
adapter: Adapter;
|
|
450
|
-
options: Plugin<TOptions>['options'];
|
|
451
|
-
nodes: Array<OperationNode>;
|
|
452
|
-
};
|
|
453
|
-
type OperationV1Props<TOptions extends PluginFactoryOptions> = {
|
|
454
|
-
config: Config;
|
|
455
|
-
generator: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
456
|
-
plugin: Plugin<TOptions>;
|
|
457
|
-
operation: Operation;
|
|
458
|
-
};
|
|
459
|
-
type OperationV2Props<TOptions extends PluginFactoryOptions> = {
|
|
460
|
-
config: Config;
|
|
461
|
-
adapter: Adapter;
|
|
462
|
-
options: Plugin<TOptions>['options'];
|
|
463
|
-
node: OperationNode;
|
|
464
|
-
};
|
|
465
|
-
type OperationsProps<TOptions extends PluginFactoryOptions, TVersion extends Version = '1'> = TVersion extends '2' ? OperationsV2Props<TOptions> : OperationsV1Props<TOptions>;
|
|
466
|
-
type OperationProps<TOptions extends PluginFactoryOptions, TVersion extends Version = '1'> = TVersion extends '2' ? OperationV2Props<TOptions> : OperationV1Props<TOptions>;
|
|
467
|
-
type SchemaV1Props<TOptions extends PluginFactoryOptions> = {
|
|
468
|
-
config: Config;
|
|
469
|
-
generator: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>;
|
|
470
|
-
plugin: Plugin<TOptions>;
|
|
471
|
-
schema: {
|
|
472
|
-
name: string;
|
|
473
|
-
tree: Array<Schema>;
|
|
474
|
-
value: SchemaObject;
|
|
475
|
-
};
|
|
476
|
-
};
|
|
477
|
-
type SchemaV2Props<TOptions extends PluginFactoryOptions> = {
|
|
478
|
-
config: Config;
|
|
479
|
-
options: Plugin<TOptions>['options'];
|
|
480
|
-
node: SchemaNode;
|
|
481
|
-
adapter: Adapter;
|
|
482
|
-
};
|
|
483
|
-
type SchemaProps<TOptions extends PluginFactoryOptions, TVersion extends Version = '1'> = TVersion extends '2' ? SchemaV2Props<TOptions> : SchemaV1Props<TOptions>;
|
|
484
|
-
type Generator<TOptions extends PluginFactoryOptions, TVersion extends Version = Version> = CoreGenerator<TOptions, TVersion> | ReactGenerator<TOptions, TVersion>;
|
|
485
|
-
//#endregion
|
|
486
|
-
//#region ../plugin-oas/src/generators/createReactGenerator.d.ts
|
|
487
|
-
type ReactGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version> = {
|
|
488
|
-
name: string;
|
|
489
|
-
type: 'react';
|
|
490
|
-
version: TVersion;
|
|
491
|
-
Operations: (props: OperationsProps<TOptions, TVersion>) => FabricReactNode;
|
|
492
|
-
Operation: (props: OperationProps<TOptions, TVersion>) => FabricReactNode;
|
|
493
|
-
Schema: (props: SchemaProps<TOptions, TVersion>) => FabricReactNode;
|
|
494
|
-
};
|
|
495
|
-
//#endregion
|
|
496
5
|
//#region src/generators/fakerGenerator.d.ts
|
|
497
|
-
declare const fakerGenerator: ReactGenerator<PluginFaker
|
|
6
|
+
declare const fakerGenerator: _$_kubb_plugin_oas_generators0.ReactGenerator<PluginFaker>;
|
|
498
7
|
//#endregion
|
|
499
8
|
export { fakerGenerator };
|
|
500
9
|
//# sourceMappingURL=generators.d.ts.map
|
package/dist/generators.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as fakerGenerator } from "./fakerGenerator-
|
|
1
|
+
import { t as fakerGenerator } from "./fakerGenerator-BviedIXa.js";
|
|
2
2
|
export { fakerGenerator };
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_components = require("./components-
|
|
3
|
-
const require_fakerGenerator = require("./fakerGenerator-
|
|
2
|
+
const require_components = require("./components-Cmw1Lygb.cjs");
|
|
3
|
+
const require_fakerGenerator = require("./fakerGenerator-Cqs2pBO4.cjs");
|
|
4
4
|
let node_path = require("node:path");
|
|
5
5
|
node_path = require_components.__toESM(node_path);
|
|
6
6
|
let _kubb_core = require("@kubb/core");
|
|
@@ -25,9 +25,12 @@ function toCamelOrPascal(text, pascal) {
|
|
|
25
25
|
* Splits `text` on `.` and applies `transformPart` to each segment.
|
|
26
26
|
* The last segment receives `isLast = true`, all earlier segments receive `false`.
|
|
27
27
|
* Segments are joined with `/` to form a file path.
|
|
28
|
+
*
|
|
29
|
+
* Only splits on dots followed by a letter so that version numbers
|
|
30
|
+
* embedded in operationIds (e.g. `v2025.0`) are kept intact.
|
|
28
31
|
*/
|
|
29
32
|
function applyToFileParts(text, transformPart) {
|
|
30
|
-
const parts = text.split(
|
|
33
|
+
const parts = text.split(/\.(?=[a-zA-Z])/);
|
|
31
34
|
return parts.map((part, i) => transformPart(part, i === parts.length - 1)).join("/");
|
|
32
35
|
}
|
|
33
36
|
/**
|
|
@@ -46,15 +49,19 @@ function camelCase(text, { isFile, prefix = "", suffix = "" } = {}) {
|
|
|
46
49
|
return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false);
|
|
47
50
|
}
|
|
48
51
|
//#endregion
|
|
52
|
+
//#region package.json
|
|
53
|
+
var version = "5.0.0-alpha.30";
|
|
54
|
+
//#endregion
|
|
49
55
|
//#region src/plugin.ts
|
|
50
56
|
const pluginFakerName = "plugin-faker";
|
|
51
|
-
const pluginFaker = (0, _kubb_core.
|
|
57
|
+
const pluginFaker = (0, _kubb_core.createPlugin)((options) => {
|
|
52
58
|
const { output = {
|
|
53
59
|
path: "mocks",
|
|
54
60
|
barrelType: "named"
|
|
55
61
|
}, seed, group, exclude = [], include, override = [], transformers = {}, mapper = {}, unknownType = "any", emptySchemaType = unknownType, dateType = "string", integerType = "number", dateParser = "faker", generators = [require_fakerGenerator.fakerGenerator].filter(Boolean), regexGenerator = "faker", paramsCasing, contentType } = options;
|
|
56
62
|
return {
|
|
57
63
|
name: pluginFakerName,
|
|
64
|
+
version,
|
|
58
65
|
options: {
|
|
59
66
|
output,
|
|
60
67
|
transformers,
|
|
@@ -66,6 +73,8 @@ const pluginFaker = (0, _kubb_core.definePlugin)((options) => {
|
|
|
66
73
|
dateParser,
|
|
67
74
|
mapper,
|
|
68
75
|
override,
|
|
76
|
+
exclude,
|
|
77
|
+
include,
|
|
69
78
|
regexGenerator,
|
|
70
79
|
paramsCasing,
|
|
71
80
|
group,
|
|
@@ -73,8 +82,8 @@ const pluginFaker = (0, _kubb_core.definePlugin)((options) => {
|
|
|
73
82
|
},
|
|
74
83
|
pre: [_kubb_plugin_oas.pluginOasName, _kubb_plugin_ts.pluginTsName],
|
|
75
84
|
resolvePath(baseName, pathMode, options) {
|
|
76
|
-
const root =
|
|
77
|
-
if ((pathMode ??
|
|
85
|
+
const root = this.root;
|
|
86
|
+
if ((pathMode ?? this.getMode(output)) === "single")
|
|
78
87
|
/**
|
|
79
88
|
* when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend
|
|
80
89
|
* Other plugins then need to call addOrAppend instead of just add from the fileManager class
|
|
@@ -97,14 +106,14 @@ const pluginFaker = (0, _kubb_core.definePlugin)((options) => {
|
|
|
97
106
|
if (type) return transformers?.name?.(resolvedName, type) || resolvedName;
|
|
98
107
|
return resolvedName;
|
|
99
108
|
},
|
|
100
|
-
async
|
|
101
|
-
const root =
|
|
102
|
-
const mode =
|
|
109
|
+
async buildStart() {
|
|
110
|
+
const root = this.root;
|
|
111
|
+
const mode = this.getMode(output);
|
|
103
112
|
const oas = await this.getOas();
|
|
104
113
|
const schemaFiles = await new _kubb_plugin_oas.SchemaGenerator(this.plugin.options, {
|
|
105
114
|
fabric: this.fabric,
|
|
106
115
|
oas,
|
|
107
|
-
|
|
116
|
+
driver: this.driver,
|
|
108
117
|
events: this.events,
|
|
109
118
|
plugin: this.plugin,
|
|
110
119
|
contentType,
|
|
@@ -117,7 +126,7 @@ const pluginFaker = (0, _kubb_core.definePlugin)((options) => {
|
|
|
117
126
|
const operationFiles = await new _kubb_plugin_oas.OperationGenerator(this.plugin.options, {
|
|
118
127
|
fabric: this.fabric,
|
|
119
128
|
oas,
|
|
120
|
-
|
|
129
|
+
driver: this.driver,
|
|
121
130
|
events: this.events,
|
|
122
131
|
plugin: this.plugin,
|
|
123
132
|
contentType,
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["fakerGenerator","pluginOasName","pluginTsName","path","SchemaGenerator","OperationGenerator"],"sources":["../../../internals/utils/src/casing.ts","../src/plugin.ts"],"sourcesContent":["type Options = {\n /** When `true`, dot-separated segments are split on `.` and joined with `/` after casing. */\n isFile?: boolean\n /** Text prepended before casing is applied. */\n prefix?: string\n /** Text appended before casing is applied. */\n suffix?: string\n}\n\n/**\n * Shared implementation for camelCase and PascalCase conversion.\n * Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)\n * and capitalizes each word according to `pascal`.\n *\n * When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.\n */\nfunction toCamelOrPascal(text: string, pascal: boolean): string {\n const normalized = text\n .trim()\n .replace(/([a-z\\d])([A-Z])/g, '$1 $2')\n .replace(/([A-Z]+)([A-Z][a-z])/g, '$1 $2')\n .replace(/(\\d)([a-z])/g, '$1 $2')\n\n const words = normalized.split(/[\\s\\-_./\\\\:]+/).filter(Boolean)\n\n return words\n .map((word, i) => {\n const allUpper = word.length > 1 && word === word.toUpperCase()\n if (allUpper) return word\n if (i === 0 && !pascal) return word.charAt(0).toLowerCase() + word.slice(1)\n return word.charAt(0).toUpperCase() + word.slice(1)\n })\n .join('')\n .replace(/[^a-zA-Z0-9]/g, '')\n}\n\n/**\n * Splits `text` on `.` and applies `transformPart` to each segment.\n * The last segment receives `isLast = true`, all earlier segments receive `false`.\n * Segments are joined with `/` to form a file path.\n */\nfunction applyToFileParts(text: string, transformPart: (part: string, isLast: boolean) => string): string {\n const parts = text.split('.')\n return parts.map((part, i) => transformPart(part, i === parts.length - 1)).join('/')\n}\n\n/**\n * Converts `text` to camelCase.\n * When `isFile` is `true`, dot-separated segments are each cased independently and joined with `/`.\n *\n * @example\n * camelCase('hello-world') // 'helloWorld'\n * camelCase('pet.petId', { isFile: true }) // 'pet/petId'\n */\nexport function camelCase(text: string, { isFile, prefix = '', suffix = '' }: Options = {}): string {\n if (isFile) {\n return applyToFileParts(text, (part, isLast) => camelCase(part, isLast ? { prefix, suffix } : {}))\n }\n\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false)\n}\n\n/**\n * Converts `text` to PascalCase.\n * When `isFile` is `true`, the last dot-separated segment is PascalCased and earlier segments are camelCased.\n *\n * @example\n * pascalCase('hello-world') // 'HelloWorld'\n * pascalCase('pet.petId', { isFile: true }) // 'pet/PetId'\n */\nexport function pascalCase(text: string, { isFile, prefix = '', suffix = '' }: Options = {}): string {\n if (isFile) {\n return applyToFileParts(text, (part, isLast) => (isLast ? pascalCase(part, { prefix, suffix }) : camelCase(part)))\n }\n\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true)\n}\n\n/**\n * Converts `text` to snake_case.\n *\n * @example\n * snakeCase('helloWorld') // 'hello_world'\n * snakeCase('Hello-World') // 'hello_world'\n */\nexport function snakeCase(text: string, { prefix = '', suffix = '' }: Omit<Options, 'isFile'> = {}): string {\n const processed = `${prefix} ${text} ${suffix}`.trim()\n return processed\n .replace(/([a-z])([A-Z])/g, '$1_$2')\n .replace(/[\\s\\-.]+/g, '_')\n .replace(/[^a-zA-Z0-9_]/g, '')\n .toLowerCase()\n .split('_')\n .filter(Boolean)\n .join('_')\n}\n\n/**\n * Converts `text` to SCREAMING_SNAKE_CASE.\n *\n * @example\n * screamingSnakeCase('helloWorld') // 'HELLO_WORLD'\n */\nexport function screamingSnakeCase(text: string, { prefix = '', suffix = '' }: Omit<Options, 'isFile'> = {}): string {\n return snakeCase(text, { prefix, suffix }).toUpperCase()\n}\n","import path from 'node:path'\nimport { camelCase } from '@internals/utils'\nimport { definePlugin, type Group, getBarrelFiles, getMode } from '@kubb/core'\nimport { OperationGenerator, pluginOasName, SchemaGenerator } from '@kubb/plugin-oas'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { fakerGenerator } from './generators/fakerGenerator.tsx'\nimport type { PluginFaker } from './types.ts'\n\nexport const pluginFakerName = 'plugin-faker' satisfies PluginFaker['name']\n\nexport const pluginFaker = definePlugin<PluginFaker>((options) => {\n const {\n output = { path: 'mocks', barrelType: 'named' },\n seed,\n group,\n exclude = [],\n include,\n override = [],\n transformers = {},\n mapper = {},\n unknownType = 'any',\n emptySchemaType = unknownType,\n dateType = 'string',\n integerType = 'number',\n dateParser = 'faker',\n generators = [fakerGenerator].filter(Boolean),\n regexGenerator = 'faker',\n paramsCasing,\n contentType,\n } = options\n\n // @deprecated Will be removed in v5 when collisionDetection defaults to true\n const usedEnumNames = {}\n\n return {\n name: pluginFakerName,\n options: {\n output,\n transformers,\n seed,\n dateType,\n integerType,\n unknownType,\n emptySchemaType,\n dateParser,\n mapper,\n override,\n regexGenerator,\n paramsCasing,\n group,\n usedEnumNames,\n },\n pre: [pluginOasName, pluginTsName],\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Controller`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n const resolvedName = camelCase(name, {\n prefix: type ? 'create' : undefined,\n isFile: type === 'file',\n })\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async install() {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = getMode(path.resolve(root, output.path))\n const oas = await this.getOas()\n\n const schemaGenerator = new SchemaGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\n events: this.events,\n plugin: this.plugin,\n contentType,\n include: undefined,\n override,\n mode,\n output: output.path,\n })\n\n const schemaFiles = await schemaGenerator.build(...generators)\n await this.upsertFile(...schemaFiles)\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\n events: this.events,\n plugin: this.plugin,\n contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const operationFiles = await operationGenerator.build(...generators)\n await this.upsertFile(...operationFiles)\n\n const barrelFiles = await getBarrelFiles(this.fabric.files, {\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginName: this.plugin.name,\n },\n })\n\n await this.upsertFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;;;;;AAgBA,SAAS,gBAAgB,MAAc,QAAyB;AAS9D,QARmB,KAChB,MAAM,CACN,QAAQ,qBAAqB,QAAQ,CACrC,QAAQ,yBAAyB,QAAQ,CACzC,QAAQ,gBAAgB,QAAQ,CAEV,MAAM,gBAAgB,CAAC,OAAO,QAAQ,CAG5D,KAAK,MAAM,MAAM;AAEhB,MADiB,KAAK,SAAS,KAAK,SAAS,KAAK,aAAa,CACjD,QAAO;AACrB,MAAI,MAAM,KAAK,CAAC,OAAQ,QAAO,KAAK,OAAO,EAAE,CAAC,aAAa,GAAG,KAAK,MAAM,EAAE;AAC3E,SAAO,KAAK,OAAO,EAAE,CAAC,aAAa,GAAG,KAAK,MAAM,EAAE;GACnD,CACD,KAAK,GAAG,CACR,QAAQ,iBAAiB,GAAG;;;;;;;AAQjC,SAAS,iBAAiB,MAAc,eAAkE;CACxG,MAAM,QAAQ,KA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pE,SAAM,KAAK,WAAW,GAAG,eAAe;GAExC,MAAM,cAAc,OAAA,GAAA,WAAA,gBAAqB,KAAK,OAAO,OAAO;IAC1D,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,YAAY,KAAK,OAAO,MACzB;IACF,CAAC;AAEF,SAAM,KAAK,WAAW,GAAG,YAAY;;EAExC;EACD"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["fakerGenerator","pluginOasName","pluginTsName","path","SchemaGenerator","OperationGenerator"],"sources":["../../../internals/utils/src/casing.ts","../package.json","../src/plugin.ts"],"sourcesContent":["type Options = {\n /**\n * When `true`, dot-separated segments are split on `.` and joined with `/` after casing.\n */\n isFile?: boolean\n /**\n * Text prepended before casing is applied.\n */\n prefix?: string\n /**\n * Text appended before casing is applied.\n */\n suffix?: string\n}\n\n/**\n * Shared implementation for camelCase and PascalCase conversion.\n * Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)\n * and capitalizes each word according to `pascal`.\n *\n * When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.\n */\nfunction toCamelOrPascal(text: string, pascal: boolean): string {\n const normalized = text\n .trim()\n .replace(/([a-z\\d])([A-Z])/g, '$1 $2')\n .replace(/([A-Z]+)([A-Z][a-z])/g, '$1 $2')\n .replace(/(\\d)([a-z])/g, '$1 $2')\n\n const words = normalized.split(/[\\s\\-_./\\\\:]+/).filter(Boolean)\n\n return words\n .map((word, i) => {\n const allUpper = word.length > 1 && word === word.toUpperCase()\n if (allUpper) return word\n if (i === 0 && !pascal) return word.charAt(0).toLowerCase() + word.slice(1)\n return word.charAt(0).toUpperCase() + word.slice(1)\n })\n .join('')\n .replace(/[^a-zA-Z0-9]/g, '')\n}\n\n/**\n * Splits `text` on `.` and applies `transformPart` to each segment.\n * The last segment receives `isLast = true`, all earlier segments receive `false`.\n * Segments are joined with `/` to form a file path.\n *\n * Only splits on dots followed by a letter so that version numbers\n * embedded in operationIds (e.g. `v2025.0`) are kept intact.\n */\nfunction applyToFileParts(text: string, transformPart: (part: string, isLast: boolean) => string): string {\n const parts = text.split(/\\.(?=[a-zA-Z])/)\n return parts.map((part, i) => transformPart(part, i === parts.length - 1)).join('/')\n}\n\n/**\n * Converts `text` to camelCase.\n * When `isFile` is `true`, dot-separated segments are each cased independently and joined with `/`.\n *\n * @example\n * camelCase('hello-world') // 'helloWorld'\n * camelCase('pet.petId', { isFile: true }) // 'pet/petId'\n */\nexport function camelCase(text: string, { isFile, prefix = '', suffix = '' }: Options = {}): string {\n if (isFile) {\n return applyToFileParts(text, (part, isLast) => camelCase(part, isLast ? { prefix, suffix } : {}))\n }\n\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false)\n}\n\n/**\n * Converts `text` to PascalCase.\n * When `isFile` is `true`, the last dot-separated segment is PascalCased and earlier segments are camelCased.\n *\n * @example\n * pascalCase('hello-world') // 'HelloWorld'\n * pascalCase('pet.petId', { isFile: true }) // 'pet/PetId'\n */\nexport function pascalCase(text: string, { isFile, prefix = '', suffix = '' }: Options = {}): string {\n if (isFile) {\n return applyToFileParts(text, (part, isLast) => (isLast ? pascalCase(part, { prefix, suffix }) : camelCase(part)))\n }\n\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true)\n}\n\n/**\n * Converts `text` to snake_case.\n *\n * @example\n * snakeCase('helloWorld') // 'hello_world'\n * snakeCase('Hello-World') // 'hello_world'\n */\nexport function snakeCase(text: string, { prefix = '', suffix = '' }: Omit<Options, 'isFile'> = {}): string {\n const processed = `${prefix} ${text} ${suffix}`.trim()\n return processed\n .replace(/([a-z])([A-Z])/g, '$1_$2')\n .replace(/[\\s\\-.]+/g, '_')\n .replace(/[^a-zA-Z0-9_]/g, '')\n .toLowerCase()\n .split('_')\n .filter(Boolean)\n .join('_')\n}\n\n/**\n * Converts `text` to SCREAMING_SNAKE_CASE.\n *\n * @example\n * screamingSnakeCase('helloWorld') // 'HELLO_WORLD'\n */\nexport function screamingSnakeCase(text: string, { prefix = '', suffix = '' }: Omit<Options, 'isFile'> = {}): string {\n return snakeCase(text, { prefix, suffix }).toUpperCase()\n}\n","","import path from 'node:path'\nimport { camelCase } from '@internals/utils'\nimport { createPlugin, getBarrelFiles, type UserGroup } from '@kubb/core'\nimport { OperationGenerator, pluginOasName, SchemaGenerator } from '@kubb/plugin-oas'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { version } from '../package.json'\nimport { fakerGenerator } from './generators/fakerGenerator.tsx'\nimport type { PluginFaker } from './types.ts'\n\nexport const pluginFakerName = 'plugin-faker' satisfies PluginFaker['name']\n\nexport const pluginFaker = createPlugin<PluginFaker>((options) => {\n const {\n output = { path: 'mocks', barrelType: 'named' },\n seed,\n group,\n exclude = [],\n include,\n override = [],\n transformers = {},\n mapper = {},\n unknownType = 'any',\n emptySchemaType = unknownType,\n dateType = 'string',\n integerType = 'number',\n dateParser = 'faker',\n generators = [fakerGenerator].filter(Boolean),\n regexGenerator = 'faker',\n paramsCasing,\n contentType,\n } = options\n\n // @deprecated Will be removed in v5 when collisionDetection defaults to true\n const usedEnumNames = {}\n\n return {\n name: pluginFakerName,\n version,\n options: {\n output,\n transformers,\n seed,\n dateType,\n integerType,\n unknownType,\n emptySchemaType,\n dateParser,\n mapper,\n override,\n exclude,\n include,\n regexGenerator,\n paramsCasing,\n group,\n usedEnumNames,\n },\n pre: [pluginOasName, pluginTsName],\n resolvePath(baseName, pathMode, options) {\n const root = this.root\n const mode = pathMode ?? this.getMode(output)\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: UserGroup['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Controller`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n const resolvedName = camelCase(name, {\n prefix: type ? 'create' : undefined,\n isFile: type === 'file',\n })\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async buildStart() {\n const root = this.root\n const mode = this.getMode(output)\n const oas = await this.getOas()\n\n const schemaGenerator = new SchemaGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n driver: this.driver,\n events: this.events,\n plugin: this.plugin,\n contentType,\n include: undefined,\n override,\n mode,\n output: output.path,\n })\n\n const schemaFiles = await schemaGenerator.build(...generators)\n await this.upsertFile(...schemaFiles)\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n driver: this.driver,\n events: this.events,\n plugin: this.plugin,\n contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const operationFiles = await operationGenerator.build(...generators)\n await this.upsertFile(...operationFiles)\n\n const barrelFiles = await getBarrelFiles(this.fabric.files, {\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginName: this.plugin.name,\n },\n })\n\n await this.upsertFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;;;;;AAsBA,SAAS,gBAAgB,MAAc,QAAyB;AAS9D,QARmB,KAChB,MAAM,CACN,QAAQ,qBAAqB,QAAQ,CACrC,QAAQ,yBAAyB,QAAQ,CACzC,QAAQ,gBAAgB,QAAQ,CAEV,MAAM,gBAAgB,CAAC,OAAO,QAAQ,CAG5D,KAAK,MAAM,MAAM;AAEhB,MADiB,KAAK,SAAS,KAAK,SAAS,KAAK,aAAa,CACjD,QAAO;AACrB,MAAI,MAAM,KAAK,CAAC,OAAQ,QAAO,KAAK,OAAO,EAAE,CAAC,aAAa,GAAG,KAAK,MAAM,EAAE;AAC3E,SAAO,KAAK,OAAO,EAAE,CAAC,aAAa,GAAG,KAAK,MAAM,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,WAAA,gBAAqB,KAAK,OAAO,OAAO;IAC1D,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,YAAY,KAAK,OAAO,MACzB;IACF,CAAC;AAEF,SAAM,KAAK,WAAW,GAAG,YAAY;;EAExC;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 PluginFaker, t as Options } from "./types
|
|
3
|
-
import * as _kubb_core0 from "@kubb/core";
|
|
2
|
+
import { n as PluginFaker, t as Options } from "./types--Cz1mk4t.js";
|
|
3
|
+
import * as _$_kubb_core0 from "@kubb/core";
|
|
4
4
|
|
|
5
5
|
//#region src/plugin.d.ts
|
|
6
6
|
declare const pluginFakerName = "plugin-faker";
|
|
7
|
-
declare const pluginFaker: (options?: Options | undefined) => _kubb_core0.UserPluginWithLifeCycle<PluginFaker>;
|
|
7
|
+
declare const pluginFaker: (options?: Options | undefined) => _$_kubb_core0.UserPluginWithLifeCycle<PluginFaker>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { type PluginFaker, pluginFaker, pluginFakerName };
|
|
10
10
|
//# sourceMappingURL=index.d.ts.map
|