@kubb/plugin-zod 4.33.5 → 4.35.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.
- package/dist/generators.d.ts +39 -46
- package/package.json +5 -5
package/dist/generators.d.ts
CHANGED
|
@@ -1,40 +1,12 @@
|
|
|
1
1
|
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
2
|
import { n as PluginZod } from "./types-D0wsPC6Y.js";
|
|
3
|
-
import { Config, FileMetaBase, Group, KubbEvents, Output, Plugin, PluginFactoryOptions, PluginManager, ResolveNameParams } from "@kubb/core";
|
|
3
|
+
import { AsyncEventEmitter, Config, FileMetaBase, Group, KubbEvents, Output, Plugin, PluginFactoryOptions, PluginManager, ResolveNameParams } from "@kubb/core";
|
|
4
4
|
import { Fabric } from "@kubb/react-fabric";
|
|
5
5
|
import { HttpMethod, Oas, Operation, SchemaObject, contentType } from "@kubb/oas";
|
|
6
6
|
import { FabricReactNode } from "@kubb/react-fabric/types";
|
|
7
|
+
import { OperationNode, SchemaNode } from "@kubb/ast/types";
|
|
7
8
|
import { KubbFile } from "@kubb/fabric-core/types";
|
|
8
9
|
|
|
9
|
-
//#region ../../internals/utils/src/asyncEventEmitter.d.ts
|
|
10
|
-
/** A function that can be registered as an event listener, synchronous or async. */
|
|
11
|
-
type AsyncListener<TArgs extends unknown[]> = (...args: TArgs) => void | Promise<void>;
|
|
12
|
-
/**
|
|
13
|
-
* A typed EventEmitter that awaits all async listeners before resolving.
|
|
14
|
-
* Wraps Node's `EventEmitter` with full TypeScript event-map inference.
|
|
15
|
-
*/
|
|
16
|
-
declare class AsyncEventEmitter<TEvents extends { [K in keyof TEvents]: unknown[] }> {
|
|
17
|
-
#private;
|
|
18
|
-
/**
|
|
19
|
-
* `maxListener` controls the maximum number of listeners per event before Node emits a memory-leak warning.
|
|
20
|
-
* @default 10
|
|
21
|
-
*/
|
|
22
|
-
constructor(maxListener?: number);
|
|
23
|
-
/**
|
|
24
|
-
* Emits an event and awaits all registered listeners in parallel.
|
|
25
|
-
* Throws if any listener rejects, wrapping the cause with the event name and serialized arguments.
|
|
26
|
-
*/
|
|
27
|
-
emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArgs: TEvents[TEventName]): Promise<void>;
|
|
28
|
-
/** Registers a persistent listener for the given event. */
|
|
29
|
-
on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: AsyncListener<TEvents[TEventName]>): void;
|
|
30
|
-
/** Registers a one-shot listener that removes itself after the first invocation. */
|
|
31
|
-
onOnce<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: AsyncListener<TEvents[TEventName]>): void;
|
|
32
|
-
/** Removes a previously registered listener. */
|
|
33
|
-
off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: AsyncListener<TEvents[TEventName]>): void;
|
|
34
|
-
/** Removes all listeners from every event channel. */
|
|
35
|
-
removeAll(): void;
|
|
36
|
-
}
|
|
37
|
-
//#endregion
|
|
38
10
|
//#region ../plugin-oas/src/types.d.ts
|
|
39
11
|
type GetOasOptions = {
|
|
40
12
|
validate?: boolean;
|
|
@@ -161,7 +133,7 @@ declare class OperationGenerator<TPluginOptions extends PluginFactoryOptions = P
|
|
|
161
133
|
method: HttpMethod;
|
|
162
134
|
operation: Operation;
|
|
163
135
|
}>>;
|
|
164
|
-
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
136
|
+
build(...generators: Array<Generator<TPluginOptions, Version>>): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
165
137
|
}
|
|
166
138
|
//#endregion
|
|
167
139
|
//#region ../plugin-oas/src/SchemaMapper.d.ts
|
|
@@ -451,32 +423,46 @@ declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGe
|
|
|
451
423
|
static deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
|
|
452
424
|
static find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
453
425
|
static combineObjects(tree: Schema[] | undefined): Schema[];
|
|
454
|
-
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
426
|
+
build(...generators: Array<Generator<TPluginOptions, Version>>): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
455
427
|
}
|
|
456
428
|
//#endregion
|
|
457
429
|
//#region ../plugin-oas/src/generators/createGenerator.d.ts
|
|
458
|
-
type CoreGenerator<TOptions extends PluginFactoryOptions> = {
|
|
430
|
+
type CoreGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version> = {
|
|
459
431
|
name: string;
|
|
460
432
|
type: 'core';
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
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[]>;
|
|
464
437
|
};
|
|
465
438
|
//#endregion
|
|
466
439
|
//#region ../plugin-oas/src/generators/types.d.ts
|
|
467
|
-
type
|
|
440
|
+
type Version = '1' | '2';
|
|
441
|
+
type OperationsV1Props<TOptions extends PluginFactoryOptions> = {
|
|
468
442
|
config: Config;
|
|
469
443
|
generator: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
470
444
|
plugin: Plugin<TOptions>;
|
|
471
445
|
operations: Array<Operation>;
|
|
472
446
|
};
|
|
473
|
-
type
|
|
447
|
+
type OperationsV2Props<TOptions extends PluginFactoryOptions> = {
|
|
448
|
+
config: Config;
|
|
449
|
+
plugin: Plugin<TOptions>;
|
|
450
|
+
nodes: Array<OperationNode>;
|
|
451
|
+
};
|
|
452
|
+
type OperationV1Props<TOptions extends PluginFactoryOptions> = {
|
|
474
453
|
config: Config;
|
|
475
454
|
generator: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
476
455
|
plugin: Plugin<TOptions>;
|
|
477
456
|
operation: Operation;
|
|
478
457
|
};
|
|
479
|
-
type
|
|
458
|
+
type OperationV2Props<TOptions extends PluginFactoryOptions> = {
|
|
459
|
+
config: Config;
|
|
460
|
+
plugin: Plugin<TOptions>;
|
|
461
|
+
node: OperationNode;
|
|
462
|
+
};
|
|
463
|
+
type OperationsProps<TOptions extends PluginFactoryOptions, TVersion extends Version = '1'> = TVersion extends '2' ? OperationsV2Props<TOptions> : OperationsV1Props<TOptions>;
|
|
464
|
+
type OperationProps<TOptions extends PluginFactoryOptions, TVersion extends Version = '1'> = TVersion extends '2' ? OperationV2Props<TOptions> : OperationV1Props<TOptions>;
|
|
465
|
+
type SchemaV1Props<TOptions extends PluginFactoryOptions> = {
|
|
480
466
|
config: Config;
|
|
481
467
|
generator: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>;
|
|
482
468
|
plugin: Plugin<TOptions>;
|
|
@@ -486,22 +472,29 @@ type SchemaProps<TOptions extends PluginFactoryOptions> = {
|
|
|
486
472
|
value: SchemaObject;
|
|
487
473
|
};
|
|
488
474
|
};
|
|
489
|
-
type
|
|
475
|
+
type SchemaV2Props<TOptions extends PluginFactoryOptions> = {
|
|
476
|
+
config: Config;
|
|
477
|
+
plugin: Plugin<TOptions>;
|
|
478
|
+
node: SchemaNode;
|
|
479
|
+
};
|
|
480
|
+
type SchemaProps<TOptions extends PluginFactoryOptions, TVersion extends Version = '1'> = TVersion extends '2' ? SchemaV2Props<TOptions> : SchemaV1Props<TOptions>;
|
|
481
|
+
type Generator<TOptions extends PluginFactoryOptions, TVersion extends Version = Version> = CoreGenerator<TOptions, TVersion> | ReactGenerator<TOptions, TVersion>;
|
|
490
482
|
//#endregion
|
|
491
483
|
//#region ../plugin-oas/src/generators/createReactGenerator.d.ts
|
|
492
|
-
type ReactGenerator<TOptions extends PluginFactoryOptions> = {
|
|
484
|
+
type ReactGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version> = {
|
|
493
485
|
name: string;
|
|
494
486
|
type: 'react';
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
487
|
+
version: TVersion;
|
|
488
|
+
Operations: (props: OperationsProps<TOptions, TVersion>) => FabricReactNode;
|
|
489
|
+
Operation: (props: OperationProps<TOptions, TVersion>) => FabricReactNode;
|
|
490
|
+
Schema: (props: SchemaProps<TOptions, TVersion>) => FabricReactNode;
|
|
498
491
|
};
|
|
499
492
|
//#endregion
|
|
500
493
|
//#region src/generators/operationsGenerator.d.ts
|
|
501
|
-
declare const operationsGenerator: ReactGenerator<PluginZod>;
|
|
494
|
+
declare const operationsGenerator: ReactGenerator<PluginZod, "1">;
|
|
502
495
|
//#endregion
|
|
503
496
|
//#region src/generators/zodGenerator.d.ts
|
|
504
|
-
declare const zodGenerator: ReactGenerator<PluginZod>;
|
|
497
|
+
declare const zodGenerator: ReactGenerator<PluginZod, "1">;
|
|
505
498
|
//#endregion
|
|
506
499
|
export { operationsGenerator, zodGenerator };
|
|
507
500
|
//# sourceMappingURL=generators.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-zod",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.35.0",
|
|
4
4
|
"description": "Zod schema generator plugin for Kubb, creating type-safe validation schemas from OpenAPI specifications for runtime data validation.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"zod",
|
|
@@ -79,10 +79,10 @@
|
|
|
79
79
|
"dependencies": {
|
|
80
80
|
"@kubb/react-fabric": "0.13.3",
|
|
81
81
|
"remeda": "^2.33.6",
|
|
82
|
-
"@kubb/core": "4.
|
|
83
|
-
"@kubb/
|
|
84
|
-
"@kubb/plugin-oas": "4.
|
|
85
|
-
"@kubb/
|
|
82
|
+
"@kubb/core": "4.35.0",
|
|
83
|
+
"@kubb/oas": "4.35.0",
|
|
84
|
+
"@kubb/plugin-oas": "4.35.0",
|
|
85
|
+
"@kubb/plugin-ts": "4.35.0"
|
|
86
86
|
},
|
|
87
87
|
"devDependencies": {
|
|
88
88
|
"@asteasolutions/zod-to-openapi": "^8.4.3",
|