@kubb/plugin-msw 3.0.0-alpha.13 → 3.0.0-alpha.15
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/chunk-2H7SYKGX.js +24 -0
- package/dist/chunk-2H7SYKGX.js.map +1 -0
- package/dist/chunk-HYNRHFXE.cjs +130 -0
- package/dist/chunk-HYNRHFXE.cjs.map +1 -0
- package/dist/chunk-SFLIUHHL.cjs +27 -0
- package/dist/chunk-SFLIUHHL.cjs.map +1 -0
- package/dist/chunk-YSIJ7IAG.js +121 -0
- package/dist/chunk-YSIJ7IAG.js.map +1 -0
- package/dist/components.cjs +5 -5
- package/dist/components.d.cts +7 -71
- package/dist/components.d.ts +7 -71
- package/dist/components.js +1 -1
- package/dist/generators.cjs +17 -0
- package/dist/generators.cjs.map +1 -0
- package/dist/generators.d.cts +10 -0
- package/dist/generators.d.ts +10 -0
- package/dist/generators.js +4 -0
- package/dist/generators.js.map +1 -0
- package/dist/index.cjs +9 -125
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -86
- package/dist/index.d.ts +4 -86
- package/dist/index.js +2 -124
- package/dist/index.js.map +1 -1
- package/dist/types-cZ4a5aFe.d.cts +76 -0
- package/dist/types-cZ4a5aFe.d.ts +76 -0
- package/package.json +21 -13
- package/src/components/Handlers.tsx +19 -0
- package/src/components/Mock.tsx +10 -85
- package/src/components/index.ts +1 -1
- package/src/generators/handlersGenerator.tsx +32 -0
- package/src/generators/index.ts +2 -0
- package/src/generators/mockGenerator.tsx +35 -0
- package/src/plugin.ts +5 -14
- package/src/types.ts +4 -12
- package/dist/chunk-3KHLTEUD.js +0 -98
- package/dist/chunk-3KHLTEUD.js.map +0 -1
- package/dist/chunk-BD7UJBXM.cjs +0 -101
- package/dist/chunk-BD7UJBXM.cjs.map +0 -1
- package/src/OperationGenerator.tsx +0 -66
- package/src/components/Operations.tsx +0 -94
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { URLPath } from '@kubb/core/utils';
|
|
2
|
+
import { File } from '@kubb/react';
|
|
3
|
+
import { jsx } from '@kubb/react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
// src/components/Mock.tsx
|
|
6
|
+
function Mock({ name, responseName, operation }) {
|
|
7
|
+
const path = new URLPath(operation.path);
|
|
8
|
+
return /* @__PURE__ */ jsx(File.Source, { name, isIndexable: true, isExportable: true, children: `
|
|
9
|
+
export const ${name} = http.${operation.method}('*${path.toURLPath()}', function handler(info) {
|
|
10
|
+
return new Response(JSON.stringify(${responseName}()), {
|
|
11
|
+
headers: {
|
|
12
|
+
'Content-Type': 'application/json',
|
|
13
|
+
},
|
|
14
|
+
})
|
|
15
|
+
})
|
|
16
|
+
` });
|
|
17
|
+
}
|
|
18
|
+
function Handlers({ name, handlers }) {
|
|
19
|
+
return /* @__PURE__ */ jsx(File.Source, { name, isIndexable: true, isExportable: true, children: `export const ${name} = ${JSON.stringify(handlers).replaceAll(`"`, "")} as const` });
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export { Handlers, Mock };
|
|
23
|
+
//# sourceMappingURL=chunk-2H7SYKGX.js.map
|
|
24
|
+
//# sourceMappingURL=chunk-2H7SYKGX.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/Mock.tsx","../src/components/Handlers.tsx"],"names":["jsx","File"],"mappings":";;;;;AAgBO,SAAS,IAAK,CAAA,EAAE,IAAM,EAAA,YAAA,EAAc,WAA+B,EAAA;AACxE,EAAA,MAAM,IAAO,GAAA,IAAI,OAAQ,CAAA,SAAA,CAAU,IAAI,CAAA,CAAA;AAEvC,EACE,uBAAA,GAAA,CAAC,KAAK,MAAL,EAAA,EAAY,MAAY,WAAW,EAAA,IAAA,EAAC,cAAY,IAC9C,EAAA,QAAA,EAAA,CAAA;AAAA,eAAA,EACU,IAAI,CAAW,QAAA,EAAA,SAAA,CAAU,MAAM,CAAM,GAAA,EAAA,IAAA,CAAK,WAAW,CAAA;AAAA,uCAAA,EAC7B,YAAY,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOjD,CAAA,EAAA,CAAA,CAAA;AAEJ,CAAA;ACpBO,SAAS,QAAS,CAAA,EAAE,IAAM,EAAA,QAAA,EAAsC,EAAA;AACrE,EACE,uBAAAA,IAACC,IAAK,CAAA,MAAA,EAAL,EAAY,IAAY,EAAA,WAAA,EAAW,MAAC,YAAY,EAAA,IAAA,EAC9C,0BAAgB,IAAI,CAAA,GAAA,EAAM,KAAK,SAAU,CAAA,QAAQ,EAAE,UAAW,CAAA,CAAA,CAAA,CAAA,EAAK,EAAE,CAAC,CACzE,SAAA,CAAA,EAAA,CAAA,CAAA;AAEJ","file":"chunk-2H7SYKGX.js","sourcesContent":["import { URLPath } from '@kubb/core/utils'\nimport { File } from '@kubb/react'\n\nimport type { Operation } from '@kubb/oas'\nimport type { ReactNode } from 'react'\n\ntype Props = {\n /**\n * Name of the function\n */\n name: string\n operation: Operation\n // custom\n responseName: string\n}\n\nexport function Mock({ name, responseName, operation }: Props): ReactNode {\n const path = new URLPath(operation.path)\n\n return (\n <File.Source name={name} isIndexable isExportable>\n {`\n export const ${name} = http.${operation.method}('*${path.toURLPath()}', function handler(info) {\n return new Response(JSON.stringify(${responseName}()), {\n headers: {\n 'Content-Type': 'application/json',\n },\n })\n })\n `}\n </File.Source>\n )\n}\n","import { File } from '@kubb/react'\nimport type { ReactNode } from 'react'\n\ntype HandlersProps = {\n /**\n * Name of the function\n */\n name: string\n // custom\n handlers: string[]\n}\n\nexport function Handlers({ name, handlers }: HandlersProps): ReactNode {\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"]}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkSFLIUHHL_cjs = require('./chunk-SFLIUHHL.cjs');
|
|
4
|
+
var pluginFaker = require('@kubb/plugin-faker');
|
|
5
|
+
var pluginOas = require('@kubb/plugin-oas');
|
|
6
|
+
var hooks = require('@kubb/plugin-oas/hooks');
|
|
7
|
+
var pluginTs = require('@kubb/plugin-ts');
|
|
8
|
+
var react = require('@kubb/react');
|
|
9
|
+
var jsxRuntime = require('@kubb/react/jsx-runtime');
|
|
10
|
+
var path = require('path');
|
|
11
|
+
var core = require('@kubb/core');
|
|
12
|
+
var transformers = require('@kubb/core/transformers');
|
|
13
|
+
var utils = require('@kubb/core/utils');
|
|
14
|
+
|
|
15
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
|
+
|
|
17
|
+
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
18
|
+
|
|
19
|
+
var mockGenerator = pluginOas.createReactGenerator({
|
|
20
|
+
name: "plugin-msw",
|
|
21
|
+
Operation({ operation }) {
|
|
22
|
+
const { pluginManager, plugin } = react.useApp();
|
|
23
|
+
const { getSchemas, getName, getFile } = hooks.useOperationManager();
|
|
24
|
+
const name = getName(operation, { type: "function" });
|
|
25
|
+
const file = getFile(operation);
|
|
26
|
+
const fakerFile = getFile(operation, { pluginKey: [pluginFaker.pluginFakerName] });
|
|
27
|
+
const fakerSchemas = getSchemas(operation, { pluginKey: [pluginTs.pluginTsName] });
|
|
28
|
+
const responseName = pluginManager.resolveName({
|
|
29
|
+
pluginKey: [pluginFaker.pluginFakerName],
|
|
30
|
+
name: fakerSchemas.response.name,
|
|
31
|
+
type: "function"
|
|
32
|
+
});
|
|
33
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(react.File, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
|
|
34
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["http"], path: "msw" }),
|
|
35
|
+
fakerFile && responseName && /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { extName: plugin.output?.extName, name: [responseName], root: file.path, path: fakerFile.path }),
|
|
36
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkSFLIUHHL_cjs.Mock, { name, responseName, operation })
|
|
37
|
+
] });
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
var pluginMswName = "plugin-msw";
|
|
41
|
+
var pluginMsw = core.createPlugin((options) => {
|
|
42
|
+
const { output = { path: "handlers" }, group, exclude = [], include, override = [], transformers: transformers$1 = {}, handlers = false } = options;
|
|
43
|
+
const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`;
|
|
44
|
+
return {
|
|
45
|
+
name: pluginMswName,
|
|
46
|
+
output: {
|
|
47
|
+
exportType: "barrelNamed",
|
|
48
|
+
...output
|
|
49
|
+
},
|
|
50
|
+
options: {},
|
|
51
|
+
pre: [pluginOas.pluginOasName, pluginTs.pluginTsName, pluginFaker.pluginFakerName],
|
|
52
|
+
resolvePath(baseName, pathMode, options2) {
|
|
53
|
+
const root = path__default.default.resolve(this.config.root, this.config.output.path);
|
|
54
|
+
const mode = pathMode ?? core.FileManager.getMode(path__default.default.resolve(root, output.path));
|
|
55
|
+
if (mode === "single") {
|
|
56
|
+
return path__default.default.resolve(root, output.path);
|
|
57
|
+
}
|
|
58
|
+
if (options2?.tag && group?.type === "tag") {
|
|
59
|
+
const tag = transformers.camelCase(options2.tag);
|
|
60
|
+
return path__default.default.resolve(root, utils.renderTemplate(template, { tag }), baseName);
|
|
61
|
+
}
|
|
62
|
+
return path__default.default.resolve(root, output.path, baseName);
|
|
63
|
+
},
|
|
64
|
+
resolveName(name, type) {
|
|
65
|
+
const resolvedName = transformers.camelCase(name, {
|
|
66
|
+
suffix: type ? "handler" : void 0,
|
|
67
|
+
isFile: type === "file"
|
|
68
|
+
});
|
|
69
|
+
if (type) {
|
|
70
|
+
return transformers$1?.name?.(resolvedName, type) || resolvedName;
|
|
71
|
+
}
|
|
72
|
+
return resolvedName;
|
|
73
|
+
},
|
|
74
|
+
async buildStart() {
|
|
75
|
+
const [swaggerPlugin] = core.PluginManager.getDependedPlugins(this.plugins, [pluginOas.pluginOasName]);
|
|
76
|
+
const oas = await swaggerPlugin.context.getOas();
|
|
77
|
+
const root = path__default.default.resolve(this.config.root, this.config.output.path);
|
|
78
|
+
const mode = core.FileManager.getMode(path__default.default.resolve(root, output.path));
|
|
79
|
+
const operationGenerator = new pluginOas.OperationGenerator(this.plugin.options, {
|
|
80
|
+
oas,
|
|
81
|
+
pluginManager: this.pluginManager,
|
|
82
|
+
plugin: this.plugin,
|
|
83
|
+
contentType: swaggerPlugin.context.contentType,
|
|
84
|
+
exclude,
|
|
85
|
+
include,
|
|
86
|
+
override,
|
|
87
|
+
mode
|
|
88
|
+
});
|
|
89
|
+
const files = await operationGenerator.build(...[mockGenerator, handlers ? handlersGenerator : void 0].filter(Boolean));
|
|
90
|
+
await this.addFile(...files);
|
|
91
|
+
if (this.config.output.exportType) {
|
|
92
|
+
const barrelFiles = await this.fileManager.getBarrelFiles({
|
|
93
|
+
root,
|
|
94
|
+
output,
|
|
95
|
+
files: this.fileManager.files,
|
|
96
|
+
meta: {
|
|
97
|
+
pluginKey: this.plugin.key
|
|
98
|
+
},
|
|
99
|
+
logger: this.logger
|
|
100
|
+
});
|
|
101
|
+
await this.addFile(...barrelFiles);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
});
|
|
106
|
+
var handlersGenerator = pluginOas.createReactGenerator({
|
|
107
|
+
name: "plugin-msw",
|
|
108
|
+
Operations({ operations }) {
|
|
109
|
+
const { pluginManager } = react.useApp();
|
|
110
|
+
const { getName, getFile } = hooks.useOperationManager();
|
|
111
|
+
const file = pluginManager.getFile({ name: "handlers", extName: ".ts", pluginKey: [pluginMswName] });
|
|
112
|
+
const imports = operations.map((operation) => {
|
|
113
|
+
const operationFile = getFile(operation, { pluginKey: [pluginMswName] });
|
|
114
|
+
const operationName = getName(operation, { pluginKey: [pluginMswName], type: "function" });
|
|
115
|
+
return /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: [operationName], root: file.path, path: operationFile.path }, operationFile.path);
|
|
116
|
+
});
|
|
117
|
+
const handlers = operations.map((operation) => getName(operation, { type: "function", pluginKey: [pluginMswName] }));
|
|
118
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(react.File, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
|
|
119
|
+
imports,
|
|
120
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkSFLIUHHL_cjs.Handlers, { name: "handlers", handlers })
|
|
121
|
+
] });
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
exports.handlersGenerator = handlersGenerator;
|
|
126
|
+
exports.mockGenerator = mockGenerator;
|
|
127
|
+
exports.pluginMsw = pluginMsw;
|
|
128
|
+
exports.pluginMswName = pluginMswName;
|
|
129
|
+
//# sourceMappingURL=chunk-HYNRHFXE.cjs.map
|
|
130
|
+
//# sourceMappingURL=chunk-HYNRHFXE.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/generators/mockGenerator.tsx","../src/plugin.ts","../src/generators/handlersGenerator.tsx"],"names":["createReactGenerator","useApp","useOperationManager","pluginFakerName","pluginTsName","jsxs","File","jsx","Mock","createPlugin","transformers","pluginOasName","options","path","FileManager","camelCase","renderTemplate","PluginManager","OperationGenerator","Handlers"],"mappings":";;;;;;;;;;;;;;;;;;AAQO,IAAM,gBAAgBA,8BAAgC,CAAA;AAAA,EAC3D,IAAM,EAAA,YAAA;AAAA,EACN,SAAA,CAAU,EAAE,SAAA,EAAa,EAAA;AACvB,IAAA,MAAM,EAAE,aAAA,EAAe,MAAO,EAAA,GAAIC,YAAkB,EAAA,CAAA;AACpD,IAAA,MAAM,EAAE,UAAA,EAAY,OAAS,EAAA,OAAA,KAAYC,yBAAoB,EAAA,CAAA;AAE7D,IAAA,MAAM,OAAO,OAAQ,CAAA,SAAA,EAAW,EAAE,IAAA,EAAM,YAAY,CAAA,CAAA;AACpD,IAAM,MAAA,IAAA,GAAO,QAAQ,SAAS,CAAA,CAAA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AA,aAAA,GAAgB,QAAQ,SAAW,EAAA,EAAE,WAAW,CAAC,aAAa,GAAG,CAAA,CAAA;AACvE,MAAM,MAAA,aAAA,GAAgB,OAAQ,CAAA,SAAA,EAAW,EAAE,SAAA,EAAW,CAAC,aAAa,CAAA,EAAG,IAAM,EAAA,UAAA,EAAY,CAAA,CAAA;AAEzF,MAAA,uBAAOK,cAACD,CAAAA,UAAAA,CAAK,MAAL,EAAA,EAAqC,MAAM,CAAC,aAAa,CAAG,EAAA,IAAA,EAAM,KAAK,IAAM,EAAA,IAAA,EAAM,aAAc,CAAA,IAAA,EAAA,EAAhF,cAAc,IAAwE,CAAA,CAAA;AAAA,KAChH,CAAA,CAAA;AAED,IAAA,MAAM,QAAW,GAAA,UAAA,CAAW,GAAI,CAAA,CAAC,cAAc,OAAQ,CAAA,SAAA,EAAW,EAAE,IAAA,EAAM,YAAY,SAAW,EAAA,CAAC,aAAa,CAAA,EAAG,CAAC,CAAA,CAAA;AAEnH,IAAA,uBACED,eAAAA,CAACC,UAAA,EAAA,EAAK,QAAU,EAAA,IAAA,CAAK,QAAU,EAAA,IAAA,EAAM,IAAK,CAAA,IAAA,EAAM,IAAM,EAAA,IAAA,CAAK,IACxD,EAAA,QAAA,EAAA;AAAA,MAAA,OAAA;AAAA,sBACDC,cAAAA,CAACY,0BAAS,EAAA,EAAA,IAAA,EAAM,YAAY,QAAoB,EAAA,CAAA;AAAA,KAClD,EAAA,CAAA,CAAA;AAAA,GAEJ;AACF,CAAC","file":"chunk-HYNRHFXE.cjs","sourcesContent":["import { pluginFakerName } from '@kubb/plugin-faker'\nimport { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { File, useApp } from '@kubb/react'\nimport { Mock } from '../components'\nimport type { PluginMsw } from '../types'\n\nexport const mockGenerator = createReactGenerator<PluginMsw>({\n name: 'plugin-msw',\n Operation({ operation }) {\n const { pluginManager, plugin } = useApp<PluginMsw>()\n const { getSchemas, getName, getFile } = useOperationManager()\n\n const name = getName(operation, { type: 'function' })\n const file = getFile(operation)\n const fakerFile = getFile(operation, { pluginKey: [pluginFakerName] })\n const fakerSchemas = getSchemas(operation, { pluginKey: [pluginTsName] })\n\n const responseName = pluginManager.resolveName({\n pluginKey: [pluginFakerName],\n name: fakerSchemas.response.name,\n type: 'function',\n })\n\n return (\n <File baseName={file.baseName} path={file.path} meta={file.meta}>\n <File.Import name={['http']} path={'msw'} />\n {fakerFile && responseName && <File.Import extName={plugin.output?.extName} name={[responseName]} root={file.path} path={fakerFile.path} />}\n\n <Mock name={name} responseName={responseName} operation={operation} />\n </File>\n )\n },\n})\n","import path from 'node:path'\n\nimport { FileManager, PluginManager, createPlugin } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\nimport { renderTemplate } from '@kubb/core/utils'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\n\nimport { pluginFakerName } from '@kubb/plugin-faker'\nimport { pluginTsName } from '@kubb/plugin-ts'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'\nimport { handlersGenerator, mockGenerator } from './generators'\nimport type { PluginMsw } from './types.ts'\n\nexport const pluginMswName = 'plugin-msw' satisfies PluginMsw['name']\n\nexport const pluginMsw = createPlugin<PluginMsw>((options) => {\n const { output = { path: 'handlers' }, group, exclude = [], include, override = [], transformers = {}, handlers = false } = options\n const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`\n\n return {\n name: pluginMswName,\n output: {\n exportType: 'barrelNamed',\n ...output,\n },\n options: {},\n pre: [pluginOasName, pluginTsName, pluginFakerName],\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? FileManager.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 (options?.tag && group?.type === 'tag') {\n const tag = camelCase(options.tag)\n\n return path.resolve(root, renderTemplate(template, { tag }), baseName)\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 if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async buildStart() {\n const [swaggerPlugin]: [Plugin<SwaggerPluginOptions>] = PluginManager.getDependedPlugins<SwaggerPluginOptions>(this.plugins, [pluginOasName])\n\n const oas = await swaggerPlugin.context.getOas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = FileManager.getMode(path.resolve(root, output.path))\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType: swaggerPlugin.context.contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const files = await operationGenerator.build(...[mockGenerator, handlers ? handlersGenerator : undefined].filter(Boolean))\n await this.addFile(...files)\n\n if (this.config.output.exportType) {\n const barrelFiles = await this.fileManager.getBarrelFiles({\n root,\n output,\n files: this.fileManager.files,\n meta: {\n pluginKey: this.plugin.key,\n },\n logger: this.logger,\n })\n\n await this.addFile(...barrelFiles)\n }\n },\n }\n})\n","import { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { File, useApp } from '@kubb/react'\nimport { Handlers } from '../components/Handlers.tsx'\nimport { pluginMswName } from '../plugin.ts'\nimport type { PluginMsw } from '../types'\n\nexport const handlersGenerator = createReactGenerator<PluginMsw>({\n name: 'plugin-msw',\n Operations({ operations }) {\n const { pluginManager } = useApp<PluginMsw>()\n const { getName, getFile } = useOperationManager()\n\n const file = pluginManager.getFile({ name: 'handlers', extName: '.ts', pluginKey: [pluginMswName] })\n\n const imports = operations.map((operation) => {\n const operationFile = getFile(operation, { pluginKey: [pluginMswName] })\n const operationName = getName(operation, { pluginKey: [pluginMswName], 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: [pluginMswName] }))\n\n return (\n <File baseName={file.baseName} path={file.path} meta={file.meta}>\n {imports}\n <Handlers name={'handlers'} handlers={handlers} />\n </File>\n )\n },\n})\n"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var utils = require('@kubb/core/utils');
|
|
4
|
+
var react = require('@kubb/react');
|
|
5
|
+
var jsxRuntime = require('@kubb/react/jsx-runtime');
|
|
6
|
+
|
|
7
|
+
// src/components/Mock.tsx
|
|
8
|
+
function Mock({ name, responseName, operation }) {
|
|
9
|
+
const path = new utils.URLPath(operation.path);
|
|
10
|
+
return /* @__PURE__ */ jsxRuntime.jsx(react.File.Source, { name, isIndexable: true, isExportable: true, children: `
|
|
11
|
+
export const ${name} = http.${operation.method}('*${path.toURLPath()}', function handler(info) {
|
|
12
|
+
return new Response(JSON.stringify(${responseName}()), {
|
|
13
|
+
headers: {
|
|
14
|
+
'Content-Type': 'application/json',
|
|
15
|
+
},
|
|
16
|
+
})
|
|
17
|
+
})
|
|
18
|
+
` });
|
|
19
|
+
}
|
|
20
|
+
function Handlers({ name, handlers }) {
|
|
21
|
+
return /* @__PURE__ */ jsxRuntime.jsx(react.File.Source, { name, isIndexable: true, isExportable: true, children: `export const ${name} = ${JSON.stringify(handlers).replaceAll(`"`, "")} as const` });
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
exports.Handlers = Handlers;
|
|
25
|
+
exports.Mock = Mock;
|
|
26
|
+
//# sourceMappingURL=chunk-SFLIUHHL.cjs.map
|
|
27
|
+
//# sourceMappingURL=chunk-SFLIUHHL.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/Mock.tsx","../src/components/Handlers.tsx"],"names":["URLPath","jsx","File"],"mappings":";;;;;;;AAgBO,SAAS,IAAK,CAAA,EAAE,IAAM,EAAA,YAAA,EAAc,WAA+B,EAAA;AACxE,EAAA,MAAM,IAAO,GAAA,IAAIA,aAAQ,CAAA,SAAA,CAAU,IAAI,CAAA,CAAA;AAEvC,EACE,uBAAAC,cAAA,CAACC,WAAK,MAAL,EAAA,EAAY,MAAY,WAAW,EAAA,IAAA,EAAC,cAAY,IAC9C,EAAA,QAAA,EAAA,CAAA;AAAA,eAAA,EACU,IAAI,CAAW,QAAA,EAAA,SAAA,CAAU,MAAM,CAAM,GAAA,EAAA,IAAA,CAAK,WAAW,CAAA;AAAA,uCAAA,EAC7B,YAAY,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOjD,CAAA,EAAA,CAAA,CAAA;AAEJ,CAAA;ACpBO,SAAS,QAAS,CAAA,EAAE,IAAM,EAAA,QAAA,EAAsC,EAAA;AACrE,EACE,uBAAAD,eAACC,UAAK,CAAA,MAAA,EAAL,EAAY,IAAY,EAAA,WAAA,EAAW,MAAC,YAAY,EAAA,IAAA,EAC9C,0BAAgB,IAAI,CAAA,GAAA,EAAM,KAAK,SAAU,CAAA,QAAQ,EAAE,UAAW,CAAA,CAAA,CAAA,CAAA,EAAK,EAAE,CAAC,CACzE,SAAA,CAAA,EAAA,CAAA,CAAA;AAEJ","file":"chunk-SFLIUHHL.cjs","sourcesContent":["import { URLPath } from '@kubb/core/utils'\nimport { File } from '@kubb/react'\n\nimport type { Operation } from '@kubb/oas'\nimport type { ReactNode } from 'react'\n\ntype Props = {\n /**\n * Name of the function\n */\n name: string\n operation: Operation\n // custom\n responseName: string\n}\n\nexport function Mock({ name, responseName, operation }: Props): ReactNode {\n const path = new URLPath(operation.path)\n\n return (\n <File.Source name={name} isIndexable isExportable>\n {`\n export const ${name} = http.${operation.method}('*${path.toURLPath()}', function handler(info) {\n return new Response(JSON.stringify(${responseName}()), {\n headers: {\n 'Content-Type': 'application/json',\n },\n })\n })\n `}\n </File.Source>\n )\n}\n","import { File } from '@kubb/react'\nimport type { ReactNode } from 'react'\n\ntype HandlersProps = {\n /**\n * Name of the function\n */\n name: string\n // custom\n handlers: string[]\n}\n\nexport function Handlers({ name, handlers }: HandlersProps): ReactNode {\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"]}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { Mock, Handlers } from './chunk-2H7SYKGX.js';
|
|
2
|
+
import { pluginFakerName } from '@kubb/plugin-faker';
|
|
3
|
+
import { createReactGenerator, pluginOasName, OperationGenerator } from '@kubb/plugin-oas';
|
|
4
|
+
import { useOperationManager } from '@kubb/plugin-oas/hooks';
|
|
5
|
+
import { pluginTsName } from '@kubb/plugin-ts';
|
|
6
|
+
import { useApp, File } from '@kubb/react';
|
|
7
|
+
import { jsxs, jsx } from '@kubb/react/jsx-runtime';
|
|
8
|
+
import path from 'node:path';
|
|
9
|
+
import { createPlugin, FileManager, PluginManager } from '@kubb/core';
|
|
10
|
+
import { camelCase } from '@kubb/core/transformers';
|
|
11
|
+
import { renderTemplate } from '@kubb/core/utils';
|
|
12
|
+
|
|
13
|
+
var mockGenerator = createReactGenerator({
|
|
14
|
+
name: "plugin-msw",
|
|
15
|
+
Operation({ operation }) {
|
|
16
|
+
const { pluginManager, plugin } = useApp();
|
|
17
|
+
const { getSchemas, getName, getFile } = useOperationManager();
|
|
18
|
+
const name = getName(operation, { type: "function" });
|
|
19
|
+
const file = getFile(operation);
|
|
20
|
+
const fakerFile = getFile(operation, { pluginKey: [pluginFakerName] });
|
|
21
|
+
const fakerSchemas = getSchemas(operation, { pluginKey: [pluginTsName] });
|
|
22
|
+
const responseName = pluginManager.resolveName({
|
|
23
|
+
pluginKey: [pluginFakerName],
|
|
24
|
+
name: fakerSchemas.response.name,
|
|
25
|
+
type: "function"
|
|
26
|
+
});
|
|
27
|
+
return /* @__PURE__ */ jsxs(File, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
|
|
28
|
+
/* @__PURE__ */ jsx(File.Import, { name: ["http"], path: "msw" }),
|
|
29
|
+
fakerFile && responseName && /* @__PURE__ */ jsx(File.Import, { extName: plugin.output?.extName, name: [responseName], root: file.path, path: fakerFile.path }),
|
|
30
|
+
/* @__PURE__ */ jsx(Mock, { name, responseName, operation })
|
|
31
|
+
] });
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
var pluginMswName = "plugin-msw";
|
|
35
|
+
var pluginMsw = createPlugin((options) => {
|
|
36
|
+
const { output = { path: "handlers" }, group, exclude = [], include, override = [], transformers = {}, handlers = false } = options;
|
|
37
|
+
const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`;
|
|
38
|
+
return {
|
|
39
|
+
name: pluginMswName,
|
|
40
|
+
output: {
|
|
41
|
+
exportType: "barrelNamed",
|
|
42
|
+
...output
|
|
43
|
+
},
|
|
44
|
+
options: {},
|
|
45
|
+
pre: [pluginOasName, pluginTsName, pluginFakerName],
|
|
46
|
+
resolvePath(baseName, pathMode, options2) {
|
|
47
|
+
const root = path.resolve(this.config.root, this.config.output.path);
|
|
48
|
+
const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path));
|
|
49
|
+
if (mode === "single") {
|
|
50
|
+
return path.resolve(root, output.path);
|
|
51
|
+
}
|
|
52
|
+
if (options2?.tag && group?.type === "tag") {
|
|
53
|
+
const tag = camelCase(options2.tag);
|
|
54
|
+
return path.resolve(root, renderTemplate(template, { tag }), baseName);
|
|
55
|
+
}
|
|
56
|
+
return path.resolve(root, output.path, baseName);
|
|
57
|
+
},
|
|
58
|
+
resolveName(name, type) {
|
|
59
|
+
const resolvedName = camelCase(name, {
|
|
60
|
+
suffix: type ? "handler" : void 0,
|
|
61
|
+
isFile: type === "file"
|
|
62
|
+
});
|
|
63
|
+
if (type) {
|
|
64
|
+
return transformers?.name?.(resolvedName, type) || resolvedName;
|
|
65
|
+
}
|
|
66
|
+
return resolvedName;
|
|
67
|
+
},
|
|
68
|
+
async buildStart() {
|
|
69
|
+
const [swaggerPlugin] = PluginManager.getDependedPlugins(this.plugins, [pluginOasName]);
|
|
70
|
+
const oas = await swaggerPlugin.context.getOas();
|
|
71
|
+
const root = path.resolve(this.config.root, this.config.output.path);
|
|
72
|
+
const mode = FileManager.getMode(path.resolve(root, output.path));
|
|
73
|
+
const operationGenerator = new OperationGenerator(this.plugin.options, {
|
|
74
|
+
oas,
|
|
75
|
+
pluginManager: this.pluginManager,
|
|
76
|
+
plugin: this.plugin,
|
|
77
|
+
contentType: swaggerPlugin.context.contentType,
|
|
78
|
+
exclude,
|
|
79
|
+
include,
|
|
80
|
+
override,
|
|
81
|
+
mode
|
|
82
|
+
});
|
|
83
|
+
const files = await operationGenerator.build(...[mockGenerator, handlers ? handlersGenerator : void 0].filter(Boolean));
|
|
84
|
+
await this.addFile(...files);
|
|
85
|
+
if (this.config.output.exportType) {
|
|
86
|
+
const barrelFiles = await this.fileManager.getBarrelFiles({
|
|
87
|
+
root,
|
|
88
|
+
output,
|
|
89
|
+
files: this.fileManager.files,
|
|
90
|
+
meta: {
|
|
91
|
+
pluginKey: this.plugin.key
|
|
92
|
+
},
|
|
93
|
+
logger: this.logger
|
|
94
|
+
});
|
|
95
|
+
await this.addFile(...barrelFiles);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
});
|
|
100
|
+
var handlersGenerator = createReactGenerator({
|
|
101
|
+
name: "plugin-msw",
|
|
102
|
+
Operations({ operations }) {
|
|
103
|
+
const { pluginManager } = useApp();
|
|
104
|
+
const { getName, getFile } = useOperationManager();
|
|
105
|
+
const file = pluginManager.getFile({ name: "handlers", extName: ".ts", pluginKey: [pluginMswName] });
|
|
106
|
+
const imports = operations.map((operation) => {
|
|
107
|
+
const operationFile = getFile(operation, { pluginKey: [pluginMswName] });
|
|
108
|
+
const operationName = getName(operation, { pluginKey: [pluginMswName], type: "function" });
|
|
109
|
+
return /* @__PURE__ */ jsx(File.Import, { name: [operationName], root: file.path, path: operationFile.path }, operationFile.path);
|
|
110
|
+
});
|
|
111
|
+
const handlers = operations.map((operation) => getName(operation, { type: "function", pluginKey: [pluginMswName] }));
|
|
112
|
+
return /* @__PURE__ */ jsxs(File, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
|
|
113
|
+
imports,
|
|
114
|
+
/* @__PURE__ */ jsx(Handlers, { name: "handlers", handlers })
|
|
115
|
+
] });
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
export { handlersGenerator, mockGenerator, pluginMsw, pluginMswName };
|
|
120
|
+
//# sourceMappingURL=chunk-YSIJ7IAG.js.map
|
|
121
|
+
//# sourceMappingURL=chunk-YSIJ7IAG.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/generators/mockGenerator.tsx","../src/plugin.ts","../src/generators/handlersGenerator.tsx"],"names":["pluginTsName","pluginFakerName","options","createReactGenerator","useApp","useOperationManager","jsx","File","jsxs"],"mappings":";;;;;;;;;;;;AAQO,IAAM,gBAAgB,oBAAgC,CAAA;AAAA,EAC3D,IAAM,EAAA,YAAA;AAAA,EACN,SAAA,CAAU,EAAE,SAAA,EAAa,EAAA;AACvB,IAAA,MAAM,EAAE,aAAA,EAAe,MAAO,EAAA,GAAI,MAAkB,EAAA,CAAA;AACpD,IAAA,MAAM,EAAE,UAAA,EAAY,OAAS,EAAA,OAAA,KAAY,mBAAoB,EAAA,CAAA;AAE7D,IAAA,MAAM,OAAO,OAAQ,CAAA,SAAA,EAAW,EAAE,IAAA,EAAM,YAAY,CAAA,CAAA;AACpD,IAAM,MAAA,IAAA,GAAO,QAAQ,SAAS,CAAA,CAAA;AAC9B,IAAM,MAAA,SAAA,GAAY,QAAQ,SAAW,EAAA,EAAE,WAAW,CAAC,eAAe,GAAG,CAAA,CAAA;AACrE,IAAM,MAAA,YAAA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,EAAG,IAAM,EAAA,UAAA,EAAY,CAAA,CAAA;AAEzF,MAAA,uBAAOC,GAACC,CAAAA,IAAAA,CAAK,MAAL,EAAA,EAAqC,MAAM,CAAC,aAAa,CAAG,EAAA,IAAA,EAAM,KAAK,IAAM,EAAA,IAAA,EAAM,aAAc,CAAA,IAAA,EAAA,EAAhF,cAAc,IAAwE,CAAA,CAAA;AAAA,KAChH,CAAA,CAAA;AAED,IAAA,MAAM,QAAW,GAAA,UAAA,CAAW,GAAI,CAAA,CAAC,cAAc,OAAQ,CAAA,SAAA,EAAW,EAAE,IAAA,EAAM,YAAY,SAAW,EAAA,CAAC,aAAa,CAAA,EAAG,CAAC,CAAA,CAAA;AAEnH,IAAA,uBACEC,IAAAA,CAACD,IAAA,EAAA,EAAK,QAAU,EAAA,IAAA,CAAK,QAAU,EAAA,IAAA,EAAM,IAAK,CAAA,IAAA,EAAM,IAAM,EAAA,IAAA,CAAK,IACxD,EAAA,QAAA,EAAA;AAAA,MAAA,OAAA;AAAA,sBACDD,GAAAA,CAAC,QAAS,EAAA,EAAA,IAAA,EAAM,YAAY,QAAoB,EAAA,CAAA;AAAA,KAClD,EAAA,CAAA,CAAA;AAAA,GAEJ;AACF,CAAC","file":"chunk-YSIJ7IAG.js","sourcesContent":["import { pluginFakerName } from '@kubb/plugin-faker'\nimport { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { File, useApp } from '@kubb/react'\nimport { Mock } from '../components'\nimport type { PluginMsw } from '../types'\n\nexport const mockGenerator = createReactGenerator<PluginMsw>({\n name: 'plugin-msw',\n Operation({ operation }) {\n const { pluginManager, plugin } = useApp<PluginMsw>()\n const { getSchemas, getName, getFile } = useOperationManager()\n\n const name = getName(operation, { type: 'function' })\n const file = getFile(operation)\n const fakerFile = getFile(operation, { pluginKey: [pluginFakerName] })\n const fakerSchemas = getSchemas(operation, { pluginKey: [pluginTsName] })\n\n const responseName = pluginManager.resolveName({\n pluginKey: [pluginFakerName],\n name: fakerSchemas.response.name,\n type: 'function',\n })\n\n return (\n <File baseName={file.baseName} path={file.path} meta={file.meta}>\n <File.Import name={['http']} path={'msw'} />\n {fakerFile && responseName && <File.Import extName={plugin.output?.extName} name={[responseName]} root={file.path} path={fakerFile.path} />}\n\n <Mock name={name} responseName={responseName} operation={operation} />\n </File>\n )\n },\n})\n","import path from 'node:path'\n\nimport { FileManager, PluginManager, createPlugin } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\nimport { renderTemplate } from '@kubb/core/utils'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\n\nimport { pluginFakerName } from '@kubb/plugin-faker'\nimport { pluginTsName } from '@kubb/plugin-ts'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'\nimport { handlersGenerator, mockGenerator } from './generators'\nimport type { PluginMsw } from './types.ts'\n\nexport const pluginMswName = 'plugin-msw' satisfies PluginMsw['name']\n\nexport const pluginMsw = createPlugin<PluginMsw>((options) => {\n const { output = { path: 'handlers' }, group, exclude = [], include, override = [], transformers = {}, handlers = false } = options\n const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`\n\n return {\n name: pluginMswName,\n output: {\n exportType: 'barrelNamed',\n ...output,\n },\n options: {},\n pre: [pluginOasName, pluginTsName, pluginFakerName],\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? FileManager.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 (options?.tag && group?.type === 'tag') {\n const tag = camelCase(options.tag)\n\n return path.resolve(root, renderTemplate(template, { tag }), baseName)\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 if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async buildStart() {\n const [swaggerPlugin]: [Plugin<SwaggerPluginOptions>] = PluginManager.getDependedPlugins<SwaggerPluginOptions>(this.plugins, [pluginOasName])\n\n const oas = await swaggerPlugin.context.getOas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = FileManager.getMode(path.resolve(root, output.path))\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType: swaggerPlugin.context.contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const files = await operationGenerator.build(...[mockGenerator, handlers ? handlersGenerator : undefined].filter(Boolean))\n await this.addFile(...files)\n\n if (this.config.output.exportType) {\n const barrelFiles = await this.fileManager.getBarrelFiles({\n root,\n output,\n files: this.fileManager.files,\n meta: {\n pluginKey: this.plugin.key,\n },\n logger: this.logger,\n })\n\n await this.addFile(...barrelFiles)\n }\n },\n }\n})\n","import { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { File, useApp } from '@kubb/react'\nimport { Handlers } from '../components/Handlers.tsx'\nimport { pluginMswName } from '../plugin.ts'\nimport type { PluginMsw } from '../types'\n\nexport const handlersGenerator = createReactGenerator<PluginMsw>({\n name: 'plugin-msw',\n Operations({ operations }) {\n const { pluginManager } = useApp<PluginMsw>()\n const { getName, getFile } = useOperationManager()\n\n const file = pluginManager.getFile({ name: 'handlers', extName: '.ts', pluginKey: [pluginMswName] })\n\n const imports = operations.map((operation) => {\n const operationFile = getFile(operation, { pluginKey: [pluginMswName] })\n const operationName = getName(operation, { pluginKey: [pluginMswName], 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: [pluginMswName] }))\n\n return (\n <File baseName={file.baseName} path={file.path} meta={file.meta}>\n {imports}\n <Handlers name={'handlers'} handlers={handlers} />\n </File>\n )\n },\n})\n"]}
|
package/dist/components.cjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkSFLIUHHL_cjs = require('./chunk-SFLIUHHL.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
Object.defineProperty(exports, "
|
|
7
|
+
Object.defineProperty(exports, "Handlers", {
|
|
8
8
|
enumerable: true,
|
|
9
|
-
get: function () { return
|
|
9
|
+
get: function () { return chunkSFLIUHHL_cjs.Handlers; }
|
|
10
10
|
});
|
|
11
|
-
Object.defineProperty(exports, "
|
|
11
|
+
Object.defineProperty(exports, "Mock", {
|
|
12
12
|
enumerable: true,
|
|
13
|
-
get: function () { return
|
|
13
|
+
get: function () { return chunkSFLIUHHL_cjs.Mock; }
|
|
14
14
|
});
|
|
15
15
|
//# sourceMappingURL=components.cjs.map
|
|
16
16
|
//# sourceMappingURL=components.cjs.map
|
package/dist/components.d.cts
CHANGED
|
@@ -1,87 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { HttpMethod } from '@kubb/oas';
|
|
1
|
+
import { Operation } from '@kubb/oas';
|
|
3
2
|
import { ReactNode } from 'react';
|
|
4
|
-
import { KubbNode } from '@kubb/react/types';
|
|
5
3
|
|
|
6
|
-
type
|
|
4
|
+
type Props = {
|
|
7
5
|
/**
|
|
8
6
|
* Name of the function
|
|
9
7
|
*/
|
|
10
8
|
name: string;
|
|
11
|
-
|
|
12
|
-
* Method of the current operation, see useOperation.
|
|
13
|
-
*/
|
|
14
|
-
method: HttpMethod;
|
|
15
|
-
/**
|
|
16
|
-
* Path of the mock
|
|
17
|
-
*/
|
|
18
|
-
path: URLPath;
|
|
19
|
-
/**
|
|
20
|
-
* Name of the import for the mock(this is a function).
|
|
21
|
-
* @example createPet
|
|
22
|
-
*/
|
|
9
|
+
operation: Operation;
|
|
23
10
|
responseName: string;
|
|
24
11
|
};
|
|
25
|
-
declare function
|
|
26
|
-
declare const defaultTemplates$1: {
|
|
27
|
-
readonly default: typeof Template$1;
|
|
28
|
-
};
|
|
29
|
-
type Props$1 = {
|
|
30
|
-
/**
|
|
31
|
-
* This will make it possible to override the default behaviour.
|
|
32
|
-
*/
|
|
33
|
-
Template?: React.ComponentType<React.ComponentProps<typeof Template$1>>;
|
|
34
|
-
};
|
|
35
|
-
declare function Mock({ Template }: Props$1): ReactNode;
|
|
36
|
-
declare namespace Mock {
|
|
37
|
-
var File: ({ templates }: FileProps$1) => ReactNode;
|
|
38
|
-
var templates: {
|
|
39
|
-
readonly default: typeof Template$1;
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
type FileProps$1 = {
|
|
43
|
-
/**
|
|
44
|
-
* This will make it possible to override the default behaviour.
|
|
45
|
-
*/
|
|
46
|
-
templates?: typeof defaultTemplates$1;
|
|
47
|
-
};
|
|
12
|
+
declare function Mock({ name, responseName, operation }: Props): ReactNode;
|
|
48
13
|
|
|
49
|
-
type
|
|
14
|
+
type HandlersProps = {
|
|
50
15
|
/**
|
|
51
16
|
* Name of the function
|
|
52
17
|
*/
|
|
53
18
|
name: string;
|
|
54
19
|
handlers: string[];
|
|
55
20
|
};
|
|
56
|
-
declare function
|
|
57
|
-
type ParserTemplateProps = {
|
|
58
|
-
children?: React.ReactNode;
|
|
59
|
-
};
|
|
60
|
-
declare function RootTemplate({ children }: ParserTemplateProps): JSX.Element;
|
|
61
|
-
declare const defaultTemplates: {
|
|
62
|
-
readonly default: typeof Template;
|
|
63
|
-
readonly root: typeof RootTemplate;
|
|
64
|
-
};
|
|
65
|
-
type Templates = Partial<typeof defaultTemplates>;
|
|
66
|
-
type Props = {
|
|
67
|
-
/**
|
|
68
|
-
* This will make it possible to override the default behaviour.
|
|
69
|
-
*/
|
|
70
|
-
Template?: React.ComponentType<React.ComponentProps<typeof Template>>;
|
|
71
|
-
};
|
|
72
|
-
declare function Operations({ Template }: Props): ReactNode;
|
|
73
|
-
declare namespace Operations {
|
|
74
|
-
var File: (props: FileProps) => KubbNode;
|
|
75
|
-
var templates: {
|
|
76
|
-
readonly default: typeof Template;
|
|
77
|
-
readonly root: typeof RootTemplate;
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
type FileProps = {
|
|
81
|
-
/**
|
|
82
|
-
* This will make it possible to override the default behaviour.
|
|
83
|
-
*/
|
|
84
|
-
templates?: Templates;
|
|
85
|
-
};
|
|
21
|
+
declare function Handlers({ name, handlers }: HandlersProps): ReactNode;
|
|
86
22
|
|
|
87
|
-
export {
|
|
23
|
+
export { Handlers, Mock };
|
package/dist/components.d.ts
CHANGED
|
@@ -1,87 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { HttpMethod } from '@kubb/oas';
|
|
1
|
+
import { Operation } from '@kubb/oas';
|
|
3
2
|
import { ReactNode } from 'react';
|
|
4
|
-
import { KubbNode } from '@kubb/react/types';
|
|
5
3
|
|
|
6
|
-
type
|
|
4
|
+
type Props = {
|
|
7
5
|
/**
|
|
8
6
|
* Name of the function
|
|
9
7
|
*/
|
|
10
8
|
name: string;
|
|
11
|
-
|
|
12
|
-
* Method of the current operation, see useOperation.
|
|
13
|
-
*/
|
|
14
|
-
method: HttpMethod;
|
|
15
|
-
/**
|
|
16
|
-
* Path of the mock
|
|
17
|
-
*/
|
|
18
|
-
path: URLPath;
|
|
19
|
-
/**
|
|
20
|
-
* Name of the import for the mock(this is a function).
|
|
21
|
-
* @example createPet
|
|
22
|
-
*/
|
|
9
|
+
operation: Operation;
|
|
23
10
|
responseName: string;
|
|
24
11
|
};
|
|
25
|
-
declare function
|
|
26
|
-
declare const defaultTemplates$1: {
|
|
27
|
-
readonly default: typeof Template$1;
|
|
28
|
-
};
|
|
29
|
-
type Props$1 = {
|
|
30
|
-
/**
|
|
31
|
-
* This will make it possible to override the default behaviour.
|
|
32
|
-
*/
|
|
33
|
-
Template?: React.ComponentType<React.ComponentProps<typeof Template$1>>;
|
|
34
|
-
};
|
|
35
|
-
declare function Mock({ Template }: Props$1): ReactNode;
|
|
36
|
-
declare namespace Mock {
|
|
37
|
-
var File: ({ templates }: FileProps$1) => ReactNode;
|
|
38
|
-
var templates: {
|
|
39
|
-
readonly default: typeof Template$1;
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
type FileProps$1 = {
|
|
43
|
-
/**
|
|
44
|
-
* This will make it possible to override the default behaviour.
|
|
45
|
-
*/
|
|
46
|
-
templates?: typeof defaultTemplates$1;
|
|
47
|
-
};
|
|
12
|
+
declare function Mock({ name, responseName, operation }: Props): ReactNode;
|
|
48
13
|
|
|
49
|
-
type
|
|
14
|
+
type HandlersProps = {
|
|
50
15
|
/**
|
|
51
16
|
* Name of the function
|
|
52
17
|
*/
|
|
53
18
|
name: string;
|
|
54
19
|
handlers: string[];
|
|
55
20
|
};
|
|
56
|
-
declare function
|
|
57
|
-
type ParserTemplateProps = {
|
|
58
|
-
children?: React.ReactNode;
|
|
59
|
-
};
|
|
60
|
-
declare function RootTemplate({ children }: ParserTemplateProps): JSX.Element;
|
|
61
|
-
declare const defaultTemplates: {
|
|
62
|
-
readonly default: typeof Template;
|
|
63
|
-
readonly root: typeof RootTemplate;
|
|
64
|
-
};
|
|
65
|
-
type Templates = Partial<typeof defaultTemplates>;
|
|
66
|
-
type Props = {
|
|
67
|
-
/**
|
|
68
|
-
* This will make it possible to override the default behaviour.
|
|
69
|
-
*/
|
|
70
|
-
Template?: React.ComponentType<React.ComponentProps<typeof Template>>;
|
|
71
|
-
};
|
|
72
|
-
declare function Operations({ Template }: Props): ReactNode;
|
|
73
|
-
declare namespace Operations {
|
|
74
|
-
var File: (props: FileProps) => KubbNode;
|
|
75
|
-
var templates: {
|
|
76
|
-
readonly default: typeof Template;
|
|
77
|
-
readonly root: typeof RootTemplate;
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
type FileProps = {
|
|
81
|
-
/**
|
|
82
|
-
* This will make it possible to override the default behaviour.
|
|
83
|
-
*/
|
|
84
|
-
templates?: Templates;
|
|
85
|
-
};
|
|
21
|
+
declare function Handlers({ name, handlers }: HandlersProps): ReactNode;
|
|
86
22
|
|
|
87
|
-
export {
|
|
23
|
+
export { Handlers, Mock };
|
package/dist/components.js
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkHYNRHFXE_cjs = require('./chunk-HYNRHFXE.cjs');
|
|
4
|
+
require('./chunk-SFLIUHHL.cjs');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
Object.defineProperty(exports, "handlersGenerator", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () { return chunkHYNRHFXE_cjs.handlersGenerator; }
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "mockGenerator", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () { return chunkHYNRHFXE_cjs.mockGenerator; }
|
|
15
|
+
});
|
|
16
|
+
//# sourceMappingURL=generators.cjs.map
|
|
17
|
+
//# sourceMappingURL=generators.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"generators.cjs"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as _kubb_plugin_oas from '@kubb/plugin-oas';
|
|
2
|
+
import { P as PluginMsw } from './types-cZ4a5aFe.cjs';
|
|
3
|
+
import '@kubb/core';
|
|
4
|
+
import '@kubb/fs/types';
|
|
5
|
+
|
|
6
|
+
declare const mockGenerator: _kubb_plugin_oas.Generator<PluginMsw>;
|
|
7
|
+
|
|
8
|
+
declare const handlersGenerator: _kubb_plugin_oas.Generator<PluginMsw>;
|
|
9
|
+
|
|
10
|
+
export { handlersGenerator, mockGenerator };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as _kubb_plugin_oas from '@kubb/plugin-oas';
|
|
2
|
+
import { P as PluginMsw } from './types-cZ4a5aFe.js';
|
|
3
|
+
import '@kubb/core';
|
|
4
|
+
import '@kubb/fs/types';
|
|
5
|
+
|
|
6
|
+
declare const mockGenerator: _kubb_plugin_oas.Generator<PluginMsw>;
|
|
7
|
+
|
|
8
|
+
declare const handlersGenerator: _kubb_plugin_oas.Generator<PluginMsw>;
|
|
9
|
+
|
|
10
|
+
export { handlersGenerator, mockGenerator };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"generators.js"}
|