@kubb/plugin-msw 4.1.3 → 4.2.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/README.md +18 -16
- package/dist/{components-Bcz4mvn3.cjs → components-CULOceYX.cjs} +34 -1
- package/dist/components-CULOceYX.cjs.map +1 -0
- package/dist/{components-Ba13vW1_.js → components-DcRndqwD.js} +29 -2
- package/dist/components-DcRndqwD.js.map +1 -0
- package/dist/components.cjs +3 -2
- package/dist/components.d.cts +21 -8
- package/dist/components.d.ts +21 -8
- package/dist/components.js +2 -2
- package/dist/{generators-DgwpklSC.cjs → generators-CPaZGj9Z.cjs} +29 -5
- package/dist/generators-CPaZGj9Z.cjs.map +1 -0
- package/dist/{generators-lMP39igU.js → generators-DY8aHf0H.js} +30 -7
- package/dist/generators-DY8aHf0H.js.map +1 -0
- package/dist/generators.cjs +2 -2
- package/dist/generators.d.cts +2 -2
- package/dist/generators.d.ts +2 -2
- package/dist/generators.js +2 -2
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/{types-BOMj2hjt.d.ts → types-8ZXwr93_.d.cts} +2 -2
- package/dist/{types-BdC96j80.d.ts → types-B0eas7Yy.d.ts} +70 -70
- package/dist/{types-DYAniEBx.d.cts → types-IbHKcY02.d.ts} +2 -2
- package/dist/{types-DLxzBV0T.d.cts → types-eHiK8Pi0.d.cts} +70 -70
- package/package.json +8 -10
- package/src/components/Handlers.tsx +1 -2
- package/src/components/Mock.tsx +1 -2
- package/src/components/MockWithFaker.tsx +1 -2
- package/src/components/Response.tsx +42 -0
- package/src/components/index.ts +1 -0
- package/src/generators/__snapshots__/createPet.ts +6 -0
- package/src/generators/__snapshots__/createPetFaker.ts +6 -0
- package/src/generators/__snapshots__/getPets.ts +15 -0
- package/src/generators/__snapshots__/getPetsFaker.ts +15 -0
- package/src/generators/__snapshots__/showPetById.ts +9 -0
- package/src/generators/handlersGenerator.tsx +5 -2
- package/src/generators/mswGenerator.tsx +37 -8
- package/dist/components-Ba13vW1_.js.map +0 -1
- package/dist/components-Bcz4mvn3.cjs.map +0 -1
- package/dist/generators-DgwpklSC.cjs.map +0 -1
- package/dist/generators-lMP39igU.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
<div align="center">
|
|
2
|
+
<h1>Plugin MSW</h1>
|
|
3
|
+
<a href="https://kubb.dev" target="_blank" rel="noopener noreferrer">
|
|
4
|
+
<img width="180" src="https://raw.githubusercontent.com/kubb-labs/kubb/main/assets/logo.png" alt="Kubb logo">
|
|
5
|
+
</a>
|
|
2
6
|
|
|
3
|
-
<!-- <img src="assets/logo.png" alt="logo" width="200" height="auto" /> -->
|
|
4
|
-
<h1>@kubb/plugin-msw</h1>
|
|
5
|
-
|
|
6
|
-
<p>
|
|
7
|
-
Swagger integration to create mock data based on MSW
|
|
8
|
-
</p>
|
|
9
|
-
<img src="https://raw.githubusercontent.com/kubb-labs/kubb/main/assets/banner.png" alt="logo" height="auto" />
|
|
10
7
|
|
|
11
8
|
[![npm version][npm-version-src]][npm-version-href]
|
|
12
9
|
[![npm downloads][npm-downloads-src]][npm-downloads-href]
|
|
13
10
|
[![Coverage][coverage-src]][coverage-href]
|
|
14
11
|
[![License][license-src]][license-href]
|
|
15
|
-
|
|
12
|
+
[![Sponsors][sponsors-src]][sponsors-href]
|
|
16
13
|
<h4>
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
14
|
+
<a href="https://codesandbox.io/s/github/kubb-labs/kubb/tree/main//examples/typescript" target="_blank">View Demo</a>
|
|
15
|
+
<span> · </span>
|
|
16
|
+
<a href="https://kubb.dev/" target="_blank">Documentation</a>
|
|
17
|
+
<span> · </span>
|
|
18
|
+
<a href="https://github.com/kubb-labs/kubb/issues/" target="_blank">Report Bug</a>
|
|
19
|
+
<span> · </span>
|
|
20
|
+
<a href="https://github.com/kubb-labs/kubb/issues/" target="_blank">Request Feature</a>
|
|
21
|
+
</h4>
|
|
25
22
|
</div>
|
|
26
23
|
|
|
24
|
+
Swagger integration to create mock data based on MSW
|
|
25
|
+
|
|
26
|
+
|
|
27
27
|
## Supporting Kubb
|
|
28
28
|
|
|
29
29
|
Kubb uses an MIT-licensed open source project with its ongoing development made possible entirely by the support of Sponsors. If you would like to become a sponsor, please consider:
|
|
@@ -51,3 +51,5 @@ Kubb uses an MIT-licensed open source project with its ongoing development made
|
|
|
51
51
|
[minified-href]: https://www.npmjs.com/package/@kubb/plugin-msw
|
|
52
52
|
[coverage-src]: https://img.shields.io/codecov/c/github/kubb-labs/kubb?style=flat&colorA=18181B&colorB=f58517
|
|
53
53
|
[coverage-href]: https://www.npmjs.com/package/@kubb/plugin-msw
|
|
54
|
+
[sponsors-src]: https://img.shields.io/github/sponsors/stijnvanhulle?style=flat&colorA=18181B&colorB=f58517
|
|
55
|
+
[sponsors-href]: https://github.com/sponsors/stijnvanhulle/
|
|
@@ -114,6 +114,33 @@ function MockWithFaker({ baseURL = "", name, fakerName, typeName, operation }) {
|
|
|
114
114
|
});
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
+
//#endregion
|
|
118
|
+
//#region src/components/Response.tsx
|
|
119
|
+
function Response({ name, typeName, operation, statusCode }) {
|
|
120
|
+
const responseObject = operation.getResponseByStatusCode(statusCode);
|
|
121
|
+
const contentType = Object.keys(responseObject.content || {})?.[0];
|
|
122
|
+
const headers = [contentType ? `'Content-Type': '${contentType}'` : void 0].filter(Boolean);
|
|
123
|
+
const params = __kubb_react.FunctionParams.factory({ data: { type: `${typeName}` } });
|
|
124
|
+
const responseName = `${name}Response${statusCode}`;
|
|
125
|
+
return /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Source, {
|
|
126
|
+
name: responseName,
|
|
127
|
+
isIndexable: true,
|
|
128
|
+
isExportable: true,
|
|
129
|
+
children: /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.Function, {
|
|
130
|
+
name: responseName,
|
|
131
|
+
export: true,
|
|
132
|
+
params: params.toConstructor(),
|
|
133
|
+
children: `
|
|
134
|
+
return new Response(JSON.stringify(data), {
|
|
135
|
+
status: ${statusCode},
|
|
136
|
+
${headers.length ? ` headers: {
|
|
137
|
+
${headers.join(", \n")}
|
|
138
|
+
},` : ""}
|
|
139
|
+
})`
|
|
140
|
+
})
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
|
|
117
144
|
//#endregion
|
|
118
145
|
Object.defineProperty(exports, 'Handlers', {
|
|
119
146
|
enumerable: true,
|
|
@@ -133,10 +160,16 @@ Object.defineProperty(exports, 'MockWithFaker', {
|
|
|
133
160
|
return MockWithFaker;
|
|
134
161
|
}
|
|
135
162
|
});
|
|
163
|
+
Object.defineProperty(exports, 'Response', {
|
|
164
|
+
enumerable: true,
|
|
165
|
+
get: function () {
|
|
166
|
+
return Response;
|
|
167
|
+
}
|
|
168
|
+
});
|
|
136
169
|
Object.defineProperty(exports, '__toESM', {
|
|
137
170
|
enumerable: true,
|
|
138
171
|
get: function () {
|
|
139
172
|
return __toESM;
|
|
140
173
|
}
|
|
141
174
|
});
|
|
142
|
-
//# sourceMappingURL=components-
|
|
175
|
+
//# sourceMappingURL=components-CULOceYX.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components-CULOceYX.cjs","names":["URLPath","FunctionParams","File","Function","File","URLPath","FunctionParams","File","Function","FunctionParams","File","Function"],"sources":["../src/components/Mock.tsx","../src/components/Handlers.tsx","../src/components/MockWithFaker.tsx","../src/components/Response.tsx"],"sourcesContent":["import { URLPath } from '@kubb/core/utils'\nimport type { OasTypes, Operation } from '@kubb/oas'\nimport { File, Function, FunctionParams } from '@kubb/react'\n\ntype Props = {\n /**\n * Name of the function\n */\n name: string\n typeName: string\n fakerName: string\n baseURL: string | undefined\n operation: Operation\n}\n\nexport function Mock({ baseURL = '', name, typeName, operation }: Props) {\n const method = operation.method\n const successStatusCodes = operation.getResponseStatusCodes().filter((code) => code.startsWith('2'))\n const statusCode = successStatusCodes.length > 0 ? Number(successStatusCodes[0]) : 200\n\n const responseObject = operation.getResponseByStatusCode(statusCode) as OasTypes.ResponseObject\n const contentType = Object.keys(responseObject.content || {})?.[0]\n const url = new URLPath(operation.path).toURLPath().replace(/([^/]):/g, '$1\\\\\\\\:')\n\n const headers = [contentType ? `'Content-Type': '${contentType}'` : undefined].filter(Boolean)\n\n const params = FunctionParams.factory({\n data: {\n type: `${typeName} | ((\n info: Parameters<Parameters<typeof http.${method}>[1]>[0],\n ) => Response | Promise<Response>)`,\n optional: true,\n },\n })\n\n return (\n <File.Source name={name} isIndexable isExportable>\n <Function name={name} export params={params.toConstructor()}>\n {`return http.${method}('${baseURL}${url.replace(/([^/]):/g, '$1\\\\\\\\:')}', function handler(info) {\n if(typeof data === 'function') return data(info)\n\n return new Response(JSON.stringify(data), {\n status: ${statusCode},\n ${\n headers.length\n ? ` headers: {\n ${headers.join(', \\n')}\n },`\n : ''\n }\n })\n })`}\n </Function>\n </File.Source>\n )\n}\n","import { File } from '@kubb/react'\n\ntype HandlersProps = {\n /**\n * Name of the function\n */\n name: string\n // custom\n handlers: string[]\n}\n\nexport function Handlers({ name, handlers }: HandlersProps) {\n return (\n <File.Source name={name} isIndexable isExportable>\n {`export const ${name} = ${JSON.stringify(handlers).replaceAll(`\"`, '')} as const`}\n </File.Source>\n )\n}\n","import { URLPath } from '@kubb/core/utils'\n\nimport type { OasTypes, Operation } from '@kubb/oas'\nimport { File, Function, FunctionParams } from '@kubb/react'\n\ntype Props = {\n /**\n * Name of the function\n */\n name: string\n typeName: string\n fakerName: string\n baseURL: string | undefined\n operation: Operation\n}\n\nexport function MockWithFaker({ baseURL = '', name, fakerName, typeName, operation }: Props) {\n const method = operation.method\n const successStatusCodes = operation.getResponseStatusCodes().filter((code) => code.startsWith('2'))\n const statusCode = successStatusCodes.length > 0 ? Number(successStatusCodes[0]) : 200\n\n const responseObject = operation.getResponseByStatusCode(statusCode) as OasTypes.ResponseObject\n const contentType = Object.keys(responseObject.content || {})?.[0]\n const url = new URLPath(operation.path).toURLPath().replace(/([^/]):/g, '$1\\\\\\\\:')\n\n const headers = [contentType ? `'Content-Type': '${contentType}'` : undefined].filter(Boolean)\n\n const params = FunctionParams.factory({\n data: {\n type: `${typeName} | ((\n info: Parameters<Parameters<typeof http.${method}>[1]>[0],\n ) => Response | Promise<Response>)`,\n optional: true,\n },\n })\n\n return (\n <File.Source name={name} isIndexable isExportable>\n <Function name={name} export params={params.toConstructor()}>\n {`return http.${method}('${baseURL}${url.replace(/([^/]):/g, '$1\\\\\\\\:')}', function handler(info) {\n if(typeof data === 'function') return data(info)\n\n return new Response(JSON.stringify(data || ${fakerName}(data)), {\n status: ${statusCode},\n ${\n headers.length\n ? ` headers: {\n ${headers.join(', \\n')}\n },`\n : ''\n }\n })\n })`}\n </Function>\n </File.Source>\n )\n}\n","import type { OasTypes, Operation } from '@kubb/oas'\nimport { File, Function, FunctionParams } from '@kubb/react'\n\ntype Props = {\n typeName: string\n operation: Operation\n name: string\n statusCode: number\n}\n\nexport function Response({ name, typeName, operation, statusCode }: Props) {\n const responseObject = operation.getResponseByStatusCode(statusCode) as OasTypes.ResponseObject\n const contentType = Object.keys(responseObject.content || {})?.[0]\n\n const headers = [contentType ? `'Content-Type': '${contentType}'` : undefined].filter(Boolean)\n\n const params = FunctionParams.factory({\n data: {\n type: `${typeName}`,\n },\n })\n\n const responseName = `${name}Response${statusCode}`\n\n return (\n <File.Source name={responseName} isIndexable isExportable>\n <Function name={responseName} export params={params.toConstructor()}>\n {`\n return new Response(JSON.stringify(data), {\n status: ${statusCode},\n ${\n headers.length\n ? ` headers: {\n ${headers.join(', \\n')}\n },`\n : ''\n }\n })`}\n </Function>\n </File.Source>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;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|
@@ -89,5 +89,32 @@ function MockWithFaker({ baseURL = "", name, fakerName, typeName, operation }) {
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
//#endregion
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
//#region src/components/Response.tsx
|
|
93
|
+
function Response({ name, typeName, operation, statusCode }) {
|
|
94
|
+
const responseObject = operation.getResponseByStatusCode(statusCode);
|
|
95
|
+
const contentType = Object.keys(responseObject.content || {})?.[0];
|
|
96
|
+
const headers = [contentType ? `'Content-Type': '${contentType}'` : void 0].filter(Boolean);
|
|
97
|
+
const params = FunctionParams.factory({ data: { type: `${typeName}` } });
|
|
98
|
+
const responseName = `${name}Response${statusCode}`;
|
|
99
|
+
return /* @__PURE__ */ jsx(File.Source, {
|
|
100
|
+
name: responseName,
|
|
101
|
+
isIndexable: true,
|
|
102
|
+
isExportable: true,
|
|
103
|
+
children: /* @__PURE__ */ jsx(Function, {
|
|
104
|
+
name: responseName,
|
|
105
|
+
export: true,
|
|
106
|
+
params: params.toConstructor(),
|
|
107
|
+
children: `
|
|
108
|
+
return new Response(JSON.stringify(data), {
|
|
109
|
+
status: ${statusCode},
|
|
110
|
+
${headers.length ? ` headers: {
|
|
111
|
+
${headers.join(", \n")}
|
|
112
|
+
},` : ""}
|
|
113
|
+
})`
|
|
114
|
+
})
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
//#endregion
|
|
119
|
+
export { Mock as i, MockWithFaker as n, Handlers as r, Response as t };
|
|
120
|
+
//# sourceMappingURL=components-DcRndqwD.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components-DcRndqwD.js","names":[],"sources":["../src/components/Mock.tsx","../src/components/Handlers.tsx","../src/components/MockWithFaker.tsx","../src/components/Response.tsx"],"sourcesContent":["import { URLPath } from '@kubb/core/utils'\nimport type { OasTypes, Operation } from '@kubb/oas'\nimport { File, Function, FunctionParams } from '@kubb/react'\n\ntype Props = {\n /**\n * Name of the function\n */\n name: string\n typeName: string\n fakerName: string\n baseURL: string | undefined\n operation: Operation\n}\n\nexport function Mock({ baseURL = '', name, typeName, operation }: Props) {\n const method = operation.method\n const successStatusCodes = operation.getResponseStatusCodes().filter((code) => code.startsWith('2'))\n const statusCode = successStatusCodes.length > 0 ? Number(successStatusCodes[0]) : 200\n\n const responseObject = operation.getResponseByStatusCode(statusCode) as OasTypes.ResponseObject\n const contentType = Object.keys(responseObject.content || {})?.[0]\n const url = new URLPath(operation.path).toURLPath().replace(/([^/]):/g, '$1\\\\\\\\:')\n\n const headers = [contentType ? `'Content-Type': '${contentType}'` : undefined].filter(Boolean)\n\n const params = FunctionParams.factory({\n data: {\n type: `${typeName} | ((\n info: Parameters<Parameters<typeof http.${method}>[1]>[0],\n ) => Response | Promise<Response>)`,\n optional: true,\n },\n })\n\n return (\n <File.Source name={name} isIndexable isExportable>\n <Function name={name} export params={params.toConstructor()}>\n {`return http.${method}('${baseURL}${url.replace(/([^/]):/g, '$1\\\\\\\\:')}', function handler(info) {\n if(typeof data === 'function') return data(info)\n\n return new Response(JSON.stringify(data), {\n status: ${statusCode},\n ${\n headers.length\n ? ` headers: {\n ${headers.join(', \\n')}\n },`\n : ''\n }\n })\n })`}\n </Function>\n </File.Source>\n )\n}\n","import { File } from '@kubb/react'\n\ntype HandlersProps = {\n /**\n * Name of the function\n */\n name: string\n // custom\n handlers: string[]\n}\n\nexport function Handlers({ name, handlers }: HandlersProps) {\n return (\n <File.Source name={name} isIndexable isExportable>\n {`export const ${name} = ${JSON.stringify(handlers).replaceAll(`\"`, '')} as const`}\n </File.Source>\n )\n}\n","import { URLPath } from '@kubb/core/utils'\n\nimport type { OasTypes, Operation } from '@kubb/oas'\nimport { File, Function, FunctionParams } from '@kubb/react'\n\ntype Props = {\n /**\n * Name of the function\n */\n name: string\n typeName: string\n fakerName: string\n baseURL: string | undefined\n operation: Operation\n}\n\nexport function MockWithFaker({ baseURL = '', name, fakerName, typeName, operation }: Props) {\n const method = operation.method\n const successStatusCodes = operation.getResponseStatusCodes().filter((code) => code.startsWith('2'))\n const statusCode = successStatusCodes.length > 0 ? Number(successStatusCodes[0]) : 200\n\n const responseObject = operation.getResponseByStatusCode(statusCode) as OasTypes.ResponseObject\n const contentType = Object.keys(responseObject.content || {})?.[0]\n const url = new URLPath(operation.path).toURLPath().replace(/([^/]):/g, '$1\\\\\\\\:')\n\n const headers = [contentType ? `'Content-Type': '${contentType}'` : undefined].filter(Boolean)\n\n const params = FunctionParams.factory({\n data: {\n type: `${typeName} | ((\n info: Parameters<Parameters<typeof http.${method}>[1]>[0],\n ) => Response | Promise<Response>)`,\n optional: true,\n },\n })\n\n return (\n <File.Source name={name} isIndexable isExportable>\n <Function name={name} export params={params.toConstructor()}>\n {`return http.${method}('${baseURL}${url.replace(/([^/]):/g, '$1\\\\\\\\:')}', function handler(info) {\n if(typeof data === 'function') return data(info)\n\n return new Response(JSON.stringify(data || ${fakerName}(data)), {\n status: ${statusCode},\n ${\n headers.length\n ? ` headers: {\n ${headers.join(', \\n')}\n },`\n : ''\n }\n })\n })`}\n </Function>\n </File.Source>\n )\n}\n","import type { OasTypes, Operation } from '@kubb/oas'\nimport { File, Function, FunctionParams } from '@kubb/react'\n\ntype Props = {\n typeName: string\n operation: Operation\n name: string\n statusCode: number\n}\n\nexport function Response({ name, typeName, operation, statusCode }: Props) {\n const responseObject = operation.getResponseByStatusCode(statusCode) as OasTypes.ResponseObject\n const contentType = Object.keys(responseObject.content || {})?.[0]\n\n const headers = [contentType ? `'Content-Type': '${contentType}'` : undefined].filter(Boolean)\n\n const params = FunctionParams.factory({\n data: {\n type: `${typeName}`,\n },\n })\n\n const responseName = `${name}Response${statusCode}`\n\n return (\n <File.Source name={responseName} isIndexable isExportable>\n <Function name={responseName} export params={params.toConstructor()}>\n {`\n return new Response(JSON.stringify(data), {\n status: ${statusCode},\n ${\n headers.length\n ? ` headers: {\n ${headers.join(', \\n')}\n },`\n : ''\n }\n })`}\n </Function>\n </File.Source>\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/dist/components.cjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
const require_components = require('./components-
|
|
1
|
+
const require_components = require('./components-CULOceYX.cjs');
|
|
2
2
|
|
|
3
3
|
exports.Handlers = require_components.Handlers;
|
|
4
4
|
exports.Mock = require_components.Mock;
|
|
5
|
-
exports.MockWithFaker = require_components.MockWithFaker;
|
|
5
|
+
exports.MockWithFaker = require_components.MockWithFaker;
|
|
6
|
+
exports.Response = require_components.Response;
|
package/dist/components.d.cts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { Operation } from "./types-
|
|
2
|
-
import { ReactNode } from "react";
|
|
1
|
+
import { r as Operation } from "./types-8ZXwr93_.cjs";
|
|
3
2
|
|
|
4
3
|
//#region src/components/Mock.d.ts
|
|
5
|
-
type Props$
|
|
4
|
+
type Props$2 = {
|
|
6
5
|
/**
|
|
7
6
|
* Name of the function
|
|
8
7
|
*/
|
|
@@ -17,7 +16,7 @@ declare function Mock({
|
|
|
17
16
|
name,
|
|
18
17
|
typeName,
|
|
19
18
|
operation
|
|
20
|
-
}: Props$
|
|
19
|
+
}: Props$2): any;
|
|
21
20
|
//#endregion
|
|
22
21
|
//#region src/components/Handlers.d.ts
|
|
23
22
|
type HandlersProps = {
|
|
@@ -30,10 +29,10 @@ type HandlersProps = {
|
|
|
30
29
|
declare function Handlers({
|
|
31
30
|
name,
|
|
32
31
|
handlers
|
|
33
|
-
}: HandlersProps):
|
|
32
|
+
}: HandlersProps): any;
|
|
34
33
|
//#endregion
|
|
35
34
|
//#region src/components/MockWithFaker.d.ts
|
|
36
|
-
type Props = {
|
|
35
|
+
type Props$1 = {
|
|
37
36
|
/**
|
|
38
37
|
* Name of the function
|
|
39
38
|
*/
|
|
@@ -49,7 +48,21 @@ declare function MockWithFaker({
|
|
|
49
48
|
fakerName,
|
|
50
49
|
typeName,
|
|
51
50
|
operation
|
|
52
|
-
}: Props):
|
|
51
|
+
}: Props$1): any;
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region src/components/Response.d.ts
|
|
54
|
+
type Props = {
|
|
55
|
+
typeName: string;
|
|
56
|
+
operation: Operation;
|
|
57
|
+
name: string;
|
|
58
|
+
statusCode: number;
|
|
59
|
+
};
|
|
60
|
+
declare function Response({
|
|
61
|
+
name,
|
|
62
|
+
typeName,
|
|
63
|
+
operation,
|
|
64
|
+
statusCode
|
|
65
|
+
}: Props): any;
|
|
53
66
|
//#endregion
|
|
54
|
-
export { Handlers, Mock, MockWithFaker };
|
|
67
|
+
export { Handlers, Mock, MockWithFaker, Response };
|
|
55
68
|
//# sourceMappingURL=components.d.cts.map
|
package/dist/components.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { Operation } from "./types-
|
|
2
|
-
import { ReactNode } from "react";
|
|
1
|
+
import { r as Operation } from "./types-IbHKcY02.js";
|
|
3
2
|
|
|
4
3
|
//#region src/components/Mock.d.ts
|
|
5
|
-
type Props$
|
|
4
|
+
type Props$2 = {
|
|
6
5
|
/**
|
|
7
6
|
* Name of the function
|
|
8
7
|
*/
|
|
@@ -17,7 +16,7 @@ declare function Mock({
|
|
|
17
16
|
name,
|
|
18
17
|
typeName,
|
|
19
18
|
operation
|
|
20
|
-
}: Props$
|
|
19
|
+
}: Props$2): any;
|
|
21
20
|
//#endregion
|
|
22
21
|
//#region src/components/Handlers.d.ts
|
|
23
22
|
type HandlersProps = {
|
|
@@ -30,10 +29,10 @@ type HandlersProps = {
|
|
|
30
29
|
declare function Handlers({
|
|
31
30
|
name,
|
|
32
31
|
handlers
|
|
33
|
-
}: HandlersProps):
|
|
32
|
+
}: HandlersProps): any;
|
|
34
33
|
//#endregion
|
|
35
34
|
//#region src/components/MockWithFaker.d.ts
|
|
36
|
-
type Props = {
|
|
35
|
+
type Props$1 = {
|
|
37
36
|
/**
|
|
38
37
|
* Name of the function
|
|
39
38
|
*/
|
|
@@ -49,7 +48,21 @@ declare function MockWithFaker({
|
|
|
49
48
|
fakerName,
|
|
50
49
|
typeName,
|
|
51
50
|
operation
|
|
52
|
-
}: Props):
|
|
51
|
+
}: Props$1): any;
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region src/components/Response.d.ts
|
|
54
|
+
type Props = {
|
|
55
|
+
typeName: string;
|
|
56
|
+
operation: Operation;
|
|
57
|
+
name: string;
|
|
58
|
+
statusCode: number;
|
|
59
|
+
};
|
|
60
|
+
declare function Response({
|
|
61
|
+
name,
|
|
62
|
+
typeName,
|
|
63
|
+
operation,
|
|
64
|
+
statusCode
|
|
65
|
+
}: Props): any;
|
|
53
66
|
//#endregion
|
|
54
|
-
export { Handlers, Mock, MockWithFaker };
|
|
67
|
+
export { Handlers, Mock, MockWithFaker, Response };
|
|
55
68
|
//# sourceMappingURL=components.d.ts.map
|
package/dist/components.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as Mock, n as MockWithFaker, r as Handlers, t as Response } from "./components-DcRndqwD.js";
|
|
2
2
|
|
|
3
|
-
export { Handlers, Mock, MockWithFaker };
|
|
3
|
+
export { Handlers, Mock, MockWithFaker, Response };
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
const require_components = require('./components-
|
|
1
|
+
const require_components = require('./components-CULOceYX.cjs');
|
|
2
2
|
let __kubb_plugin_oas = require("@kubb/plugin-oas");
|
|
3
3
|
__kubb_plugin_oas = require_components.__toESM(__kubb_plugin_oas);
|
|
4
4
|
let __kubb_plugin_faker = require("@kubb/plugin-faker");
|
|
5
5
|
__kubb_plugin_faker = require_components.__toESM(__kubb_plugin_faker);
|
|
6
6
|
let __kubb_plugin_ts = require("@kubb/plugin-ts");
|
|
7
7
|
__kubb_plugin_ts = require_components.__toESM(__kubb_plugin_ts);
|
|
8
|
+
let __kubb_core_hooks = require("@kubb/core/hooks");
|
|
9
|
+
__kubb_core_hooks = require_components.__toESM(__kubb_core_hooks);
|
|
8
10
|
let __kubb_plugin_oas_hooks = require("@kubb/plugin-oas/hooks");
|
|
9
11
|
__kubb_plugin_oas_hooks = require_components.__toESM(__kubb_plugin_oas_hooks);
|
|
10
12
|
let __kubb_plugin_oas_utils = require("@kubb/plugin-oas/utils");
|
|
@@ -18,7 +20,8 @@ __kubb_react_jsx_runtime = require_components.__toESM(__kubb_react_jsx_runtime);
|
|
|
18
20
|
const mswGenerator = (0, __kubb_plugin_oas.createReactGenerator)({
|
|
19
21
|
name: "msw",
|
|
20
22
|
Operation({ operation }) {
|
|
21
|
-
const {
|
|
23
|
+
const { options: { output, parser, baseURL } } = (0, __kubb_core_hooks.usePlugin)();
|
|
24
|
+
const pluginManager = (0, __kubb_core_hooks.usePluginManager)();
|
|
22
25
|
const oas = (0, __kubb_plugin_oas_hooks.useOas)();
|
|
23
26
|
const { getSchemas, getName, getFile } = (0, __kubb_plugin_oas_hooks.useOperationManager)();
|
|
24
27
|
const mock = {
|
|
@@ -39,6 +42,20 @@ const mswGenerator = (0, __kubb_plugin_oas.createReactGenerator)({
|
|
|
39
42
|
type: "type"
|
|
40
43
|
})
|
|
41
44
|
};
|
|
45
|
+
const responseStatusCodes = operation.getResponseStatusCodes();
|
|
46
|
+
const types = [];
|
|
47
|
+
for (const code of responseStatusCodes) {
|
|
48
|
+
if (code === "default") {
|
|
49
|
+
types.push(["default", type.schemas.response.name]);
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
if (code.startsWith("2")) {
|
|
53
|
+
types.push([Number(code), type.schemas.response.name]);
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
const codeType = type.schemas.errors?.find((err) => err.statusCode === Number(code));
|
|
57
|
+
if (codeType) types.push([Number(code), codeType.name]);
|
|
58
|
+
}
|
|
42
59
|
return /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsxs)(__kubb_react.File, {
|
|
43
60
|
baseName: mock.file.baseName,
|
|
44
61
|
path: mock.file.path,
|
|
@@ -63,7 +80,7 @@ const mswGenerator = (0, __kubb_plugin_oas.createReactGenerator)({
|
|
|
63
80
|
path: "msw"
|
|
64
81
|
}),
|
|
65
82
|
/* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Import, {
|
|
66
|
-
name: [type.schemas.response.name],
|
|
83
|
+
name: Array.from(new Set([type.schemas.response.name, ...types.map((t) => t[1])])),
|
|
67
84
|
path: type.file.path,
|
|
68
85
|
root: mock.file.path,
|
|
69
86
|
isTypeOnly: true
|
|
@@ -73,6 +90,12 @@ const mswGenerator = (0, __kubb_plugin_oas.createReactGenerator)({
|
|
|
73
90
|
root: mock.file.path,
|
|
74
91
|
path: faker.file.path
|
|
75
92
|
}),
|
|
93
|
+
types.filter(([code]) => code !== "default").map(([code, typeName]) => /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(require_components.Response, {
|
|
94
|
+
typeName,
|
|
95
|
+
operation,
|
|
96
|
+
name: mock.name,
|
|
97
|
+
statusCode: code
|
|
98
|
+
})),
|
|
76
99
|
parser === "faker" && /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(require_components.MockWithFaker, {
|
|
77
100
|
name: mock.name,
|
|
78
101
|
typeName: type.schemas.response.name,
|
|
@@ -97,7 +120,8 @@ const mswGenerator = (0, __kubb_plugin_oas.createReactGenerator)({
|
|
|
97
120
|
const handlersGenerator = (0, __kubb_plugin_oas.createReactGenerator)({
|
|
98
121
|
name: "plugin-msw",
|
|
99
122
|
Operations({ operations }) {
|
|
100
|
-
const
|
|
123
|
+
const plugin = (0, __kubb_core_hooks.usePlugin)();
|
|
124
|
+
const pluginManager = (0, __kubb_core_hooks.usePluginManager)();
|
|
101
125
|
const oas = (0, __kubb_plugin_oas_hooks.useOas)();
|
|
102
126
|
const { getName, getFile } = (0, __kubb_plugin_oas_hooks.useOperationManager)();
|
|
103
127
|
const file = pluginManager.getFile({
|
|
@@ -155,4 +179,4 @@ Object.defineProperty(exports, 'mswGenerator', {
|
|
|
155
179
|
return mswGenerator;
|
|
156
180
|
}
|
|
157
181
|
});
|
|
158
|
-
//# sourceMappingURL=generators-
|
|
182
|
+
//# sourceMappingURL=generators-CPaZGj9Z.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generators-CPaZGj9Z.cjs","names":["pluginFakerName","pluginTsName","types: [statusCode: number | 'default', typeName: string][]","File","Response","MockWithFaker","Mock","File","Handlers"],"sources":["../src/generators/mswGenerator.tsx","../src/generators/handlersGenerator.tsx"],"sourcesContent":["import { usePlugin, usePluginManager } from '@kubb/core/hooks'\nimport { pluginFakerName } from '@kubb/plugin-faker'\nimport { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { File } from '@kubb/react'\nimport { Mock, MockWithFaker, Response } from '../components'\nimport type { PluginMsw } from '../types'\n\nexport const mswGenerator = createReactGenerator<PluginMsw>({\n name: 'msw',\n Operation({ operation }) {\n const {\n options: { output, parser, baseURL },\n } = usePlugin<PluginMsw>()\n const pluginManager = usePluginManager()\n\n const oas = useOas()\n const { getSchemas, getName, getFile } = useOperationManager()\n\n const mock = {\n name: getName(operation, { type: 'function' }),\n file: getFile(operation),\n }\n\n const faker = {\n file: getFile(operation, { pluginKey: [pluginFakerName] }),\n schemas: getSchemas(operation, { pluginKey: [pluginFakerName], type: 'function' }),\n }\n\n const type = {\n file: getFile(operation, { pluginKey: [pluginTsName] }),\n schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' }),\n }\n\n const responseStatusCodes = operation.getResponseStatusCodes()\n\n const types: [statusCode: number | 'default', typeName: string][] = []\n\n for (const code of responseStatusCodes) {\n if (code === 'default') {\n types.push(['default', type.schemas.response.name])\n continue\n }\n\n if (code.startsWith('2')) {\n types.push([Number(code), type.schemas.response.name])\n continue\n }\n\n const codeType = type.schemas.errors?.find((err) => err.statusCode === Number(code))\n if (codeType) types.push([Number(code), codeType.name])\n }\n\n return (\n <File\n baseName={mock.file.baseName}\n path={mock.file.path}\n meta={mock.file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n <File.Import name={['http']} path=\"msw\" />\n <File.Import name={['ResponseResolver']} isTypeOnly path=\"msw\" />\n <File.Import\n name={Array.from(new Set([type.schemas.response.name, ...types.map((t) => t[1])]))}\n path={type.file.path}\n root={mock.file.path}\n isTypeOnly\n />\n {parser === 'faker' && faker.file && faker.schemas.response && (\n <File.Import name={[faker.schemas.response.name]} root={mock.file.path} path={faker.file.path} />\n )}\n\n {types\n .filter(([code]) => code !== 'default')\n .map(([code, typeName]) => (\n <Response typeName={typeName} operation={operation} name={mock.name} statusCode={code as number} />\n ))}\n {parser === 'faker' && (\n <MockWithFaker\n name={mock.name}\n typeName={type.schemas.response.name}\n fakerName={faker.schemas.response.name}\n operation={operation}\n baseURL={baseURL}\n />\n )}\n {parser === 'data' && (\n <Mock name={mock.name} typeName={type.schemas.response.name} fakerName={faker.schemas.response.name} operation={operation} baseURL={baseURL} />\n )}\n </File>\n )\n },\n})\n","import { usePlugin, usePluginManager } from '@kubb/core/hooks'\nimport { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { File } from '@kubb/react'\nimport { Handlers } from '../components/Handlers.tsx'\nimport type { PluginMsw } from '../types'\n\nexport const handlersGenerator = createReactGenerator<PluginMsw>({\n name: 'plugin-msw',\n Operations({ operations }) {\n const plugin = usePlugin<PluginMsw>()\n const pluginManager = usePluginManager()\n\n const oas = useOas()\n const { getName, getFile } = useOperationManager()\n\n const file = pluginManager.getFile({ name: 'handlers', extname: '.ts', pluginKey: plugin.key })\n\n const imports = operations.map((operation) => {\n const operationFile = getFile(operation, { pluginKey: plugin.key })\n const operationName = getName(operation, { pluginKey: plugin.key, type: 'function' })\n\n return <File.Import key={operationFile.path} name={[operationName]} root={file.path} path={operationFile.path} />\n })\n\n const handlers = operations.map((operation) => `${getName(operation, { type: 'function', pluginKey: plugin.key })}()`)\n\n return (\n <File\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={getBanner({ oas, output: plugin.options.output, config: pluginManager.config })}\n footer={getFooter({ oas, output: plugin.options.output })}\n >\n {imports}\n <Handlers name={'handlers'} handlers={handlers} />\n </File>\n )\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAUA,MAAa,2DAA+C;CAC1D,MAAM;CACN,UAAU,EAAE,aAAa;EACvB,MAAM,EACJ,SAAS,EAAE,QAAQ,QAAQ,gDACH;EAC1B,MAAM,yDAAkC;EAExC,MAAM,2CAAc;EACpB,MAAM,EAAE,YAAY,SAAS,8DAAiC;EAE9D,MAAM,OAAO;GACX,MAAM,QAAQ,WAAW,EAAE,MAAM,YAAY,CAAC;GAC9C,MAAM,QAAQ,UAAU;GACzB;EAED,MAAM,QAAQ;GACZ,MAAM,QAAQ,WAAW,EAAE,WAAW,CAACA,oCAAgB,EAAE,CAAC;GAC1D,SAAS,WAAW,WAAW;IAAE,WAAW,CAACA,oCAAgB;IAAE,MAAM;IAAY,CAAC;GACnF;EAED,MAAM,OAAO;GACX,MAAM,QAAQ,WAAW,EAAE,WAAW,CAACC,8BAAa,EAAE,CAAC;GACvD,SAAS,WAAW,WAAW;IAAE,WAAW,CAACA,8BAAa;IAAE,MAAM;IAAQ,CAAC;GAC5E;EAED,MAAM,sBAAsB,UAAU,wBAAwB;EAE9D,MAAMC,QAA8D,EAAE;AAEtE,OAAK,MAAM,QAAQ,qBAAqB;AACtC,OAAI,SAAS,WAAW;AACtB,UAAM,KAAK,CAAC,WAAW,KAAK,QAAQ,SAAS,KAAK,CAAC;AACnD;;AAGF,OAAI,KAAK,WAAW,IAAI,EAAE;AACxB,UAAM,KAAK,CAAC,OAAO,KAAK,EAAE,KAAK,QAAQ,SAAS,KAAK,CAAC;AACtD;;GAGF,MAAM,WAAW,KAAK,QAAQ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Aa,gEAAoD;CAC/D,MAAM;CACN,WAAW,EAAE,cAAc;EACzB,MAAM,2CAA+B;EACrC,MAAM,yDAAkC;EAExC,MAAM,2CAAc;EACpB,MAAM,EAAE,SAAS,8DAAiC;EAElD,MAAM,OAAO,cAAc,QAAQ;GAAE,MAAM;GAAY,SAAS;GAAO,WAAW,OAAO;GAAK,CAAC;EAE/F,MAAM,UAAU,WAAW,KAAK,cAAc;GAC5C,MAAM,gBAAgB,QAAQ,WAAW,EAAE,WAAW,OAAO,KAAK,CAAC;GACnE,MAAM,gBAAgB,QAAQ,WAAW;IAAE,WAAW,OAAO;IAAK,MAAM;IAAY,CAAC;AAErF,UAAO,kDAACC,kBAAK;IAAgC,MAAM,CAAC,cAAc;IAAE,MAAM,KAAK;IAAM,MAAM,cAAc;MAAhF,cAAc,KAA0E;IACjH;EAEF,MAAM,WAAW,WAAW,KAAK,cAAc,GAAG,QAAQ,WAAW;GAAE,MAAM;GAAY,WAAW,OAAO;GAAK,CAAC,CAAC,IAAI;AAEtH,SACE,mDAACA;GACC,UAAU,KAAK;GACf,MAAM,KAAK;GACX,MAAM,KAAK;GACX,+CAAkB;IAAE;IAAK,QAAQ,OAAO,QAAQ;IAAQ,QAAQ,cAAc;IAAQ,CAAC;GACvF,+CAAkB;IAAE;IAAK,QAAQ,OAAO,QAAQ;IAAQ,CAAC;cAExD,SACD,kDAACC;IAAS,MAAM;IAAsB;KAAY;IAC7C;;CAGZ,CAAC"}
|
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as Mock, n as MockWithFaker, r as Handlers, t as Response } from "./components-DcRndqwD.js";
|
|
2
2
|
import { createReactGenerator } from "@kubb/plugin-oas";
|
|
3
3
|
import { pluginFakerName } from "@kubb/plugin-faker";
|
|
4
4
|
import { pluginTsName } from "@kubb/plugin-ts";
|
|
5
|
+
import { usePlugin, usePluginManager } from "@kubb/core/hooks";
|
|
5
6
|
import { useOas, useOperationManager } from "@kubb/plugin-oas/hooks";
|
|
6
7
|
import { getBanner, getFooter } from "@kubb/plugin-oas/utils";
|
|
7
|
-
import { File
|
|
8
|
+
import { File } from "@kubb/react";
|
|
8
9
|
import { jsx, jsxs } from "@kubb/react/jsx-runtime";
|
|
9
10
|
|
|
10
11
|
//#region src/generators/mswGenerator.tsx
|
|
11
12
|
const mswGenerator = createReactGenerator({
|
|
12
13
|
name: "msw",
|
|
13
14
|
Operation({ operation }) {
|
|
14
|
-
const {
|
|
15
|
+
const { options: { output, parser, baseURL } } = usePlugin();
|
|
16
|
+
const pluginManager = usePluginManager();
|
|
15
17
|
const oas = useOas();
|
|
16
18
|
const { getSchemas, getName, getFile } = useOperationManager();
|
|
17
19
|
const mock = {
|
|
@@ -32,6 +34,20 @@ const mswGenerator = createReactGenerator({
|
|
|
32
34
|
type: "type"
|
|
33
35
|
})
|
|
34
36
|
};
|
|
37
|
+
const responseStatusCodes = operation.getResponseStatusCodes();
|
|
38
|
+
const types = [];
|
|
39
|
+
for (const code of responseStatusCodes) {
|
|
40
|
+
if (code === "default") {
|
|
41
|
+
types.push(["default", type.schemas.response.name]);
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
if (code.startsWith("2")) {
|
|
45
|
+
types.push([Number(code), type.schemas.response.name]);
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
const codeType = type.schemas.errors?.find((err) => err.statusCode === Number(code));
|
|
49
|
+
if (codeType) types.push([Number(code), codeType.name]);
|
|
50
|
+
}
|
|
35
51
|
return /* @__PURE__ */ jsxs(File, {
|
|
36
52
|
baseName: mock.file.baseName,
|
|
37
53
|
path: mock.file.path,
|
|
@@ -56,7 +72,7 @@ const mswGenerator = createReactGenerator({
|
|
|
56
72
|
path: "msw"
|
|
57
73
|
}),
|
|
58
74
|
/* @__PURE__ */ jsx(File.Import, {
|
|
59
|
-
name: [type.schemas.response.name],
|
|
75
|
+
name: Array.from(new Set([type.schemas.response.name, ...types.map((t) => t[1])])),
|
|
60
76
|
path: type.file.path,
|
|
61
77
|
root: mock.file.path,
|
|
62
78
|
isTypeOnly: true
|
|
@@ -66,6 +82,12 @@ const mswGenerator = createReactGenerator({
|
|
|
66
82
|
root: mock.file.path,
|
|
67
83
|
path: faker.file.path
|
|
68
84
|
}),
|
|
85
|
+
types.filter(([code]) => code !== "default").map(([code, typeName]) => /* @__PURE__ */ jsx(Response, {
|
|
86
|
+
typeName,
|
|
87
|
+
operation,
|
|
88
|
+
name: mock.name,
|
|
89
|
+
statusCode: code
|
|
90
|
+
})),
|
|
69
91
|
parser === "faker" && /* @__PURE__ */ jsx(MockWithFaker, {
|
|
70
92
|
name: mock.name,
|
|
71
93
|
typeName: type.schemas.response.name,
|
|
@@ -90,7 +112,8 @@ const mswGenerator = createReactGenerator({
|
|
|
90
112
|
const handlersGenerator = createReactGenerator({
|
|
91
113
|
name: "plugin-msw",
|
|
92
114
|
Operations({ operations }) {
|
|
93
|
-
const
|
|
115
|
+
const plugin = usePlugin();
|
|
116
|
+
const pluginManager = usePluginManager();
|
|
94
117
|
const oas = useOas();
|
|
95
118
|
const { getName, getFile } = useOperationManager();
|
|
96
119
|
const file = pluginManager.getFile({
|
|
@@ -136,5 +159,5 @@ const handlersGenerator = createReactGenerator({
|
|
|
136
159
|
});
|
|
137
160
|
|
|
138
161
|
//#endregion
|
|
139
|
-
export {
|
|
140
|
-
//# sourceMappingURL=generators-
|
|
162
|
+
export { mswGenerator as n, handlersGenerator as t };
|
|
163
|
+
//# sourceMappingURL=generators-DY8aHf0H.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generators-DY8aHf0H.js","names":["types: [statusCode: number | 'default', typeName: string][]"],"sources":["../src/generators/mswGenerator.tsx","../src/generators/handlersGenerator.tsx"],"sourcesContent":["import { usePlugin, usePluginManager } from '@kubb/core/hooks'\nimport { pluginFakerName } from '@kubb/plugin-faker'\nimport { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { File } from '@kubb/react'\nimport { Mock, MockWithFaker, Response } from '../components'\nimport type { PluginMsw } from '../types'\n\nexport const mswGenerator = createReactGenerator<PluginMsw>({\n name: 'msw',\n Operation({ operation }) {\n const {\n options: { output, parser, baseURL },\n } = usePlugin<PluginMsw>()\n const pluginManager = usePluginManager()\n\n const oas = useOas()\n const { getSchemas, getName, getFile } = useOperationManager()\n\n const mock = {\n name: getName(operation, { type: 'function' }),\n file: getFile(operation),\n }\n\n const faker = {\n file: getFile(operation, { pluginKey: [pluginFakerName] }),\n schemas: getSchemas(operation, { pluginKey: [pluginFakerName], type: 'function' }),\n }\n\n const type = {\n file: getFile(operation, { pluginKey: [pluginTsName] }),\n schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' }),\n }\n\n const responseStatusCodes = operation.getResponseStatusCodes()\n\n const types: [statusCode: number | 'default', typeName: string][] = []\n\n for (const code of responseStatusCodes) {\n if (code === 'default') {\n types.push(['default', type.schemas.response.name])\n continue\n }\n\n if (code.startsWith('2')) {\n types.push([Number(code), type.schemas.response.name])\n continue\n }\n\n const codeType = type.schemas.errors?.find((err) => err.statusCode === Number(code))\n if (codeType) types.push([Number(code), codeType.name])\n }\n\n return (\n <File\n baseName={mock.file.baseName}\n path={mock.file.path}\n meta={mock.file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n <File.Import name={['http']} path=\"msw\" />\n <File.Import name={['ResponseResolver']} isTypeOnly path=\"msw\" />\n <File.Import\n name={Array.from(new Set([type.schemas.response.name, ...types.map((t) => t[1])]))}\n path={type.file.path}\n root={mock.file.path}\n isTypeOnly\n />\n {parser === 'faker' && faker.file && faker.schemas.response && (\n <File.Import name={[faker.schemas.response.name]} root={mock.file.path} path={faker.file.path} />\n )}\n\n {types\n .filter(([code]) => code !== 'default')\n .map(([code, typeName]) => (\n <Response typeName={typeName} operation={operation} name={mock.name} statusCode={code as number} />\n ))}\n {parser === 'faker' && (\n <MockWithFaker\n name={mock.name}\n typeName={type.schemas.response.name}\n fakerName={faker.schemas.response.name}\n operation={operation}\n baseURL={baseURL}\n />\n )}\n {parser === 'data' && (\n <Mock name={mock.name} typeName={type.schemas.response.name} fakerName={faker.schemas.response.name} operation={operation} baseURL={baseURL} />\n )}\n </File>\n )\n },\n})\n","import { usePlugin, usePluginManager } from '@kubb/core/hooks'\nimport { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { File } from '@kubb/react'\nimport { Handlers } from '../components/Handlers.tsx'\nimport type { PluginMsw } from '../types'\n\nexport const handlersGenerator = createReactGenerator<PluginMsw>({\n name: 'plugin-msw',\n Operations({ operations }) {\n const plugin = usePlugin<PluginMsw>()\n const pluginManager = usePluginManager()\n\n const oas = useOas()\n const { getName, getFile } = useOperationManager()\n\n const file = pluginManager.getFile({ name: 'handlers', extname: '.ts', pluginKey: plugin.key })\n\n const imports = operations.map((operation) => {\n const operationFile = getFile(operation, { pluginKey: plugin.key })\n const operationName = getName(operation, { pluginKey: plugin.key, type: 'function' })\n\n return <File.Import key={operationFile.path} name={[operationName]} root={file.path} path={operationFile.path} />\n })\n\n const handlers = operations.map((operation) => `${getName(operation, { type: 'function', pluginKey: plugin.key })}()`)\n\n return (\n <File\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={getBanner({ oas, output: plugin.options.output, config: pluginManager.config })}\n footer={getFooter({ oas, output: plugin.options.output })}\n >\n {imports}\n <Handlers name={'handlers'} handlers={handlers} />\n </File>\n )\n },\n})\n"],"mappings":";;;;;;;;;;;AAUA,MAAa,eAAe,qBAAgC;CAC1D,MAAM;CACN,UAAU,EAAE,aAAa;EACvB,MAAM,EACJ,SAAS,EAAE,QAAQ,QAAQ,cACzB,WAAsB;EAC1B,MA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B,QAAQ,WAAW;IAAE,WAAW,OAAO;IAAK,MAAM;IAAY,CAAC;AAErF,UAAO,oBAAC,KAAK;IAAgC,MAAM,CAAC,cAAc;IAAE,MAAM,KAAK;IAAM,MAAM,cAAc;MAAhF,cAAc,KAA0E;IACjH;EAEF,MAAM,WAAW,WAAW,KAAK,cAAc,GAAG,QAAQ,WAAW;GAAE,MAAM;GAAY,WAAW,OAAO;GAAK,CAAC,CAAC,IAAI;AAEtH,SACE,qBAAC;GACC,UAAU,KAAK;GACf,MAAM,KAAK;GACX,MAAM,KAAK;GACX,QAAQ,UAAU;IAAE;IAAK,QAAQ,OAAO,QAAQ;IAAQ,QAAQ,cAAc;IAAQ,CAAC;GACvF,QAAQ,UAAU;IAAE;IAAK,QAAQ,OAAO,QAAQ;IAAQ,CAAC;cAExD,SACD,oBAAC;IAAS,MAAM;IAAsB;KAAY;IAC7C;;CAGZ,CAAC"}
|
package/dist/generators.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
require('./components-
|
|
2
|
-
const require_generators = require('./generators-
|
|
1
|
+
require('./components-CULOceYX.cjs');
|
|
2
|
+
const require_generators = require('./generators-CPaZGj9Z.cjs');
|
|
3
3
|
|
|
4
4
|
exports.handlersGenerator = require_generators.handlersGenerator;
|
|
5
5
|
exports.mswGenerator = require_generators.mswGenerator;
|
package/dist/generators.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./types-
|
|
2
|
-
import {
|
|
1
|
+
import "./types-8ZXwr93_.cjs";
|
|
2
|
+
import { n as PluginMsw, r as Generator } from "./types-eHiK8Pi0.cjs";
|
|
3
3
|
|
|
4
4
|
//#region src/generators/mswGenerator.d.ts
|
|
5
5
|
declare const mswGenerator: Generator<PluginMsw>;
|
package/dist/generators.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./types-
|
|
2
|
-
import {
|
|
1
|
+
import "./types-IbHKcY02.js";
|
|
2
|
+
import { n as PluginMsw, r as Generator } from "./types-B0eas7Yy.js";
|
|
3
3
|
|
|
4
4
|
//#region src/generators/mswGenerator.d.ts
|
|
5
5
|
declare const mswGenerator: Generator<PluginMsw>;
|
package/dist/generators.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./components-
|
|
2
|
-
import {
|
|
1
|
+
import "./components-DcRndqwD.js";
|
|
2
|
+
import { n as mswGenerator, t as handlersGenerator } from "./generators-DY8aHf0H.js";
|
|
3
3
|
|
|
4
4
|
export { handlersGenerator, mswGenerator };
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const require_components = require('./components-
|
|
2
|
-
const require_generators = require('./generators-
|
|
1
|
+
const require_components = require('./components-CULOceYX.cjs');
|
|
2
|
+
const require_generators = require('./generators-CPaZGj9Z.cjs');
|
|
3
3
|
let node_path = require("node:path");
|
|
4
4
|
node_path = require_components.__toESM(node_path);
|
|
5
5
|
let __kubb_core = require("@kubb/core");
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./types-
|
|
2
|
-
import {
|
|
1
|
+
import "./types-8ZXwr93_.cjs";
|
|
2
|
+
import { i as UserPluginWithLifeCycle, n as PluginMsw, t as Options } from "./types-eHiK8Pi0.cjs";
|
|
3
3
|
|
|
4
4
|
//#region src/plugin.d.ts
|
|
5
5
|
declare const pluginMswName = "plugin-msw";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./types-
|
|
2
|
-
import {
|
|
1
|
+
import "./types-IbHKcY02.js";
|
|
2
|
+
import { i as UserPluginWithLifeCycle, n as PluginMsw, t as Options } from "./types-B0eas7Yy.js";
|
|
3
3
|
|
|
4
4
|
//#region src/plugin.d.ts
|
|
5
5
|
declare const pluginMswName = "plugin-msw";
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./components-
|
|
2
|
-
import {
|
|
1
|
+
import "./components-DcRndqwD.js";
|
|
2
|
+
import { n as mswGenerator, t as handlersGenerator } from "./generators-DY8aHf0H.js";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { FileManager, PluginManager, createPlugin } from "@kubb/core";
|
|
5
5
|
import { camelCase } from "@kubb/core/transformers";
|
|
@@ -9,5 +9,5 @@ type SchemaObject$1 = OasTypes.SchemaObject & {
|
|
|
9
9
|
$ref?: string;
|
|
10
10
|
};
|
|
11
11
|
//#endregion
|
|
12
|
-
export {
|
|
13
|
-
//# sourceMappingURL=types-
|
|
12
|
+
export { contentType as a, SchemaObject$1 as i, OasTypes as n, Operation$1 as r, HttpMethod as t };
|
|
13
|
+
//# sourceMappingURL=types-8ZXwr93_.d.cts.map
|