@kubb/plugin-zod 4.11.1 → 4.11.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/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as UserPluginWithLifeCycle, n as PluginZod, t as Options } from "./types-BJRQY0iM.js";
1
+ import { a as UserPluginWithLifeCycle, n as PluginZod, t as Options } from "./types-BIZhZG2K.js";
2
2
 
3
3
  //#region src/plugin.d.ts
4
4
  declare const pluginZodName = "plugin-zod";
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { n as operationsGenerator, t as zodGenerator } from "./generators-DKQPsBns.js";
1
+ import { n as operationsGenerator, t as zodGenerator } from "./generators-Df7mE4WQ.js";
2
2
  import path from "node:path";
3
3
  import { PackageManager, definePlugin, getBarrelFiles, getMode } from "@kubb/core";
4
4
  import { camelCase, pascalCase } from "@kubb/core/transformers";
@@ -79,6 +79,7 @@ const pluginZod = definePlugin((options) => {
79
79
  fabric: this.fabric,
80
80
  oas,
81
81
  pluginManager: this.pluginManager,
82
+ logger: this.logger,
82
83
  plugin: this.plugin,
83
84
  contentType,
84
85
  include: void 0,
@@ -91,6 +92,7 @@ const pluginZod = definePlugin((options) => {
91
92
  fabric: this.fabric,
92
93
  oas,
93
94
  pluginManager: this.pluginManager,
95
+ logger: this.logger,
94
96
  plugin: this.plugin,
95
97
  contentType,
96
98
  exclude,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["options","groupName: Group['name']","transformers"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { definePlugin, type Group, getBarrelFiles, getMode, PackageManager } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport { resolveModuleSource } from '@kubb/core/utils'\nimport { OperationGenerator, pluginOasName, SchemaGenerator } from '@kubb/plugin-oas'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { operationsGenerator } from './generators'\nimport { zodGenerator } from './generators/zodGenerator.tsx'\nimport type { PluginZod } from './types.ts'\n\nexport const pluginZodName = 'plugin-zod' satisfies PluginZod['name']\n\nexport const pluginZod = definePlugin<PluginZod>((options) => {\n const {\n output = { path: 'zod', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n transformers = {},\n dateType = 'string',\n unknownType = 'any',\n emptySchemaType = unknownType,\n typed = false,\n mapper = {},\n operations = false,\n mini = false,\n version = mini ? '4' : new PackageManager().isValidSync('zod', '>=4') ? '4' : '3',\n importPath = mini ? 'zod/mini' : version === '4' ? 'zod/v4' : 'zod',\n coercion = false,\n inferred = false,\n generators = [zodGenerator, operations ? operationsGenerator : undefined].filter(Boolean),\n wrapOutput = undefined,\n contentType,\n } = options\n\n const usedEnumNames = {}\n\n return {\n name: pluginZodName,\n options: {\n output,\n transformers,\n include,\n exclude,\n override,\n typed,\n dateType,\n unknownType,\n emptySchemaType,\n mapper,\n importPath,\n coercion,\n operations,\n inferred,\n group,\n wrapOutput,\n version,\n mini,\n usedEnumNames,\n },\n pre: [pluginOasName, typed ? pluginTsName : undefined].filter(Boolean),\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 let resolvedName = camelCase(name, {\n suffix: type ? 'schema' : undefined,\n isFile: type === 'file',\n })\n\n if (type === 'type') {\n resolvedName = pascalCase(resolvedName)\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 if (this.plugin.options.typed && this.plugin.options.version === '3') {\n // pre add bundled\n await this.addFile({\n baseName: 'ToZod.ts',\n path: path.resolve(root, '.kubb/ToZod.ts'),\n sources: [\n {\n name: 'ToZod',\n value: resolveModuleSource('@kubb/plugin-zod/templates/ToZod').source,\n },\n ],\n })\n }\n\n const schemaGenerator = new SchemaGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\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 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 pluginKey: this.plugin.key,\n },\n logger: this.logger,\n })\n\n await this.upsertFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;AAUA,MAAa,gBAAgB;AAE7B,MAAa,YAAY,cAAyB,YAAY;CAC5D,MAAM,EACJ,SAAS;EAAE,MAAM;EAAO,YAAY;EAAS,EAC7C,OACA,UAAU,EAAE,EACZ,SACA,WAAW,EAAE,EACb,+BAAe,EAAE,EACjB,WAAW,UACX,cAAc,OACd,kBAAkB,aAClB,QAAQ,OACR,SAAS,EAAE,EACX,aAAa,OACb,OAAO,OACP,UAAU,OAAO,MAAM,IAAI,gBAAgB,C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IAAI;AAGrD,UAAO;;EAET,MAAM,UAAU;GACd,MAAM,OAAO,KAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,KAAK;GACpE,MAAM,OAAO,QAAQ,KAAK,QAAQ,MAAM,OAAO,KAAK,CAAC;GACrD,MAAM,MAAM,MAAM,KAAK,QAAQ;AAE/B,OAAI,KAAK,OAAO,QAAQ,SAAS,KAAK,OAAO,QAAQ,YAAY,IAE/D,OAAM,KAAK,QAAQ;IACjB,UAAU;IACV,MAAM,KAAK,QAAQ,MAAM,iBAAiB;IAC1C,SAAS,CACP;KACE,MAAM;KACN,OAAO,oBAAoB,mCAAmC,CAAC;KAChE,CACF;IACF,CAAC;GAeJ,MAAM,cAAc,MAZI,IAAI,gBAAgB,KAAK,OAAO,SAAS;IAC/D,QAAQ,KAAK;IACb;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb;IACA,SAAS;IACT;IACA;IACA,QAAQ,OAAO;IAChB,CAAC,CAEwC,MAAM,GAAG,WAAW;AAC9D,SAAM,KAAK,WAAW,GAAG,YAAY;GAcrC,MAAM,iBAAiB,MAZI,IAAI,mBAAmB,KAAK,OAAO,SAAS;IACrE,QAAQ,KAAK;IACb;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb;IACA;IACA;IACA;IACA;IACD,CAAC,CAE8C,MAAM,GAAG,WAAW;AACpE,SAAM,KAAK,WAAW,GAAG,eAAe;GAExC,MAAM,cAAc,MAAM,eAAe,KAAK,OAAO,OAAO;IAC1D,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,WAAW,KAAK,OAAO,KACxB;IACD,QAAQ,KAAK;IACd,CAAC;AAEF,SAAM,KAAK,WAAW,GAAG,YAAY;;EAExC;EACD"}
1
+ {"version":3,"file":"index.js","names":["options","groupName: Group['name']","transformers"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { definePlugin, type Group, getBarrelFiles, getMode, PackageManager } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport { resolveModuleSource } from '@kubb/core/utils'\nimport { OperationGenerator, pluginOasName, SchemaGenerator } from '@kubb/plugin-oas'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { operationsGenerator } from './generators'\nimport { zodGenerator } from './generators/zodGenerator.tsx'\nimport type { PluginZod } from './types.ts'\n\nexport const pluginZodName = 'plugin-zod' satisfies PluginZod['name']\n\nexport const pluginZod = definePlugin<PluginZod>((options) => {\n const {\n output = { path: 'zod', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n transformers = {},\n dateType = 'string',\n unknownType = 'any',\n emptySchemaType = unknownType,\n typed = false,\n mapper = {},\n operations = false,\n mini = false,\n version = mini ? '4' : new PackageManager().isValidSync('zod', '>=4') ? '4' : '3',\n importPath = mini ? 'zod/mini' : version === '4' ? 'zod/v4' : 'zod',\n coercion = false,\n inferred = false,\n generators = [zodGenerator, operations ? operationsGenerator : undefined].filter(Boolean),\n wrapOutput = undefined,\n contentType,\n } = options\n\n const usedEnumNames = {}\n\n return {\n name: pluginZodName,\n options: {\n output,\n transformers,\n include,\n exclude,\n override,\n typed,\n dateType,\n unknownType,\n emptySchemaType,\n mapper,\n importPath,\n coercion,\n operations,\n inferred,\n group,\n wrapOutput,\n version,\n mini,\n usedEnumNames,\n },\n pre: [pluginOasName, typed ? pluginTsName : undefined].filter(Boolean),\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 let resolvedName = camelCase(name, {\n suffix: type ? 'schema' : undefined,\n isFile: type === 'file',\n })\n\n if (type === 'type') {\n resolvedName = pascalCase(resolvedName)\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 if (this.plugin.options.typed && this.plugin.options.version === '3') {\n // pre add bundled\n await this.addFile({\n baseName: 'ToZod.ts',\n path: path.resolve(root, '.kubb/ToZod.ts'),\n sources: [\n {\n name: 'ToZod',\n value: resolveModuleSource('@kubb/plugin-zod/templates/ToZod').source,\n },\n ],\n })\n }\n\n const schemaGenerator = new SchemaGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\n logger: this.logger,\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 logger: this.logger,\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 pluginKey: this.plugin.key,\n },\n logger: this.logger,\n })\n\n await this.upsertFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;AAUA,MAAa,gBAAgB;AAE7B,MAAa,YAAY,cAAyB,YAAY;CAC5D,MAAM,EACJ,SAAS;EAAE,MAAM;EAAO,YAAY;EAA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OAAO,KACxB;IACD,QAAQ,KAAK;IACd,CAAC;AAEF,SAAM,KAAK,WAAW,GAAG,YAAY;;EAExC;EACD"}
@@ -1,3 +1,4 @@
1
+ import { Fabric } from "@kubb/react-fabric";
1
2
  import * as OasTypes from "oas/types";
2
3
  import { HttpMethods as HttpMethod, OASDocument, SchemaObject, User } from "oas/types";
3
4
  import { Operation, Operation as Operation$1 } from "oas/operation";
@@ -5,7 +6,6 @@ import { OpenAPIV3 } from "openapi-types";
5
6
  import * as oas_normalize_lib_types0 from "oas-normalize/lib/types";
6
7
  import BaseOas from "oas";
7
8
  import { KubbFile } from "@kubb/fabric-core/types";
8
- import { Fabric } from "@kubb/react-fabric";
9
9
  import { ConsolaInstance, LogLevel } from "consola";
10
10
  import { KubbNode } from "@kubb/react-fabric/types";
11
11
 
@@ -73,13 +73,35 @@ type DebugEvent = {
73
73
  date: Date;
74
74
  logs: string[];
75
75
  fileName?: string;
76
+ /**
77
+ * Category of the debug log, used for GitHub Actions grouping
78
+ * - 'setup': Initial configuration and environment setup
79
+ * - 'plugin': Plugin installation and execution
80
+ * - 'hook': Plugin hook execution details
81
+ * - 'schema': Schema parsing and generation
82
+ * - 'file': File operations (read/write/generate)
83
+ * - 'error': Error details and stack traces
84
+ * - undefined: Generic logs (always inline)
85
+ */
86
+ category?: 'setup' | 'plugin' | 'hook' | 'schema' | 'file' | 'error';
87
+ /**
88
+ * Plugin name for grouping plugin-specific logs together
89
+ */
90
+ pluginName?: string;
91
+ /**
92
+ * Indicates if this is the start or end of a plugin's execution
93
+ * - 'start': Start of plugin execution group
94
+ * - 'end': End of plugin execution group
95
+ */
96
+ pluginGroupMarker?: 'start' | 'end';
76
97
  };
77
98
  type Events$1 = {
78
99
  start: [message: string];
79
100
  success: [message: string];
80
- error: [message: string, cause: Error];
101
+ error: [message: string, error: Error];
81
102
  warning: [message: string];
82
103
  debug: [DebugEvent];
104
+ verbose: [DebugEvent];
83
105
  info: [message: string];
84
106
  progress_start: [{
85
107
  id: string;
@@ -103,7 +125,7 @@ type Logger = {
103
125
  consola?: ConsolaInstance;
104
126
  on: EventEmitter<Events$1>['on'];
105
127
  emit: EventEmitter<Events$1>['emit'];
106
- writeLogs: () => Promise<string[]>;
128
+ writeLogs: () => Promise<void>;
107
129
  };
108
130
  //#endregion
109
131
  //#region ../core/src/utils/types.d.ts
@@ -414,14 +436,35 @@ type Group = {
414
436
  //#region ../core/src/PluginManager.d.ts
415
437
  type RequiredPluginLifecycle = Required<PluginLifecycle>;
416
438
  type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
417
- type Executer<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
418
- message: string;
439
+ type ExecutingMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
440
+ strategy: Strategy;
441
+ hookName: H;
442
+ plugin: Plugin;
443
+ parameters?: unknown[] | undefined;
444
+ output?: unknown;
445
+ };
446
+ type ExecutedMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
447
+ duration: number;
419
448
  strategy: Strategy;
420
449
  hookName: H;
421
450
  plugin: Plugin;
422
451
  parameters?: unknown[] | undefined;
423
452
  output?: unknown;
424
453
  };
454
+ type ErrorMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
455
+ hookName: H;
456
+ duration: number;
457
+ strategy: Strategy;
458
+ parameters?: unknown[] | undefined;
459
+ plugin: Plugin;
460
+ };
461
+ type ProgressStartMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
462
+ hookName: H;
463
+ plugins: Array<Plugin>;
464
+ };
465
+ type ProgressStopMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
466
+ hookName: H;
467
+ };
425
468
  type ParseResult<H extends PluginLifecycleHooks> = RequiredPluginLifecycle[H];
426
469
  type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {
427
470
  result: Result;
@@ -436,9 +479,11 @@ type Options$1 = {
436
479
  concurrency?: number;
437
480
  };
438
481
  type Events = {
439
- executing: [executer: Executer];
440
- executed: [executer: Executer];
441
- error: [error: Error];
482
+ progress_start: [meta: ProgressStartMeta];
483
+ progress_stop: [meta: ProgressStopMeta];
484
+ executing: [meta: ExecutingMeta];
485
+ executed: [meta: ExecutedMeta];
486
+ error: [error: Error, meta: ErrorMeta];
442
487
  };
443
488
  type GetFileProps<TOptions = object> = {
444
489
  name: string;
@@ -451,8 +496,6 @@ declare class PluginManager {
451
496
  #private;
452
497
  readonly events: EventEmitter<Events>;
453
498
  readonly config: Config;
454
- readonly executed: Array<Executer>;
455
- readonly logger: Logger;
456
499
  readonly options: Options$1;
457
500
  constructor(config: Config, options: Options$1);
458
501
  getContext<TOptions extends PluginFactoryOptions>(plugin: Plugin<TOptions>): PluginContext<TOptions> & Record<string, any>;
@@ -478,13 +521,11 @@ declare class PluginManager {
478
521
  hookForPlugin<H extends PluginLifecycleHooks>({
479
522
  pluginKey,
480
523
  hookName,
481
- parameters,
482
- message
524
+ parameters
483
525
  }: {
484
526
  pluginKey: Plugin['key'];
485
527
  hookName: H;
486
528
  parameters: PluginParameter<H>;
487
- message: string;
488
529
  }): Promise<Array<ReturnType<ParseResult<H>> | null>>;
489
530
  /**
490
531
  * Run a specific hookName for plugin x.
@@ -492,13 +533,11 @@ declare class PluginManager {
492
533
  hookForPluginSync<H extends PluginLifecycleHooks>({
493
534
  pluginKey,
494
535
  hookName,
495
- parameters,
496
- message
536
+ parameters
497
537
  }: {
498
538
  pluginKey: Plugin['key'];
499
539
  hookName: H;
500
540
  parameters: PluginParameter<H>;
501
- message: string;
502
541
  }): Array<ReturnType<ParseResult<H>>> | null;
503
542
  /**
504
543
  * First non-null result stops and will return it's value.
@@ -506,13 +545,11 @@ declare class PluginManager {
506
545
  hookFirst<H extends PluginLifecycleHooks>({
507
546
  hookName,
508
547
  parameters,
509
- skipped,
510
- message
548
+ skipped
511
549
  }: {
512
550
  hookName: H;
513
551
  parameters: PluginParameter<H>;
514
552
  skipped?: ReadonlySet<Plugin> | null;
515
- message: string;
516
553
  }): Promise<SafeParseResult<H>>;
517
554
  /**
518
555
  * First non-null result stops and will return it's value.
@@ -520,37 +557,31 @@ declare class PluginManager {
520
557
  hookFirstSync<H extends PluginLifecycleHooks>({
521
558
  hookName,
522
559
  parameters,
523
- skipped,
524
- message
560
+ skipped
525
561
  }: {
526
562
  hookName: H;
527
563
  parameters: PluginParameter<H>;
528
564
  skipped?: ReadonlySet<Plugin> | null;
529
- message: string;
530
565
  }): SafeParseResult<H>;
531
566
  /**
532
567
  * Run all plugins in parallel(order will be based on `this.plugin` and if `pre` or `post` is set).
533
568
  */
534
569
  hookParallel<H extends PluginLifecycleHooks, TOuput = void>({
535
570
  hookName,
536
- parameters,
537
- message
571
+ parameters
538
572
  }: {
539
573
  hookName: H;
540
574
  parameters?: Parameters<RequiredPluginLifecycle[H]> | undefined;
541
- message: string;
542
575
  }): Promise<Awaited<TOuput>[]>;
543
576
  /**
544
577
  * Chains plugins
545
578
  */
546
579
  hookSeq<H extends PluginLifecycleHooks>({
547
580
  hookName,
548
- parameters,
549
- message
581
+ parameters
550
582
  }: {
551
583
  hookName: H;
552
584
  parameters?: PluginParameter<H>;
553
- message: string;
554
585
  }): Promise<void>;
555
586
  getPluginByKey(pluginKey: Plugin['key']): Plugin | undefined;
556
587
  getPluginsByKey(hookName: keyof PluginWithLifeCycle, pluginKey: Plugin['key']): Plugin[];
@@ -880,6 +911,7 @@ type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
880
911
  fabric: Fabric;
881
912
  oas: Oas;
882
913
  pluginManager: PluginManager;
914
+ logger?: Logger;
883
915
  /**
884
916
  * Current plugin
885
917
  */
@@ -984,6 +1016,7 @@ type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
984
1016
  override: Array<Override<TOptions>> | undefined;
985
1017
  contentType: contentType | undefined;
986
1018
  pluginManager: PluginManager;
1019
+ logger?: Logger;
987
1020
  /**
988
1021
  * Current plugin
989
1022
  */
@@ -1140,4 +1173,4 @@ type ResolvedOptions = {
1140
1173
  type PluginZod = PluginFactoryOptions<'plugin-zod', Options, ResolvedOptions, never, ResolvePathOptions>;
1141
1174
  //#endregion
1142
1175
  export { UserPluginWithLifeCycle as a, Schema as i, PluginZod as n, Operation$1 as o, ReactGenerator as r, SchemaObject$1 as s, Options as t };
1143
- //# sourceMappingURL=types-DL8vhJwK.d.cts.map
1176
+ //# sourceMappingURL=types-BIZhZG2K.d.ts.map
@@ -1,4 +1,3 @@
1
- import { Fabric } from "@kubb/react-fabric";
2
1
  import * as OasTypes from "oas/types";
3
2
  import { HttpMethods as HttpMethod, OASDocument, SchemaObject, User } from "oas/types";
4
3
  import { Operation, Operation as Operation$1 } from "oas/operation";
@@ -6,6 +5,7 @@ import { OpenAPIV3 } from "openapi-types";
6
5
  import * as oas_normalize_lib_types0 from "oas-normalize/lib/types";
7
6
  import BaseOas from "oas";
8
7
  import { KubbFile } from "@kubb/fabric-core/types";
8
+ import { Fabric } from "@kubb/react-fabric";
9
9
  import { ConsolaInstance, LogLevel } from "consola";
10
10
  import { KubbNode } from "@kubb/react-fabric/types";
11
11
 
@@ -73,13 +73,35 @@ type DebugEvent = {
73
73
  date: Date;
74
74
  logs: string[];
75
75
  fileName?: string;
76
+ /**
77
+ * Category of the debug log, used for GitHub Actions grouping
78
+ * - 'setup': Initial configuration and environment setup
79
+ * - 'plugin': Plugin installation and execution
80
+ * - 'hook': Plugin hook execution details
81
+ * - 'schema': Schema parsing and generation
82
+ * - 'file': File operations (read/write/generate)
83
+ * - 'error': Error details and stack traces
84
+ * - undefined: Generic logs (always inline)
85
+ */
86
+ category?: 'setup' | 'plugin' | 'hook' | 'schema' | 'file' | 'error';
87
+ /**
88
+ * Plugin name for grouping plugin-specific logs together
89
+ */
90
+ pluginName?: string;
91
+ /**
92
+ * Indicates if this is the start or end of a plugin's execution
93
+ * - 'start': Start of plugin execution group
94
+ * - 'end': End of plugin execution group
95
+ */
96
+ pluginGroupMarker?: 'start' | 'end';
76
97
  };
77
98
  type Events$1 = {
78
99
  start: [message: string];
79
100
  success: [message: string];
80
- error: [message: string, cause: Error];
101
+ error: [message: string, error: Error];
81
102
  warning: [message: string];
82
103
  debug: [DebugEvent];
104
+ verbose: [DebugEvent];
83
105
  info: [message: string];
84
106
  progress_start: [{
85
107
  id: string;
@@ -103,7 +125,7 @@ type Logger = {
103
125
  consola?: ConsolaInstance;
104
126
  on: EventEmitter<Events$1>['on'];
105
127
  emit: EventEmitter<Events$1>['emit'];
106
- writeLogs: () => Promise<string[]>;
128
+ writeLogs: () => Promise<void>;
107
129
  };
108
130
  //#endregion
109
131
  //#region ../core/src/utils/types.d.ts
@@ -414,14 +436,35 @@ type Group = {
414
436
  //#region ../core/src/PluginManager.d.ts
415
437
  type RequiredPluginLifecycle = Required<PluginLifecycle>;
416
438
  type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
417
- type Executer<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
418
- message: string;
439
+ type ExecutingMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
440
+ strategy: Strategy;
441
+ hookName: H;
442
+ plugin: Plugin;
443
+ parameters?: unknown[] | undefined;
444
+ output?: unknown;
445
+ };
446
+ type ExecutedMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
447
+ duration: number;
419
448
  strategy: Strategy;
420
449
  hookName: H;
421
450
  plugin: Plugin;
422
451
  parameters?: unknown[] | undefined;
423
452
  output?: unknown;
424
453
  };
454
+ type ErrorMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
455
+ hookName: H;
456
+ duration: number;
457
+ strategy: Strategy;
458
+ parameters?: unknown[] | undefined;
459
+ plugin: Plugin;
460
+ };
461
+ type ProgressStartMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
462
+ hookName: H;
463
+ plugins: Array<Plugin>;
464
+ };
465
+ type ProgressStopMeta<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
466
+ hookName: H;
467
+ };
425
468
  type ParseResult<H extends PluginLifecycleHooks> = RequiredPluginLifecycle[H];
426
469
  type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {
427
470
  result: Result;
@@ -436,9 +479,11 @@ type Options$1 = {
436
479
  concurrency?: number;
437
480
  };
438
481
  type Events = {
439
- executing: [executer: Executer];
440
- executed: [executer: Executer];
441
- error: [error: Error];
482
+ progress_start: [meta: ProgressStartMeta];
483
+ progress_stop: [meta: ProgressStopMeta];
484
+ executing: [meta: ExecutingMeta];
485
+ executed: [meta: ExecutedMeta];
486
+ error: [error: Error, meta: ErrorMeta];
442
487
  };
443
488
  type GetFileProps<TOptions = object> = {
444
489
  name: string;
@@ -451,8 +496,6 @@ declare class PluginManager {
451
496
  #private;
452
497
  readonly events: EventEmitter<Events>;
453
498
  readonly config: Config;
454
- readonly executed: Array<Executer>;
455
- readonly logger: Logger;
456
499
  readonly options: Options$1;
457
500
  constructor(config: Config, options: Options$1);
458
501
  getContext<TOptions extends PluginFactoryOptions>(plugin: Plugin<TOptions>): PluginContext<TOptions> & Record<string, any>;
@@ -478,13 +521,11 @@ declare class PluginManager {
478
521
  hookForPlugin<H extends PluginLifecycleHooks>({
479
522
  pluginKey,
480
523
  hookName,
481
- parameters,
482
- message
524
+ parameters
483
525
  }: {
484
526
  pluginKey: Plugin['key'];
485
527
  hookName: H;
486
528
  parameters: PluginParameter<H>;
487
- message: string;
488
529
  }): Promise<Array<ReturnType<ParseResult<H>> | null>>;
489
530
  /**
490
531
  * Run a specific hookName for plugin x.
@@ -492,13 +533,11 @@ declare class PluginManager {
492
533
  hookForPluginSync<H extends PluginLifecycleHooks>({
493
534
  pluginKey,
494
535
  hookName,
495
- parameters,
496
- message
536
+ parameters
497
537
  }: {
498
538
  pluginKey: Plugin['key'];
499
539
  hookName: H;
500
540
  parameters: PluginParameter<H>;
501
- message: string;
502
541
  }): Array<ReturnType<ParseResult<H>>> | null;
503
542
  /**
504
543
  * First non-null result stops and will return it's value.
@@ -506,13 +545,11 @@ declare class PluginManager {
506
545
  hookFirst<H extends PluginLifecycleHooks>({
507
546
  hookName,
508
547
  parameters,
509
- skipped,
510
- message
548
+ skipped
511
549
  }: {
512
550
  hookName: H;
513
551
  parameters: PluginParameter<H>;
514
552
  skipped?: ReadonlySet<Plugin> | null;
515
- message: string;
516
553
  }): Promise<SafeParseResult<H>>;
517
554
  /**
518
555
  * First non-null result stops and will return it's value.
@@ -520,37 +557,31 @@ declare class PluginManager {
520
557
  hookFirstSync<H extends PluginLifecycleHooks>({
521
558
  hookName,
522
559
  parameters,
523
- skipped,
524
- message
560
+ skipped
525
561
  }: {
526
562
  hookName: H;
527
563
  parameters: PluginParameter<H>;
528
564
  skipped?: ReadonlySet<Plugin> | null;
529
- message: string;
530
565
  }): SafeParseResult<H>;
531
566
  /**
532
567
  * Run all plugins in parallel(order will be based on `this.plugin` and if `pre` or `post` is set).
533
568
  */
534
569
  hookParallel<H extends PluginLifecycleHooks, TOuput = void>({
535
570
  hookName,
536
- parameters,
537
- message
571
+ parameters
538
572
  }: {
539
573
  hookName: H;
540
574
  parameters?: Parameters<RequiredPluginLifecycle[H]> | undefined;
541
- message: string;
542
575
  }): Promise<Awaited<TOuput>[]>;
543
576
  /**
544
577
  * Chains plugins
545
578
  */
546
579
  hookSeq<H extends PluginLifecycleHooks>({
547
580
  hookName,
548
- parameters,
549
- message
581
+ parameters
550
582
  }: {
551
583
  hookName: H;
552
584
  parameters?: PluginParameter<H>;
553
- message: string;
554
585
  }): Promise<void>;
555
586
  getPluginByKey(pluginKey: Plugin['key']): Plugin | undefined;
556
587
  getPluginsByKey(hookName: keyof PluginWithLifeCycle, pluginKey: Plugin['key']): Plugin[];
@@ -880,6 +911,7 @@ type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
880
911
  fabric: Fabric;
881
912
  oas: Oas;
882
913
  pluginManager: PluginManager;
914
+ logger?: Logger;
883
915
  /**
884
916
  * Current plugin
885
917
  */
@@ -984,6 +1016,7 @@ type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
984
1016
  override: Array<Override<TOptions>> | undefined;
985
1017
  contentType: contentType | undefined;
986
1018
  pluginManager: PluginManager;
1019
+ logger?: Logger;
987
1020
  /**
988
1021
  * Current plugin
989
1022
  */
@@ -1140,4 +1173,4 @@ type ResolvedOptions = {
1140
1173
  type PluginZod = PluginFactoryOptions<'plugin-zod', Options, ResolvedOptions, never, ResolvePathOptions>;
1141
1174
  //#endregion
1142
1175
  export { UserPluginWithLifeCycle as a, Schema as i, PluginZod as n, Operation$1 as o, ReactGenerator as r, SchemaObject$1 as s, Options as t };
1143
- //# sourceMappingURL=types-BJRQY0iM.d.ts.map
1176
+ //# sourceMappingURL=types-BNjvGwN4.d.cts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-zod",
3
- "version": "4.11.1",
3
+ "version": "4.11.3",
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",
@@ -69,16 +69,16 @@
69
69
  ],
70
70
  "dependencies": {
71
71
  "@kubb/react-fabric": "0.5.4",
72
- "@kubb/core": "4.11.1",
73
- "@kubb/oas": "4.11.1",
74
- "@kubb/plugin-oas": "4.11.1",
75
- "@kubb/plugin-ts": "4.11.1"
72
+ "@kubb/core": "4.11.3",
73
+ "@kubb/oas": "4.11.3",
74
+ "@kubb/plugin-oas": "4.11.3",
75
+ "@kubb/plugin-ts": "4.11.3"
76
76
  },
77
77
  "devDependencies": {
78
78
  "@asteasolutions/zod-to-openapi": "^8.2.0",
79
79
  "@hono/zod-openapi": "0.19.2",
80
80
  "zod": "^3.25.76",
81
- "@kubb/plugin-oas": "4.11.1"
81
+ "@kubb/plugin-oas": "4.11.3"
82
82
  },
83
83
  "engines": {
84
84
  "node": ">=20"
@@ -31,6 +31,7 @@ export const zodGenerator = createReactGenerator<PluginZod>({
31
31
  oas,
32
32
  plugin,
33
33
  pluginManager,
34
+ logger: generator.context.logger,
34
35
  mode,
35
36
  override: options.override,
36
37
  })
package/src/parser.ts CHANGED
@@ -303,11 +303,20 @@ const zodKeywordMapper = {
303
303
  }
304
304
  return '.optional()'
305
305
  },
306
- matches: (value = '', coercion?: boolean, mini?: boolean) => {
306
+ matches: (value = '', coercion?: boolean, mini?: boolean, min?: number, max?: number) => {
307
307
  if (mini) {
308
- return `z.string().check(z.regex(${value}))`
308
+ const checks = buildLengthChecks(min, max)
309
+ checks.push(`z.regex(${value})`)
310
+ return `z.string().check(${checks.join(', ')})`
309
311
  }
310
- return coercion ? `z.coerce.string().regex(${value})` : `z.string().regex(${value})`
312
+ return [
313
+ coercion ? 'z.coerce.string()' : 'z.string()',
314
+ min !== undefined ? `.min(${min})` : undefined,
315
+ max !== undefined ? `.max(${max})` : undefined,
316
+ `.regex(${value})`,
317
+ ]
318
+ .filter(Boolean)
319
+ .join('')
311
320
  },
312
321
  email: (coercion?: boolean, version: '3' | '4' = '3', min?: number, max?: number, mini?: boolean) => {
313
322
  if (mini) {
@@ -739,8 +748,11 @@ export const parse = createParser<string, ParserOptions>({
739
748
  return undefined // strip matches
740
749
  }
741
750
 
751
+ const minSchema = findSchemaKeyword(siblings, 'min')
752
+ const maxSchema = findSchemaKeyword(siblings, 'max')
753
+
742
754
  if (current.args) {
743
- return zodKeywordMapper.matches(transformers.toRegExpString(current.args, null), shouldCoerce(options.coercion, 'strings'), options.mini)
755
+ return zodKeywordMapper.matches(transformers.toRegExpString(current.args, null), shouldCoerce(options.coercion, 'strings'), options.mini, minSchema?.args, maxSchema?.args)
744
756
  }
745
757
  return undefined
746
758
  },
package/src/plugin.ts CHANGED
@@ -133,6 +133,7 @@ export const pluginZod = definePlugin<PluginZod>((options) => {
133
133
  fabric: this.fabric,
134
134
  oas,
135
135
  pluginManager: this.pluginManager,
136
+ logger: this.logger,
136
137
  plugin: this.plugin,
137
138
  contentType,
138
139
  include: undefined,
@@ -148,6 +149,7 @@ export const pluginZod = definePlugin<PluginZod>((options) => {
148
149
  fabric: this.fabric,
149
150
  oas,
150
151
  pluginManager: this.pluginManager,
152
+ logger: this.logger,
151
153
  plugin: this.plugin,
152
154
  contentType,
153
155
  exclude,