@kubb/plugin-msw 4.28.1 → 4.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{components-Fe6NiCbv.cjs → Response-BZ_UcHP9.cjs} +2 -2
- package/dist/Response-BZ_UcHP9.cjs.map +1 -0
- package/dist/{components-r7XTqwE7.js → Response-rq32ZXGn.js} +2 -2
- package/dist/Response-rq32ZXGn.js.map +1 -0
- package/dist/{chunk-eQyhnF5A.js → chunk-DKWOrOAv.js} +1 -1
- package/dist/components.cjs +6 -5
- package/dist/components.d.ts +1 -1
- package/dist/components.js +1 -1
- package/dist/generators.cjs +4 -3
- package/dist/generators.d.ts +2 -2
- package/dist/generators.js +1 -1
- package/dist/index.cjs +8 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/{generators-CCZr_EdQ.cjs → mswGenerator-D0rA2oe9.cjs} +6 -6
- package/dist/mswGenerator-D0rA2oe9.cjs.map +1 -0
- package/dist/{generators-CKxCewx3.js → mswGenerator-Tg2NjhsD.js} +3 -3
- package/dist/mswGenerator-Tg2NjhsD.js.map +1 -0
- package/dist/{types-BQtW13UI.d.cts → types-BvqplGx0.d.ts} +2 -2
- package/dist/{types-DXZqM6KD.d.ts → types-DUwv-QOP.d.ts} +2 -2
- package/package.json +17 -17
- package/src/generators/__snapshots__/handlers.ts +1 -1
- package/dist/components-Fe6NiCbv.cjs.map +0 -1
- package/dist/components-r7XTqwE7.js.map +0 -1
- package/dist/components.d.cts +0 -70
- package/dist/generators-CCZr_EdQ.cjs.map +0 -1
- package/dist/generators-CKxCewx3.js.map +0 -1
- package/dist/generators.d.cts +0 -471
- package/dist/index.d.cts +0 -10
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
2
|
var __create = Object.create;
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __name = (target, value) => __defProp(target, "name", {
|
|
@@ -188,4 +188,4 @@ Object.defineProperty(exports, '__toESM', {
|
|
|
188
188
|
return __toESM;
|
|
189
189
|
}
|
|
190
190
|
});
|
|
191
|
-
//# sourceMappingURL=
|
|
191
|
+
//# sourceMappingURL=Response-BZ_UcHP9.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Response-BZ_UcHP9.cjs","names":["File","URLPath","FunctionParams","File","Function","URLPath","FunctionParams","File","Function","FunctionParams","File","Function"],"sources":["../src/components/Handlers.tsx","../src/components/Mock.tsx","../src/components/MockWithFaker.tsx","../src/components/Response.tsx"],"sourcesContent":["import { File } from '@kubb/react-fabric'\nimport type { FabricReactNode } from '@kubb/react-fabric/types'\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): FabricReactNode {\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'\nimport type { OasTypes, Operation } from '@kubb/oas'\nimport { File, Function, FunctionParams } from '@kubb/react-fabric'\nimport type { FabricReactNode } from '@kubb/react-fabric/types'\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): FabricReactNode {\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 hasResponseSchema = contentType && responseObject?.content?.[contentType]?.schema !== undefined\n\n // If no response schema, uses any type but function to avoid overriding callback\n const dataType = hasResponseSchema ? typeName : 'string | number | boolean | null | object'\n\n const params = FunctionParams.factory({\n data: {\n type: `${dataType} | ((\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 { URLPath } from '@kubb/core/utils'\n\nimport type { OasTypes, Operation } from '@kubb/oas'\nimport { File, Function, FunctionParams } from '@kubb/react-fabric'\nimport type { FabricReactNode } from '@kubb/react-fabric/types'\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): FabricReactNode {\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-fabric'\nimport type { FabricReactNode } from '@kubb/react-fabric/types'\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): FabricReactNode {\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 hasResponseSchema = contentType && responseObject?.content?.[contentType]?.schema !== undefined\n\n const params = FunctionParams.factory({\n data: {\n type: `${typeName}`,\n optional: !hasResponseSchema,\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,SAAgB,SAAS,EAAE,MAAM,YAA4C;AAC3E,QACE,wDAACA,wBAAK;EAAa;EAAM;EAAY;YAClC,gBAAgB,KAAK,KAAK,KAAK,UAAU,SAAS,CAAC,WAAW,KAAK,GAAG,CAAC;GAC5D;;;;;ACAlB,SAAgB,KAAK,EAAE,UAAU,IAAI,MAAM,UAAU,aAAqC;CACxF,MAAM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
import { File, Function, FunctionParams } from "@kubb/react-fabric";
|
|
3
3
|
import { jsx } from "@kubb/react-fabric/jsx-runtime";
|
|
4
4
|
import { URLPath } from "@kubb/core/utils";
|
|
@@ -123,4 +123,4 @@ function Response({ name, typeName, operation, statusCode }) {
|
|
|
123
123
|
|
|
124
124
|
//#endregion
|
|
125
125
|
export { Handlers as i, MockWithFaker as n, Mock as r, Response as t };
|
|
126
|
-
//# sourceMappingURL=
|
|
126
|
+
//# sourceMappingURL=Response-rq32ZXGn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Response-rq32ZXGn.js","names":[],"sources":["../src/components/Handlers.tsx","../src/components/Mock.tsx","../src/components/MockWithFaker.tsx","../src/components/Response.tsx"],"sourcesContent":["import { File } from '@kubb/react-fabric'\nimport type { FabricReactNode } from '@kubb/react-fabric/types'\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): FabricReactNode {\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'\nimport type { OasTypes, Operation } from '@kubb/oas'\nimport { File, Function, FunctionParams } from '@kubb/react-fabric'\nimport type { FabricReactNode } from '@kubb/react-fabric/types'\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): FabricReactNode {\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 hasResponseSchema = contentType && responseObject?.content?.[contentType]?.schema !== undefined\n\n // If no response schema, uses any type but function to avoid overriding callback\n const dataType = hasResponseSchema ? typeName : 'string | number | boolean | null | object'\n\n const params = FunctionParams.factory({\n data: {\n type: `${dataType} | ((\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 { URLPath } from '@kubb/core/utils'\n\nimport type { OasTypes, Operation } from '@kubb/oas'\nimport { File, Function, FunctionParams } from '@kubb/react-fabric'\nimport type { FabricReactNode } from '@kubb/react-fabric/types'\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): FabricReactNode {\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-fabric'\nimport type { FabricReactNode } from '@kubb/react-fabric/types'\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): FabricReactNode {\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 hasResponseSchema = contentType && responseObject?.content?.[contentType]?.schema !== undefined\n\n const params = FunctionParams.factory({\n data: {\n type: `${typeName}`,\n optional: !hasResponseSchema,\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":";;;;;;AAYA,SAAgB,SAAS,EAAE,MAAM,YAA4C;AAC3E,QACE,oBAAC,KAAK;EAAa;EAAM;EAAY;YAClC,gBAAgB,KAAK,KAAK,KAAK,UAAU,SAAS,CAAC,WAAW,KAAK,GAAG,CAAC;GAC5D;;;;;ACAlB,SAAgB,KAAK,EAAE,UAAU,IAAI,MAAM,UAAU,aAAqC;CACxF,M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
+
const require_Response = require('./Response-BZ_UcHP9.cjs');
|
|
2
3
|
|
|
3
|
-
exports.Handlers =
|
|
4
|
-
exports.Mock =
|
|
5
|
-
exports.MockWithFaker =
|
|
6
|
-
exports.Response =
|
|
4
|
+
exports.Handlers = require_Response.Handlers;
|
|
5
|
+
exports.Mock = require_Response.Mock;
|
|
6
|
+
exports.MockWithFaker = require_Response.MockWithFaker;
|
|
7
|
+
exports.Response = require_Response.Response;
|
package/dist/components.d.ts
CHANGED
package/dist/components.js
CHANGED
package/dist/generators.cjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_mswGenerator = require('./mswGenerator-D0rA2oe9.cjs');
|
|
2
3
|
|
|
3
|
-
exports.handlersGenerator =
|
|
4
|
-
exports.mswGenerator =
|
|
4
|
+
exports.handlersGenerator = require_mswGenerator.handlersGenerator;
|
|
5
|
+
exports.mswGenerator = require_mswGenerator.mswGenerator;
|
package/dist/generators.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as __name } from "./chunk-
|
|
2
|
-
import { n as PluginMsw } from "./types-
|
|
1
|
+
import { t as __name } from "./chunk-DKWOrOAv.js";
|
|
2
|
+
import { n as PluginMsw } from "./types-DUwv-QOP.js";
|
|
3
3
|
import { BaseGenerator, Config, FileMetaBase, Group, KubbEvents, Output, Plugin, PluginFactoryOptions, PluginManager, ResolveNameParams } from "@kubb/core";
|
|
4
4
|
import { Fabric } from "@kubb/react-fabric";
|
|
5
5
|
import { AsyncEventEmitter } from "@kubb/core/utils";
|
package/dist/generators.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
const
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_Response = require('./Response-BZ_UcHP9.cjs');
|
|
3
|
+
const require_mswGenerator = require('./mswGenerator-D0rA2oe9.cjs');
|
|
3
4
|
let node_path = require("node:path");
|
|
4
|
-
node_path =
|
|
5
|
+
node_path = require_Response.__toESM(node_path);
|
|
5
6
|
let _kubb_core = require("@kubb/core");
|
|
6
7
|
let _kubb_core_transformers = require("@kubb/core/transformers");
|
|
7
8
|
let _kubb_plugin_faker = require("@kubb/plugin-faker");
|
|
@@ -14,7 +15,7 @@ const pluginMsw = (0, _kubb_core.definePlugin)((options) => {
|
|
|
14
15
|
const { output = {
|
|
15
16
|
path: "handlers",
|
|
16
17
|
barrelType: "named"
|
|
17
|
-
}, group, exclude = [], include, override = [], transformers = {}, handlers = false, parser = "data", generators = [
|
|
18
|
+
}, group, exclude = [], include, override = [], transformers = {}, handlers = false, parser = "data", generators = [require_mswGenerator.mswGenerator, handlers ? require_mswGenerator.handlersGenerator : void 0].filter(Boolean), contentType, baseURL } = options;
|
|
18
19
|
return {
|
|
19
20
|
name: pluginMswName,
|
|
20
21
|
options: {
|
|
@@ -28,7 +29,7 @@ const pluginMsw = (0, _kubb_core.definePlugin)((options) => {
|
|
|
28
29
|
_kubb_plugin_ts.pluginTsName,
|
|
29
30
|
parser === "faker" ? _kubb_plugin_faker.pluginFakerName : void 0
|
|
30
31
|
].filter(Boolean),
|
|
31
|
-
resolvePath(baseName, pathMode, options
|
|
32
|
+
resolvePath(baseName, pathMode, options) {
|
|
32
33
|
const root = node_path.default.resolve(this.config.root, this.config.output.path);
|
|
33
34
|
if ((pathMode ?? (0, _kubb_core.getMode)(node_path.default.resolve(root, output.path))) === "single")
|
|
34
35
|
/**
|
|
@@ -36,12 +37,12 @@ const pluginMsw = (0, _kubb_core.definePlugin)((options) => {
|
|
|
36
37
|
* Other plugins then need to call addOrAppend instead of just add from the fileManager class
|
|
37
38
|
*/
|
|
38
39
|
return node_path.default.resolve(root, output.path);
|
|
39
|
-
if (group && (options
|
|
40
|
+
if (group && (options?.group?.path || options?.group?.tag)) {
|
|
40
41
|
const groupName = group?.name ? group.name : (ctx) => {
|
|
41
42
|
if (group?.type === "path") return `${ctx.group.split("/")[1]}`;
|
|
42
43
|
return `${(0, _kubb_core_transformers.camelCase)(ctx.group)}Controller`;
|
|
43
44
|
};
|
|
44
|
-
return node_path.default.resolve(root, output.path, groupName({ group: group.type === "path" ? options
|
|
45
|
+
return node_path.default.resolve(root, output.path, groupName({ group: group.type === "path" ? options.group.path : options.group.tag }), baseName);
|
|
45
46
|
}
|
|
46
47
|
return node_path.default.resolve(root, output.path, baseName);
|
|
47
48
|
},
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["mswGenerator","handlersGenerator","pluginOasName","pluginTsName","pluginFakerName","path","
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["mswGenerator","handlersGenerator","pluginOasName","pluginTsName","pluginFakerName","path","OperationGenerator"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { definePlugin, type Group, getBarrelFiles, getMode } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\n\nimport { pluginFakerName } from '@kubb/plugin-faker'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { handlersGenerator, mswGenerator } from './generators'\nimport type { PluginMsw } from './types.ts'\n\nexport const pluginMswName = 'plugin-msw' satisfies PluginMsw['name']\n\nexport const pluginMsw = definePlugin<PluginMsw>((options) => {\n const {\n output = { path: 'handlers', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n transformers = {},\n handlers = false,\n parser = 'data',\n generators = [mswGenerator, handlers ? handlersGenerator : undefined].filter(Boolean),\n contentType,\n baseURL,\n } = options\n\n return {\n name: pluginMswName,\n options: {\n output,\n parser,\n group,\n baseURL,\n },\n pre: [pluginOasName, pluginTsName, parser === 'faker' ? pluginFakerName : 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 const resolvedName = camelCase(name, {\n suffix: type ? 'handler' : undefined,\n isFile: type === 'file',\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 const operationGenerator = new OperationGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\n events: this.events,\n plugin: this.plugin,\n contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const files = await operationGenerator.build(...generators)\n await this.upsertFile(...files)\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 })\n\n await this.upsertFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;AAUA,MAAa,gBAAgB;AAE7B,MAAa,0CAAqC,YAAY;CAC5D,MAAM,EACJ,SAAS;EAAE,MAAM;EAAY,YAAY;EAAS,EAClD,OACA,UAAU,EAAE,EACZ,SACA,WAAW,EAAE,EACb,eAAe,EAAE,EACjB,WAAW,OACX,SAAS,QACT,aAAa,CAACA,mCAAc,WAAWC,yCAAoB,OAAU,CAAC,OAAO,QAAQ,EACrF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,KAAK;IACpB,QAAQ,KAAK;IACb,QAAQ,KAAK;IACb;IACA;IACA;IACA;IACA;IACD,CAAC,CAEqC,MAAM,GAAG,WAAW;AAC3D,SAAM,KAAK,WAAW,GAAG,MAAM;GAE/B,MAAM,cAAc,qCAAqB,KAAK,OAAO,OAAO;IAC1D,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,WAAW,KAAK,OAAO,KACxB;IACF,CAAC;AAEF,SAAM,KAAK,WAAW,GAAG,YAAY;;EAExC;EACD"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as __name } from "./chunk-
|
|
2
|
-
import { n as PluginMsw, t as Options } from "./types-
|
|
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/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as __name } from "./chunk-
|
|
2
|
-
import { n as handlersGenerator, t as mswGenerator } from "./
|
|
1
|
+
import { t as __name } from "./chunk-DKWOrOAv.js";
|
|
2
|
+
import { n as handlersGenerator, t as mswGenerator } from "./mswGenerator-Tg2NjhsD.js";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { definePlugin, getBarrelFiles, getMode } from "@kubb/core";
|
|
5
5
|
import { camelCase } from "@kubb/core/transformers";
|
|
@@ -27,7 +27,7 @@ const pluginMsw = definePlugin((options) => {
|
|
|
27
27
|
pluginTsName,
|
|
28
28
|
parser === "faker" ? pluginFakerName : void 0
|
|
29
29
|
].filter(Boolean),
|
|
30
|
-
resolvePath(baseName, pathMode, options
|
|
30
|
+
resolvePath(baseName, pathMode, options) {
|
|
31
31
|
const root = path.resolve(this.config.root, this.config.output.path);
|
|
32
32
|
if ((pathMode ?? getMode(path.resolve(root, output.path))) === "single")
|
|
33
33
|
/**
|
|
@@ -35,12 +35,12 @@ const pluginMsw = definePlugin((options) => {
|
|
|
35
35
|
* Other plugins then need to call addOrAppend instead of just add from the fileManager class
|
|
36
36
|
*/
|
|
37
37
|
return path.resolve(root, output.path);
|
|
38
|
-
if (group && (options
|
|
38
|
+
if (group && (options?.group?.path || options?.group?.tag)) {
|
|
39
39
|
const groupName = group?.name ? group.name : (ctx) => {
|
|
40
40
|
if (group?.type === "path") return `${ctx.group.split("/")[1]}`;
|
|
41
41
|
return `${camelCase(ctx.group)}Controller`;
|
|
42
42
|
};
|
|
43
|
-
return path.resolve(root, output.path, groupName({ group: group.type === "path" ? options
|
|
43
|
+
return path.resolve(root, output.path, groupName({ group: group.type === "path" ? options.group.path : options.group.tag }), baseName);
|
|
44
44
|
}
|
|
45
45
|
return path.resolve(root, output.path, baseName);
|
|
46
46
|
},
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { definePlugin, type Group, getBarrelFiles, getMode } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\n\nimport { pluginFakerName } from '@kubb/plugin-faker'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { handlersGenerator, mswGenerator } from './generators'\nimport type { PluginMsw } from './types.ts'\n\nexport const pluginMswName = 'plugin-msw' satisfies PluginMsw['name']\n\nexport const pluginMsw = definePlugin<PluginMsw>((options) => {\n const {\n output = { path: 'handlers', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n transformers = {},\n handlers = false,\n parser = 'data',\n generators = [mswGenerator, handlers ? handlersGenerator : undefined].filter(Boolean),\n contentType,\n baseURL,\n } = options\n\n return {\n name: pluginMswName,\n options: {\n output,\n parser,\n group,\n baseURL,\n },\n pre: [pluginOasName, pluginTsName, parser === 'faker' ? pluginFakerName : 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 const resolvedName = camelCase(name, {\n suffix: type ? 'handler' : undefined,\n isFile: type === 'file',\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 const operationGenerator = new OperationGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\n events: this.events,\n plugin: this.plugin,\n contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const files = await operationGenerator.build(...generators)\n await this.upsertFile(...files)\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 })\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;EAAY,YAAY;EAAS,EAClD,OACA,UAAU,EAAE,EACZ,SACA,WAAW,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,MAAM,KAAK,QAAQ;GAe/B,MAAM,QAAQ,MAba,IAAI,mBAAmB,KAAK,OAAO,SAAS;IACrE,QAAQ,KAAK;IACb;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb,QAAQ,KAAK;IACb;IACA;IACA;IACA;IACA;IACD,CAAC,CAEqC,MAAM,GAAG,WAAW;AAC3D,SAAM,KAAK,WAAW,GAAG,MAAM;GAE/B,MAAM,cAAc,MAAM,eAAe,KAAK,OAAO,OAAO;IAC1D,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,WAAW,KAAK,OAAO,KACxB;IACF,CAAC;AAEF,SAAM,KAAK,WAAW,GAAG,YAAY;;EAExC;EACD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_Response = require('./Response-BZ_UcHP9.cjs');
|
|
2
2
|
let _kubb_plugin_faker = require("@kubb/plugin-faker");
|
|
3
3
|
let _kubb_plugin_ts = require("@kubb/plugin-ts");
|
|
4
4
|
let _kubb_core_hooks = require("@kubb/core/hooks");
|
|
@@ -49,7 +49,7 @@ const handlersGenerator = (0, _kubb_plugin_oas_generators.createReactGenerator)(
|
|
|
49
49
|
oas,
|
|
50
50
|
output: plugin.options.output
|
|
51
51
|
}),
|
|
52
|
-
children: [imports, /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(
|
|
52
|
+
children: [imports, /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(require_Response.Handlers, {
|
|
53
53
|
name: "handlers",
|
|
54
54
|
handlers
|
|
55
55
|
})]
|
|
@@ -132,20 +132,20 @@ const mswGenerator = (0, _kubb_plugin_oas_generators.createReactGenerator)({
|
|
|
132
132
|
root: mock.file.path,
|
|
133
133
|
path: faker.file.path
|
|
134
134
|
}),
|
|
135
|
-
types.filter(([code]) => code !== "default").map(([code, typeName]) => /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(
|
|
135
|
+
types.filter(([code]) => code !== "default").map(([code, typeName]) => /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(require_Response.Response, {
|
|
136
136
|
typeName,
|
|
137
137
|
operation,
|
|
138
138
|
name: mock.name,
|
|
139
139
|
statusCode: code
|
|
140
140
|
})),
|
|
141
|
-
parser === "faker" && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(
|
|
141
|
+
parser === "faker" && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(require_Response.MockWithFaker, {
|
|
142
142
|
name: mock.name,
|
|
143
143
|
typeName: type.schemas.response.name,
|
|
144
144
|
fakerName: faker.schemas.response.name,
|
|
145
145
|
operation,
|
|
146
146
|
baseURL
|
|
147
147
|
}),
|
|
148
|
-
parser === "data" && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(
|
|
148
|
+
parser === "data" && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(require_Response.Mock, {
|
|
149
149
|
name: mock.name,
|
|
150
150
|
typeName: type.schemas.response.name,
|
|
151
151
|
fakerName: faker.schemas.response.name,
|
|
@@ -170,4 +170,4 @@ Object.defineProperty(exports, 'mswGenerator', {
|
|
|
170
170
|
return mswGenerator;
|
|
171
171
|
}
|
|
172
172
|
});
|
|
173
|
-
//# sourceMappingURL=
|
|
173
|
+
//# sourceMappingURL=mswGenerator-D0rA2oe9.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mswGenerator-D0rA2oe9.cjs","names":["File","Handlers","pluginFakerName","pluginTsName","File","Response","MockWithFaker","Mock"],"sources":["../src/generators/handlersGenerator.tsx","../src/generators/mswGenerator.tsx"],"sourcesContent":["import { usePluginManager } from '@kubb/core/hooks'\nimport { createReactGenerator } from '@kubb/plugin-oas/generators'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { File } from '@kubb/react-fabric'\nimport { Handlers } from '../components/Handlers.tsx'\nimport type { PluginMsw } from '../types'\n\nexport const handlersGenerator = createReactGenerator<PluginMsw>({\n name: 'plugin-msw',\n Operations({ operations, generator, plugin }) {\n const pluginManager = usePluginManager()\n\n const oas = useOas()\n const { getName, getFile } = useOperationManager(generator)\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","import { usePluginManager } from '@kubb/core/hooks'\nimport { pluginFakerName } from '@kubb/plugin-faker'\nimport { createReactGenerator } from '@kubb/plugin-oas/generators'\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-fabric'\nimport { Mock, MockWithFaker, Response } from '../components'\nimport type { PluginMsw } from '../types'\n\nexport const mswGenerator = createReactGenerator<PluginMsw>({\n name: 'msw',\n Operation({ operation, generator, plugin }) {\n const {\n options: { output, parser, baseURL },\n } = plugin\n const pluginManager = usePluginManager()\n\n const oas = useOas()\n const { getSchemas, getName, getFile } = useOperationManager(generator)\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"],"mappings":";;;;;;;;;;;AAQA,MAAa,0EAAoD;CAC/D,MAAM;CACN,WAAW,EAAE,YAAY,WAAW,UAAU;EAC5C,MAAM,wDAAkC;EAExC,MAAM,0CAAc;EACpB,MAAM,EAAE,SAAS,4DAAgC,UAAU;EAE3D,MAAM,OAAO,cAAc,Q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;KAAE,MAAM,KAAK,KAAK;KAAM,MAAM,MAAM,KAAK;MAAQ;IAGlG,MACE,QAAQ,CAAC,UAAU,SAAS,UAAU,CACtC,KAAK,CAAC,MAAM,cACX,wDAACC;KAAmB;KAAqB;KAAW,MAAM,KAAK;KAAM,YAAY;MAAkB,CACnG;IACH,WAAW,WACV,wDAACC;KACC,MAAM,KAAK;KACX,UAAU,KAAK,QAAQ,SAAS;KAChC,WAAW,MAAM,QAAQ,SAAS;KACvB;KACF;MACT;IAEH,WAAW,UACV,wDAACC;KAAK,MAAM,KAAK;KAAM,UAAU,KAAK,QAAQ,SAAS;KAAM,WAAW,MAAM,QAAQ,SAAS;KAAiB;KAAoB;MAAW;;IAE5I;;CAGZ,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as __name } from "./chunk-
|
|
2
|
-
import { i as Handlers, n as MockWithFaker, r as Mock, t as Response } from "./
|
|
1
|
+
import { t as __name } from "./chunk-DKWOrOAv.js";
|
|
2
|
+
import { i as Handlers, n as MockWithFaker, r as Mock, t as Response } from "./Response-rq32ZXGn.js";
|
|
3
3
|
import { pluginFakerName } from "@kubb/plugin-faker";
|
|
4
4
|
import { pluginTsName } from "@kubb/plugin-ts";
|
|
5
5
|
import { usePluginManager } from "@kubb/core/hooks";
|
|
@@ -160,4 +160,4 @@ const mswGenerator = createReactGenerator({
|
|
|
160
160
|
|
|
161
161
|
//#endregion
|
|
162
162
|
export { handlersGenerator as n, mswGenerator as t };
|
|
163
|
-
//# sourceMappingURL=
|
|
163
|
+
//# sourceMappingURL=mswGenerator-Tg2NjhsD.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mswGenerator-Tg2NjhsD.js","names":[],"sources":["../src/generators/handlersGenerator.tsx","../src/generators/mswGenerator.tsx"],"sourcesContent":["import { usePluginManager } from '@kubb/core/hooks'\nimport { createReactGenerator } from '@kubb/plugin-oas/generators'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { File } from '@kubb/react-fabric'\nimport { Handlers } from '../components/Handlers.tsx'\nimport type { PluginMsw } from '../types'\n\nexport const handlersGenerator = createReactGenerator<PluginMsw>({\n name: 'plugin-msw',\n Operations({ operations, generator, plugin }) {\n const pluginManager = usePluginManager()\n\n const oas = useOas()\n const { getName, getFile } = useOperationManager(generator)\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","import { usePluginManager } from '@kubb/core/hooks'\nimport { pluginFakerName } from '@kubb/plugin-faker'\nimport { createReactGenerator } from '@kubb/plugin-oas/generators'\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-fabric'\nimport { Mock, MockWithFaker, Response } from '../components'\nimport type { PluginMsw } from '../types'\n\nexport const mswGenerator = createReactGenerator<PluginMsw>({\n name: 'msw',\n Operation({ operation, generator, plugin }) {\n const {\n options: { output, parser, baseURL },\n } = plugin\n const pluginManager = usePluginManager()\n\n const oas = useOas()\n const { getSchemas, getName, getFile } = useOperationManager(generator)\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"],"mappings":";;;;;;;;;;;;AAQA,MAAa,oBAAoB,qBAAgC;CAC/D,MAAM;CACN,WAAW,EAAE,YAAY,WAAW,UAAU;EAC5C,MAAM,gBAAgB,kBA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AChB,MAAM,KAAK,KAAK;KAChB;MACA;IACD,WAAW,WAAW,MAAM,QAAQ,MAAM,QAAQ,YACjD,oBAAC,KAAK;KAAO,MAAM,CAAC,MAAM,QAAQ,SAAS,KAAK;KAAE,MAAM,KAAK,KAAK;KAAM,MAAM,MAAM,KAAK;MAAQ;IAGlG,MACE,QAAQ,CAAC,UAAU,SAAS,UAAU,CACtC,KAAK,CAAC,MAAM,cACX,oBAAC;KAAmB;KAAqB;KAAW,MAAM,KAAK;KAAM,YAAY;MAAkB,CACnG;IACH,WAAW,WACV,oBAAC;KACC,MAAM,KAAK;KACX,UAAU,KAAK,QAAQ,SAAS;KAChC,WAAW,MAAM,QAAQ,SAAS;KACvB;KACF;MACT;IAEH,WAAW,UACV,oBAAC;KAAK,MAAM,KAAK;KAAM,UAAU,KAAK,QAAQ,SAAS;KAAM,WAAW,MAAM,QAAQ,SAAS;KAAiB;KAAoB;MAAW;;IAE5I;;CAGZ,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as __name } from "./chunk-
|
|
1
|
+
import { t as __name } from "./chunk-cy2TeOE5.cjs";
|
|
2
2
|
import { Oas, contentType } from "@kubb/oas";
|
|
3
3
|
import { Group, Output, PluginFactoryOptions, ResolveNameParams } from "@kubb/core";
|
|
4
4
|
import { Exclude, Include, Override, ResolvePathOptions } from "@kubb/plugin-oas";
|
|
@@ -65,4 +65,4 @@ type ResolvedOptions = {
|
|
|
65
65
|
type PluginMsw = PluginFactoryOptions<'plugin-msw', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
66
66
|
//#endregion
|
|
67
67
|
export { PluginMsw as n, Options as t };
|
|
68
|
-
//# sourceMappingURL=types-
|
|
68
|
+
//# sourceMappingURL=types-BvqplGx0.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as __name } from "./chunk-
|
|
1
|
+
import { t as __name } from "./chunk-DKWOrOAv.js";
|
|
2
2
|
import { Group, Output, PluginFactoryOptions, ResolveNameParams } from "@kubb/core";
|
|
3
3
|
import { Exclude, Include, Override, ResolvePathOptions } from "@kubb/plugin-oas";
|
|
4
4
|
import { Generator } from "@kubb/plugin-oas/generators";
|
|
@@ -65,4 +65,4 @@ type ResolvedOptions = {
|
|
|
65
65
|
type PluginMsw = PluginFactoryOptions<'plugin-msw', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
66
66
|
//#endregion
|
|
67
67
|
export { PluginMsw as n, Options as t };
|
|
68
|
-
//# sourceMappingURL=types-
|
|
68
|
+
//# sourceMappingURL=types-DUwv-QOP.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-msw",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.29.0",
|
|
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",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
],
|
|
23
23
|
"repository": {
|
|
24
24
|
"type": "git",
|
|
25
|
-
"url": "https://github.com/kubb-labs/kubb.git",
|
|
25
|
+
"url": "git+https://github.com/kubb-labs/kubb.git",
|
|
26
26
|
"directory": "packages/plugin-msw"
|
|
27
27
|
},
|
|
28
28
|
"license": "MIT",
|
|
@@ -31,22 +31,20 @@
|
|
|
31
31
|
"type": "module",
|
|
32
32
|
"exports": {
|
|
33
33
|
".": {
|
|
34
|
-
"
|
|
35
|
-
"
|
|
34
|
+
"import": "./dist/index.js",
|
|
35
|
+
"require": "./dist/index.cjs"
|
|
36
36
|
},
|
|
37
37
|
"./components": {
|
|
38
|
-
"
|
|
39
|
-
"
|
|
38
|
+
"import": "./dist/components.js",
|
|
39
|
+
"require": "./dist/components.cjs"
|
|
40
40
|
},
|
|
41
41
|
"./generators": {
|
|
42
|
-
"
|
|
43
|
-
"
|
|
42
|
+
"import": "./dist/generators.js",
|
|
43
|
+
"require": "./dist/generators.cjs"
|
|
44
44
|
},
|
|
45
45
|
"./package.json": "./package.json"
|
|
46
46
|
},
|
|
47
|
-
"
|
|
48
|
-
"module": "./dist/index.js",
|
|
49
|
-
"types": "./dist/index.d.cts",
|
|
47
|
+
"types": "./dist/index.d.ts",
|
|
50
48
|
"typesVersions": {
|
|
51
49
|
"*": {
|
|
52
50
|
"utils": [
|
|
@@ -77,12 +75,12 @@
|
|
|
77
75
|
}
|
|
78
76
|
],
|
|
79
77
|
"dependencies": {
|
|
80
|
-
"@kubb/react-fabric": "0.
|
|
81
|
-
"@kubb/core": "4.
|
|
82
|
-
"@kubb/oas": "4.
|
|
83
|
-
"@kubb/plugin-
|
|
84
|
-
"@kubb/plugin-
|
|
85
|
-
"@kubb/plugin-
|
|
78
|
+
"@kubb/react-fabric": "0.13.1",
|
|
79
|
+
"@kubb/core": "4.29.0",
|
|
80
|
+
"@kubb/oas": "4.29.0",
|
|
81
|
+
"@kubb/plugin-faker": "4.29.0",
|
|
82
|
+
"@kubb/plugin-oas": "4.29.0",
|
|
83
|
+
"@kubb/plugin-ts": "4.29.0"
|
|
86
84
|
},
|
|
87
85
|
"devDependencies": {},
|
|
88
86
|
"engines": {
|
|
@@ -92,6 +90,8 @@
|
|
|
92
90
|
"access": "public",
|
|
93
91
|
"registry": "https://registry.npmjs.org/"
|
|
94
92
|
},
|
|
93
|
+
"main": "./dist/index.cjs",
|
|
94
|
+
"module": "./dist/index.js",
|
|
95
95
|
"scripts": {
|
|
96
96
|
"build": "tsdown && size-limit",
|
|
97
97
|
"clean": "npx rimraf ./dist",
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
* Generated by Kubb (https://kubb.dev/).
|
|
3
3
|
* Do not edit manually.
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
5
|
+
import { createPets, listPets, showPetById } from './findByTags'
|
|
6
6
|
|
|
7
7
|
export const handlers = [listPets(), createPets(), showPetById()] as const
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"components-Fe6NiCbv.cjs","names":["File","URLPath","FunctionParams","File","Function","URLPath","FunctionParams","File","Function","FunctionParams","File","Function"],"sources":["../src/components/Handlers.tsx","../src/components/Mock.tsx","../src/components/MockWithFaker.tsx","../src/components/Response.tsx"],"sourcesContent":["import { File } from '@kubb/react-fabric'\nimport type { FabricReactNode } from '@kubb/react-fabric/types'\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): FabricReactNode {\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'\nimport type { OasTypes, Operation } from '@kubb/oas'\nimport { File, Function, FunctionParams } from '@kubb/react-fabric'\nimport type { FabricReactNode } from '@kubb/react-fabric/types'\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): FabricReactNode {\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 hasResponseSchema = contentType && responseObject?.content?.[contentType]?.schema !== undefined\n\n // If no response schema, uses any type but function to avoid overriding callback\n const dataType = hasResponseSchema ? typeName : 'string | number | boolean | null | object'\n\n const params = FunctionParams.factory({\n data: {\n type: `${dataType} | ((\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 { URLPath } from '@kubb/core/utils'\n\nimport type { OasTypes, Operation } from '@kubb/oas'\nimport { File, Function, FunctionParams } from '@kubb/react-fabric'\nimport type { FabricReactNode } from '@kubb/react-fabric/types'\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): FabricReactNode {\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-fabric'\nimport type { FabricReactNode } from '@kubb/react-fabric/types'\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): FabricReactNode {\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 hasResponseSchema = contentType && responseObject?.content?.[contentType]?.schema !== undefined\n\n const params = FunctionParams.factory({\n data: {\n type: `${typeName}`,\n optional: !hasResponseSchema,\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,SAAgB,SAAS,EAAE,MAAM,YAA4C;AAC3E,QACE,wDAACA,wBAAK;EAAa;EAAM;EAAY;YAClC,gBAAgB,KAAK,KAAK,KAAK,UAAU,SAAS,CAAC,WAAW,KAAK,GAAG,CAAC;GAC5D;;;;;ACAlB,SAAgB,KAAK,EAAE,UAAU,IAAI,MAAM,UAAU,aAAqC;CACxF,MAAM,SAAS,UAAU;CACzB,MAAM,qBAAqB,UAAU,wBAAwB,CAAC,QAAQ,SAAS,KAAK,WAAW,IAAI,CAAC;CACpG,MAAM,aAAa,mBAAmB,SAAS,IAAI,OAAO,mBAAmB,GAAG,GAAG;CAEnF,MAAM,iBAAiB,UAAU,wBAAwB,WAAW;CACpE,MAAM,cAAc,OAAO,KAAK,eAAe,WA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E,wDAACC,wBAAK;EAAa;EAAM;EAAY;YACnC,wDAACC;GAAe;GAAM;GAAO,QAAQ,OAAO,eAAe;aACxD,eAAe,OAAO,IAAI,UAAU,IAAI,QAAQ,YAAY,UAAU,CAAC;;;iDAG/B,UAAU;gBAC3C,WAAW;QAEnB,QAAQ,SACJ;UACF,QAAQ,KAAK,OAAO,CAAC;YAEnB,GACL;;;IAGU;GACC;;;;;AC5ClB,SAAgB,SAAS,EAAE,MAAM,UAAU,WAAW,cAAsC;CAC1F,MAAM,iBAAiB,UAAU,wBAAwB,WAAW;CACpE,MAAM,cAAc,OAAO,KAAK,eAAe,WAAW,EAAE,CAAC,GAAG;CAEhE,MAAM,UAAU,CAAC,cAAc,oBAAoB,YAAY,KAAK,OAAU,CAAC,OAAO,QAAQ;CAE9F,MAAM,oBAAoB,eAAe,gBAAgB,UAAU,cAAc,WAAW;CAE5F,MAAM,SAASC,kCAAe,QAAQ,EACpC,MAAM;EACJ,MAAM,GAAG;EACT,UAAU,CAAC;EACZ,EACF,CAAC;CAEF,MAAM,eAAe,GAAG,KAAK,UAAU;AAEvC,QACE,wDAACC,wBAAK;EAAO,MAAM;EAAc;EAAY;YAC3C,wDAACC;GAAS,MAAM;GAAc;GAAO,QAAQ,OAAO,eAAe;aAChE;;gBAEO,WAAW;QAEnB,QAAQ,SACJ;UACF,QAAQ,KAAK,OAAO,CAAC;YAEnB,GACL;;IAEU;GACC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"components-r7XTqwE7.js","names":[],"sources":["../src/components/Handlers.tsx","../src/components/Mock.tsx","../src/components/MockWithFaker.tsx","../src/components/Response.tsx"],"sourcesContent":["import { File } from '@kubb/react-fabric'\nimport type { FabricReactNode } from '@kubb/react-fabric/types'\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): FabricReactNode {\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'\nimport type { OasTypes, Operation } from '@kubb/oas'\nimport { File, Function, FunctionParams } from '@kubb/react-fabric'\nimport type { FabricReactNode } from '@kubb/react-fabric/types'\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): FabricReactNode {\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 hasResponseSchema = contentType && responseObject?.content?.[contentType]?.schema !== undefined\n\n // If no response schema, uses any type but function to avoid overriding callback\n const dataType = hasResponseSchema ? typeName : 'string | number | boolean | null | object'\n\n const params = FunctionParams.factory({\n data: {\n type: `${dataType} | ((\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 { URLPath } from '@kubb/core/utils'\n\nimport type { OasTypes, Operation } from '@kubb/oas'\nimport { File, Function, FunctionParams } from '@kubb/react-fabric'\nimport type { FabricReactNode } from '@kubb/react-fabric/types'\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): FabricReactNode {\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-fabric'\nimport type { FabricReactNode } from '@kubb/react-fabric/types'\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): FabricReactNode {\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 hasResponseSchema = contentType && responseObject?.content?.[contentType]?.schema !== undefined\n\n const params = FunctionParams.factory({\n data: {\n type: `${typeName}`,\n optional: !hasResponseSchema,\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":";;;;;;AAYA,SAAgB,SAAS,EAAE,MAAM,YAA4C;AAC3E,QACE,oBAAC,KAAK;EAAa;EAAM;EAAY;YAClC,gBAAgB,KAAK,KAAK,KAAK,UAAU,SAAS,CAAC,WAAW,KAAK,GAAG,CAAC;GAC5D;;;;;ACAlB,SAAgB,KAAK,EAAE,UAAU,IAAI,MAAM,UAAU,aAAqC;CACxF,MAAM,SAAS,UAAU;CACzB,MAAM,qBAAqB,UAAU,wBAAwB,CAAC,QAAQ,SAAS,KAAK,WAAW,IAAI,CAAC;CACpG,MAAM,aAAa,mBAAmB,SAAS,IAAI,OAAO,mBAAmB,GAAG,GAAG;CAEnF,MAAM,iBAAiB,UAAU,wBAAwB,WAAW;CACpE,MAAM,cAAc,OAAO,KAAK,eAAe,WAAW,EAAE,CAAC,GAAG;CAChE,MAAM,MAAM,IAAI,QAAQ,UAAU,KAAK,CAAC,WAAW,CAAC,QAAQ,YAAY,UAAU;CAElF,MAAM,UAAU,CAAC,cAAc,oBAAoB,YAAY,KAAK,OAAU,CAAC,OAAO,QAAQ;CAK9F,MAAM,WAHoB,eAAe,gBAAgB,UAAU,cAAc,WAAW,SAGvD,WAAW;CAEhD,MAAM,SAAS,eAAe,QAAQ,EACpC,MAAM;EACJ,MAAM,GAAG,SAAS;kDAC0B,OAAO;;EAEnD,UAAU;EACX,EACF,CAAC;AAEF,QACE,oBAAC,KAAK;EAAa;EAAM;EAAY;YACnC,oBAAC;GAAe;GAAM;GAAO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cAAc,oBAAoB,YAAY,KAAK,OAAU,CAAC,OAAO,QAAQ;CAE9F,MAAM,oBAAoB,eAAe,gBAAgB,UAAU,cAAc,WAAW;CAE5F,MAAM,SAAS,eAAe,QAAQ,EACpC,MAAM;EACJ,MAAM,GAAG;EACT,UAAU,CAAC;EACZ,EACF,CAAC;CAEF,MAAM,eAAe,GAAG,KAAK,UAAU;AAEvC,QACE,oBAAC,KAAK;EAAO,MAAM;EAAc;EAAY;YAC3C,oBAAC;GAAS,MAAM;GAAc;GAAO,QAAQ,OAAO,eAAe;aAChE;;gBAEO,WAAW;QAEnB,QAAQ,SACJ;UACF,QAAQ,KAAK,OAAO,CAAC;YAEnB,GACL;;IAEU;GACC"}
|
package/dist/components.d.cts
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { t as __name } from "./chunk-DHUGjThq.cjs";
|
|
2
|
-
import { FabricReactNode } from "@kubb/react-fabric/types";
|
|
3
|
-
import { Operation } from "@kubb/oas";
|
|
4
|
-
|
|
5
|
-
//#region src/components/Handlers.d.ts
|
|
6
|
-
type HandlersProps = {
|
|
7
|
-
/**
|
|
8
|
-
* Name of the function
|
|
9
|
-
*/
|
|
10
|
-
name: string;
|
|
11
|
-
handlers: string[];
|
|
12
|
-
};
|
|
13
|
-
declare function Handlers({
|
|
14
|
-
name,
|
|
15
|
-
handlers
|
|
16
|
-
}: HandlersProps): FabricReactNode;
|
|
17
|
-
//#endregion
|
|
18
|
-
//#region src/components/Mock.d.ts
|
|
19
|
-
type Props$2 = {
|
|
20
|
-
/**
|
|
21
|
-
* Name of the function
|
|
22
|
-
*/
|
|
23
|
-
name: string;
|
|
24
|
-
typeName: string;
|
|
25
|
-
fakerName: string;
|
|
26
|
-
baseURL: string | undefined;
|
|
27
|
-
operation: Operation;
|
|
28
|
-
};
|
|
29
|
-
declare function Mock({
|
|
30
|
-
baseURL,
|
|
31
|
-
name,
|
|
32
|
-
typeName,
|
|
33
|
-
operation
|
|
34
|
-
}: Props$2): FabricReactNode;
|
|
35
|
-
//#endregion
|
|
36
|
-
//#region src/components/MockWithFaker.d.ts
|
|
37
|
-
type Props$1 = {
|
|
38
|
-
/**
|
|
39
|
-
* Name of the function
|
|
40
|
-
*/
|
|
41
|
-
name: string;
|
|
42
|
-
typeName: string;
|
|
43
|
-
fakerName: string;
|
|
44
|
-
baseURL: string | undefined;
|
|
45
|
-
operation: Operation;
|
|
46
|
-
};
|
|
47
|
-
declare function MockWithFaker({
|
|
48
|
-
baseURL,
|
|
49
|
-
name,
|
|
50
|
-
fakerName,
|
|
51
|
-
typeName,
|
|
52
|
-
operation
|
|
53
|
-
}: Props$1): FabricReactNode;
|
|
54
|
-
//#endregion
|
|
55
|
-
//#region src/components/Response.d.ts
|
|
56
|
-
type Props = {
|
|
57
|
-
typeName: string;
|
|
58
|
-
operation: Operation;
|
|
59
|
-
name: string;
|
|
60
|
-
statusCode: number;
|
|
61
|
-
};
|
|
62
|
-
declare function Response({
|
|
63
|
-
name,
|
|
64
|
-
typeName,
|
|
65
|
-
operation,
|
|
66
|
-
statusCode
|
|
67
|
-
}: Props): FabricReactNode;
|
|
68
|
-
//#endregion
|
|
69
|
-
export { Handlers, Mock, MockWithFaker, Response };
|
|
70
|
-
//# sourceMappingURL=components.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generators-CCZr_EdQ.cjs","names":["File","Handlers","pluginFakerName","pluginTsName","File","Response","MockWithFaker","Mock"],"sources":["../src/generators/handlersGenerator.tsx","../src/generators/mswGenerator.tsx"],"sourcesContent":["import { usePluginManager } from '@kubb/core/hooks'\nimport { createReactGenerator } from '@kubb/plugin-oas/generators'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { File } from '@kubb/react-fabric'\nimport { Handlers } from '../components/Handlers.tsx'\nimport type { PluginMsw } from '../types'\n\nexport const handlersGenerator = createReactGenerator<PluginMsw>({\n name: 'plugin-msw',\n Operations({ operations, generator, plugin }) {\n const pluginManager = usePluginManager()\n\n const oas = useOas()\n const { getName, getFile } = useOperationManager(generator)\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","import { usePluginManager } from '@kubb/core/hooks'\nimport { pluginFakerName } from '@kubb/plugin-faker'\nimport { createReactGenerator } from '@kubb/plugin-oas/generators'\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-fabric'\nimport { Mock, MockWithFaker, Response } from '../components'\nimport type { PluginMsw } from '../types'\n\nexport const mswGenerator = createReactGenerator<PluginMsw>({\n name: 'msw',\n Operation({ operation, generator, plugin }) {\n const {\n options: { output, parser, baseURL },\n } = plugin\n const pluginManager = usePluginManager()\n\n const oas = useOas()\n const { getSchemas, getName, getFile } = useOperationManager(generator)\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"],"mappings":";;;;;;;;;;;AAQA,MAAa,0EAAoD;CAC/D,MAAM;CACN,WAAW,EAAE,YAAY,WAAW,UAAU;EAC5C,MAAM,wDAAkC;EAExC,MAAM,0CAAc;EACpB,MAAM,EAAE,SAAS,4DAAgC,UAAU;EAE3D,MAAM,OAAO,cAAc,QAAQ;GAAE,MAAM;GAAY,SAAS;GAAO,WAAW,OAAO;GAAK,CAAC;EAE/F,MAAM,UAAU,WAAW,KAAK,cAAc;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U,CACtC,KAAK,CAAC,MAAM,cACX,wDAACC;KAAmB;KAAqB;KAAW,MAAM,KAAK;KAAM,YAAY;MAAkB,CACnG;IACH,WAAW,WACV,wDAACC;KACC,MAAM,KAAK;KACX,UAAU,KAAK,QAAQ,SAAS;KAChC,WAAW,MAAM,QAAQ,SAAS;KACvB;KACF;MACT;IAEH,WAAW,UACV,wDAACC;KAAK,MAAM,KAAK;KAAM,UAAU,KAAK,QAAQ,SAAS;KAAM,WAAW,MAAM,QAAQ,SAAS;KAAiB;KAAoB;MAAW;;IAE5I;;CAGZ,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generators-CKxCewx3.js","names":[],"sources":["../src/generators/handlersGenerator.tsx","../src/generators/mswGenerator.tsx"],"sourcesContent":["import { usePluginManager } from '@kubb/core/hooks'\nimport { createReactGenerator } from '@kubb/plugin-oas/generators'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { File } from '@kubb/react-fabric'\nimport { Handlers } from '../components/Handlers.tsx'\nimport type { PluginMsw } from '../types'\n\nexport const handlersGenerator = createReactGenerator<PluginMsw>({\n name: 'plugin-msw',\n Operations({ operations, generator, plugin }) {\n const pluginManager = usePluginManager()\n\n const oas = useOas()\n const { getName, getFile } = useOperationManager(generator)\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","import { usePluginManager } from '@kubb/core/hooks'\nimport { pluginFakerName } from '@kubb/plugin-faker'\nimport { createReactGenerator } from '@kubb/plugin-oas/generators'\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-fabric'\nimport { Mock, MockWithFaker, Response } from '../components'\nimport type { PluginMsw } from '../types'\n\nexport const mswGenerator = createReactGenerator<PluginMsw>({\n name: 'msw',\n Operation({ operation, generator, plugin }) {\n const {\n options: { output, parser, baseURL },\n } = plugin\n const pluginManager = usePluginManager()\n\n const oas = useOas()\n const { getSchemas, getName, getFile } = useOperationManager(generator)\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"],"mappings":";;;;;;;;;;;;AAQA,MAAa,oBAAoB,qBAAgC;CAC/D,MAAM;CACN,WAAW,EAAE,YAAY,WAAW,UAAU;EAC5C,MAAM,gBAAgB,kBAAkB;EAExC,MAAM,MAAM,QAAQ;EACpB,MAAM,EAAE,SAAS,YAAY,oBAAoB,UAAU;EAE3D,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,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,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
|
|
|
1
|
-
import { t as __name } from "./chunk-DHUGjThq.cjs";
|
|
2
|
-
import { n as PluginMsw } from "./types-BQtW13UI.cjs";
|
|
3
|
-
import { FabricReactNode } from "@kubb/react-fabric/types";
|
|
4
|
-
import { HttpMethod, Oas, Operation, SchemaObject, contentType } from "@kubb/oas";
|
|
5
|
-
import { BaseGenerator, Config, FileMetaBase, Group, KubbEvents, Output, Plugin, PluginFactoryOptions, PluginManager, ResolveNameParams } from "@kubb/core";
|
|
6
|
-
import { AsyncEventEmitter } from "@kubb/core/utils";
|
|
7
|
-
import { KubbFile } from "@kubb/fabric-core/types";
|
|
8
|
-
import { Fabric } from "@kubb/react-fabric";
|
|
9
|
-
|
|
10
|
-
//#region ../plugin-oas/src/types.d.ts
|
|
11
|
-
type GetOasOptions = {
|
|
12
|
-
validate?: boolean;
|
|
13
|
-
};
|
|
14
|
-
type Context$2 = {
|
|
15
|
-
getOas(options?: GetOasOptions): Promise<Oas>;
|
|
16
|
-
getBaseURL(): Promise<string | undefined>;
|
|
17
|
-
};
|
|
18
|
-
declare global {
|
|
19
|
-
namespace Kubb {
|
|
20
|
-
interface PluginContext extends Context$2 {}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* `propertyName` is the ref name + resolved with the nameResolver
|
|
25
|
-
* @example import { Pet } from './Pet'
|
|
26
|
-
*
|
|
27
|
-
* `originalName` is the original name used(in PascalCase), only used to remove duplicates
|
|
28
|
-
*
|
|
29
|
-
* `pluginKey` can be used to override the current plugin being used, handy when you want to import a type/schema out of another plugin
|
|
30
|
-
* @example import a type(plugin-ts) for a mock file(swagger-faker)
|
|
31
|
-
*/
|
|
32
|
-
type Ref = {
|
|
33
|
-
propertyName: string;
|
|
34
|
-
originalName: string;
|
|
35
|
-
path: KubbFile.Path;
|
|
36
|
-
pluginKey?: Plugin['key'];
|
|
37
|
-
};
|
|
38
|
-
type Refs = Record<string, Ref>;
|
|
39
|
-
type OperationSchema = {
|
|
40
|
-
/**
|
|
41
|
-
* Converted name, contains already `PathParams`, `QueryParams`, ...
|
|
42
|
-
*/
|
|
43
|
-
name: string;
|
|
44
|
-
schema: SchemaObject;
|
|
45
|
-
operation?: Operation;
|
|
46
|
-
/**
|
|
47
|
-
* OperationName in PascalCase, only being used in OperationGenerator
|
|
48
|
-
*/
|
|
49
|
-
operationName: string;
|
|
50
|
-
description?: string;
|
|
51
|
-
statusCode?: number;
|
|
52
|
-
keys?: string[];
|
|
53
|
-
keysToOmit?: string[];
|
|
54
|
-
withData?: boolean;
|
|
55
|
-
};
|
|
56
|
-
type OperationSchemas = {
|
|
57
|
-
pathParams?: OperationSchema & {
|
|
58
|
-
keysToOmit?: never;
|
|
59
|
-
};
|
|
60
|
-
queryParams?: OperationSchema & {
|
|
61
|
-
keysToOmit?: never;
|
|
62
|
-
};
|
|
63
|
-
headerParams?: OperationSchema & {
|
|
64
|
-
keysToOmit?: never;
|
|
65
|
-
};
|
|
66
|
-
request?: OperationSchema;
|
|
67
|
-
response: OperationSchema;
|
|
68
|
-
responses: Array<OperationSchema>;
|
|
69
|
-
statusCodes?: Array<OperationSchema>;
|
|
70
|
-
errors?: Array<OperationSchema>;
|
|
71
|
-
};
|
|
72
|
-
type ByTag = {
|
|
73
|
-
type: 'tag';
|
|
74
|
-
pattern: string | RegExp;
|
|
75
|
-
};
|
|
76
|
-
type ByOperationId = {
|
|
77
|
-
type: 'operationId';
|
|
78
|
-
pattern: string | RegExp;
|
|
79
|
-
};
|
|
80
|
-
type ByPath = {
|
|
81
|
-
type: 'path';
|
|
82
|
-
pattern: string | RegExp;
|
|
83
|
-
};
|
|
84
|
-
type ByMethod = {
|
|
85
|
-
type: 'method';
|
|
86
|
-
pattern: HttpMethod | RegExp;
|
|
87
|
-
};
|
|
88
|
-
type BySchemaName = {
|
|
89
|
-
type: 'schemaName';
|
|
90
|
-
pattern: string | RegExp;
|
|
91
|
-
};
|
|
92
|
-
type ByContentType = {
|
|
93
|
-
type: 'contentType';
|
|
94
|
-
pattern: string | RegExp;
|
|
95
|
-
};
|
|
96
|
-
type Exclude = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
|
|
97
|
-
type Include = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
|
|
98
|
-
type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName | ByContentType) & {
|
|
99
|
-
options: Partial<TOptions>;
|
|
100
|
-
};
|
|
101
|
-
//#endregion
|
|
102
|
-
//#region ../plugin-oas/src/OperationGenerator.d.ts
|
|
103
|
-
type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
104
|
-
fabric: Fabric;
|
|
105
|
-
oas: Oas;
|
|
106
|
-
exclude: Array<Exclude> | undefined;
|
|
107
|
-
include: Array<Include> | undefined;
|
|
108
|
-
override: Array<Override<TOptions>> | undefined;
|
|
109
|
-
contentType: contentType | undefined;
|
|
110
|
-
pluginManager: PluginManager;
|
|
111
|
-
events?: AsyncEventEmitter<KubbEvents>;
|
|
112
|
-
/**
|
|
113
|
-
* Current plugin
|
|
114
|
-
*/
|
|
115
|
-
plugin: Plugin<TPluginOptions>;
|
|
116
|
-
mode: KubbFile.Mode;
|
|
117
|
-
UNSTABLE_NAMING?: true;
|
|
118
|
-
};
|
|
119
|
-
declare class OperationGenerator<TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TPluginOptions['resolvedOptions'], Context$1<TPluginOptions['resolvedOptions'], TPluginOptions>> {
|
|
120
|
-
#private;
|
|
121
|
-
getOptions(operation: Operation, method: HttpMethod): Partial<TPluginOptions['resolvedOptions']>;
|
|
122
|
-
getSchemas(operation: Operation, {
|
|
123
|
-
resolveName
|
|
124
|
-
}?: {
|
|
125
|
-
resolveName?: (name: string) => string;
|
|
126
|
-
}): OperationSchemas;
|
|
127
|
-
getOperations(): Promise<Array<{
|
|
128
|
-
path: string;
|
|
129
|
-
method: HttpMethod;
|
|
130
|
-
operation: Operation;
|
|
131
|
-
}>>;
|
|
132
|
-
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
133
|
-
}
|
|
134
|
-
//#endregion
|
|
135
|
-
//#region ../plugin-oas/src/SchemaMapper.d.ts
|
|
136
|
-
type SchemaKeywordMapper = {
|
|
137
|
-
object: {
|
|
138
|
-
keyword: 'object';
|
|
139
|
-
args: {
|
|
140
|
-
properties: {
|
|
141
|
-
[x: string]: Schema[];
|
|
142
|
-
};
|
|
143
|
-
additionalProperties: Schema[];
|
|
144
|
-
patternProperties?: Record<string, Schema[]>;
|
|
145
|
-
strict?: boolean;
|
|
146
|
-
};
|
|
147
|
-
};
|
|
148
|
-
url: {
|
|
149
|
-
keyword: 'url';
|
|
150
|
-
};
|
|
151
|
-
readOnly: {
|
|
152
|
-
keyword: 'readOnly';
|
|
153
|
-
};
|
|
154
|
-
writeOnly: {
|
|
155
|
-
keyword: 'writeOnly';
|
|
156
|
-
};
|
|
157
|
-
uuid: {
|
|
158
|
-
keyword: 'uuid';
|
|
159
|
-
};
|
|
160
|
-
email: {
|
|
161
|
-
keyword: 'email';
|
|
162
|
-
};
|
|
163
|
-
firstName: {
|
|
164
|
-
keyword: 'firstName';
|
|
165
|
-
};
|
|
166
|
-
lastName: {
|
|
167
|
-
keyword: 'lastName';
|
|
168
|
-
};
|
|
169
|
-
phone: {
|
|
170
|
-
keyword: 'phone';
|
|
171
|
-
};
|
|
172
|
-
password: {
|
|
173
|
-
keyword: 'password';
|
|
174
|
-
};
|
|
175
|
-
date: {
|
|
176
|
-
keyword: 'date';
|
|
177
|
-
args: {
|
|
178
|
-
type?: 'date' | 'string';
|
|
179
|
-
};
|
|
180
|
-
};
|
|
181
|
-
time: {
|
|
182
|
-
keyword: 'time';
|
|
183
|
-
args: {
|
|
184
|
-
type?: 'date' | 'string';
|
|
185
|
-
};
|
|
186
|
-
};
|
|
187
|
-
datetime: {
|
|
188
|
-
keyword: 'datetime';
|
|
189
|
-
args: {
|
|
190
|
-
offset?: boolean;
|
|
191
|
-
local?: boolean;
|
|
192
|
-
};
|
|
193
|
-
};
|
|
194
|
-
tuple: {
|
|
195
|
-
keyword: 'tuple';
|
|
196
|
-
args: {
|
|
197
|
-
items: Schema[];
|
|
198
|
-
min?: number;
|
|
199
|
-
max?: number;
|
|
200
|
-
rest?: Schema;
|
|
201
|
-
};
|
|
202
|
-
};
|
|
203
|
-
array: {
|
|
204
|
-
keyword: 'array';
|
|
205
|
-
args: {
|
|
206
|
-
items: Schema[];
|
|
207
|
-
min?: number;
|
|
208
|
-
max?: number;
|
|
209
|
-
unique?: boolean;
|
|
210
|
-
};
|
|
211
|
-
};
|
|
212
|
-
enum: {
|
|
213
|
-
keyword: 'enum';
|
|
214
|
-
args: {
|
|
215
|
-
name: string;
|
|
216
|
-
typeName: string;
|
|
217
|
-
asConst: boolean;
|
|
218
|
-
items: Array<{
|
|
219
|
-
name: string | number;
|
|
220
|
-
format: 'string' | 'number' | 'boolean';
|
|
221
|
-
value?: string | number | boolean;
|
|
222
|
-
}>;
|
|
223
|
-
};
|
|
224
|
-
};
|
|
225
|
-
and: {
|
|
226
|
-
keyword: 'and';
|
|
227
|
-
args: Schema[];
|
|
228
|
-
};
|
|
229
|
-
const: {
|
|
230
|
-
keyword: 'const';
|
|
231
|
-
args: {
|
|
232
|
-
name: string | number;
|
|
233
|
-
format: 'string' | 'number' | 'boolean';
|
|
234
|
-
value?: string | number | boolean;
|
|
235
|
-
};
|
|
236
|
-
};
|
|
237
|
-
union: {
|
|
238
|
-
keyword: 'union';
|
|
239
|
-
args: Schema[];
|
|
240
|
-
};
|
|
241
|
-
ref: {
|
|
242
|
-
keyword: 'ref';
|
|
243
|
-
args: {
|
|
244
|
-
name: string;
|
|
245
|
-
$ref: string;
|
|
246
|
-
/**
|
|
247
|
-
* Full qualified path.
|
|
248
|
-
*/
|
|
249
|
-
path: KubbFile.Path;
|
|
250
|
-
/**
|
|
251
|
-
* When true `File.Import` is used.
|
|
252
|
-
* When false a reference is used inside the current file.
|
|
253
|
-
*/
|
|
254
|
-
isImportable: boolean;
|
|
255
|
-
};
|
|
256
|
-
};
|
|
257
|
-
matches: {
|
|
258
|
-
keyword: 'matches';
|
|
259
|
-
args?: string;
|
|
260
|
-
};
|
|
261
|
-
boolean: {
|
|
262
|
-
keyword: 'boolean';
|
|
263
|
-
};
|
|
264
|
-
default: {
|
|
265
|
-
keyword: 'default';
|
|
266
|
-
args: string | number | boolean;
|
|
267
|
-
};
|
|
268
|
-
string: {
|
|
269
|
-
keyword: 'string';
|
|
270
|
-
};
|
|
271
|
-
integer: {
|
|
272
|
-
keyword: 'integer';
|
|
273
|
-
};
|
|
274
|
-
bigint: {
|
|
275
|
-
keyword: 'bigint';
|
|
276
|
-
};
|
|
277
|
-
number: {
|
|
278
|
-
keyword: 'number';
|
|
279
|
-
};
|
|
280
|
-
max: {
|
|
281
|
-
keyword: 'max';
|
|
282
|
-
args: number;
|
|
283
|
-
};
|
|
284
|
-
min: {
|
|
285
|
-
keyword: 'min';
|
|
286
|
-
args: number;
|
|
287
|
-
};
|
|
288
|
-
exclusiveMaximum: {
|
|
289
|
-
keyword: 'exclusiveMaximum';
|
|
290
|
-
args: number;
|
|
291
|
-
};
|
|
292
|
-
exclusiveMinimum: {
|
|
293
|
-
keyword: 'exclusiveMinimum';
|
|
294
|
-
args: number;
|
|
295
|
-
};
|
|
296
|
-
describe: {
|
|
297
|
-
keyword: 'describe';
|
|
298
|
-
args: string;
|
|
299
|
-
};
|
|
300
|
-
example: {
|
|
301
|
-
keyword: 'example';
|
|
302
|
-
args: string;
|
|
303
|
-
};
|
|
304
|
-
deprecated: {
|
|
305
|
-
keyword: 'deprecated';
|
|
306
|
-
};
|
|
307
|
-
optional: {
|
|
308
|
-
keyword: 'optional';
|
|
309
|
-
};
|
|
310
|
-
undefined: {
|
|
311
|
-
keyword: 'undefined';
|
|
312
|
-
};
|
|
313
|
-
nullish: {
|
|
314
|
-
keyword: 'nullish';
|
|
315
|
-
};
|
|
316
|
-
nullable: {
|
|
317
|
-
keyword: 'nullable';
|
|
318
|
-
};
|
|
319
|
-
null: {
|
|
320
|
-
keyword: 'null';
|
|
321
|
-
};
|
|
322
|
-
any: {
|
|
323
|
-
keyword: 'any';
|
|
324
|
-
};
|
|
325
|
-
unknown: {
|
|
326
|
-
keyword: 'unknown';
|
|
327
|
-
};
|
|
328
|
-
void: {
|
|
329
|
-
keyword: 'void';
|
|
330
|
-
};
|
|
331
|
-
blob: {
|
|
332
|
-
keyword: 'blob';
|
|
333
|
-
};
|
|
334
|
-
schema: {
|
|
335
|
-
keyword: 'schema';
|
|
336
|
-
args: {
|
|
337
|
-
type: 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'object';
|
|
338
|
-
format?: string;
|
|
339
|
-
};
|
|
340
|
-
};
|
|
341
|
-
name: {
|
|
342
|
-
keyword: 'name';
|
|
343
|
-
args: string;
|
|
344
|
-
};
|
|
345
|
-
catchall: {
|
|
346
|
-
keyword: 'catchall';
|
|
347
|
-
};
|
|
348
|
-
interface: {
|
|
349
|
-
keyword: 'interface';
|
|
350
|
-
};
|
|
351
|
-
};
|
|
352
|
-
type Schema = {
|
|
353
|
-
keyword: string;
|
|
354
|
-
} | SchemaKeywordMapper[keyof SchemaKeywordMapper];
|
|
355
|
-
//#endregion
|
|
356
|
-
//#region ../plugin-oas/src/SchemaGenerator.d.ts
|
|
357
|
-
type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
358
|
-
fabric: Fabric;
|
|
359
|
-
oas: Oas;
|
|
360
|
-
pluginManager: PluginManager;
|
|
361
|
-
events?: AsyncEventEmitter<KubbEvents>;
|
|
362
|
-
/**
|
|
363
|
-
* Current plugin
|
|
364
|
-
*/
|
|
365
|
-
plugin: Plugin<TPluginOptions>;
|
|
366
|
-
mode: KubbFile.Mode;
|
|
367
|
-
include?: Array<'schemas' | 'responses' | 'requestBodies'>;
|
|
368
|
-
override: Array<Override<TOptions>> | undefined;
|
|
369
|
-
contentType?: contentType;
|
|
370
|
-
output?: string;
|
|
371
|
-
};
|
|
372
|
-
type SchemaGeneratorOptions = {
|
|
373
|
-
dateType: false | 'string' | 'stringOffset' | 'stringLocal' | 'date';
|
|
374
|
-
integerType?: 'number' | 'bigint';
|
|
375
|
-
unknownType: 'any' | 'unknown' | 'void';
|
|
376
|
-
emptySchemaType: 'any' | 'unknown' | 'void';
|
|
377
|
-
enumType?: 'enum' | 'asConst' | 'asPascalConst' | 'constEnum' | 'literal' | 'inlineLiteral';
|
|
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
|
-
*/
|
|
384
|
-
usedEnumNames?: Record<string, number>;
|
|
385
|
-
mapper?: Record<string, string>;
|
|
386
|
-
typed?: boolean;
|
|
387
|
-
transformers: {
|
|
388
|
-
/**
|
|
389
|
-
* Customize the names based on the type that is provided by the plugin.
|
|
390
|
-
*/
|
|
391
|
-
name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
392
|
-
/**
|
|
393
|
-
* Receive schema and name(propertyName) and return FakerMeta array
|
|
394
|
-
* TODO TODO add docs
|
|
395
|
-
* @beta
|
|
396
|
-
*/
|
|
397
|
-
schema?: (schemaProps: SchemaProps$1, defaultSchemas: Schema[]) => Array<Schema> | undefined;
|
|
398
|
-
};
|
|
399
|
-
};
|
|
400
|
-
type SchemaProps$1 = {
|
|
401
|
-
schema: SchemaObject | null;
|
|
402
|
-
name: string | null;
|
|
403
|
-
parentName: string | null;
|
|
404
|
-
rootName?: string | null;
|
|
405
|
-
};
|
|
406
|
-
declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions, Context<TOptions, TPluginOptions>> {
|
|
407
|
-
#private;
|
|
408
|
-
refs: Refs;
|
|
409
|
-
/**
|
|
410
|
-
* Creates a type node from a given schema.
|
|
411
|
-
* Delegates to getBaseTypeFromSchema internally and
|
|
412
|
-
* optionally adds a union with null.
|
|
413
|
-
*/
|
|
414
|
-
parse(props: SchemaProps$1): Schema[];
|
|
415
|
-
static deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
|
|
416
|
-
static find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
417
|
-
static combineObjects(tree: Schema[] | undefined): Schema[];
|
|
418
|
-
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
419
|
-
}
|
|
420
|
-
//#endregion
|
|
421
|
-
//#region ../plugin-oas/src/generators/createGenerator.d.ts
|
|
422
|
-
type CoreGenerator<TOptions extends PluginFactoryOptions> = {
|
|
423
|
-
name: string;
|
|
424
|
-
type: 'core';
|
|
425
|
-
operations: (props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
426
|
-
operation: (props: OperationProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
427
|
-
schema: (props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
428
|
-
};
|
|
429
|
-
//#endregion
|
|
430
|
-
//#region ../plugin-oas/src/generators/types.d.ts
|
|
431
|
-
type OperationsProps<TOptions extends PluginFactoryOptions> = {
|
|
432
|
-
config: Config;
|
|
433
|
-
generator: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
434
|
-
plugin: Plugin<TOptions>;
|
|
435
|
-
operations: Array<Operation>;
|
|
436
|
-
};
|
|
437
|
-
type OperationProps<TOptions extends PluginFactoryOptions> = {
|
|
438
|
-
config: Config;
|
|
439
|
-
generator: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
440
|
-
plugin: Plugin<TOptions>;
|
|
441
|
-
operation: Operation;
|
|
442
|
-
};
|
|
443
|
-
type SchemaProps<TOptions extends PluginFactoryOptions> = {
|
|
444
|
-
config: Config;
|
|
445
|
-
generator: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>;
|
|
446
|
-
plugin: Plugin<TOptions>;
|
|
447
|
-
schema: {
|
|
448
|
-
name: string;
|
|
449
|
-
tree: Array<Schema>;
|
|
450
|
-
value: SchemaObject;
|
|
451
|
-
};
|
|
452
|
-
};
|
|
453
|
-
type Generator<TOptions extends PluginFactoryOptions> = CoreGenerator<TOptions> | ReactGenerator<TOptions>;
|
|
454
|
-
//#endregion
|
|
455
|
-
//#region ../plugin-oas/src/generators/createReactGenerator.d.ts
|
|
456
|
-
type ReactGenerator<TOptions extends PluginFactoryOptions> = {
|
|
457
|
-
name: string;
|
|
458
|
-
type: 'react';
|
|
459
|
-
Operations: (props: OperationsProps<TOptions>) => FabricReactNode;
|
|
460
|
-
Operation: (props: OperationProps<TOptions>) => FabricReactNode;
|
|
461
|
-
Schema: (props: SchemaProps<TOptions>) => FabricReactNode;
|
|
462
|
-
};
|
|
463
|
-
//#endregion
|
|
464
|
-
//#region src/generators/handlersGenerator.d.ts
|
|
465
|
-
declare const handlersGenerator: ReactGenerator<PluginMsw>;
|
|
466
|
-
//#endregion
|
|
467
|
-
//#region src/generators/mswGenerator.d.ts
|
|
468
|
-
declare const mswGenerator: ReactGenerator<PluginMsw>;
|
|
469
|
-
//#endregion
|
|
470
|
-
export { handlersGenerator, mswGenerator };
|
|
471
|
-
//# sourceMappingURL=generators.d.cts.map
|
package/dist/index.d.cts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { t as __name } from "./chunk-DHUGjThq.cjs";
|
|
2
|
-
import { n as PluginMsw, t as Options } from "./types-BQtW13UI.cjs";
|
|
3
|
-
import * as _kubb_core0 from "@kubb/core";
|
|
4
|
-
|
|
5
|
-
//#region src/plugin.d.ts
|
|
6
|
-
declare const pluginMswName = "plugin-msw";
|
|
7
|
-
declare const pluginMsw: (options?: Options | undefined) => _kubb_core0.UserPluginWithLifeCycle<PluginMsw>;
|
|
8
|
-
//#endregion
|
|
9
|
-
export { type PluginMsw, pluginMsw, pluginMswName };
|
|
10
|
-
//# sourceMappingURL=index.d.cts.map
|