@kubb/plugin-msw 5.0.0-beta.10 → 5.0.0-beta.101
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -26
- package/dist/index.cjs +478 -40
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +139 -6
- package/dist/index.js +475 -39
- package/dist/index.js.map +1 -1
- package/package.json +9 -30
- package/dist/components-BYvgvrY7.cjs +0 -569
- package/dist/components-BYvgvrY7.cjs.map +0 -1
- package/dist/components-Cm17DMTE.js +0 -510
- package/dist/components-Cm17DMTE.js.map +0 -1
- package/dist/components.cjs +0 -6
- package/dist/components.d.ts +0 -66
- package/dist/components.js +0 -2
- package/dist/generators-D9gvdP7Z.js +0 -177
- package/dist/generators-D9gvdP7Z.js.map +0 -1
- package/dist/generators-rZ99WaWQ.cjs +0 -187
- package/dist/generators-rZ99WaWQ.cjs.map +0 -1
- package/dist/generators.cjs +0 -4
- package/dist/generators.d.ts +0 -12
- package/dist/generators.js +0 -2
- package/dist/types-ItsHsMvC.d.ts +0 -94
- package/extension.yaml +0 -233
- package/src/components/Handlers.tsx +0 -19
- package/src/components/Mock.tsx +0 -71
- package/src/components/MockWithFaker.tsx +0 -70
- package/src/components/Response.tsx +0 -52
- package/src/components/index.ts +0 -4
- package/src/generators/handlersGenerator.tsx +0 -41
- package/src/generators/index.ts +0 -2
- package/src/generators/mswGenerator.tsx +0 -86
- package/src/index.ts +0 -2
- package/src/plugin.ts +0 -76
- package/src/resolvers/resolverMsw.ts +0 -28
- package/src/types.ts +0 -93
- package/src/utils.ts +0 -58
- /package/dist/{chunk--u3MIqq1.js → rolldown-runtime-C0LytTxp.js} +0 -0
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
import "./chunk--u3MIqq1.js";
|
|
2
|
-
import { a as getOperationSuccessResponses, i as resolveFakerMeta, n as MockWithFaker, o as resolveResponseTypes, r as Mock, s as Handlers, t as Response } from "./components-Cm17DMTE.js";
|
|
3
|
-
import { defineGenerator } from "@kubb/core";
|
|
4
|
-
import { pluginFakerName } from "@kubb/plugin-faker";
|
|
5
|
-
import { pluginTsName } from "@kubb/plugin-ts";
|
|
6
|
-
import { File, jsxRenderer } from "@kubb/renderer-jsx";
|
|
7
|
-
import { jsx, jsxs } from "@kubb/renderer-jsx/jsx-runtime";
|
|
8
|
-
//#region src/generators/handlersGenerator.tsx
|
|
9
|
-
const handlersGenerator = defineGenerator({
|
|
10
|
-
name: "plugin-msw",
|
|
11
|
-
renderer: jsxRenderer,
|
|
12
|
-
operations(nodes, ctx) {
|
|
13
|
-
const { resolver, config, root, adapter } = ctx;
|
|
14
|
-
const { output, group } = ctx.options;
|
|
15
|
-
const handlersName = resolver.resolveHandlersName();
|
|
16
|
-
const file = resolver.resolveFile({
|
|
17
|
-
name: resolver.resolvePathName(handlersName, "file"),
|
|
18
|
-
extname: ".ts"
|
|
19
|
-
}, {
|
|
20
|
-
root,
|
|
21
|
-
output,
|
|
22
|
-
group
|
|
23
|
-
});
|
|
24
|
-
const imports = nodes.map((node) => {
|
|
25
|
-
const operationName = resolver.resolveHandlerName(node);
|
|
26
|
-
const operationFile = resolver.resolveFile({
|
|
27
|
-
name: resolver.resolveName(node.operationId),
|
|
28
|
-
extname: ".ts",
|
|
29
|
-
tag: node.tags[0] ?? "default",
|
|
30
|
-
path: node.path
|
|
31
|
-
}, {
|
|
32
|
-
root,
|
|
33
|
-
output,
|
|
34
|
-
group
|
|
35
|
-
});
|
|
36
|
-
return /* @__PURE__ */ jsx(File.Import, {
|
|
37
|
-
name: [operationName],
|
|
38
|
-
root: file.path,
|
|
39
|
-
path: operationFile.path
|
|
40
|
-
}, operationFile.path);
|
|
41
|
-
});
|
|
42
|
-
const handlers = nodes.map((node) => `${resolver.resolveHandlerName(node)}()`);
|
|
43
|
-
return /* @__PURE__ */ jsxs(File, {
|
|
44
|
-
baseName: file.baseName,
|
|
45
|
-
path: file.path,
|
|
46
|
-
meta: file.meta,
|
|
47
|
-
banner: resolver.resolveBanner(adapter.inputNode, {
|
|
48
|
-
output,
|
|
49
|
-
config
|
|
50
|
-
}),
|
|
51
|
-
footer: resolver.resolveFooter(adapter.inputNode, {
|
|
52
|
-
output,
|
|
53
|
-
config
|
|
54
|
-
}),
|
|
55
|
-
children: [imports, /* @__PURE__ */ jsx(Handlers, {
|
|
56
|
-
name: handlersName,
|
|
57
|
-
handlers
|
|
58
|
-
})]
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
//#endregion
|
|
63
|
-
//#region src/generators/mswGenerator.tsx
|
|
64
|
-
const mswGenerator = defineGenerator({
|
|
65
|
-
name: "msw",
|
|
66
|
-
renderer: jsxRenderer,
|
|
67
|
-
operation(node, ctx) {
|
|
68
|
-
const { driver, resolver, config, root, adapter } = ctx;
|
|
69
|
-
const { output, parser, baseURL, group } = ctx.options;
|
|
70
|
-
const fileName = resolver.resolveName(node.operationId);
|
|
71
|
-
const mock = {
|
|
72
|
-
name: resolver.resolveHandlerName(node),
|
|
73
|
-
file: resolver.resolveFile({
|
|
74
|
-
name: fileName,
|
|
75
|
-
extname: ".ts",
|
|
76
|
-
tag: node.tags[0] ?? "default",
|
|
77
|
-
path: node.path
|
|
78
|
-
}, {
|
|
79
|
-
root,
|
|
80
|
-
output,
|
|
81
|
-
group
|
|
82
|
-
})
|
|
83
|
-
};
|
|
84
|
-
const fakerPlugin = parser === "faker" ? driver.getPlugin(pluginFakerName) : void 0;
|
|
85
|
-
const faker = parser === "faker" && fakerPlugin ? resolveFakerMeta(node, {
|
|
86
|
-
root,
|
|
87
|
-
fakerResolver: driver.getResolver(pluginFakerName),
|
|
88
|
-
fakerOutput: fakerPlugin.options?.output ?? output,
|
|
89
|
-
fakerGroup: fakerPlugin.options?.group
|
|
90
|
-
}) : void 0;
|
|
91
|
-
const pluginTs = driver.getPlugin(pluginTsName);
|
|
92
|
-
if (!pluginTs) return null;
|
|
93
|
-
const tsResolver = driver.getResolver(pluginTsName);
|
|
94
|
-
const type = {
|
|
95
|
-
file: tsResolver.resolveFile({
|
|
96
|
-
name: node.operationId,
|
|
97
|
-
extname: ".ts",
|
|
98
|
-
tag: node.tags[0] ?? "default",
|
|
99
|
-
path: node.path
|
|
100
|
-
}, {
|
|
101
|
-
root,
|
|
102
|
-
output: pluginTs.options?.output ?? output,
|
|
103
|
-
group: pluginTs.options?.group
|
|
104
|
-
}),
|
|
105
|
-
responseName: tsResolver.resolveResponseName(node)
|
|
106
|
-
};
|
|
107
|
-
const types = resolveResponseTypes(node, tsResolver);
|
|
108
|
-
const hasSuccessSchema = getOperationSuccessResponses(node).some((response) => !!response.schema);
|
|
109
|
-
const requestName = node.requestBody?.content?.[0]?.schema ? tsResolver.resolveDataName(node) : void 0;
|
|
110
|
-
return /* @__PURE__ */ jsxs(File, {
|
|
111
|
-
baseName: mock.file.baseName,
|
|
112
|
-
path: mock.file.path,
|
|
113
|
-
meta: mock.file.meta,
|
|
114
|
-
banner: resolver.resolveBanner(adapter.inputNode, {
|
|
115
|
-
output,
|
|
116
|
-
config
|
|
117
|
-
}),
|
|
118
|
-
footer: resolver.resolveFooter(adapter.inputNode, {
|
|
119
|
-
output,
|
|
120
|
-
config
|
|
121
|
-
}),
|
|
122
|
-
children: [
|
|
123
|
-
/* @__PURE__ */ jsx(File.Import, {
|
|
124
|
-
name: ["http"],
|
|
125
|
-
path: "msw"
|
|
126
|
-
}),
|
|
127
|
-
/* @__PURE__ */ jsx(File.Import, {
|
|
128
|
-
name: ["HttpResponseResolver"],
|
|
129
|
-
isTypeOnly: true,
|
|
130
|
-
path: "msw"
|
|
131
|
-
}),
|
|
132
|
-
/* @__PURE__ */ jsx(File.Import, {
|
|
133
|
-
name: Array.from(new Set([
|
|
134
|
-
type.responseName,
|
|
135
|
-
...types.map((t) => t[1]),
|
|
136
|
-
...requestName ? [requestName] : []
|
|
137
|
-
])),
|
|
138
|
-
path: type.file.path,
|
|
139
|
-
root: mock.file.path,
|
|
140
|
-
isTypeOnly: true
|
|
141
|
-
}),
|
|
142
|
-
parser === "faker" && faker && /* @__PURE__ */ jsx(File.Import, {
|
|
143
|
-
name: [faker.name],
|
|
144
|
-
root: mock.file.path,
|
|
145
|
-
path: faker.file.path
|
|
146
|
-
}),
|
|
147
|
-
types.filter(([code]) => code !== "default").map(([code, typeName]) => {
|
|
148
|
-
const response = node.responses.find((item) => item.statusCode === String(code));
|
|
149
|
-
if (!response) return null;
|
|
150
|
-
return /* @__PURE__ */ jsx(Response, {
|
|
151
|
-
typeName,
|
|
152
|
-
response,
|
|
153
|
-
name: mock.name
|
|
154
|
-
}, typeName);
|
|
155
|
-
}),
|
|
156
|
-
parser === "faker" && faker && hasSuccessSchema ? /* @__PURE__ */ jsx(MockWithFaker, {
|
|
157
|
-
name: mock.name,
|
|
158
|
-
typeName: type.responseName,
|
|
159
|
-
requestTypeName: requestName,
|
|
160
|
-
fakerName: faker.name,
|
|
161
|
-
node,
|
|
162
|
-
baseURL
|
|
163
|
-
}) : /* @__PURE__ */ jsx(Mock, {
|
|
164
|
-
name: mock.name,
|
|
165
|
-
typeName: type.responseName,
|
|
166
|
-
requestTypeName: requestName,
|
|
167
|
-
node,
|
|
168
|
-
baseURL
|
|
169
|
-
})
|
|
170
|
-
]
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
//#endregion
|
|
175
|
-
export { handlersGenerator as n, mswGenerator as t };
|
|
176
|
-
|
|
177
|
-
//# sourceMappingURL=generators-D9gvdP7Z.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generators-D9gvdP7Z.js","names":[],"sources":["../src/generators/handlersGenerator.tsx","../src/generators/mswGenerator.tsx"],"sourcesContent":["import { defineGenerator } from '@kubb/core'\nimport { File, jsxRenderer } from '@kubb/renderer-jsx'\nimport { Handlers } from '../components/Handlers.tsx'\nimport type { PluginMsw } from '../types'\n\nexport const handlersGenerator = defineGenerator<PluginMsw>({\n name: 'plugin-msw',\n renderer: jsxRenderer,\n operations(nodes, ctx) {\n const { resolver, config, root, adapter } = ctx\n const { output, group } = ctx.options\n\n const handlersName = resolver.resolveHandlersName()\n const file = resolver.resolveFile({ name: resolver.resolvePathName(handlersName, 'file'), extname: '.ts' }, { root, output, group })\n\n const imports = nodes.map((node) => {\n const operationName = resolver.resolveHandlerName(node)\n const operationFile = resolver.resolveFile(\n { name: resolver.resolveName(node.operationId), extname: '.ts', tag: node.tags[0] ?? 'default', path: node.path },\n { root, output, group },\n )\n\n return <File.Import key={operationFile.path} name={[operationName]} root={file.path} path={operationFile.path} />\n })\n\n const handlers = nodes.map((node) => `${resolver.resolveHandlerName(node)}()`)\n\n return (\n <File\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={resolver.resolveBanner(adapter.inputNode, { output, config })}\n footer={resolver.resolveFooter(adapter.inputNode, { output, config })}\n >\n {imports}\n <Handlers name={handlersName} handlers={handlers} />\n </File>\n )\n },\n})\n","import { getOperationSuccessResponses, resolveResponseTypes } from '@internals/shared'\nimport { defineGenerator } from '@kubb/core'\nimport { pluginFakerName } from '@kubb/plugin-faker'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { File, jsxRenderer } from '@kubb/renderer-jsx'\nimport { Mock, MockWithFaker, Response } from '../components'\nimport type { PluginMsw } from '../types'\nimport { resolveFakerMeta } from '../utils.ts'\n\nexport const mswGenerator = defineGenerator<PluginMsw>({\n name: 'msw',\n renderer: jsxRenderer,\n operation(node, ctx) {\n const { driver, resolver, config, root, adapter } = ctx\n const { output, parser, baseURL, group } = ctx.options\n\n const fileName = resolver.resolveName(node.operationId)\n const mock = {\n name: resolver.resolveHandlerName(node),\n file: resolver.resolveFile({ name: fileName, extname: '.ts', tag: node.tags[0] ?? 'default', path: node.path }, { root, output, group }),\n }\n\n const fakerPlugin = parser === 'faker' ? driver.getPlugin(pluginFakerName) : undefined\n const faker =\n parser === 'faker' && fakerPlugin\n ? resolveFakerMeta(node, {\n root,\n fakerResolver: driver.getResolver(pluginFakerName),\n fakerOutput: fakerPlugin.options?.output ?? output,\n fakerGroup: fakerPlugin.options?.group,\n })\n : undefined\n\n const pluginTs = driver.getPlugin(pluginTsName)\n if (!pluginTs) return null\n const tsResolver = driver.getResolver(pluginTsName)\n\n const type = {\n file: tsResolver.resolveFile(\n { name: node.operationId, extname: '.ts', tag: node.tags[0] ?? 'default', path: node.path },\n { root, output: pluginTs.options?.output ?? output, group: pluginTs.options?.group },\n ),\n responseName: tsResolver.resolveResponseName(node),\n }\n\n const types = resolveResponseTypes(node, tsResolver)\n const successResponses = getOperationSuccessResponses(node)\n const hasSuccessSchema = successResponses.some((response) => !!response.schema)\n\n const requestName = node.requestBody?.content?.[0]?.schema ? tsResolver.resolveDataName(node) : undefined\n\n return (\n <File\n baseName={mock.file.baseName}\n path={mock.file.path}\n meta={mock.file.meta}\n banner={resolver.resolveBanner(adapter.inputNode, { output, config })}\n footer={resolver.resolveFooter(adapter.inputNode, { output, config })}\n >\n <File.Import name={['http']} path=\"msw\" />\n <File.Import name={['HttpResponseResolver']} isTypeOnly path=\"msw\" />\n <File.Import\n name={Array.from(new Set([type.responseName, ...types.map((t) => t[1]), ...(requestName ? [requestName] : [])]))}\n path={type.file.path}\n root={mock.file.path}\n isTypeOnly\n />\n {parser === 'faker' && faker && <File.Import name={[faker.name]} root={mock.file.path} path={faker.file.path} />}\n\n {types\n .filter(([code]) => code !== 'default')\n .map(([code, typeName]) => {\n const response = node.responses.find((item) => item.statusCode === String(code))\n if (!response) return null\n return <Response key={typeName} typeName={typeName} response={response} name={mock.name} />\n })}\n\n {parser === 'faker' && faker && hasSuccessSchema ? (\n <MockWithFaker name={mock.name} typeName={type.responseName} requestTypeName={requestName} fakerName={faker.name} node={node} baseURL={baseURL} />\n ) : (\n <Mock name={mock.name} typeName={type.responseName} requestTypeName={requestName} node={node} baseURL={baseURL} />\n )}\n </File>\n )\n },\n})\n"],"mappings":";;;;;;;;AAKA,MAAa,oBAAoB,gBAA2B;CAC1D,MAA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a,MAAM,CAAC,OAAO;KAAE,MAAK;KAAQ,CAAA;IAC1C,oBAAC,KAAK,QAAN;KAAa,MAAM,CAAC,uBAAuB;KAAE,YAAA;KAAW,MAAK;KAAQ,CAAA;IACrE,oBAAC,KAAK,QAAN;KACE,MAAM,MAAM,KAAK,IAAI,IAAI;MAAC,KAAK;MAAc,GAAG,MAAM,KAAK,MAAM,EAAE,GAAG;MAAE,GAAI,cAAc,CAAC,YAAY,GAAG,EAAE;MAAE,CAAC,CAAC;KAChH,MAAM,KAAK,KAAK;KAChB,MAAM,KAAK,KAAK;KAChB,YAAA;KACA,CAAA;IACD,WAAW,WAAW,SAAS,oBAAC,KAAK,QAAN;KAAa,MAAM,CAAC,MAAM,KAAK;KAAE,MAAM,KAAK,KAAK;KAAM,MAAM,MAAM,KAAK;KAAQ,CAAA;IAE/G,MACE,QAAQ,CAAC,UAAU,SAAS,UAAU,CACtC,KAAK,CAAC,MAAM,cAAc;KACzB,MAAM,WAAW,KAAK,UAAU,MAAM,SAAS,KAAK,eAAe,OAAO,KAAK,CAAC;KAChF,IAAI,CAAC,UAAU,OAAO;KACtB,OAAO,oBAAC,UAAD;MAAmC;MAAoB;MAAU,MAAM,KAAK;MAAQ,EAArE,SAAqE;MAC3F;IAEH,WAAW,WAAW,SAAS,mBAC9B,oBAAC,eAAD;KAAe,MAAM,KAAK;KAAM,UAAU,KAAK;KAAc,iBAAiB;KAAa,WAAW,MAAM;KAAY;KAAe;KAAW,CAAA,GAElJ,oBAAC,MAAD;KAAM,MAAM,KAAK;KAAM,UAAU,KAAK;KAAc,iBAAiB;KAAmB;KAAe;KAAW,CAAA;IAE/G;;;CAGZ,CAAC"}
|
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
const require_components = require("./components-BYvgvrY7.cjs");
|
|
2
|
-
let _kubb_core = require("@kubb/core");
|
|
3
|
-
let _kubb_plugin_faker = require("@kubb/plugin-faker");
|
|
4
|
-
let _kubb_plugin_ts = require("@kubb/plugin-ts");
|
|
5
|
-
let _kubb_renderer_jsx = require("@kubb/renderer-jsx");
|
|
6
|
-
let _kubb_renderer_jsx_jsx_runtime = require("@kubb/renderer-jsx/jsx-runtime");
|
|
7
|
-
//#region src/generators/handlersGenerator.tsx
|
|
8
|
-
const handlersGenerator = (0, _kubb_core.defineGenerator)({
|
|
9
|
-
name: "plugin-msw",
|
|
10
|
-
renderer: _kubb_renderer_jsx.jsxRenderer,
|
|
11
|
-
operations(nodes, ctx) {
|
|
12
|
-
const { resolver, config, root, adapter } = ctx;
|
|
13
|
-
const { output, group } = ctx.options;
|
|
14
|
-
const handlersName = resolver.resolveHandlersName();
|
|
15
|
-
const file = resolver.resolveFile({
|
|
16
|
-
name: resolver.resolvePathName(handlersName, "file"),
|
|
17
|
-
extname: ".ts"
|
|
18
|
-
}, {
|
|
19
|
-
root,
|
|
20
|
-
output,
|
|
21
|
-
group
|
|
22
|
-
});
|
|
23
|
-
const imports = nodes.map((node) => {
|
|
24
|
-
const operationName = resolver.resolveHandlerName(node);
|
|
25
|
-
const operationFile = resolver.resolveFile({
|
|
26
|
-
name: resolver.resolveName(node.operationId),
|
|
27
|
-
extname: ".ts",
|
|
28
|
-
tag: node.tags[0] ?? "default",
|
|
29
|
-
path: node.path
|
|
30
|
-
}, {
|
|
31
|
-
root,
|
|
32
|
-
output,
|
|
33
|
-
group
|
|
34
|
-
});
|
|
35
|
-
return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
36
|
-
name: [operationName],
|
|
37
|
-
root: file.path,
|
|
38
|
-
path: operationFile.path
|
|
39
|
-
}, operationFile.path);
|
|
40
|
-
});
|
|
41
|
-
const handlers = nodes.map((node) => `${resolver.resolveHandlerName(node)}()`);
|
|
42
|
-
return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx.File, {
|
|
43
|
-
baseName: file.baseName,
|
|
44
|
-
path: file.path,
|
|
45
|
-
meta: file.meta,
|
|
46
|
-
banner: resolver.resolveBanner(adapter.inputNode, {
|
|
47
|
-
output,
|
|
48
|
-
config
|
|
49
|
-
}),
|
|
50
|
-
footer: resolver.resolveFooter(adapter.inputNode, {
|
|
51
|
-
output,
|
|
52
|
-
config
|
|
53
|
-
}),
|
|
54
|
-
children: [imports, /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(require_components.Handlers, {
|
|
55
|
-
name: handlersName,
|
|
56
|
-
handlers
|
|
57
|
-
})]
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
//#endregion
|
|
62
|
-
//#region src/generators/mswGenerator.tsx
|
|
63
|
-
const mswGenerator = (0, _kubb_core.defineGenerator)({
|
|
64
|
-
name: "msw",
|
|
65
|
-
renderer: _kubb_renderer_jsx.jsxRenderer,
|
|
66
|
-
operation(node, ctx) {
|
|
67
|
-
const { driver, resolver, config, root, adapter } = ctx;
|
|
68
|
-
const { output, parser, baseURL, group } = ctx.options;
|
|
69
|
-
const fileName = resolver.resolveName(node.operationId);
|
|
70
|
-
const mock = {
|
|
71
|
-
name: resolver.resolveHandlerName(node),
|
|
72
|
-
file: resolver.resolveFile({
|
|
73
|
-
name: fileName,
|
|
74
|
-
extname: ".ts",
|
|
75
|
-
tag: node.tags[0] ?? "default",
|
|
76
|
-
path: node.path
|
|
77
|
-
}, {
|
|
78
|
-
root,
|
|
79
|
-
output,
|
|
80
|
-
group
|
|
81
|
-
})
|
|
82
|
-
};
|
|
83
|
-
const fakerPlugin = parser === "faker" ? driver.getPlugin(_kubb_plugin_faker.pluginFakerName) : void 0;
|
|
84
|
-
const faker = parser === "faker" && fakerPlugin ? require_components.resolveFakerMeta(node, {
|
|
85
|
-
root,
|
|
86
|
-
fakerResolver: driver.getResolver(_kubb_plugin_faker.pluginFakerName),
|
|
87
|
-
fakerOutput: fakerPlugin.options?.output ?? output,
|
|
88
|
-
fakerGroup: fakerPlugin.options?.group
|
|
89
|
-
}) : void 0;
|
|
90
|
-
const pluginTs = driver.getPlugin(_kubb_plugin_ts.pluginTsName);
|
|
91
|
-
if (!pluginTs) return null;
|
|
92
|
-
const tsResolver = driver.getResolver(_kubb_plugin_ts.pluginTsName);
|
|
93
|
-
const type = {
|
|
94
|
-
file: tsResolver.resolveFile({
|
|
95
|
-
name: node.operationId,
|
|
96
|
-
extname: ".ts",
|
|
97
|
-
tag: node.tags[0] ?? "default",
|
|
98
|
-
path: node.path
|
|
99
|
-
}, {
|
|
100
|
-
root,
|
|
101
|
-
output: pluginTs.options?.output ?? output,
|
|
102
|
-
group: pluginTs.options?.group
|
|
103
|
-
}),
|
|
104
|
-
responseName: tsResolver.resolveResponseName(node)
|
|
105
|
-
};
|
|
106
|
-
const types = require_components.resolveResponseTypes(node, tsResolver);
|
|
107
|
-
const hasSuccessSchema = require_components.getOperationSuccessResponses(node).some((response) => !!response.schema);
|
|
108
|
-
const requestName = node.requestBody?.content?.[0]?.schema ? tsResolver.resolveDataName(node) : void 0;
|
|
109
|
-
return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx.File, {
|
|
110
|
-
baseName: mock.file.baseName,
|
|
111
|
-
path: mock.file.path,
|
|
112
|
-
meta: mock.file.meta,
|
|
113
|
-
banner: resolver.resolveBanner(adapter.inputNode, {
|
|
114
|
-
output,
|
|
115
|
-
config
|
|
116
|
-
}),
|
|
117
|
-
footer: resolver.resolveFooter(adapter.inputNode, {
|
|
118
|
-
output,
|
|
119
|
-
config
|
|
120
|
-
}),
|
|
121
|
-
children: [
|
|
122
|
-
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
123
|
-
name: ["http"],
|
|
124
|
-
path: "msw"
|
|
125
|
-
}),
|
|
126
|
-
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
127
|
-
name: ["HttpResponseResolver"],
|
|
128
|
-
isTypeOnly: true,
|
|
129
|
-
path: "msw"
|
|
130
|
-
}),
|
|
131
|
-
/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
132
|
-
name: Array.from(new Set([
|
|
133
|
-
type.responseName,
|
|
134
|
-
...types.map((t) => t[1]),
|
|
135
|
-
...requestName ? [requestName] : []
|
|
136
|
-
])),
|
|
137
|
-
path: type.file.path,
|
|
138
|
-
root: mock.file.path,
|
|
139
|
-
isTypeOnly: true
|
|
140
|
-
}),
|
|
141
|
-
parser === "faker" && faker && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
142
|
-
name: [faker.name],
|
|
143
|
-
root: mock.file.path,
|
|
144
|
-
path: faker.file.path
|
|
145
|
-
}),
|
|
146
|
-
types.filter(([code]) => code !== "default").map(([code, typeName]) => {
|
|
147
|
-
const response = node.responses.find((item) => item.statusCode === String(code));
|
|
148
|
-
if (!response) return null;
|
|
149
|
-
return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(require_components.Response, {
|
|
150
|
-
typeName,
|
|
151
|
-
response,
|
|
152
|
-
name: mock.name
|
|
153
|
-
}, typeName);
|
|
154
|
-
}),
|
|
155
|
-
parser === "faker" && faker && hasSuccessSchema ? /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(require_components.MockWithFaker, {
|
|
156
|
-
name: mock.name,
|
|
157
|
-
typeName: type.responseName,
|
|
158
|
-
requestTypeName: requestName,
|
|
159
|
-
fakerName: faker.name,
|
|
160
|
-
node,
|
|
161
|
-
baseURL
|
|
162
|
-
}) : /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(require_components.Mock, {
|
|
163
|
-
name: mock.name,
|
|
164
|
-
typeName: type.responseName,
|
|
165
|
-
requestTypeName: requestName,
|
|
166
|
-
node,
|
|
167
|
-
baseURL
|
|
168
|
-
})
|
|
169
|
-
]
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
//#endregion
|
|
174
|
-
Object.defineProperty(exports, "handlersGenerator", {
|
|
175
|
-
enumerable: true,
|
|
176
|
-
get: function() {
|
|
177
|
-
return handlersGenerator;
|
|
178
|
-
}
|
|
179
|
-
});
|
|
180
|
-
Object.defineProperty(exports, "mswGenerator", {
|
|
181
|
-
enumerable: true,
|
|
182
|
-
get: function() {
|
|
183
|
-
return mswGenerator;
|
|
184
|
-
}
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
//# sourceMappingURL=generators-rZ99WaWQ.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generators-rZ99WaWQ.cjs","names":["jsxRenderer","File","Handlers","jsxRenderer","pluginFakerName","resolveFakerMeta","pluginTsName","resolveResponseTypes","getOperationSuccessResponses","File","Response","MockWithFaker","Mock"],"sources":["../src/generators/handlersGenerator.tsx","../src/generators/mswGenerator.tsx"],"sourcesContent":["import { defineGenerator } from '@kubb/core'\nimport { File, jsxRenderer } from '@kubb/renderer-jsx'\nimport { Handlers } from '../components/Handlers.tsx'\nimport type { PluginMsw } from '../types'\n\nexport const handlersGenerator = defineGenerator<PluginMsw>({\n name: 'plugin-msw',\n renderer: jsxRenderer,\n operations(nodes, ctx) {\n const { resolver, config, root, adapter } = ctx\n const { output, group } = ctx.options\n\n const handlersName = resolver.resolveHandlersName()\n const file = resolver.resolveFile({ name: resolver.resolvePathName(handlersName, 'file'), extname: '.ts' }, { root, output, group })\n\n const imports = nodes.map((node) => {\n const operationName = resolver.resolveHandlerName(node)\n const operationFile = resolver.resolveFile(\n { name: resolver.resolveName(node.operationId), extname: '.ts', tag: node.tags[0] ?? 'default', path: node.path },\n { root, output, group },\n )\n\n return <File.Import key={operationFile.path} name={[operationName]} root={file.path} path={operationFile.path} />\n })\n\n const handlers = nodes.map((node) => `${resolver.resolveHandlerName(node)}()`)\n\n return (\n <File\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={resolver.resolveBanner(adapter.inputNode, { output, config })}\n footer={resolver.resolveFooter(adapter.inputNode, { output, config })}\n >\n {imports}\n <Handlers name={handlersName} handlers={handlers} />\n </File>\n )\n },\n})\n","import { getOperationSuccessResponses, resolveResponseTypes } from '@internals/shared'\nimport { defineGenerator } from '@kubb/core'\nimport { pluginFakerName } from '@kubb/plugin-faker'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { File, jsxRenderer } from '@kubb/renderer-jsx'\nimport { Mock, MockWithFaker, Response } from '../components'\nimport type { PluginMsw } from '../types'\nimport { resolveFakerMeta } from '../utils.ts'\n\nexport const mswGenerator = defineGenerator<PluginMsw>({\n name: 'msw',\n renderer: jsxRenderer,\n operation(node, ctx) {\n const { driver, resolver, config, root, adapter } = ctx\n const { output, parser, baseURL, group } = ctx.options\n\n const fileName = resolver.resolveName(node.operationId)\n const mock = {\n name: resolver.resolveHandlerName(node),\n file: resolver.resolveFile({ name: fileName, extname: '.ts', tag: node.tags[0] ?? 'default', path: node.path }, { root, output, group }),\n }\n\n const fakerPlugin = parser === 'faker' ? driver.getPlugin(pluginFakerName) : undefined\n const faker =\n parser === 'faker' && fakerPlugin\n ? resolveFakerMeta(node, {\n root,\n fakerResolver: driver.getResolver(pluginFakerName),\n fakerOutput: fakerPlugin.options?.output ?? output,\n fakerGroup: fakerPlugin.options?.group,\n })\n : undefined\n\n const pluginTs = driver.getPlugin(pluginTsName)\n if (!pluginTs) return null\n const tsResolver = driver.getResolver(pluginTsName)\n\n const type = {\n file: tsResolver.resolveFile(\n { name: node.operationId, extname: '.ts', tag: node.tags[0] ?? 'default', path: node.path },\n { root, output: pluginTs.options?.output ?? output, group: pluginTs.options?.group },\n ),\n responseName: tsResolver.resolveResponseName(node),\n }\n\n const types = resolveResponseTypes(node, tsResolver)\n const successResponses = getOperationSuccessResponses(node)\n const hasSuccessSchema = successResponses.some((response) => !!response.schema)\n\n const requestName = node.requestBody?.content?.[0]?.schema ? tsResolver.resolveDataName(node) : undefined\n\n return (\n <File\n baseName={mock.file.baseName}\n path={mock.file.path}\n meta={mock.file.meta}\n banner={resolver.resolveBanner(adapter.inputNode, { output, config })}\n footer={resolver.resolveFooter(adapter.inputNode, { output, config })}\n >\n <File.Import name={['http']} path=\"msw\" />\n <File.Import name={['HttpResponseResolver']} isTypeOnly path=\"msw\" />\n <File.Import\n name={Array.from(new Set([type.responseName, ...types.map((t) => t[1]), ...(requestName ? [requestName] : [])]))}\n path={type.file.path}\n root={mock.file.path}\n isTypeOnly\n />\n {parser === 'faker' && faker && <File.Import name={[faker.name]} root={mock.file.path} path={faker.file.path} />}\n\n {types\n .filter(([code]) => code !== 'default')\n .map(([code, typeName]) => {\n const response = node.responses.find((item) => item.statusCode === String(code))\n if (!response) return null\n return <Response key={typeName} typeName={typeName} response={response} name={mock.name} />\n })}\n\n {parser === 'faker' && faker && hasSuccessSchema ? (\n <MockWithFaker name={mock.name} typeName={type.responseName} requestTypeName={requestName} fakerName={faker.name} node={node} baseURL={baseURL} />\n ) : (\n <Mock name={mock.name} typeName={type.responseName} requestTypeName={requestName} node={node} baseURL={baseURL} />\n )}\n </File>\n )\n },\n})\n"],"mappings":";;;;;;;AAKA,MAAa,qBAAA,GAAA,WAAA,iBAA+C;CAC1D,MAAM;CACN,UAAUA,mBAAAA;CACV,WAAW,OAAO,KAAK;EACrB,MAAM,EAAE,UAAU,QAAQ,MAAM,YAAY;EAC5C,MAAM,EAAE,QAAQ,UAAU,IAAI;EAE9B,MAAM,eAAe,SAAS,qBAAqB;EACnD,MAAM,OAAO,SAAS,YAAY;GAAE,MAAM,SAAS,gBAAgB,cAAc,OAAO;GAAE,SAAS;GAAO,EAAE;GAAE;GAAM;GAAQ;GAAO,CAAC;EAEpI,MAAM,UAAU,MAAM,KAAK,SAAS;GAClC,MAAM,gBAAgB,SAAS,mBAAmB,KAAK;GACvD,MAAM,gBAAgB,SAAS,YAC7B;IAA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IACrE,iBAAA,GAAA,+BAAA,KAACA,mBAAAA,KAAK,QAAN;KACE,MAAM,MAAM,KAAK,IAAI,IAAI;MAAC,KAAK;MAAc,GAAG,MAAM,KAAK,MAAM,EAAE,GAAG;MAAE,GAAI,cAAc,CAAC,YAAY,GAAG,EAAE;MAAE,CAAC,CAAC;KAChH,MAAM,KAAK,KAAK;KAChB,MAAM,KAAK,KAAK;KAChB,YAAA;KACA,CAAA;IACD,WAAW,WAAW,SAAS,iBAAA,GAAA,+BAAA,KAACA,mBAAAA,KAAK,QAAN;KAAa,MAAM,CAAC,MAAM,KAAK;KAAE,MAAM,KAAK,KAAK;KAAM,MAAM,MAAM,KAAK;KAAQ,CAAA;IAE/G,MACE,QAAQ,CAAC,UAAU,SAAS,UAAU,CACtC,KAAK,CAAC,MAAM,cAAc;KACzB,MAAM,WAAW,KAAK,UAAU,MAAM,SAAS,KAAK,eAAe,OAAO,KAAK,CAAC;KAChF,IAAI,CAAC,UAAU,OAAO;KACtB,OAAO,iBAAA,GAAA,+BAAA,KAACC,mBAAAA,UAAD;MAAmC;MAAoB;MAAU,MAAM,KAAK;MAAQ,EAArE,SAAqE;MAC3F;IAEH,WAAW,WAAW,SAAS,mBAC9B,iBAAA,GAAA,+BAAA,KAACC,mBAAAA,eAAD;KAAe,MAAM,KAAK;KAAM,UAAU,KAAK;KAAc,iBAAiB;KAAa,WAAW,MAAM;KAAY;KAAe;KAAW,CAAA,GAElJ,iBAAA,GAAA,+BAAA,KAACC,mBAAAA,MAAD;KAAM,MAAM,KAAK;KAAM,UAAU,KAAK;KAAc,iBAAiB;KAAmB;KAAe;KAAW,CAAA;IAE/G;;;CAGZ,CAAC"}
|
package/dist/generators.cjs
DELETED
package/dist/generators.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
|
-
import { n as PluginMsw } from "./types-ItsHsMvC.js";
|
|
3
|
-
import * as _$_kubb_core0 from "@kubb/core";
|
|
4
|
-
|
|
5
|
-
//#region src/generators/handlersGenerator.d.ts
|
|
6
|
-
declare const handlersGenerator: _$_kubb_core0.Generator<PluginMsw, unknown>;
|
|
7
|
-
//#endregion
|
|
8
|
-
//#region src/generators/mswGenerator.d.ts
|
|
9
|
-
declare const mswGenerator: _$_kubb_core0.Generator<PluginMsw, unknown>;
|
|
10
|
-
//#endregion
|
|
11
|
-
export { handlersGenerator, mswGenerator };
|
|
12
|
-
//# sourceMappingURL=generators.d.ts.map
|
package/dist/generators.js
DELETED
package/dist/types-ItsHsMvC.d.ts
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
|
-
import { Exclude, Generator, Group, Include, Output, Override, PluginFactoryOptions, Resolver, ast } from "@kubb/core";
|
|
3
|
-
|
|
4
|
-
//#region src/types.d.ts
|
|
5
|
-
/**
|
|
6
|
-
* Resolver for MSW that provides naming methods for handler functions.
|
|
7
|
-
*/
|
|
8
|
-
type ResolverMsw = Resolver & {
|
|
9
|
-
/**
|
|
10
|
-
* Resolves the base handler function name for an operation.
|
|
11
|
-
*/
|
|
12
|
-
resolveName(this: ResolverMsw, name: string): string;
|
|
13
|
-
/**
|
|
14
|
-
* Resolves the output file name for an MSW handler module.
|
|
15
|
-
*/
|
|
16
|
-
resolvePathName(this: ResolverMsw, name: string, type?: 'file' | 'function' | 'type' | 'const'): string;
|
|
17
|
-
/**
|
|
18
|
-
* Resolves the handler function name for an operation.
|
|
19
|
-
*/
|
|
20
|
-
resolveHandlerName(this: ResolverMsw, node: ast.OperationNode): string;
|
|
21
|
-
/**
|
|
22
|
-
* Resolves the exported handlers collection name.
|
|
23
|
-
*/
|
|
24
|
-
resolveHandlersName(this: ResolverMsw): string;
|
|
25
|
-
};
|
|
26
|
-
type Options = {
|
|
27
|
-
/**
|
|
28
|
-
* Specify the export location for the files and define the behavior of the output
|
|
29
|
-
* @default { path: 'handlers', barrelType: 'named' }
|
|
30
|
-
*/
|
|
31
|
-
output?: Output;
|
|
32
|
-
baseURL?: string;
|
|
33
|
-
/**
|
|
34
|
-
* Group the MSW mocks based on the provided name.
|
|
35
|
-
*/
|
|
36
|
-
group?: Group;
|
|
37
|
-
/**
|
|
38
|
-
* Tags, operations, or paths to exclude from generation.
|
|
39
|
-
*/
|
|
40
|
-
exclude?: Array<Exclude>;
|
|
41
|
-
/**
|
|
42
|
-
* Tags, operations, or paths to include in generation.
|
|
43
|
-
*/
|
|
44
|
-
include?: Array<Include>;
|
|
45
|
-
/**
|
|
46
|
-
* Override options for specific tags, operations, or paths.
|
|
47
|
-
*/
|
|
48
|
-
override?: Array<Override<ResolvedOptions>>;
|
|
49
|
-
/**
|
|
50
|
-
* Override naming conventions for function names and types.
|
|
51
|
-
*/
|
|
52
|
-
resolver?: Partial<ResolverMsw> & ThisType<ResolverMsw>;
|
|
53
|
-
/**
|
|
54
|
-
* AST visitor to transform generated nodes.
|
|
55
|
-
*/
|
|
56
|
-
transformer?: ast.Visitor;
|
|
57
|
-
/**
|
|
58
|
-
* Create `handlers.ts` file with all handlers grouped by methods.
|
|
59
|
-
* @default false
|
|
60
|
-
*/
|
|
61
|
-
handlers?: boolean;
|
|
62
|
-
/**
|
|
63
|
-
* Which parser to use for generating response data.
|
|
64
|
-
*
|
|
65
|
-
* @default 'data'
|
|
66
|
-
*/
|
|
67
|
-
parser?: 'data' | 'faker';
|
|
68
|
-
/**
|
|
69
|
-
* Additional generators alongside the default generators.
|
|
70
|
-
*/
|
|
71
|
-
generators?: Array<Generator<PluginMsw>>;
|
|
72
|
-
};
|
|
73
|
-
type ResolvedOptions = {
|
|
74
|
-
output: Output;
|
|
75
|
-
group: Group | undefined;
|
|
76
|
-
exclude: NonNullable<Options['exclude']>;
|
|
77
|
-
include: Options['include'];
|
|
78
|
-
override: NonNullable<Options['override']>;
|
|
79
|
-
parser: NonNullable<Options['parser']>;
|
|
80
|
-
baseURL: Options['baseURL'] | undefined;
|
|
81
|
-
handlers: boolean;
|
|
82
|
-
resolver: ResolverMsw;
|
|
83
|
-
};
|
|
84
|
-
type PluginMsw = PluginFactoryOptions<'plugin-msw', Options, ResolvedOptions, ResolverMsw>;
|
|
85
|
-
declare global {
|
|
86
|
-
namespace Kubb {
|
|
87
|
-
interface PluginRegistry {
|
|
88
|
-
'plugin-msw': PluginMsw;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
//#endregion
|
|
93
|
-
export { PluginMsw as n, Options as t };
|
|
94
|
-
//# sourceMappingURL=types-ItsHsMvC.d.ts.map
|