@kubb/plugin-msw 4.29.1 → 4.31.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 { t as __name } from "./chunk-cy2TeOE5.cjs";
1
+ import { t as __name } from "./chunk-DKWOrOAv.js";
2
2
  import { FabricReactNode } from "@kubb/react-fabric/types";
3
3
  import { Operation } from "@kubb/oas";
4
4
 
@@ -1,11 +1,11 @@
1
- import { t as __name } from "./chunk-cy2TeOE5.cjs";
2
- import { n as PluginMsw } from "./types-BvqplGx0.js";
3
- import { FabricReactNode } from "@kubb/react-fabric/types";
4
- import { HttpMethod, Oas, Operation, SchemaObject, contentType } from "@kubb/oas";
1
+ import { t as __name } from "./chunk-DKWOrOAv.js";
2
+ import { n as PluginMsw } from "./types-DUwv-QOP.js";
5
3
  import { BaseGenerator, Config, FileMetaBase, Group, KubbEvents, Output, Plugin, PluginFactoryOptions, PluginManager, ResolveNameParams } from "@kubb/core";
4
+ import { Fabric } from "@kubb/react-fabric";
6
5
  import { AsyncEventEmitter } from "@kubb/core/utils";
6
+ import { FabricReactNode } from "@kubb/react-fabric/types";
7
+ import { HttpMethod, Oas, Operation, SchemaObject, contentType } from "@kubb/oas";
7
8
  import { KubbFile } from "@kubb/fabric-core/types";
8
- import { Fabric } from "@kubb/react-fabric";
9
9
 
10
10
  //#region ../plugin-oas/src/types.d.ts
11
11
  type GetOasOptions = {
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { t as __name } from "./chunk-cy2TeOE5.cjs";
2
- import { n as PluginMsw, t as Options } from "./types-BvqplGx0.js";
1
+ import { t as __name } from "./chunk-DKWOrOAv.js";
2
+ import { n as PluginMsw, t as Options } from "./types-DUwv-QOP.js";
3
3
  import * as _kubb_core0 from "@kubb/core";
4
4
 
5
5
  //#region src/plugin.d.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-msw",
3
- "version": "4.29.1",
3
+ "version": "4.31.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",
@@ -65,7 +65,8 @@
65
65
  "src",
66
66
  "dist",
67
67
  "!/**/**.test.**",
68
- "!/**/__tests__/**"
68
+ "!/**/__tests__/**",
69
+ "!/**/__snapshots__/**"
69
70
  ],
70
71
  "size-limit": [
71
72
  {
@@ -75,12 +76,12 @@
75
76
  }
76
77
  ],
77
78
  "dependencies": {
78
- "@kubb/react-fabric": "0.13.1",
79
- "@kubb/core": "4.29.1",
80
- "@kubb/oas": "4.29.1",
81
- "@kubb/plugin-faker": "4.29.1",
82
- "@kubb/plugin-ts": "4.29.1",
83
- "@kubb/plugin-oas": "4.29.1"
79
+ "@kubb/react-fabric": "0.13.3",
80
+ "@kubb/core": "4.31.1",
81
+ "@kubb/oas": "4.31.1",
82
+ "@kubb/plugin-faker": "4.31.1",
83
+ "@kubb/plugin-oas": "4.31.1",
84
+ "@kubb/plugin-ts": "4.31.1"
84
85
  },
85
86
  "devDependencies": {},
86
87
  "engines": {
@@ -1,68 +0,0 @@
1
- import { t as __name } from "./chunk-cy2TeOE5.cjs";
2
- import { Oas, contentType } from "@kubb/oas";
3
- import { Group, Output, PluginFactoryOptions, ResolveNameParams } from "@kubb/core";
4
- import { Exclude, Include, Override, ResolvePathOptions } from "@kubb/plugin-oas";
5
- import { Generator } from "@kubb/plugin-oas/generators";
6
-
7
- //#region src/types.d.ts
8
- type Options = {
9
- /**
10
- * Specify the export location for the files and define the behavior of the output
11
- * @default { path: 'mocks', barrelType: 'named' }
12
- */
13
- output?: Output<Oas>;
14
- /**
15
- * Define which contentType should be used.
16
- * By default, the first JSON valid mediaType is used
17
- */
18
- contentType?: contentType;
19
- baseURL?: string;
20
- /**
21
- * Group the MSW mocks based on the provided name.
22
- */
23
- group?: Group;
24
- /**
25
- * Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
26
- */
27
- exclude?: Array<Exclude>;
28
- /**
29
- * Array containing include parameters to include tags/operations/methods/paths.
30
- */
31
- include?: Array<Include>;
32
- /**
33
- * Array containing override parameters to override `options` based on tags/operations/methods/paths.
34
- */
35
- override?: Array<Override<ResolvedOptions>>;
36
- transformers?: {
37
- /**
38
- * Customize the names based on the type that is provided by the plugin.
39
- */
40
- name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
41
- };
42
- /**
43
- * Create `handlers.ts` file with all handlers grouped by methods.
44
- * @default false
45
- */
46
- handlers?: boolean;
47
- /**
48
- * Which parser should be used before returning the data to the Response of MSW.
49
- * - 'data' uses your custom data to generate the data for the response.
50
- * - 'faker' uses @kubb/plugin-faker to generate the data for the response.
51
- * @default 'data'
52
- */
53
- parser?: 'data' | 'faker';
54
- /**
55
- * Define some generators next to the msw generators
56
- */
57
- generators?: Array<Generator<PluginMsw>>;
58
- };
59
- type ResolvedOptions = {
60
- output: Output<Oas>;
61
- group: Options['group'];
62
- parser: NonNullable<Options['parser']>;
63
- baseURL: Options['baseURL'] | undefined;
64
- };
65
- type PluginMsw = PluginFactoryOptions<'plugin-msw', Options, ResolvedOptions, never, ResolvePathOptions>;
66
- //#endregion
67
- export { PluginMsw as n, Options as t };
68
- //# sourceMappingURL=types-BvqplGx0.d.ts.map
@@ -1,23 +0,0 @@
1
- /**
2
- * Generated by Kubb (https://kubb.dev/).
3
- * Do not edit manually.
4
- */
5
- import { http } from 'msw'
6
-
7
- export function createPetsResponse201(data?: CreatePetsMutationResponse) {
8
- return new Response(JSON.stringify(data), {
9
- status: 201,
10
- })
11
- }
12
-
13
- export function createPets(
14
- data?: string | number | boolean | null | object | ((info: Parameters<Parameters<typeof http.post>[1]>[0]) => Response | Promise<Response>),
15
- ) {
16
- return http.post(`/pets`, function handler(info) {
17
- if (typeof data === 'function') return data(info)
18
-
19
- return new Response(JSON.stringify(data), {
20
- status: 201,
21
- })
22
- })
23
- }
@@ -1,21 +0,0 @@
1
- /**
2
- * Generated by Kubb (https://kubb.dev/).
3
- * Do not edit manually.
4
- */
5
- import { http } from 'msw'
6
-
7
- export function createPetsResponse201(data?: CreatePetsMutationResponse) {
8
- return new Response(JSON.stringify(data), {
9
- status: 201,
10
- })
11
- }
12
-
13
- export function createPets(data?: CreatePetsMutationResponse | ((info: Parameters<Parameters<typeof http.post>[1]>[0]) => Response | Promise<Response>)) {
14
- return http.post('/pets', function handler(info) {
15
- if (typeof data === 'function') return data(info)
16
-
17
- return new Response(JSON.stringify(data || createPetsMutationResponse(data)), {
18
- status: 201,
19
- })
20
- })
21
- }
@@ -1,17 +0,0 @@
1
- /**
2
- * Generated by Kubb (https://kubb.dev/).
3
- * Do not edit manually.
4
- */
5
- import { http } from 'msw'
6
-
7
- export function deletePetsPetid(
8
- data?: string | number | boolean | null | object | ((info: Parameters<Parameters<typeof http.delete>[1]>[0]) => Response | Promise<Response>),
9
- ) {
10
- return http.delete(`/pets/:petId`, function handler(info) {
11
- if (typeof data === 'function') return data(info)
12
-
13
- return new Response(JSON.stringify(data), {
14
- status: 200,
15
- })
16
- })
17
- }
@@ -1,33 +0,0 @@
1
- /**
2
- * Generated by Kubb (https://kubb.dev/).
3
- * Do not edit manually.
4
- */
5
- import { http } from 'msw'
6
-
7
- export function listPetsResponse200(data: ListPetsQueryResponse) {
8
- return new Response(JSON.stringify(data), {
9
- status: 200,
10
- headers: {
11
- 'Content-Type': 'application/json',
12
- },
13
- })
14
- }
15
-
16
- export function listPetsResponse400(data?: ListPets400) {
17
- return new Response(JSON.stringify(data), {
18
- status: 400,
19
- })
20
- }
21
-
22
- export function listPets(data?: ListPetsQueryResponse | ((info: Parameters<Parameters<typeof http.get>[1]>[0]) => Response | Promise<Response>)) {
23
- return http.get(`/pets`, function handler(info) {
24
- if (typeof data === 'function') return data(info)
25
-
26
- return new Response(JSON.stringify(data), {
27
- status: 200,
28
- headers: {
29
- 'Content-Type': 'application/json',
30
- },
31
- })
32
- })
33
- }
@@ -1,33 +0,0 @@
1
- /**
2
- * Generated by Kubb (https://kubb.dev/).
3
- * Do not edit manually.
4
- */
5
- import { http } from 'msw'
6
-
7
- export function listPetsResponse200(data: ListPetsQueryResponse) {
8
- return new Response(JSON.stringify(data), {
9
- status: 200,
10
- headers: {
11
- 'Content-Type': 'application/json',
12
- },
13
- })
14
- }
15
-
16
- export function listPetsResponse400(data?: ListPets400) {
17
- return new Response(JSON.stringify(data), {
18
- status: 400,
19
- })
20
- }
21
-
22
- export function listPets(data?: ListPetsQueryResponse | ((info: Parameters<Parameters<typeof http.get>[1]>[0]) => Response | Promise<Response>)) {
23
- return http.get('/pets', function handler(info) {
24
- if (typeof data === 'function') return data(info)
25
-
26
- return new Response(JSON.stringify(data || listPetsQueryResponse(data)), {
27
- status: 200,
28
- headers: {
29
- 'Content-Type': 'application/json',
30
- },
31
- })
32
- })
33
- }
@@ -1,33 +0,0 @@
1
- /**
2
- * Generated by Kubb (https://kubb.dev/).
3
- * Do not edit manually.
4
- */
5
- import { http } from 'msw'
6
-
7
- export function listPetsResponse200(data: ListPetsQueryResponse) {
8
- return new Response(JSON.stringify(data), {
9
- status: 200,
10
- headers: {
11
- 'Content-Type': 'application/json',
12
- },
13
- })
14
- }
15
-
16
- export function listPetsResponse400(data?: ListPets400) {
17
- return new Response(JSON.stringify(data), {
18
- status: 400,
19
- })
20
- }
21
-
22
- export function listPets(data?: ListPetsQueryResponse | ((info: Parameters<Parameters<typeof http.get>[1]>[0]) => Response | Promise<Response>)) {
23
- return http.get(`${123456}/pets`, function handler(info) {
24
- if (typeof data === 'function') return data(info)
25
-
26
- return new Response(JSON.stringify(data), {
27
- status: 200,
28
- headers: {
29
- 'Content-Type': 'application/json',
30
- },
31
- })
32
- })
33
- }
@@ -1,7 +0,0 @@
1
- /**
2
- * Generated by Kubb (https://kubb.dev/).
3
- * Do not edit manually.
4
- */
5
- import { createPets, listPets, showPetById } from './findByTags'
6
-
7
- export const handlers = [listPets(), createPets(), showPetById()] as const
@@ -1,27 +0,0 @@
1
- /**
2
- * Generated by Kubb (https://kubb.dev/).
3
- * Do not edit manually.
4
- */
5
- import { http } from 'msw'
6
-
7
- export function showPetByIdResponse200(data: ShowPetByIdQueryResponse) {
8
- return new Response(JSON.stringify(data), {
9
- status: 200,
10
- headers: {
11
- 'Content-Type': 'application/json',
12
- },
13
- })
14
- }
15
-
16
- export function showPetById(data?: ShowPetByIdQueryResponse | ((info: Parameters<Parameters<typeof http.get>[1]>[0]) => Response | Promise<Response>)) {
17
- return http.get(`/pets/:petId`, function handler(info) {
18
- if (typeof data === 'function') return data(info)
19
-
20
- return new Response(JSON.stringify(data), {
21
- status: 200,
22
- headers: {
23
- 'Content-Type': 'application/json',
24
- },
25
- })
26
- })
27
- }