@kubb/plugin-msw 3.0.0-alpha.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Stijn Van Hulle
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,44 @@
1
+ <div align="center">
2
+
3
+ <!-- <img src="assets/logo.png" alt="logo" width="200" height="auto" /> -->
4
+ <h1>@kubb/plugin-msw</h1>
5
+
6
+ <p>
7
+ Swagger integration to create mock data based on MSW
8
+ </p>
9
+ <img src="https://raw.githubusercontent.com/kubb-labs/kubb/main/assets/banner.png" alt="logo" height="auto" />
10
+
11
+ [![npm version][npm-version-src]][npm-version-href]
12
+ [![npm downloads][npm-downloads-src]][npm-downloads-href]
13
+ [![Coverage][coverage-src]][coverage-href]
14
+ [![License][license-src]][license-href]
15
+
16
+ <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
17
+ <!-- ALL-CONTRIBUTORS-BADGE:END -->
18
+ </p>
19
+
20
+ <h4>
21
+ <a href="https://codesandbox.io/s/github/kubb-labs/kubb/tree/alpha/examples/typescript" target="_blank">View Demo</a>
22
+ <span> · </span>
23
+ <a href="https://kubb.dev/" target="_blank">Documentation</a>
24
+ <span> · </span>
25
+ <a href="https://github.com/kubb-labs/kubb/issues/" target="_blank">Report Bug</a>
26
+ <span> · </span>
27
+ <a href="https://github.com/kubb-labs/kubb/issues/" target="_blank">Request Feature</a>
28
+ </h4>
29
+ </div>
30
+
31
+ <!-- Badges -->
32
+
33
+ [npm-version-src]: https://img.shields.io/npm/v/@kubb/plugin-msw?flat&colorA=18181B&colorB=f58517
34
+ [npm-version-href]: https://npmjs.com/package/@kubb/plugin-msw
35
+ [npm-downloads-src]: https://img.shields.io/npm/dm/@kubb/plugin-msw?flat&colorA=18181B&colorB=f58517
36
+ [npm-downloads-href]: https://npmjs.com/package/@kubb/plugin-msw
37
+ [license-src]: https://img.shields.io/github/license/kubb-labs/kubb.svg?flat&colorA=18181B&colorB=f58517
38
+ [license-href]: https://github.com/kubb-labs/kubb/blob/main/LICENSE
39
+ [build-src]: https://img.shields.io/github/actions/workflow/status/kubb-labs/kubb/ci.yaml?style=flat&colorA=18181B&colorB=f58517
40
+ [build-href]: https://www.npmjs.com/package/@kubb/plugin-msw
41
+ [minified-src]: https://img.shields.io/bundlephobia/min/@kubb/plugin-msw?style=flat&colorA=18181B&colorB=f58517
42
+ [minified-href]: https://www.npmjs.com/package/@kubb/plugin-msw
43
+ [coverage-src]: https://img.shields.io/codecov/c/github/kubb-labs/kubb?style=flat&colorA=18181B&colorB=f58517
44
+ [coverage-href]: https://www.npmjs.com/package/@kubb/plugin-msw
@@ -0,0 +1,105 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/components/Mock.tsx
2
+ require('@kubb/core');
3
+ var _utils = require('@kubb/core/utils');
4
+ var _react = require('@kubb/react');
5
+ var _pluginfaker = require('@kubb/plugin-faker');
6
+ var _hooks = require('@kubb/plugin-oas/hooks');
7
+ var _jsxruntime = require('@kubb/react/jsx-runtime');
8
+ function Template({ name, method, path, responseName }) {
9
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, { children: `
10
+ export const ${name} = http.${method}('*${path.toURLPath()}', function handler(info) {
11
+ return new Response(JSON.stringify(${responseName}()), {
12
+ headers: {
13
+ 'Content-Type': 'application/json',
14
+ },
15
+ })
16
+ })
17
+ ` });
18
+ }
19
+ var defaultTemplates = { default: Template };
20
+ function Mock({ Template: Template3 = defaultTemplates.default }) {
21
+ const { pluginManager } = _react.useApp.call(void 0, );
22
+ const { getSchemas, getName } = _hooks.useOperationManager.call(void 0, );
23
+ const operation = _hooks.useOperation.call(void 0, );
24
+ const schemas = getSchemas(operation);
25
+ const name = getName(operation, { type: "function" });
26
+ const responseName = pluginManager.resolveName({
27
+ pluginKey: [_pluginfaker.pluginFakerName],
28
+ name: schemas.response.name,
29
+ type: "type"
30
+ });
31
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Template3, { name, responseName, method: operation.method, path: new (0, _utils.URLPath)(operation.path) });
32
+ }
33
+ Mock.File = function({ templates = defaultTemplates }) {
34
+ const {
35
+ pluginManager,
36
+ plugin: {
37
+ options: { extName }
38
+ }
39
+ } = _react.useApp.call(void 0, );
40
+ const { getSchemas, getFile } = _hooks.useOperationManager.call(void 0, );
41
+ const operation = _hooks.useOperation.call(void 0, );
42
+ const schemas = getSchemas(operation);
43
+ const file = getFile(operation);
44
+ const fileFaker = getFile(operation, { pluginKey: [_pluginfaker.pluginFakerName] });
45
+ const responseName = pluginManager.resolveName({
46
+ pluginKey: [_pluginfaker.pluginFakerName],
47
+ name: schemas.response.name,
48
+ type: "function"
49
+ });
50
+ const Template3 = templates.default;
51
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Parser, { language: "typescript", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _react.File, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
52
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Import, { name: ["http"], path: "msw" }),
53
+ fileFaker && responseName && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Import, { extName, name: [responseName], root: file.path, path: fileFaker.path }),
54
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Source, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Mock, { Template: Template3 }) })
55
+ ] }) });
56
+ };
57
+ Mock.templates = defaultTemplates;
58
+
59
+ // src/components/Operations.tsx
60
+
61
+
62
+
63
+ function Template2({ name, handlers }) {
64
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, { children: `export const ${name} = ${JSON.stringify(handlers).replaceAll(`"`, "")} as const` });
65
+ }
66
+ function RootTemplate({ children }) {
67
+ const {
68
+ pluginManager,
69
+ plugin: { key: pluginKey }
70
+ } = _react.useApp.call(void 0, );
71
+ const { getName, getFile } = _hooks.useOperationManager.call(void 0, );
72
+ const file = pluginManager.getFile({ name: "handlers", extName: ".ts", pluginKey });
73
+ const operations = _hooks.useOperations.call(void 0, );
74
+ const imports = operations.map((operation) => {
75
+ const operationFile = getFile(operation, { pluginKey });
76
+ const operationName = getName(operation, { pluginKey, type: "function" });
77
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Import, { name: [operationName], root: file.path, path: operationFile.path }, operationFile.path);
78
+ }).filter(Boolean);
79
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Parser, { language: "typescript", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _react.File, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
80
+ imports,
81
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Source, { children })
82
+ ] }) });
83
+ }
84
+ var defaultTemplates2 = { default: Template2, root: RootTemplate };
85
+ function Operations({ Template: Template3 = defaultTemplates2.default }) {
86
+ const {
87
+ plugin: { key: pluginKey }
88
+ } = _react.useApp.call(void 0, );
89
+ const operations = _hooks.useOperations.call(void 0, );
90
+ const { getName } = _hooks.useOperationManager.call(void 0, );
91
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Template3, { name: "handlers", handlers: operations.map((operation) => getName(operation, { type: "function", pluginKey })) });
92
+ }
93
+ Operations.File = function(props) {
94
+ const templates = { ...defaultTemplates2, ...props.templates };
95
+ const Template3 = templates.default;
96
+ const RootTemplate2 = templates.root;
97
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, RootTemplate2, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Operations, { Template: Template3 }) });
98
+ };
99
+ Operations.templates = defaultTemplates2;
100
+
101
+
102
+
103
+
104
+ exports.Mock = Mock; exports.Operations = Operations;
105
+ //# sourceMappingURL=chunk-S4P5XPFN.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/kubb/kubb/packages/plugin-msw/dist/chunk-S4P5XPFN.cjs","../src/components/Mock.tsx","../src/components/Operations.tsx"],"names":["Template","jsx","Fragment","useApp","useOperationManager","File","Parser","jsxs","defaultTemplates","RootTemplate"],"mappings":"AAAA;ACAA,sBAA+B;AAC/B,yCAAwB;AACxB,oCAAqC;AACrC,iDAAgC;AAChC,+CAAkD;AA4B9C,qDAAA;AAFJ,SAAS,QAAA,CAAS,EAAE,IAAA,EAAM,MAAA,EAAQ,IAAA,EAAM,aAAa,CAAA,EAA6B;AAChF,EAAA,uBACE,6BAAA,oBAAA,EAAA,EACG,QAAA,EAAA,CAAA;AAAA,eAAA,EACU,IAAI,CAAA,QAAA,EAAW,MAAM,CAAA,GAAA,EAAM,IAAA,CAAK,SAAA,CAAU,CAAC,CAAA;AAAA,uCAAA,EACnB,YAAY,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAAA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EAAe,SAAA,CAAU,IAAA;AAE/B,EAAA,uBACER,6BAAAA,aAACQ,EAAA,EACC,QAAA,kBAAAR,6BAAAA,UAAC,EAAA,EAAW,QAAA,EAAUD,UAAAA,CAAU,EAAA,CAClC,CAAA;AAEJ,CAAA;AAEA,UAAA,CAAW,UAAA,EAAYQ,iBAAAA;AFIvB;AACA;AACE;AACA;AACF,qDAAC","file":"/home/runner/work/kubb/kubb/packages/plugin-msw/dist/chunk-S4P5XPFN.cjs","sourcesContent":[null,"import { PackageManager } from '@kubb/core'\nimport { URLPath } from '@kubb/core/utils'\nimport { Parser, File, useApp } from '@kubb/react'\nimport { pluginFakerName } from '@kubb/plugin-faker'\nimport { useOperation, useOperationManager } from '@kubb/plugin-oas/hooks'\n\nimport type { HttpMethod } from '@kubb/oas'\nimport type { ReactNode } from 'react'\nimport type { FileMeta, PluginMsw } from '../types.ts'\n\ntype TemplateProps = {\n /**\n * Name of the function\n */\n name: string\n /**\n * Method of the current operation, see useOperation.\n */\n method: HttpMethod\n /**\n * Path of the mock\n */\n path: URLPath\n /**\n * Name of the import for the mock(this is a function).\n * @example createPet\n */\n responseName: string\n}\n\nfunction Template({ name, method, path, responseName }: TemplateProps): ReactNode {\n return (\n <>\n {`\n export const ${name} = http.${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 </>\n )\n}\n\nconst defaultTemplates = { default: Template } as const\n\ntype Props = {\n /**\n * This will make it possible to override the default behaviour.\n */\n Template?: React.ComponentType<React.ComponentProps<typeof Template>>\n}\n\nexport function Mock({ Template = defaultTemplates.default }: Props): ReactNode {\n const { pluginManager } = useApp<PluginMsw>()\n const { getSchemas, getName } = useOperationManager()\n const operation = useOperation()\n\n const schemas = getSchemas(operation)\n const name = getName(operation, { type: 'function' })\n const responseName = pluginManager.resolveName({\n pluginKey: [pluginFakerName],\n name: schemas.response.name,\n type: 'type',\n })\n\n return <Template name={name} responseName={responseName} method={operation.method} path={new URLPath(operation.path)} />\n}\n\ntype FileProps = {\n /**\n * This will make it possible to override the default behaviour.\n */\n templates?: typeof defaultTemplates\n}\n\nMock.File = function ({ templates = defaultTemplates }: FileProps): ReactNode {\n const {\n pluginManager,\n plugin: {\n options: { extName },\n },\n } = useApp<PluginMsw>()\n const { getSchemas, getFile } = useOperationManager()\n const operation = useOperation()\n\n const schemas = getSchemas(operation)\n const file = getFile(operation)\n const fileFaker = getFile(operation, { pluginKey: [pluginFakerName] })\n const responseName = pluginManager.resolveName({\n pluginKey: [pluginFakerName],\n name: schemas.response.name,\n type: 'function',\n })\n\n const Template = templates.default\n\n return (\n <Parser language=\"typescript\">\n <File<FileMeta> baseName={file.baseName} path={file.path} meta={file.meta}>\n <File.Import name={['http']} path={'msw'} />\n {fileFaker && responseName && <File.Import extName={extName} name={[responseName]} root={file.path} path={fileFaker.path} />}\n <File.Source>\n <Mock Template={Template} />\n </File.Source>\n </File>\n </Parser>\n )\n}\n\nMock.templates = defaultTemplates\n","import { Parser, File, useApp } from '@kubb/react'\nimport { useOperationManager, useOperations } from '@kubb/plugin-oas/hooks'\n\nimport type { KubbNode } from '@kubb/react'\nimport type { ReactNode } from 'react'\nimport type { FileMeta, PluginMsw } from '../types.ts'\n\ntype TemplateProps = {\n /**\n * Name of the function\n */\n name: string\n handlers: string[]\n}\n\nfunction Template({ name, handlers }: TemplateProps): ReactNode {\n return <>{`export const ${name} = ${JSON.stringify(handlers).replaceAll(`\"`, '')} as const`}</>\n}\n\ntype ParserTemplateProps = {\n children?: React.ReactNode\n}\n\nfunction RootTemplate({ children }: ParserTemplateProps) {\n const {\n pluginManager,\n plugin: { key: pluginKey },\n } = useApp<PluginMsw>()\n\n const { getName, getFile } = useOperationManager()\n\n const file = pluginManager.getFile({ name: 'handlers', extName: '.ts', pluginKey })\n const operations = useOperations()\n\n const imports = operations\n .map((operation) => {\n const operationFile = getFile(operation, { pluginKey })\n const operationName = getName(operation, { pluginKey, type: 'function' })\n\n return <File.Import key={operationFile.path} name={[operationName]} root={file.path} path={operationFile.path} />\n })\n .filter(Boolean)\n\n return (\n <Parser language=\"typescript\">\n <File<FileMeta> baseName={file.baseName} path={file.path} meta={file.meta}>\n {imports}\n <File.Source>{children}</File.Source>\n </File>\n </Parser>\n )\n}\n\nconst defaultTemplates = { default: Template, root: RootTemplate } as const\n\ntype Templates = Partial<typeof defaultTemplates>\n\ntype Props = {\n /**\n * This will make it possible to override the default behaviour.\n */\n Template?: React.ComponentType<React.ComponentProps<typeof Template>>\n}\n\nexport function Operations({ Template = defaultTemplates.default }: Props): ReactNode {\n const {\n plugin: { key: pluginKey },\n } = useApp<PluginMsw>()\n\n const operations = useOperations()\n const { getName } = useOperationManager()\n\n return <Template name=\"handlers\" handlers={operations.map((operation) => getName(operation, { type: 'function', pluginKey }))} />\n}\n\ntype FileProps = {\n /**\n * This will make it possible to override the default behaviour.\n */\n templates?: Templates\n}\n\nOperations.File = function (props: FileProps): KubbNode {\n const templates = { ...defaultTemplates, ...props.templates }\n\n const Template = templates.default\n const RootTemplate = templates.root\n\n return (\n <RootTemplate>\n <Operations Template={Template} />\n </RootTemplate>\n )\n}\n\nOperations.templates = defaultTemplates\n"]}
@@ -0,0 +1,105 @@
1
+ // src/components/Mock.tsx
2
+ import "@kubb/core";
3
+ import { URLPath } from "@kubb/core/utils";
4
+ import { Parser, File, useApp } from "@kubb/react";
5
+ import { pluginFakerName } from "@kubb/plugin-faker";
6
+ import { useOperation, useOperationManager } from "@kubb/plugin-oas/hooks";
7
+ import { Fragment, jsx, jsxs } from "@kubb/react/jsx-runtime";
8
+ function Template({ name, method, path, responseName }) {
9
+ return /* @__PURE__ */ jsx(Fragment, { children: `
10
+ export const ${name} = http.${method}('*${path.toURLPath()}', function handler(info) {
11
+ return new Response(JSON.stringify(${responseName}()), {
12
+ headers: {
13
+ 'Content-Type': 'application/json',
14
+ },
15
+ })
16
+ })
17
+ ` });
18
+ }
19
+ var defaultTemplates = { default: Template };
20
+ function Mock({ Template: Template3 = defaultTemplates.default }) {
21
+ const { pluginManager } = useApp();
22
+ const { getSchemas, getName } = useOperationManager();
23
+ const operation = useOperation();
24
+ const schemas = getSchemas(operation);
25
+ const name = getName(operation, { type: "function" });
26
+ const responseName = pluginManager.resolveName({
27
+ pluginKey: [pluginFakerName],
28
+ name: schemas.response.name,
29
+ type: "type"
30
+ });
31
+ return /* @__PURE__ */ jsx(Template3, { name, responseName, method: operation.method, path: new URLPath(operation.path) });
32
+ }
33
+ Mock.File = function({ templates = defaultTemplates }) {
34
+ const {
35
+ pluginManager,
36
+ plugin: {
37
+ options: { extName }
38
+ }
39
+ } = useApp();
40
+ const { getSchemas, getFile } = useOperationManager();
41
+ const operation = useOperation();
42
+ const schemas = getSchemas(operation);
43
+ const file = getFile(operation);
44
+ const fileFaker = getFile(operation, { pluginKey: [pluginFakerName] });
45
+ const responseName = pluginManager.resolveName({
46
+ pluginKey: [pluginFakerName],
47
+ name: schemas.response.name,
48
+ type: "function"
49
+ });
50
+ const Template3 = templates.default;
51
+ return /* @__PURE__ */ jsx(Parser, { language: "typescript", children: /* @__PURE__ */ jsxs(File, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
52
+ /* @__PURE__ */ jsx(File.Import, { name: ["http"], path: "msw" }),
53
+ fileFaker && responseName && /* @__PURE__ */ jsx(File.Import, { extName, name: [responseName], root: file.path, path: fileFaker.path }),
54
+ /* @__PURE__ */ jsx(File.Source, { children: /* @__PURE__ */ jsx(Mock, { Template: Template3 }) })
55
+ ] }) });
56
+ };
57
+ Mock.templates = defaultTemplates;
58
+
59
+ // src/components/Operations.tsx
60
+ import { Parser as Parser2, File as File2, useApp as useApp2 } from "@kubb/react";
61
+ import { useOperationManager as useOperationManager2, useOperations } from "@kubb/plugin-oas/hooks";
62
+ import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "@kubb/react/jsx-runtime";
63
+ function Template2({ name, handlers }) {
64
+ return /* @__PURE__ */ jsx2(Fragment2, { children: `export const ${name} = ${JSON.stringify(handlers).replaceAll(`"`, "")} as const` });
65
+ }
66
+ function RootTemplate({ children }) {
67
+ const {
68
+ pluginManager,
69
+ plugin: { key: pluginKey }
70
+ } = useApp2();
71
+ const { getName, getFile } = useOperationManager2();
72
+ const file = pluginManager.getFile({ name: "handlers", extName: ".ts", pluginKey });
73
+ const operations = useOperations();
74
+ const imports = operations.map((operation) => {
75
+ const operationFile = getFile(operation, { pluginKey });
76
+ const operationName = getName(operation, { pluginKey, type: "function" });
77
+ return /* @__PURE__ */ jsx2(File2.Import, { name: [operationName], root: file.path, path: operationFile.path }, operationFile.path);
78
+ }).filter(Boolean);
79
+ return /* @__PURE__ */ jsx2(Parser2, { language: "typescript", children: /* @__PURE__ */ jsxs2(File2, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
80
+ imports,
81
+ /* @__PURE__ */ jsx2(File2.Source, { children })
82
+ ] }) });
83
+ }
84
+ var defaultTemplates2 = { default: Template2, root: RootTemplate };
85
+ function Operations({ Template: Template3 = defaultTemplates2.default }) {
86
+ const {
87
+ plugin: { key: pluginKey }
88
+ } = useApp2();
89
+ const operations = useOperations();
90
+ const { getName } = useOperationManager2();
91
+ return /* @__PURE__ */ jsx2(Template3, { name: "handlers", handlers: operations.map((operation) => getName(operation, { type: "function", pluginKey })) });
92
+ }
93
+ Operations.File = function(props) {
94
+ const templates = { ...defaultTemplates2, ...props.templates };
95
+ const Template3 = templates.default;
96
+ const RootTemplate2 = templates.root;
97
+ return /* @__PURE__ */ jsx2(RootTemplate2, { children: /* @__PURE__ */ jsx2(Operations, { Template: Template3 }) });
98
+ };
99
+ Operations.templates = defaultTemplates2;
100
+
101
+ export {
102
+ Mock,
103
+ Operations
104
+ };
105
+ //# sourceMappingURL=chunk-WRIEMCYI.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/Mock.tsx","../src/components/Operations.tsx"],"sourcesContent":["import { PackageManager } from '@kubb/core'\nimport { URLPath } from '@kubb/core/utils'\nimport { Parser, File, useApp } from '@kubb/react'\nimport { pluginFakerName } from '@kubb/plugin-faker'\nimport { useOperation, useOperationManager } from '@kubb/plugin-oas/hooks'\n\nimport type { HttpMethod } from '@kubb/oas'\nimport type { ReactNode } from 'react'\nimport type { FileMeta, PluginMsw } from '../types.ts'\n\ntype TemplateProps = {\n /**\n * Name of the function\n */\n name: string\n /**\n * Method of the current operation, see useOperation.\n */\n method: HttpMethod\n /**\n * Path of the mock\n */\n path: URLPath\n /**\n * Name of the import for the mock(this is a function).\n * @example createPet\n */\n responseName: string\n}\n\nfunction Template({ name, method, path, responseName }: TemplateProps): ReactNode {\n return (\n <>\n {`\n export const ${name} = http.${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 </>\n )\n}\n\nconst defaultTemplates = { default: Template } as const\n\ntype Props = {\n /**\n * This will make it possible to override the default behaviour.\n */\n Template?: React.ComponentType<React.ComponentProps<typeof Template>>\n}\n\nexport function Mock({ Template = defaultTemplates.default }: Props): ReactNode {\n const { pluginManager } = useApp<PluginMsw>()\n const { getSchemas, getName } = useOperationManager()\n const operation = useOperation()\n\n const schemas = getSchemas(operation)\n const name = getName(operation, { type: 'function' })\n const responseName = pluginManager.resolveName({\n pluginKey: [pluginFakerName],\n name: schemas.response.name,\n type: 'type',\n })\n\n return <Template name={name} responseName={responseName} method={operation.method} path={new URLPath(operation.path)} />\n}\n\ntype FileProps = {\n /**\n * This will make it possible to override the default behaviour.\n */\n templates?: typeof defaultTemplates\n}\n\nMock.File = function ({ templates = defaultTemplates }: FileProps): ReactNode {\n const {\n pluginManager,\n plugin: {\n options: { extName },\n },\n } = useApp<PluginMsw>()\n const { getSchemas, getFile } = useOperationManager()\n const operation = useOperation()\n\n const schemas = getSchemas(operation)\n const file = getFile(operation)\n const fileFaker = getFile(operation, { pluginKey: [pluginFakerName] })\n const responseName = pluginManager.resolveName({\n pluginKey: [pluginFakerName],\n name: schemas.response.name,\n type: 'function',\n })\n\n const Template = templates.default\n\n return (\n <Parser language=\"typescript\">\n <File<FileMeta> baseName={file.baseName} path={file.path} meta={file.meta}>\n <File.Import name={['http']} path={'msw'} />\n {fileFaker && responseName && <File.Import extName={extName} name={[responseName]} root={file.path} path={fileFaker.path} />}\n <File.Source>\n <Mock Template={Template} />\n </File.Source>\n </File>\n </Parser>\n )\n}\n\nMock.templates = defaultTemplates\n","import { Parser, File, useApp } from '@kubb/react'\nimport { useOperationManager, useOperations } from '@kubb/plugin-oas/hooks'\n\nimport type { KubbNode } from '@kubb/react'\nimport type { ReactNode } from 'react'\nimport type { FileMeta, PluginMsw } from '../types.ts'\n\ntype TemplateProps = {\n /**\n * Name of the function\n */\n name: string\n handlers: string[]\n}\n\nfunction Template({ name, handlers }: TemplateProps): ReactNode {\n return <>{`export const ${name} = ${JSON.stringify(handlers).replaceAll(`\"`, '')} as const`}</>\n}\n\ntype ParserTemplateProps = {\n children?: React.ReactNode\n}\n\nfunction RootTemplate({ children }: ParserTemplateProps) {\n const {\n pluginManager,\n plugin: { key: pluginKey },\n } = useApp<PluginMsw>()\n\n const { getName, getFile } = useOperationManager()\n\n const file = pluginManager.getFile({ name: 'handlers', extName: '.ts', pluginKey })\n const operations = useOperations()\n\n const imports = operations\n .map((operation) => {\n const operationFile = getFile(operation, { pluginKey })\n const operationName = getName(operation, { pluginKey, type: 'function' })\n\n return <File.Import key={operationFile.path} name={[operationName]} root={file.path} path={operationFile.path} />\n })\n .filter(Boolean)\n\n return (\n <Parser language=\"typescript\">\n <File<FileMeta> baseName={file.baseName} path={file.path} meta={file.meta}>\n {imports}\n <File.Source>{children}</File.Source>\n </File>\n </Parser>\n )\n}\n\nconst defaultTemplates = { default: Template, root: RootTemplate } as const\n\ntype Templates = Partial<typeof defaultTemplates>\n\ntype Props = {\n /**\n * This will make it possible to override the default behaviour.\n */\n Template?: React.ComponentType<React.ComponentProps<typeof Template>>\n}\n\nexport function Operations({ Template = defaultTemplates.default }: Props): ReactNode {\n const {\n plugin: { key: pluginKey },\n } = useApp<PluginMsw>()\n\n const operations = useOperations()\n const { getName } = useOperationManager()\n\n return <Template name=\"handlers\" handlers={operations.map((operation) => getName(operation, { type: 'function', pluginKey }))} />\n}\n\ntype FileProps = {\n /**\n * This will make it possible to override the default behaviour.\n */\n templates?: Templates\n}\n\nOperations.File = function (props: FileProps): KubbNode {\n const templates = { ...defaultTemplates, ...props.templates }\n\n const Template = templates.default\n const RootTemplate = templates.root\n\n return (\n <RootTemplate>\n <Operations Template={Template} />\n </RootTemplate>\n )\n}\n\nOperations.templates = defaultTemplates\n"],"mappings":";AAAA,OAA+B;AAC/B,SAAS,eAAe;AACxB,SAAS,QAAQ,MAAM,cAAc;AACrC,SAAS,uBAAuB;AAChC,SAAS,cAAc,2BAA2B;AA4B9C,wBAqEE,YArEF;AAFJ,SAAS,SAAS,EAAE,MAAM,QAAQ,MAAM,aAAa,GAA6B;AAChF,SACE,gCACG;AAAA,iBACU,IAAI,WAAW,MAAM,MAAM,KAAK,UAAU,CAAC;AAAA,yCACnB,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KAOjD;AAEJ;AAEA,IAAM,mBAAmB,EAAE,SAAS,SAAS;AAStC,SAAS,KAAK,EAAE,UAAAA,YAAW,iBAAiB,QAAQ,GAAqB;AAC9E,QAAM,EAAE,cAAc,IAAI,OAAkB;AAC5C,QAAM,EAAE,YAAY,QAAQ,IAAI,oBAAoB;AACpD,QAAM,YAAY,aAAa;AAE/B,QAAM,UAAU,WAAW,SAAS;AACpC,QAAM,OAAO,QAAQ,WAAW,EAAE,MAAM,WAAW,CAAC;AACpD,QAAM,eAAe,cAAc,YAAY;AAAA,IAC7C,WAAW,CAAC,eAAe;AAAA,IAC3B,MAAM,QAAQ,SAAS;AAAA,IACvB,MAAM;AAAA,EACR,CAAC;AAED,SAAO,oBAACA,WAAA,EAAS,MAAY,cAA4B,QAAQ,UAAU,QAAQ,M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AASA,WAAW,OAAO,SAAU,OAA4B;AACtD,QAAM,YAAY,EAAE,GAAGC,mBAAkB,GAAG,MAAM,UAAU;AAE5D,QAAMD,YAAW,UAAU;AAC3B,QAAME,gBAAe,UAAU;AAE/B,SACE,gBAAAJ,KAACI,eAAA,EACC,0BAAAJ,KAAC,cAAW,UAAUE,WAAU,GAClC;AAEJ;AAEA,WAAW,YAAYC;","names":["Template","Parser","File","useApp","useOperationManager","Fragment","jsx","jsxs","Template","defaultTemplates","RootTemplate"]}
@@ -0,0 +1,9 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+ var _chunkS4P5XPFNcjs = require('./chunk-S4P5XPFN.cjs');
5
+
6
+
7
+
8
+ exports.Mock = _chunkS4P5XPFNcjs.Mock; exports.Operations = _chunkS4P5XPFNcjs.Operations;
9
+ //# sourceMappingURL=components.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/kubb/kubb/packages/plugin-msw/dist/components.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,yFAAC","file":"/home/runner/work/kubb/kubb/packages/plugin-msw/dist/components.cjs"}
@@ -0,0 +1,87 @@
1
+ import { URLPath } from '@kubb/core/utils';
2
+ import { HttpMethod } from '@kubb/oas';
3
+ import { ReactNode } from 'react';
4
+ import { KubbNode } from '@kubb/react';
5
+
6
+ type TemplateProps$1 = {
7
+ /**
8
+ * Name of the function
9
+ */
10
+ 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
+ */
23
+ responseName: string;
24
+ };
25
+ declare function Template$1({ name, method, path, responseName }: TemplateProps$1): ReactNode;
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
+ };
48
+
49
+ type TemplateProps = {
50
+ /**
51
+ * Name of the function
52
+ */
53
+ name: string;
54
+ handlers: string[];
55
+ };
56
+ declare function Template({ name, handlers }: TemplateProps): ReactNode;
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
+ };
86
+
87
+ export { Mock, Operations };
@@ -0,0 +1,87 @@
1
+ import { URLPath } from '@kubb/core/utils';
2
+ import { HttpMethod } from '@kubb/oas';
3
+ import { ReactNode } from 'react';
4
+ import { KubbNode } from '@kubb/react';
5
+
6
+ type TemplateProps$1 = {
7
+ /**
8
+ * Name of the function
9
+ */
10
+ 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
+ */
23
+ responseName: string;
24
+ };
25
+ declare function Template$1({ name, method, path, responseName }: TemplateProps$1): ReactNode;
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
+ };
48
+
49
+ type TemplateProps = {
50
+ /**
51
+ * Name of the function
52
+ */
53
+ name: string;
54
+ handlers: string[];
55
+ };
56
+ declare function Template({ name, handlers }: TemplateProps): ReactNode;
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
+ };
86
+
87
+ export { Mock, Operations };
@@ -0,0 +1,9 @@
1
+ import {
2
+ Mock,
3
+ Operations
4
+ } from "./chunk-WRIEMCYI.js";
5
+ export {
6
+ Mock,
7
+ Operations
8
+ };
9
+ //# sourceMappingURL=components.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}