@kubb/plugin-msw 4.18.5 → 4.19.1

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.
@@ -1,4 +1,4 @@
1
- import { h as Operation, v as __name } from "./index-CJNbXw24.cjs";
1
+ import { h as Operation, v as __name } from "./index-B4gKt7dm.cjs";
2
2
  import { KubbNode } from "@kubb/react-fabric/types";
3
3
 
4
4
  //#region src/components/Handlers.d.ts
@@ -1,5 +1,5 @@
1
1
  import { t as __name } from "./chunk-eQyhnF5A.js";
2
- import { h as Operation } from "./index-CbLk6i3C.js";
2
+ import { h as Operation } from "./index-Cdqo2P0B.js";
3
3
  import { KubbNode } from "@kubb/react-fabric/types";
4
4
 
5
5
  //#region src/components/Handlers.d.ts
@@ -1,5 +1,5 @@
1
- import { v as __name } from "./index-CJNbXw24.cjs";
2
- import { n as PluginMsw, r as ReactGenerator } from "./types-B6OpXWFz.cjs";
1
+ import { v as __name } from "./index-B4gKt7dm.cjs";
2
+ import { n as PluginMsw, r as ReactGenerator } from "./types-BvhOEuZ8.cjs";
3
3
 
4
4
  //#region src/generators/handlersGenerator.d.ts
5
5
  declare const handlersGenerator: ReactGenerator<PluginMsw>;
@@ -1,6 +1,6 @@
1
1
  import { t as __name } from "./chunk-eQyhnF5A.js";
2
- import "./index-CbLk6i3C.js";
3
- import { n as PluginMsw, r as ReactGenerator } from "./types-DA9U9Z0N.js";
2
+ import "./index-Cdqo2P0B.js";
3
+ import { n as PluginMsw, r as ReactGenerator } from "./types-CBM4UWNM.js";
4
4
 
5
5
  //#region src/generators/handlersGenerator.d.ts
6
6
  declare const handlersGenerator: ReactGenerator<PluginMsw>;
@@ -19,16 +19,21 @@ type Operation$1 = Operation;
19
19
  type DiscriminatorObject$1 = DiscriminatorObject;
20
20
  //#endregion
21
21
  //#region ../oas/src/Oas.d.ts
22
- type Options$1 = {
22
+ type OasOptions = {
23
23
  contentType?: contentType;
24
24
  discriminator?: 'strict' | 'inherit';
25
+ /**
26
+ * Resolve name collisions when schemas from different components share the same name (case-insensitive).
27
+ * @default false
28
+ */
29
+ collisionDetection?: boolean;
25
30
  };
26
31
  declare class Oas extends BaseOas {
27
32
  #private;
28
33
  document: Document;
29
34
  constructor(document: Document);
30
- setOptions(options: Options$1): void;
31
- get options(): Options$1;
35
+ setOptions(options: OasOptions): void;
36
+ get options(): OasOptions;
32
37
  get<T = unknown>($ref: string): T | null;
33
38
  getKey($ref: string): string | undefined;
34
39
  set($ref: string, value: unknown): false | undefined;
@@ -39,6 +44,18 @@ declare class Oas extends BaseOas {
39
44
  getParametersSchema(operation: Operation$1, inKey: 'path' | 'query' | 'header'): SchemaObject$1 | null;
40
45
  validate(): Promise<oas_normalize_lib_types0.ValidationResult>;
41
46
  flattenSchema(schema: SchemaObject$1 | null): SchemaObject$1 | null;
47
+ /**
48
+ * Get schemas from OpenAPI components (schemas, responses, requestBodies).
49
+ * Returns schemas in dependency order along with name mapping for collision resolution.
50
+ */
51
+ getSchemas(options?: {
52
+ contentType?: contentType;
53
+ includes?: Array<'schemas' | 'responses' | 'requestBodies'>;
54
+ collisionDetection?: boolean;
55
+ }): {
56
+ schemas: Record<string, SchemaObject$1>;
57
+ nameMapping: Map<string, string>;
58
+ };
42
59
  }
43
60
  //#endregion
44
61
  //#region ../core/src/BaseGenerator.d.ts
@@ -729,4 +746,4 @@ type FileMetaBase = {
729
746
  };
730
747
  //#endregion
731
748
  export { contentType as _, Output as a, ResolveNameParams as c, KubbEvents as d, BaseGenerator as f, SchemaObject$1 as g, Operation$1 as h, Group as i, UserPluginWithLifeCycle as l, HttpMethod as m, PluginManager as n, Plugin as o, Oas as p, Config as r, PluginFactoryOptions as s, FileMetaBase as t, AsyncEventEmitter as u, __name as v };
732
- //# sourceMappingURL=index-CJNbXw24.d.cts.map
749
+ //# sourceMappingURL=index-B4gKt7dm.d.cts.map
@@ -18,16 +18,21 @@ type Operation$1 = Operation;
18
18
  type DiscriminatorObject$1 = DiscriminatorObject;
19
19
  //#endregion
20
20
  //#region ../oas/src/Oas.d.ts
21
- type Options$1 = {
21
+ type OasOptions = {
22
22
  contentType?: contentType;
23
23
  discriminator?: 'strict' | 'inherit';
24
+ /**
25
+ * Resolve name collisions when schemas from different components share the same name (case-insensitive).
26
+ * @default false
27
+ */
28
+ collisionDetection?: boolean;
24
29
  };
25
30
  declare class Oas extends BaseOas {
26
31
  #private;
27
32
  document: Document;
28
33
  constructor(document: Document);
29
- setOptions(options: Options$1): void;
30
- get options(): Options$1;
34
+ setOptions(options: OasOptions): void;
35
+ get options(): OasOptions;
31
36
  get<T = unknown>($ref: string): T | null;
32
37
  getKey($ref: string): string | undefined;
33
38
  set($ref: string, value: unknown): false | undefined;
@@ -38,6 +43,18 @@ declare class Oas extends BaseOas {
38
43
  getParametersSchema(operation: Operation$1, inKey: 'path' | 'query' | 'header'): SchemaObject$1 | null;
39
44
  validate(): Promise<oas_normalize_lib_types0.ValidationResult>;
40
45
  flattenSchema(schema: SchemaObject$1 | null): SchemaObject$1 | null;
46
+ /**
47
+ * Get schemas from OpenAPI components (schemas, responses, requestBodies).
48
+ * Returns schemas in dependency order along with name mapping for collision resolution.
49
+ */
50
+ getSchemas(options?: {
51
+ contentType?: contentType;
52
+ includes?: Array<'schemas' | 'responses' | 'requestBodies'>;
53
+ collisionDetection?: boolean;
54
+ }): {
55
+ schemas: Record<string, SchemaObject$1>;
56
+ nameMapping: Map<string, string>;
57
+ };
41
58
  }
42
59
  //#endregion
43
60
  //#region ../core/src/BaseGenerator.d.ts
@@ -728,4 +745,4 @@ type FileMetaBase = {
728
745
  };
729
746
  //#endregion
730
747
  export { contentType as _, Output as a, ResolveNameParams as c, KubbEvents as d, BaseGenerator as f, SchemaObject$1 as g, Operation$1 as h, Group as i, UserPluginWithLifeCycle as l, HttpMethod as m, PluginManager as n, Plugin as o, Oas as p, Config as r, PluginFactoryOptions as s, FileMetaBase as t, AsyncEventEmitter as u };
731
- //# sourceMappingURL=index-CbLk6i3C.d.ts.map
748
+ //# sourceMappingURL=index-Cdqo2P0B.d.ts.map
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { l as UserPluginWithLifeCycle, v as __name } from "./index-CJNbXw24.cjs";
2
- import { n as PluginMsw, t as Options } from "./types-B6OpXWFz.cjs";
1
+ import { l as UserPluginWithLifeCycle, v as __name } from "./index-B4gKt7dm.cjs";
2
+ import { n as PluginMsw, t as Options } from "./types-BvhOEuZ8.cjs";
3
3
 
4
4
  //#region src/plugin.d.ts
5
5
  declare const pluginMswName = "plugin-msw";
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { t as __name } from "./chunk-eQyhnF5A.js";
2
- import { l as UserPluginWithLifeCycle } from "./index-CbLk6i3C.js";
3
- import { n as PluginMsw, t as Options } from "./types-DA9U9Z0N.js";
2
+ import { l as UserPluginWithLifeCycle } from "./index-Cdqo2P0B.js";
3
+ import { n as PluginMsw, t as Options } from "./types-CBM4UWNM.js";
4
4
 
5
5
  //#region src/plugin.d.ts
6
6
  declare const pluginMswName = "plugin-msw";
@@ -1,4 +1,4 @@
1
- import { _ as contentType, a as Output, c as ResolveNameParams, d as KubbEvents, f as BaseGenerator, g as SchemaObject, h as Operation, i as Group, m as HttpMethod, n as PluginManager, o as Plugin, p as Oas, r as Config, s as PluginFactoryOptions, t as FileMetaBase, u as AsyncEventEmitter, v as __name } from "./index-CJNbXw24.cjs";
1
+ import { _ as contentType, a as Output, c as ResolveNameParams, d as KubbEvents, f as BaseGenerator, g as SchemaObject, h as Operation, i as Group, m as HttpMethod, n as PluginManager, o as Plugin, p as Oas, r as Config, s as PluginFactoryOptions, t as FileMetaBase, u as AsyncEventEmitter, v as __name } from "./index-B4gKt7dm.cjs";
2
2
  import { KubbNode } from "@kubb/react-fabric/types";
3
3
  import { KubbFile } from "@kubb/fabric-core/types";
4
4
  import { Fabric } from "@kubb/react-fabric";
@@ -376,6 +376,11 @@ type SchemaGeneratorOptions = {
376
376
  emptySchemaType: 'any' | 'unknown' | 'void';
377
377
  enumType?: 'enum' | 'asConst' | 'asPascalConst' | 'constEnum' | 'literal' | 'inlineLiteral';
378
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
+ */
379
384
  usedEnumNames?: Record<string, number>;
380
385
  mapper?: Record<string, string>;
381
386
  typed?: boolean;
@@ -396,6 +401,7 @@ type SchemaProps$1 = {
396
401
  schema: SchemaObject | null;
397
402
  name: string | null;
398
403
  parentName: string | null;
404
+ rootName?: string | null;
399
405
  };
400
406
  declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions, Context<TOptions, TPluginOptions>> {
401
407
  #private;
@@ -516,4 +522,4 @@ type ResolvedOptions = {
516
522
  type PluginMsw = PluginFactoryOptions<'plugin-msw', Options, ResolvedOptions, never, ResolvePathOptions>;
517
523
  //#endregion
518
524
  export { PluginMsw as n, ReactGenerator as r, Options as t };
519
- //# sourceMappingURL=types-B6OpXWFz.d.cts.map
525
+ //# sourceMappingURL=types-BvhOEuZ8.d.cts.map
@@ -1,5 +1,5 @@
1
1
  import { t as __name } from "./chunk-eQyhnF5A.js";
2
- import { _ as contentType, a as Output, c as ResolveNameParams, d as KubbEvents, f as BaseGenerator, g as SchemaObject, h as Operation, i as Group, m as HttpMethod, n as PluginManager, o as Plugin, p as Oas, r as Config, s as PluginFactoryOptions, t as FileMetaBase, u as AsyncEventEmitter } from "./index-CbLk6i3C.js";
2
+ import { _ as contentType, a as Output, c as ResolveNameParams, d as KubbEvents, f as BaseGenerator, g as SchemaObject, h as Operation, i as Group, m as HttpMethod, n as PluginManager, o as Plugin, p as Oas, r as Config, s as PluginFactoryOptions, t as FileMetaBase, u as AsyncEventEmitter } from "./index-Cdqo2P0B.js";
3
3
  import { Fabric } from "@kubb/react-fabric";
4
4
  import { KubbNode } from "@kubb/react-fabric/types";
5
5
  import { KubbFile } from "@kubb/fabric-core/types";
@@ -377,6 +377,11 @@ type SchemaGeneratorOptions = {
377
377
  emptySchemaType: 'any' | 'unknown' | 'void';
378
378
  enumType?: 'enum' | 'asConst' | 'asPascalConst' | 'constEnum' | 'literal' | 'inlineLiteral';
379
379
  enumSuffix?: string;
380
+ /**
381
+ * @deprecated Will be removed in v5. Use `collisionDetection: true` instead to prevent enum name collisions.
382
+ * When `collisionDetection` is enabled, the rootName-based approach eliminates the need for numeric suffixes.
383
+ * @internal
384
+ */
380
385
  usedEnumNames?: Record<string, number>;
381
386
  mapper?: Record<string, string>;
382
387
  typed?: boolean;
@@ -397,6 +402,7 @@ type SchemaProps$1 = {
397
402
  schema: SchemaObject | null;
398
403
  name: string | null;
399
404
  parentName: string | null;
405
+ rootName?: string | null;
400
406
  };
401
407
  declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions, Context<TOptions, TPluginOptions>> {
402
408
  #private;
@@ -517,4 +523,4 @@ type ResolvedOptions = {
517
523
  type PluginMsw = PluginFactoryOptions<'plugin-msw', Options, ResolvedOptions, never, ResolvePathOptions>;
518
524
  //#endregion
519
525
  export { PluginMsw as n, ReactGenerator as r, Options as t };
520
- //# sourceMappingURL=types-DA9U9Z0N.d.ts.map
526
+ //# sourceMappingURL=types-CBM4UWNM.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-msw",
3
- "version": "4.18.5",
3
+ "version": "4.19.1",
4
4
  "description": "Mock Service Worker (MSW) handlers generator plugin for Kubb, creating API mocks from OpenAPI specifications for frontend development and testing.",
5
5
  "keywords": [
6
6
  "msw",
@@ -74,11 +74,11 @@
74
74
  ],
75
75
  "dependencies": {
76
76
  "@kubb/react-fabric": "0.12.4",
77
- "@kubb/core": "4.18.5",
78
- "@kubb/oas": "4.18.5",
79
- "@kubb/plugin-faker": "4.18.5",
80
- "@kubb/plugin-oas": "4.18.5",
81
- "@kubb/plugin-ts": "4.18.5"
77
+ "@kubb/core": "4.19.1",
78
+ "@kubb/oas": "4.19.1",
79
+ "@kubb/plugin-faker": "4.19.1",
80
+ "@kubb/plugin-oas": "4.19.1",
81
+ "@kubb/plugin-ts": "4.19.1"
82
82
  },
83
83
  "devDependencies": {},
84
84
  "engines": {