@kubb/plugin-zod 4.28.0 → 4.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/{components-DJvhXrHc.js → Zod-GzH2I46C.js} +18 -17
  2. package/dist/Zod-GzH2I46C.js.map +1 -0
  3. package/dist/{components-C_w1hb42.cjs → Zod-SRUZu-W_.cjs} +18 -17
  4. package/dist/Zod-SRUZu-W_.cjs.map +1 -0
  5. package/dist/{chunk-1FvLCsr0.js → chunk-DKWOrOAv.js} +1 -1
  6. package/dist/components.cjs +4 -3
  7. package/dist/components.d.ts +2 -2
  8. package/dist/components.js +1 -1
  9. package/dist/generators.cjs +4 -3
  10. package/dist/generators.d.ts +2 -2
  11. package/dist/generators.js +1 -1
  12. package/dist/index.cjs +10 -9
  13. package/dist/index.cjs.map +1 -1
  14. package/dist/index.d.ts +2 -2
  15. package/dist/index.js +9 -9
  16. package/dist/index.js.map +1 -1
  17. package/dist/templates/ToZod.source.cjs +7 -2
  18. package/dist/templates/ToZod.source.cjs.map +1 -0
  19. package/dist/templates/ToZod.source.d.ts +1 -1
  20. package/dist/templates/ToZod.source.js +5 -2
  21. package/dist/templates/ToZod.source.js.map +1 -0
  22. package/dist/{types-StrSTHew.d.ts → types-36d5YOmB.d.ts} +2 -2
  23. package/dist/{types-C5U_pUo5.d.cts → types-Di6cBRev.d.ts} +2 -2
  24. package/dist/{generators-G0CD1PFV.cjs → zodGenerator-DXR_wbBQ.cjs} +9 -9
  25. package/dist/zodGenerator-DXR_wbBQ.cjs.map +1 -0
  26. package/dist/{generators-CcTPAM8G.js → zodGenerator-DomjELrZ.js} +6 -6
  27. package/dist/zodGenerator-DomjELrZ.js.map +1 -0
  28. package/package.json +10 -10
  29. package/src/generators/__snapshots__/operations.ts +6 -6
  30. package/src/parser.ts +2 -2
  31. package/dist/ToZod.source-B0uyS5aq.js +0 -6
  32. package/dist/ToZod.source-B0uyS5aq.js.map +0 -1
  33. package/dist/ToZod.source-DFtxX5zd.cjs +0 -12
  34. package/dist/ToZod.source-DFtxX5zd.cjs.map +0 -1
  35. package/dist/components-C_w1hb42.cjs.map +0 -1
  36. package/dist/components-DJvhXrHc.js.map +0 -1
  37. package/dist/components.d.cts +0 -56
  38. package/dist/generators-CcTPAM8G.js.map +0 -1
  39. package/dist/generators-G0CD1PFV.cjs.map +0 -1
  40. package/dist/generators.d.cts +0 -471
  41. package/dist/index.d.cts +0 -10
  42. package/dist/templates/ToZod.source.d.cts +0 -7
@@ -1,471 +0,0 @@
1
- import { t as __name } from "./chunk-CkKeEC2V.cjs";
2
- import { n as PluginZod } from "./types-C5U_pUo5.cjs";
3
- import { HttpMethod, Oas, Operation, SchemaObject, contentType } from "@kubb/oas";
4
- import { FabricReactNode } from "@kubb/react-fabric/types";
5
- import { BaseGenerator, Config, FileMetaBase, Group, KubbEvents, Output, Plugin, PluginFactoryOptions, PluginManager, ResolveNameParams } from "@kubb/core";
6
- import { AsyncEventEmitter } from "@kubb/core/utils";
7
- import { KubbFile } from "@kubb/fabric-core/types";
8
- import { Fabric } from "@kubb/react-fabric";
9
-
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
- * `pluginKey` 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
- pluginKey?: Plugin['key'];
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> extends BaseGenerator<TPluginOptions['resolvedOptions'], Context$1<TPluginOptions['resolvedOptions'], TPluginOptions>> {
120
- #private;
121
- getOptions(operation: Operation, method: HttpMethod): Partial<TPluginOptions['resolvedOptions']>;
122
- getSchemas(operation: Operation, {
123
- resolveName
124
- }?: {
125
- resolveName?: (name: string) => string;
126
- }): OperationSchemas;
127
- getOperations(): Promise<Array<{
128
- path: string;
129
- method: HttpMethod;
130
- operation: Operation;
131
- }>>;
132
- build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
133
- }
134
- //#endregion
135
- //#region ../plugin-oas/src/SchemaMapper.d.ts
136
- type SchemaKeywordMapper = {
137
- object: {
138
- keyword: 'object';
139
- args: {
140
- properties: {
141
- [x: string]: Schema[];
142
- };
143
- additionalProperties: Schema[];
144
- patternProperties?: Record<string, Schema[]>;
145
- strict?: boolean;
146
- };
147
- };
148
- url: {
149
- keyword: 'url';
150
- };
151
- readOnly: {
152
- keyword: 'readOnly';
153
- };
154
- writeOnly: {
155
- keyword: 'writeOnly';
156
- };
157
- uuid: {
158
- keyword: 'uuid';
159
- };
160
- email: {
161
- keyword: 'email';
162
- };
163
- firstName: {
164
- keyword: 'firstName';
165
- };
166
- lastName: {
167
- keyword: 'lastName';
168
- };
169
- phone: {
170
- keyword: 'phone';
171
- };
172
- password: {
173
- keyword: 'password';
174
- };
175
- date: {
176
- keyword: 'date';
177
- args: {
178
- type?: 'date' | 'string';
179
- };
180
- };
181
- time: {
182
- keyword: 'time';
183
- args: {
184
- type?: 'date' | 'string';
185
- };
186
- };
187
- datetime: {
188
- keyword: 'datetime';
189
- args: {
190
- offset?: boolean;
191
- local?: boolean;
192
- };
193
- };
194
- tuple: {
195
- keyword: 'tuple';
196
- args: {
197
- items: Schema[];
198
- min?: number;
199
- max?: number;
200
- rest?: Schema;
201
- };
202
- };
203
- array: {
204
- keyword: 'array';
205
- args: {
206
- items: Schema[];
207
- min?: number;
208
- max?: number;
209
- unique?: boolean;
210
- };
211
- };
212
- enum: {
213
- keyword: 'enum';
214
- args: {
215
- name: string;
216
- typeName: string;
217
- asConst: boolean;
218
- items: Array<{
219
- name: string | number;
220
- format: 'string' | 'number' | 'boolean';
221
- value?: string | number | boolean;
222
- }>;
223
- };
224
- };
225
- and: {
226
- keyword: 'and';
227
- args: Schema[];
228
- };
229
- const: {
230
- keyword: 'const';
231
- args: {
232
- name: string | number;
233
- format: 'string' | 'number' | 'boolean';
234
- value?: string | number | boolean;
235
- };
236
- };
237
- union: {
238
- keyword: 'union';
239
- args: Schema[];
240
- };
241
- ref: {
242
- keyword: 'ref';
243
- args: {
244
- name: string;
245
- $ref: string;
246
- /**
247
- * Full qualified path.
248
- */
249
- path: KubbFile.Path;
250
- /**
251
- * When true `File.Import` is used.
252
- * When false a reference is used inside the current file.
253
- */
254
- isImportable: boolean;
255
- };
256
- };
257
- matches: {
258
- keyword: 'matches';
259
- args?: string;
260
- };
261
- boolean: {
262
- keyword: 'boolean';
263
- };
264
- default: {
265
- keyword: 'default';
266
- args: string | number | boolean;
267
- };
268
- string: {
269
- keyword: 'string';
270
- };
271
- integer: {
272
- keyword: 'integer';
273
- };
274
- bigint: {
275
- keyword: 'bigint';
276
- };
277
- number: {
278
- keyword: 'number';
279
- };
280
- max: {
281
- keyword: 'max';
282
- args: number;
283
- };
284
- min: {
285
- keyword: 'min';
286
- args: number;
287
- };
288
- exclusiveMaximum: {
289
- keyword: 'exclusiveMaximum';
290
- args: number;
291
- };
292
- exclusiveMinimum: {
293
- keyword: 'exclusiveMinimum';
294
- args: number;
295
- };
296
- describe: {
297
- keyword: 'describe';
298
- args: string;
299
- };
300
- example: {
301
- keyword: 'example';
302
- args: string;
303
- };
304
- deprecated: {
305
- keyword: 'deprecated';
306
- };
307
- optional: {
308
- keyword: 'optional';
309
- };
310
- undefined: {
311
- keyword: 'undefined';
312
- };
313
- nullish: {
314
- keyword: 'nullish';
315
- };
316
- nullable: {
317
- keyword: 'nullable';
318
- };
319
- null: {
320
- keyword: 'null';
321
- };
322
- any: {
323
- keyword: 'any';
324
- };
325
- unknown: {
326
- keyword: 'unknown';
327
- };
328
- void: {
329
- keyword: 'void';
330
- };
331
- blob: {
332
- keyword: 'blob';
333
- };
334
- schema: {
335
- keyword: 'schema';
336
- args: {
337
- type: 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'object';
338
- format?: string;
339
- };
340
- };
341
- name: {
342
- keyword: 'name';
343
- args: string;
344
- };
345
- catchall: {
346
- keyword: 'catchall';
347
- };
348
- interface: {
349
- keyword: 'interface';
350
- };
351
- };
352
- type Schema = {
353
- keyword: string;
354
- } | SchemaKeywordMapper[keyof SchemaKeywordMapper];
355
- //#endregion
356
- //#region ../plugin-oas/src/SchemaGenerator.d.ts
357
- type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
358
- fabric: Fabric;
359
- oas: Oas;
360
- pluginManager: PluginManager;
361
- events?: AsyncEventEmitter<KubbEvents>;
362
- /**
363
- * Current plugin
364
- */
365
- plugin: Plugin<TPluginOptions>;
366
- mode: KubbFile.Mode;
367
- include?: Array<'schemas' | 'responses' | 'requestBodies'>;
368
- override: Array<Override<TOptions>> | undefined;
369
- contentType?: contentType;
370
- output?: string;
371
- };
372
- type SchemaGeneratorOptions = {
373
- dateType: false | 'string' | 'stringOffset' | 'stringLocal' | 'date';
374
- integerType?: 'number' | 'bigint';
375
- unknownType: 'any' | 'unknown' | 'void';
376
- emptySchemaType: 'any' | 'unknown' | 'void';
377
- enumType?: 'enum' | 'asConst' | 'asPascalConst' | 'constEnum' | 'literal' | 'inlineLiteral';
378
- enumSuffix?: string;
379
- /**
380
- * @deprecated Will be removed in v5. Use `collisionDetection: true` instead to prevent enum name collisions.
381
- * When `collisionDetection` is enabled, the rootName-based approach eliminates the need for numeric suffixes.
382
- * @internal
383
- */
384
- usedEnumNames?: Record<string, number>;
385
- mapper?: Record<string, string>;
386
- typed?: boolean;
387
- transformers: {
388
- /**
389
- * Customize the names based on the type that is provided by the plugin.
390
- */
391
- name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
392
- /**
393
- * Receive schema and name(propertyName) and return FakerMeta array
394
- * TODO TODO add docs
395
- * @beta
396
- */
397
- schema?: (schemaProps: SchemaProps$1, defaultSchemas: Schema[]) => Array<Schema> | undefined;
398
- };
399
- };
400
- type SchemaProps$1 = {
401
- schema: SchemaObject | null;
402
- name: string | null;
403
- parentName: string | null;
404
- rootName?: string | null;
405
- };
406
- declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions, Context<TOptions, TPluginOptions>> {
407
- #private;
408
- refs: Refs;
409
- /**
410
- * Creates a type node from a given schema.
411
- * Delegates to getBaseTypeFromSchema internally and
412
- * optionally adds a union with null.
413
- */
414
- parse(props: SchemaProps$1): Schema[];
415
- static deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
416
- static find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
417
- static combineObjects(tree: Schema[] | undefined): Schema[];
418
- build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
419
- }
420
- //#endregion
421
- //#region ../plugin-oas/src/generators/createGenerator.d.ts
422
- type CoreGenerator<TOptions extends PluginFactoryOptions> = {
423
- name: string;
424
- type: 'core';
425
- operations: (props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>;
426
- operation: (props: OperationProps<TOptions>) => Promise<KubbFile.File[]>;
427
- schema: (props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>;
428
- };
429
- //#endregion
430
- //#region ../plugin-oas/src/generators/types.d.ts
431
- type OperationsProps<TOptions extends PluginFactoryOptions> = {
432
- config: Config;
433
- generator: Omit<OperationGenerator<TOptions>, 'build'>;
434
- plugin: Plugin<TOptions>;
435
- operations: Array<Operation>;
436
- };
437
- type OperationProps<TOptions extends PluginFactoryOptions> = {
438
- config: Config;
439
- generator: Omit<OperationGenerator<TOptions>, 'build'>;
440
- plugin: Plugin<TOptions>;
441
- operation: Operation;
442
- };
443
- type SchemaProps<TOptions extends PluginFactoryOptions> = {
444
- config: Config;
445
- generator: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>;
446
- plugin: Plugin<TOptions>;
447
- schema: {
448
- name: string;
449
- tree: Array<Schema>;
450
- value: SchemaObject;
451
- };
452
- };
453
- type Generator<TOptions extends PluginFactoryOptions> = CoreGenerator<TOptions> | ReactGenerator<TOptions>;
454
- //#endregion
455
- //#region ../plugin-oas/src/generators/createReactGenerator.d.ts
456
- type ReactGenerator<TOptions extends PluginFactoryOptions> = {
457
- name: string;
458
- type: 'react';
459
- Operations: (props: OperationsProps<TOptions>) => FabricReactNode;
460
- Operation: (props: OperationProps<TOptions>) => FabricReactNode;
461
- Schema: (props: SchemaProps<TOptions>) => FabricReactNode;
462
- };
463
- //#endregion
464
- //#region src/generators/operationsGenerator.d.ts
465
- declare const operationsGenerator: ReactGenerator<PluginZod>;
466
- //#endregion
467
- //#region src/generators/zodGenerator.d.ts
468
- declare const zodGenerator: ReactGenerator<PluginZod>;
469
- //#endregion
470
- export { operationsGenerator, zodGenerator };
471
- //# sourceMappingURL=generators.d.cts.map
package/dist/index.d.cts DELETED
@@ -1,10 +0,0 @@
1
- import { t as __name } from "./chunk-CkKeEC2V.cjs";
2
- import { n as PluginZod, t as Options } from "./types-C5U_pUo5.cjs";
3
- import * as _kubb_core0 from "@kubb/core";
4
-
5
- //#region src/plugin.d.ts
6
- declare const pluginZodName = "plugin-zod";
7
- declare const pluginZod: (options?: Options | undefined) => _kubb_core0.UserPluginWithLifeCycle<PluginZod>;
8
- //#endregion
9
- export { type PluginZod, pluginZod, pluginZodName };
10
- //# sourceMappingURL=index.d.cts.map
@@ -1,7 +0,0 @@
1
- import { t as __name } from "../chunk-CkKeEC2V.cjs";
2
-
3
- //#region src/templates/ToZod.source.d.ts
4
- declare const source: string;
5
- //#endregion
6
- export { source };
7
- //# sourceMappingURL=ToZod.source.d.cts.map