@kubb/plugin-zod 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/index.cjs +1061 -105
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +369 -4
- package/dist/index.js +1053 -104
- package/dist/index.js.map +1 -1
- package/package.json +44 -70
- package/src/components/Operations.tsx +25 -18
- package/src/components/Zod.tsx +21 -121
- package/src/constants.ts +5 -0
- package/src/generators/zodGenerator.tsx +174 -160
- package/src/index.ts +11 -2
- package/src/plugin.ts +67 -156
- package/src/printers/printerZod.ts +339 -0
- package/src/printers/printerZodMini.ts +295 -0
- package/src/resolvers/resolverZod.ts +57 -0
- package/src/types.ts +130 -115
- package/src/utils.ts +222 -0
- package/dist/components-B7zUFnAm.cjs +0 -890
- package/dist/components-B7zUFnAm.cjs.map +0 -1
- package/dist/components-eECfXVou.js +0 -842
- package/dist/components-eECfXVou.js.map +0 -1
- package/dist/components.cjs +0 -4
- package/dist/components.d.ts +0 -56
- package/dist/components.js +0 -2
- package/dist/generators-BjPDdJUz.cjs +0 -301
- package/dist/generators-BjPDdJUz.cjs.map +0 -1
- package/dist/generators-lTWPS6oN.js +0 -290
- package/dist/generators-lTWPS6oN.js.map +0 -1
- package/dist/generators.cjs +0 -4
- package/dist/generators.d.ts +0 -479
- package/dist/generators.js +0 -2
- package/dist/templates/ToZod.source.cjs +0 -7
- package/dist/templates/ToZod.source.cjs.map +0 -1
- package/dist/templates/ToZod.source.d.ts +0 -7
- package/dist/templates/ToZod.source.js +0 -6
- package/dist/templates/ToZod.source.js.map +0 -1
- package/dist/types-CoCoOc2u.d.ts +0 -172
- package/src/components/index.ts +0 -2
- package/src/generators/index.ts +0 -2
- package/src/generators/operationsGenerator.tsx +0 -50
- package/src/parser.ts +0 -909
- package/src/templates/ToZod.source.ts +0 -4
- package/templates/ToZod.ts +0 -61
package/dist/generators.d.ts
DELETED
|
@@ -1,479 +0,0 @@
|
|
|
1
|
-
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
|
-
import { n as PluginZod } from "./types-CoCoOc2u.js";
|
|
3
|
-
import { AsyncEventEmitter, Config, FileMetaBase, Generator, Group, KubbEvents, Output, Plugin, PluginDriver, PluginFactoryOptions, ResolveNameParams } from "@kubb/core";
|
|
4
|
-
import { HttpMethod, Oas, Operation, SchemaObject, contentType } from "@kubb/oas";
|
|
5
|
-
import { FabricReactNode } from "@kubb/react-fabric/types";
|
|
6
|
-
import { Fabric, KubbFile } from "@kubb/fabric-core/types";
|
|
7
|
-
|
|
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
|
-
//#region src/generators/operationsGenerator.d.ts
|
|
473
|
-
declare const operationsGenerator: ReactGenerator<PluginZod>;
|
|
474
|
-
//#endregion
|
|
475
|
-
//#region src/generators/zodGenerator.d.ts
|
|
476
|
-
declare const zodGenerator: ReactGenerator<PluginZod>;
|
|
477
|
-
//#endregion
|
|
478
|
-
export { operationsGenerator, zodGenerator };
|
|
479
|
-
//# sourceMappingURL=generators.d.ts.map
|
package/dist/generators.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
//#region src/templates/ToZod.source.ts
|
|
3
|
-
const source = "/**\n * See https://github.com/colinhacks/tozod/blob/master/src/index.ts\n * Adapted based on https://github.com/colinhacks/zod/issues/372\n */\n\nimport type * as z from 'zod'\n\ntype IsAny<T> = [any extends T ? 'true' : 'false'] extends ['true'] ? true : false\ntype NonOptional<T> = T extends undefined ? never : T\ntype NonNullable<T> = T extends null ? never : T\ntype Equals<X, Y> = [X] extends [Y] ? ([Y] extends [X] ? true : false) : false\n\ntype ZodKey<T> =\n IsAny<T> extends true\n ? 'any'\n : Equals<T, boolean> extends true //[T] extends [booleanUtil.Type]\n ? 'boolean'\n : [undefined] extends [T]\n ? 'optional'\n : [null] extends [T]\n ? 'nullable'\n : T extends any[]\n ? 'array'\n : Equals<T, string> extends true\n ? 'string'\n : Equals<T, bigint> extends true //[T] extends [bigintUtil.Type]\n ? 'bigint'\n : Equals<T, number> extends true //[T] extends [numberUtil.Type]\n ? 'number'\n : Equals<T, Date> extends true //[T] extends [dateUtil.Type]\n ? 'date'\n : T extends { [k: string]: any } //[T] extends [structUtil.Type]\n ? 'object'\n : 'rest'\n\nexport type ToZod<T> = {\n any: z.ZodAny\n optional: z.ZodOptional<ToZod<NonOptional<T>>>\n nullable: z.ZodNullable<ToZod<NonNullable<T>>>\n array: T extends Array<infer U> ? z.ZodArray<ToZod<U>> : never\n string: z.ZodString\n bigint: z.ZodBigInt\n number: z.ZodNumber\n boolean: z.ZodBoolean\n date: z.ZodDate\n object: z.ZodObject<\n // @ts-expect-error cannot convert without Extract but Extract removes the type\n {\n [K in keyof T]: T[K]\n },\n 'passthrough',\n unknown,\n T\n >\n rest: z.ZodType<T>\n}[ZodKey<T>]\n\nexport type ZodShape<T> = {\n // Require all the keys from T\n [key in keyof T]-?: ToZod<T[key]>\n}\n";
|
|
4
|
-
//#endregion
|
|
5
|
-
exports.source = source;
|
|
6
|
-
|
|
7
|
-
//# sourceMappingURL=ToZod.source.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ToZod.source.cjs","names":[],"sources":["../../src/templates/ToZod.source.ts"],"sourcesContent":["// @ts-expect-error - import attributes are handled at build time by importAttributeTextPlugin\nimport content from '../../templates/ToZod.ts' with { type: 'text' }\n\nexport const source = content as string\n"],"mappings":";;AAAA,MAAa,SAAS"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
//#region src/templates/ToZod.source.ts
|
|
2
|
-
const source = "/**\n * See https://github.com/colinhacks/tozod/blob/master/src/index.ts\n * Adapted based on https://github.com/colinhacks/zod/issues/372\n */\n\nimport type * as z from 'zod'\n\ntype IsAny<T> = [any extends T ? 'true' : 'false'] extends ['true'] ? true : false\ntype NonOptional<T> = T extends undefined ? never : T\ntype NonNullable<T> = T extends null ? never : T\ntype Equals<X, Y> = [X] extends [Y] ? ([Y] extends [X] ? true : false) : false\n\ntype ZodKey<T> =\n IsAny<T> extends true\n ? 'any'\n : Equals<T, boolean> extends true //[T] extends [booleanUtil.Type]\n ? 'boolean'\n : [undefined] extends [T]\n ? 'optional'\n : [null] extends [T]\n ? 'nullable'\n : T extends any[]\n ? 'array'\n : Equals<T, string> extends true\n ? 'string'\n : Equals<T, bigint> extends true //[T] extends [bigintUtil.Type]\n ? 'bigint'\n : Equals<T, number> extends true //[T] extends [numberUtil.Type]\n ? 'number'\n : Equals<T, Date> extends true //[T] extends [dateUtil.Type]\n ? 'date'\n : T extends { [k: string]: any } //[T] extends [structUtil.Type]\n ? 'object'\n : 'rest'\n\nexport type ToZod<T> = {\n any: z.ZodAny\n optional: z.ZodOptional<ToZod<NonOptional<T>>>\n nullable: z.ZodNullable<ToZod<NonNullable<T>>>\n array: T extends Array<infer U> ? z.ZodArray<ToZod<U>> : never\n string: z.ZodString\n bigint: z.ZodBigInt\n number: z.ZodNumber\n boolean: z.ZodBoolean\n date: z.ZodDate\n object: z.ZodObject<\n // @ts-expect-error cannot convert without Extract but Extract removes the type\n {\n [K in keyof T]: T[K]\n },\n 'passthrough',\n unknown,\n T\n >\n rest: z.ZodType<T>\n}[ZodKey<T>]\n\nexport type ZodShape<T> = {\n // Require all the keys from T\n [key in keyof T]-?: ToZod<T[key]>\n}\n";
|
|
3
|
-
//#endregion
|
|
4
|
-
export { source };
|
|
5
|
-
|
|
6
|
-
//# sourceMappingURL=ToZod.source.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ToZod.source.js","names":[],"sources":["../../src/templates/ToZod.source.ts"],"sourcesContent":["// @ts-expect-error - import attributes are handled at build time by importAttributeTextPlugin\nimport content from '../../templates/ToZod.ts' with { type: 'text' }\n\nexport const source = content as string\n"],"mappings":";AAAA,MAAa,SAAS"}
|
package/dist/types-CoCoOc2u.d.ts
DELETED
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
|
-
import { Group, Output, PluginFactoryOptions, ResolveNameParams } from "@kubb/core";
|
|
3
|
-
import { Exclude, Include, Override, ResolvePathOptions, Schema } from "@kubb/plugin-oas";
|
|
4
|
-
import { Generator as Generator$1 } from "@kubb/plugin-oas/generators";
|
|
5
|
-
import { Oas, SchemaObject, contentType } from "@kubb/oas";
|
|
6
|
-
|
|
7
|
-
//#region src/types.d.ts
|
|
8
|
-
type Options = {
|
|
9
|
-
/**
|
|
10
|
-
* @default 'zod'
|
|
11
|
-
*/
|
|
12
|
-
output?: Output<Oas>;
|
|
13
|
-
/**
|
|
14
|
-
* Define which contentType should be used.
|
|
15
|
-
* By default, the first JSON valid mediaType is used
|
|
16
|
-
*/
|
|
17
|
-
contentType?: contentType;
|
|
18
|
-
/**
|
|
19
|
-
* Group the Zod schemas based on the provided name.
|
|
20
|
-
*/
|
|
21
|
-
group?: Group;
|
|
22
|
-
/**
|
|
23
|
-
* Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
|
|
24
|
-
*/
|
|
25
|
-
exclude?: Array<Exclude>;
|
|
26
|
-
/**
|
|
27
|
-
* Array containing include parameters to include tags/operations/methods/paths.
|
|
28
|
-
*/
|
|
29
|
-
include?: Array<Include>;
|
|
30
|
-
/**
|
|
31
|
-
* Array containing override parameters to override `options` based on tags/operations/methods/paths.
|
|
32
|
-
*/
|
|
33
|
-
override?: Array<Override<ResolvedOptions>>;
|
|
34
|
-
/**
|
|
35
|
-
* Path to Zod
|
|
36
|
-
* It used as `import { z } from '${importPath}'`.
|
|
37
|
-
* Accepts relative and absolute paths.
|
|
38
|
-
* Path is used as-is; relative paths are based on the generated file location.
|
|
39
|
-
* @default 'zod'
|
|
40
|
-
*/
|
|
41
|
-
importPath?: string;
|
|
42
|
-
/**
|
|
43
|
-
* Choose to use date or datetime as JavaScript Date instead of string.
|
|
44
|
-
* - false falls back to a simple z.string() format.
|
|
45
|
-
* - 'string' uses z.string().datetime() for datetime validation.
|
|
46
|
-
* - 'stringOffset' uses z.string().datetime({ offset: true }) for datetime with timezone offset validation.
|
|
47
|
-
* - 'stringLocal' uses z.string().datetime({ local: true }) for local datetime validation.
|
|
48
|
-
* - 'date' uses z.date() for JavaScript Date objects.
|
|
49
|
-
* @default 'string'
|
|
50
|
-
* @note 'stringOffset' will become the default in Kubb v3.
|
|
51
|
-
*/
|
|
52
|
-
dateType?: false | 'string' | 'stringOffset' | 'stringLocal' | 'date';
|
|
53
|
-
/**
|
|
54
|
-
* Choose to use `number` or `bigint` for integer fields with `int64` format.
|
|
55
|
-
* - 'number' uses the JavaScript `number` type (matches JSON.parse() runtime behavior).
|
|
56
|
-
* - 'bigint' uses the JavaScript `bigint` type (accurate for values exceeding Number.MAX_SAFE_INTEGER).
|
|
57
|
-
* @note in v5 of Kubb 'bigint' will become the default to better align with OpenAPI's int64 specification.
|
|
58
|
-
* @default 'number'
|
|
59
|
-
*/
|
|
60
|
-
integerType?: 'number' | 'bigint';
|
|
61
|
-
/**
|
|
62
|
-
* Which type to use when the Swagger/OpenAPI file is not providing more information.
|
|
63
|
-
* - 'any' allows any value.
|
|
64
|
-
* - 'unknown' requires type narrowing before use.
|
|
65
|
-
* - 'void' represents no value.
|
|
66
|
-
* @default 'any'
|
|
67
|
-
*/
|
|
68
|
-
unknownType?: 'any' | 'unknown' | 'void';
|
|
69
|
-
/**
|
|
70
|
-
* Which type to use for empty schema values.
|
|
71
|
-
* - 'any' allows any value.
|
|
72
|
-
* - 'unknown' requires type narrowing before use.
|
|
73
|
-
* - 'void' represents no value.
|
|
74
|
-
* @default `unknownType`
|
|
75
|
-
*/
|
|
76
|
-
emptySchemaType?: 'any' | 'unknown' | 'void';
|
|
77
|
-
/**
|
|
78
|
-
* Use TypeScript(`@kubb/plugin-ts`) to add type annotation.
|
|
79
|
-
*/
|
|
80
|
-
typed?: boolean;
|
|
81
|
-
/**
|
|
82
|
-
* Return Zod generated schema as type with z.infer<TYPE>
|
|
83
|
-
*/
|
|
84
|
-
inferred?: boolean;
|
|
85
|
-
/**
|
|
86
|
-
* Use of z.coerce.string() instead of z.string()
|
|
87
|
-
* can also be an object to enable coercion for dates, strings, and numbers
|
|
88
|
-
*/
|
|
89
|
-
coercion?: boolean | {
|
|
90
|
-
dates?: boolean;
|
|
91
|
-
strings?: boolean;
|
|
92
|
-
numbers?: boolean;
|
|
93
|
-
};
|
|
94
|
-
operations?: boolean;
|
|
95
|
-
mapper?: Record<string, string>;
|
|
96
|
-
transformers?: {
|
|
97
|
-
/**
|
|
98
|
-
* Customize the names based on the type that is provided by the plugin.
|
|
99
|
-
*/
|
|
100
|
-
name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
101
|
-
/**
|
|
102
|
-
* Receive schema and baseName(propertyName) and return FakerMeta array
|
|
103
|
-
* TODO TODO add docs
|
|
104
|
-
* @beta
|
|
105
|
-
*/
|
|
106
|
-
schema?: (props: {
|
|
107
|
-
schema: SchemaObject | null;
|
|
108
|
-
name: string | null;
|
|
109
|
-
parentName: string | null;
|
|
110
|
-
}, defaultSchemas: Schema[]) => Schema[] | undefined;
|
|
111
|
-
};
|
|
112
|
-
/**
|
|
113
|
-
* Which version of Zod should be used.
|
|
114
|
-
* - '3' uses Zod v3.x syntax and features.
|
|
115
|
-
* - '4' uses Zod v4.x syntax and features.
|
|
116
|
-
* @default '3'
|
|
117
|
-
*/
|
|
118
|
-
version?: '3' | '4';
|
|
119
|
-
/**
|
|
120
|
-
* Which Zod GUID validator to use for OpenAPI `format: uuid`.
|
|
121
|
-
* - 'uuid' uses UUID validation.
|
|
122
|
-
* - 'guid' uses GUID validation (Zod v4 only).
|
|
123
|
-
* @default 'uuid'
|
|
124
|
-
*/
|
|
125
|
-
guidType?: 'uuid' | 'guid';
|
|
126
|
-
/**
|
|
127
|
-
* Use Zod Mini's functional API for better tree-shaking support.
|
|
128
|
-
* When enabled, generates functional syntax (e.g., `z.optional(z.string())`) instead of chainable methods (e.g., `z.string().optional()`).
|
|
129
|
-
* Requires Zod v4 or later. When `mini: true`, `version` is set to '4' and `importPath` will default to 'zod/mini'.
|
|
130
|
-
* @default false
|
|
131
|
-
*/
|
|
132
|
-
mini?: boolean;
|
|
133
|
-
/**
|
|
134
|
-
* Callback function to wrap the output of the generated zod schema
|
|
135
|
-
*
|
|
136
|
-
* This is useful for edge case scenarios where you might leverage something like `z.object({ ... }).openapi({ example: { some: "complex-example" }})`
|
|
137
|
-
* or `extendApi(z.object({ ... }), { example: { some: "complex-example", ...otherOpenApiProperties }})`
|
|
138
|
-
* while going from openapi -> zod -> openapi
|
|
139
|
-
*/
|
|
140
|
-
wrapOutput?: (arg: {
|
|
141
|
-
output: string;
|
|
142
|
-
schema: SchemaObject;
|
|
143
|
-
}) => string | undefined;
|
|
144
|
-
/**
|
|
145
|
-
* Define some generators next to the zod generators
|
|
146
|
-
*/
|
|
147
|
-
generators?: Array<Generator$1<PluginZod>>;
|
|
148
|
-
};
|
|
149
|
-
type ResolvedOptions = {
|
|
150
|
-
output: Output<Oas>;
|
|
151
|
-
group: Options['group'];
|
|
152
|
-
override: NonNullable<Options['override']>;
|
|
153
|
-
transformers: NonNullable<Options['transformers']>;
|
|
154
|
-
dateType: NonNullable<Options['dateType']>;
|
|
155
|
-
integerType: NonNullable<Options['integerType']>;
|
|
156
|
-
unknownType: NonNullable<Options['unknownType']>;
|
|
157
|
-
emptySchemaType: NonNullable<Options['emptySchemaType']>;
|
|
158
|
-
typed: NonNullable<Options['typed']>;
|
|
159
|
-
inferred: NonNullable<Options['inferred']>;
|
|
160
|
-
mapper: NonNullable<Options['mapper']>;
|
|
161
|
-
importPath: NonNullable<Options['importPath']>;
|
|
162
|
-
coercion: NonNullable<Options['coercion']>;
|
|
163
|
-
operations: NonNullable<Options['operations']>;
|
|
164
|
-
wrapOutput: Options['wrapOutput'];
|
|
165
|
-
version: NonNullable<Options['version']>;
|
|
166
|
-
guidType: NonNullable<Options['guidType']>;
|
|
167
|
-
mini: NonNullable<Options['mini']>;
|
|
168
|
-
};
|
|
169
|
-
type PluginZod = PluginFactoryOptions<'plugin-zod', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
170
|
-
//#endregion
|
|
171
|
-
export { PluginZod as n, Options as t };
|
|
172
|
-
//# sourceMappingURL=types-CoCoOc2u.d.ts.map
|
package/src/components/index.ts
DELETED