@kubb/plugin-msw 3.0.0-alpha.1 → 3.0.0-alpha.11

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.
@@ -1,12 +1,12 @@
1
+ import { URLPath } from '@kubb/core/utils';
2
+ import { useApp, File } from '@kubb/react';
3
+ import { pluginFakerName } from '@kubb/plugin-faker';
4
+ import { useOperationManager, useOperation, useOperations } from '@kubb/plugin-oas/hooks';
5
+ import { jsx, jsxs } from '@kubb/react/jsx-runtime';
6
+
1
7
  // 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
8
  function Template({ name, method, path, responseName }) {
9
- return /* @__PURE__ */ jsx(Fragment, { children: `
9
+ return /* @__PURE__ */ jsx(File.Source, { name, isExportable: true, isIndexable: true, children: `
10
10
  export const ${name} = http.${method}('*${path.toURLPath()}', function handler(info) {
11
11
  return new Response(JSON.stringify(${responseName}()), {
12
12
  headers: {
@@ -48,58 +48,51 @@ Mock.File = function({ templates = defaultTemplates }) {
48
48
  type: "function"
49
49
  });
50
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: [
51
+ return /* @__PURE__ */ jsxs(File, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
52
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
- ] }) });
53
+ fileFaker && responseName && /* @__PURE__ */ jsx(File.Import, { name: [responseName], root: file.path, path: fileFaker.path }),
54
+ /* @__PURE__ */ jsx(Mock, { Template: Template3 })
55
+ ] });
56
56
  };
57
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
58
  function Template2({ name, handlers }) {
64
- return /* @__PURE__ */ jsx2(Fragment2, { children: `export const ${name} = ${JSON.stringify(handlers).replaceAll(`"`, "")} as const` });
59
+ return /* @__PURE__ */ jsx(File.Source, { name, isExportable: true, isIndexable: true, children: `export const ${name} = ${JSON.stringify(handlers).replaceAll(`"`, "")} as const` });
65
60
  }
66
61
  function RootTemplate({ children }) {
67
62
  const {
68
63
  pluginManager,
69
64
  plugin: { key: pluginKey }
70
- } = useApp2();
71
- const { getName, getFile } = useOperationManager2();
65
+ } = useApp();
66
+ const { getName, getFile } = useOperationManager();
72
67
  const file = pluginManager.getFile({ name: "handlers", extName: ".ts", pluginKey });
73
68
  const operations = useOperations();
74
69
  const imports = operations.map((operation) => {
75
70
  const operationFile = getFile(operation, { pluginKey });
76
71
  const operationName = getName(operation, { pluginKey, type: "function" });
77
- return /* @__PURE__ */ jsx2(File2.Import, { name: [operationName], root: file.path, path: operationFile.path }, operationFile.path);
72
+ return /* @__PURE__ */ jsx(File.Import, { name: [operationName], root: file.path, path: operationFile.path }, operationFile.path);
78
73
  }).filter(Boolean);
79
- return /* @__PURE__ */ jsx2(Parser2, { language: "typescript", children: /* @__PURE__ */ jsxs2(File2, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
74
+ return /* @__PURE__ */ jsxs(File, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
80
75
  imports,
81
- /* @__PURE__ */ jsx2(File2.Source, { children })
82
- ] }) });
76
+ children
77
+ ] });
83
78
  }
84
79
  var defaultTemplates2 = { default: Template2, root: RootTemplate };
85
80
  function Operations({ Template: Template3 = defaultTemplates2.default }) {
86
81
  const {
87
82
  plugin: { key: pluginKey }
88
- } = useApp2();
83
+ } = useApp();
89
84
  const operations = useOperations();
90
- const { getName } = useOperationManager2();
91
- return /* @__PURE__ */ jsx2(Template3, { name: "handlers", handlers: operations.map((operation) => getName(operation, { type: "function", pluginKey })) });
85
+ const { getName } = useOperationManager();
86
+ return /* @__PURE__ */ jsx(Template3, { name: "handlers", handlers: operations.map((operation) => getName(operation, { type: "function", pluginKey })) });
92
87
  }
93
88
  Operations.File = function(props) {
94
89
  const templates = { ...defaultTemplates2, ...props.templates };
95
90
  const Template3 = templates.default;
96
91
  const RootTemplate2 = templates.root;
97
- return /* @__PURE__ */ jsx2(RootTemplate2, { children: /* @__PURE__ */ jsx2(Operations, { Template: Template3 }) });
92
+ return /* @__PURE__ */ jsx(RootTemplate2, { children: /* @__PURE__ */ jsx(Operations, { Template: Template3 }) });
98
93
  };
99
94
  Operations.templates = defaultTemplates2;
100
95
 
101
- export {
102
- Mock,
103
- Operations
104
- };
105
- //# sourceMappingURL=chunk-WRIEMCYI.js.map
96
+ export { Mock, Operations };
97
+ //# sourceMappingURL=chunk-3KHLTEUD.js.map
98
+ //# sourceMappingURL=chunk-3KHLTEUD.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/Mock.tsx","../src/components/Operations.tsx"],"names":["Template","jsx","File","useApp","useOperationManager","jsxs","defaultTemplates","RootTemplate"],"mappings":";;;;;;;AA6BA,SAAS,SAAS,EAAE,IAAA,EAAM,MAAQ,EAAA,IAAA,EAAM,cAA0C,EAAA;AAChF,EACE,uBAAA,GAAA,CAAC,KAAK,MAAL,EAAA,EAAY,MAAY,YAAY,EAAA,IAAA,EAAC,aAAW,IAC9C,EAAA,QAAA,EAAA,CAAA;AAAA,eAAA,EACU,IAAI,CAAW,QAAA,EAAA,MAAM,CAAM,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AAA","file":"chunk-3KHLTEUD.js","sourcesContent":["import { URLPath } from '@kubb/core/utils'\nimport { 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 <File.Source name={name} isExportable isIndexable>\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 </File.Source>\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 <File<FileMeta> baseName={file.baseName} path={file.path} meta={file.meta}>\n <File.Import name={['http']} path={'msw'} />\n {fileFaker && responseName && <File.Import name={[responseName]} root={file.path} path={fileFaker.path} />}\n <Mock Template={Template} />\n </File>\n )\n}\n\nMock.templates = defaultTemplates\n","import { useOperationManager, useOperations } from '@kubb/plugin-oas/hooks'\nimport { File, useApp } from '@kubb/react'\n\nimport type { KubbNode } from '@kubb/react/types'\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 <File.Source name={name} isExportable isIndexable>{`export const ${name} = ${JSON.stringify(handlers).replaceAll(`\"`, '')} as const`}</File.Source>\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 <File<FileMeta> baseName={file.baseName} path={file.path} meta={file.meta}>\n {imports}\n {children}\n </File>\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,101 @@
1
+ 'use strict';
2
+
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
+
9
+ // src/components/Mock.tsx
10
+ function Template({ name, method, path, responseName }) {
11
+ return /* @__PURE__ */ jsxRuntime.jsx(react.File.Source, { name, isExportable: true, isIndexable: true, children: `
12
+ export const ${name} = http.${method}('*${path.toURLPath()}', function handler(info) {
13
+ return new Response(JSON.stringify(${responseName}()), {
14
+ headers: {
15
+ 'Content-Type': 'application/json',
16
+ },
17
+ })
18
+ })
19
+ ` });
20
+ }
21
+ var defaultTemplates = { default: Template };
22
+ function Mock({ Template: Template3 = defaultTemplates.default }) {
23
+ const { pluginManager } = react.useApp();
24
+ const { getSchemas, getName } = hooks.useOperationManager();
25
+ const operation = hooks.useOperation();
26
+ const schemas = getSchemas(operation);
27
+ const name = getName(operation, { type: "function" });
28
+ const responseName = pluginManager.resolveName({
29
+ pluginKey: [pluginFaker.pluginFakerName],
30
+ name: schemas.response.name,
31
+ type: "type"
32
+ });
33
+ return /* @__PURE__ */ jsxRuntime.jsx(Template3, { name, responseName, method: operation.method, path: new utils.URLPath(operation.path) });
34
+ }
35
+ Mock.File = function({ templates = defaultTemplates }) {
36
+ const {
37
+ pluginManager,
38
+ plugin: {
39
+ options: { extName }
40
+ }
41
+ } = react.useApp();
42
+ const { getSchemas, getFile } = hooks.useOperationManager();
43
+ const operation = hooks.useOperation();
44
+ const schemas = getSchemas(operation);
45
+ const file = getFile(operation);
46
+ const fileFaker = getFile(operation, { pluginKey: [pluginFaker.pluginFakerName] });
47
+ const responseName = pluginManager.resolveName({
48
+ pluginKey: [pluginFaker.pluginFakerName],
49
+ name: schemas.response.name,
50
+ type: "function"
51
+ });
52
+ const Template3 = templates.default;
53
+ return /* @__PURE__ */ jsxRuntime.jsxs(react.File, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
54
+ /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["http"], path: "msw" }),
55
+ fileFaker && responseName && /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: [responseName], root: file.path, path: fileFaker.path }),
56
+ /* @__PURE__ */ jsxRuntime.jsx(Mock, { Template: Template3 })
57
+ ] });
58
+ };
59
+ Mock.templates = defaultTemplates;
60
+ function Template2({ name, handlers }) {
61
+ return /* @__PURE__ */ jsxRuntime.jsx(react.File.Source, { name, isExportable: true, isIndexable: true, children: `export const ${name} = ${JSON.stringify(handlers).replaceAll(`"`, "")} as const` });
62
+ }
63
+ function RootTemplate({ children }) {
64
+ const {
65
+ pluginManager,
66
+ plugin: { key: pluginKey }
67
+ } = react.useApp();
68
+ const { getName, getFile } = hooks.useOperationManager();
69
+ const file = pluginManager.getFile({ name: "handlers", extName: ".ts", pluginKey });
70
+ const operations = hooks.useOperations();
71
+ const imports = operations.map((operation) => {
72
+ const operationFile = getFile(operation, { pluginKey });
73
+ const operationName = getName(operation, { pluginKey, type: "function" });
74
+ return /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: [operationName], root: file.path, path: operationFile.path }, operationFile.path);
75
+ }).filter(Boolean);
76
+ return /* @__PURE__ */ jsxRuntime.jsxs(react.File, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
77
+ imports,
78
+ children
79
+ ] });
80
+ }
81
+ var defaultTemplates2 = { default: Template2, root: RootTemplate };
82
+ function Operations({ Template: Template3 = defaultTemplates2.default }) {
83
+ const {
84
+ plugin: { key: pluginKey }
85
+ } = react.useApp();
86
+ const operations = hooks.useOperations();
87
+ const { getName } = hooks.useOperationManager();
88
+ return /* @__PURE__ */ jsxRuntime.jsx(Template3, { name: "handlers", handlers: operations.map((operation) => getName(operation, { type: "function", pluginKey })) });
89
+ }
90
+ Operations.File = function(props) {
91
+ const templates = { ...defaultTemplates2, ...props.templates };
92
+ const Template3 = templates.default;
93
+ const RootTemplate2 = templates.root;
94
+ return /* @__PURE__ */ jsxRuntime.jsx(RootTemplate2, { children: /* @__PURE__ */ jsxRuntime.jsx(Operations, { Template: Template3 }) });
95
+ };
96
+ Operations.templates = defaultTemplates2;
97
+
98
+ exports.Mock = Mock;
99
+ exports.Operations = Operations;
100
+ //# sourceMappingURL=chunk-BD7UJBXM.cjs.map
101
+ //# sourceMappingURL=chunk-BD7UJBXM.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/Mock.tsx","../src/components/Operations.tsx"],"names":["jsx","File","Template","useApp","useOperationManager","useOperation","pluginFakerName","URLPath","jsxs","useOperations","defaultTemplates","RootTemplate"],"mappings":";;;;;;;;;AA6BA,SAAS,SAAS,EAAE,IAAA,EAAM,MAAQ,EAAA,IAAA,EAAM,cAA0C,EAAA;AAChF,EACE,uBAAAA,cAAA,CAACC,WAAK,MAAL,EAAA,EAAY,MAAY,YAAY,EAAA,IAAA,EAAC,aAAW,IAC9C,EAAA,QAAA,EAAA,CAAA;AAAA,eAAA,EACU,IAAI,CAAW,QAAA,EAAA,MAAM,CAAM,GAAA,EAAA,IAAA,CAAK,WAAW,CAAA;AAAA,uCAAA,EACnB,YAAY,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOjD,CAAA,EAAA,CAAA,CAAA;AA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@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 <File.Source name={name} isExportable isIndexable>\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 </File.Source>\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 <File<FileMeta> baseName={file.baseName} path={file.path} meta={file.meta}>\n <File.Import name={['http']} path={'msw'} />\n {fileFaker && responseName && <File.Import name={[responseName]} root={file.path} path={fileFaker.path} />}\n <Mock Template={Template} />\n </File>\n )\n}\n\nMock.templates = defaultTemplates\n","import { useOperationManager, useOperations } from '@kubb/plugin-oas/hooks'\nimport { File, useApp } from '@kubb/react'\n\nimport type { KubbNode } from '@kubb/react/types'\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 <File.Source name={name} isExportable isIndexable>{`export const ${name} = ${JSON.stringify(handlers).replaceAll(`\"`, '')} as const`}</File.Source>\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 <File<FileMeta> baseName={file.baseName} path={file.path} meta={file.meta}>\n {imports}\n {children}\n </File>\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"]}
@@ -1,9 +1,16 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
1
+ 'use strict';
2
2
 
3
+ var chunkBD7UJBXM_cjs = require('./chunk-BD7UJBXM.cjs');
3
4
 
4
- var _chunkS4P5XPFNcjs = require('./chunk-S4P5XPFN.cjs');
5
5
 
6
6
 
7
-
8
- exports.Mock = _chunkS4P5XPFNcjs.Mock; exports.Operations = _chunkS4P5XPFNcjs.Operations;
7
+ Object.defineProperty(exports, "Mock", {
8
+ enumerable: true,
9
+ get: function () { return chunkBD7UJBXM_cjs.Mock; }
10
+ });
11
+ Object.defineProperty(exports, "Operations", {
12
+ enumerable: true,
13
+ get: function () { return chunkBD7UJBXM_cjs.Operations; }
14
+ });
15
+ //# sourceMappingURL=components.cjs.map
9
16
  //# sourceMappingURL=components.cjs.map
@@ -1 +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"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"components.cjs"}
@@ -1,7 +1,7 @@
1
1
  import { URLPath } from '@kubb/core/utils';
2
2
  import { HttpMethod } from '@kubb/oas';
3
3
  import { ReactNode } from 'react';
4
- import { KubbNode } from '@kubb/react';
4
+ import { KubbNode } from '@kubb/react/types';
5
5
 
6
6
  type TemplateProps$1 = {
7
7
  /**
@@ -1,7 +1,7 @@
1
1
  import { URLPath } from '@kubb/core/utils';
2
2
  import { HttpMethod } from '@kubb/oas';
3
3
  import { ReactNode } from 'react';
4
- import { KubbNode } from '@kubb/react';
4
+ import { KubbNode } from '@kubb/react/types';
5
5
 
6
6
  type TemplateProps$1 = {
7
7
  /**
@@ -1,9 +1,3 @@
1
- import {
2
- Mock,
3
- Operations
4
- } from "./chunk-WRIEMCYI.js";
5
- export {
6
- Mock,
7
- Operations
8
- };
1
+ export { Mock, Operations } from './chunk-3KHLTEUD.js';
2
+ //# sourceMappingURL=components.js.map
9
3
  //# sourceMappingURL=components.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"components.js"}
package/dist/index.cjs CHANGED
@@ -1,54 +1,52 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
1
+ 'use strict';
2
2
 
3
+ var chunkBD7UJBXM_cjs = require('./chunk-BD7UJBXM.cjs');
4
+ var path = require('path');
5
+ var core = require('@kubb/core');
6
+ var transformers = require('@kubb/core/transformers');
7
+ var utils = require('@kubb/core/utils');
8
+ var pluginOas = require('@kubb/plugin-oas');
9
+ var pluginFaker = require('@kubb/plugin-faker');
10
+ var pluginTs = require('@kubb/plugin-ts');
11
+ var components = require('@kubb/plugin-oas/components');
12
+ var react = require('@kubb/react');
13
+ var jsxRuntime = require('@kubb/react/jsx-runtime');
3
14
 
4
- var _chunkS4P5XPFNcjs = require('./chunk-S4P5XPFN.cjs');
15
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
5
16
 
6
- // src/plugin.ts
7
- var _path = require('path'); var _path2 = _interopRequireDefault(_path);
8
- var _core = require('@kubb/core');
9
- var _transformers = require('@kubb/core/transformers');
10
- var _utils = require('@kubb/core/utils');
11
- var _pluginoas = require('@kubb/plugin-oas');
12
- var _utils3 = require('@kubb/plugin-oas/utils');
13
- var _pluginfaker = require('@kubb/plugin-faker');
14
- var _plugints = require('@kubb/plugin-ts');
15
-
16
- // src/OperationGenerator.tsx
17
+ var path__default = /*#__PURE__*/_interopDefault(path);
17
18
 
18
- var _components = require('@kubb/plugin-oas/components');
19
- var _react = require('@kubb/react');
20
- var _jsxruntime = require('@kubb/react/jsx-runtime');
21
- var OperationGenerator = class extends _pluginoas.OperationGenerator {
19
+ var OperationGenerator = class extends pluginOas.OperationGenerator {
22
20
  async all(operations, operationsByMethod) {
23
21
  const { oas, pluginManager, plugin, mode } = this.context;
24
- const root = _react.createRoot.call(void 0, {
22
+ const root = react.createRoot({
25
23
  logger: pluginManager.logger
26
24
  });
27
25
  const templates = {
28
- operations: _chunkS4P5XPFNcjs.Operations.templates,
29
- mock: _chunkS4P5XPFNcjs.Mock.templates,
26
+ operations: chunkBD7UJBXM_cjs.Operations.templates,
27
+ mock: chunkBD7UJBXM_cjs.Mock.templates,
30
28
  ...this.options.templates
31
29
  };
32
30
  root.render(
33
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.App, { pluginManager, plugin, mode, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _components.Oas, { oas, operations, generator: this, children: _optionalChain([templates, 'optionalAccess', _ => _.operations]) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkS4P5XPFNcjs.Operations.File, { templates: templates.operations }) }) })
31
+ /* @__PURE__ */ jsxRuntime.jsx(react.App, { pluginManager, plugin, mode, children: /* @__PURE__ */ jsxRuntime.jsx(components.Oas, { oas, operations, generator: this, children: templates?.operations && /* @__PURE__ */ jsxRuntime.jsx(chunkBD7UJBXM_cjs.Operations.File, { templates: templates.operations }) }) })
34
32
  );
35
33
  return root.files;
36
34
  }
37
35
  async operation(operation, options) {
38
36
  const { oas, pluginManager, plugin, mode } = this.context;
39
- const root = _react.createRoot.call(void 0, {
37
+ const root = react.createRoot({
40
38
  logger: pluginManager.logger
41
39
  });
42
40
  const templates = {
43
- handlers: _chunkS4P5XPFNcjs.Operations.templates,
44
- mock: _chunkS4P5XPFNcjs.Mock.templates,
41
+ handlers: chunkBD7UJBXM_cjs.Operations.templates,
42
+ mock: chunkBD7UJBXM_cjs.Mock.templates,
45
43
  ...options.templates
46
44
  };
47
- if (!_optionalChain([templates, 'optionalAccess', _2 => _2.mock])) {
45
+ if (!templates?.mock) {
48
46
  return [];
49
47
  }
50
48
  root.render(
51
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.App, { pluginManager, plugin: { ...plugin, options }, mode, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _components.Oas, { oas, operations: [operation], generator: this, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _components.Oas.Operation, { operation, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkS4P5XPFNcjs.Mock.File, { templates: templates.mock }) }) }) })
49
+ /* @__PURE__ */ jsxRuntime.jsx(react.App, { pluginManager, plugin: { ...plugin, options }, mode, children: /* @__PURE__ */ jsxRuntime.jsx(components.Oas, { oas, operations: [operation], generator: this, children: /* @__PURE__ */ jsxRuntime.jsx(components.Oas.Operation, { operation, children: /* @__PURE__ */ jsxRuntime.jsx(chunkBD7UJBXM_cjs.Mock.File, { templates: templates.mock }) }) }) })
52
50
  );
53
51
  return root.files;
54
52
  }
@@ -56,58 +54,56 @@ var OperationGenerator = class extends _pluginoas.OperationGenerator {
56
54
 
57
55
  // src/plugin.ts
58
56
  var pluginMswName = "plugin-msw";
59
- var pluginMsw = _core.createPlugin.call(void 0, (options) => {
60
- const { output = { path: "handlers" }, group, exclude = [], include, override = [], transformers = {}, templates } = options;
61
- const template = _optionalChain([group, 'optionalAccess', _3 => _3.output]) ? group.output : `${output.path}/{{tag}}Controller`;
57
+ var pluginMsw = core.createPlugin((options) => {
58
+ const { output = { path: "handlers" }, group, exclude = [], include, override = [], transformers: transformers$1 = {}, templates } = options;
59
+ const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`;
62
60
  return {
63
61
  name: pluginMswName,
62
+ output: {
63
+ exportType: "barrelNamed",
64
+ ...output
65
+ },
64
66
  options: {
65
67
  extName: output.extName,
66
68
  templates: {
67
- operations: _chunkS4P5XPFNcjs.Operations.templates,
68
- mock: _chunkS4P5XPFNcjs.Mock.templates,
69
+ operations: chunkBD7UJBXM_cjs.Operations.templates,
70
+ mock: chunkBD7UJBXM_cjs.Mock.templates,
69
71
  ...templates
70
72
  }
71
73
  },
72
- pre: [_pluginoas.pluginOasName, _plugints.pluginTsName, _pluginfaker.pluginFakerName],
74
+ pre: [pluginOas.pluginOasName, pluginTs.pluginTsName, pluginFaker.pluginFakerName],
73
75
  resolvePath(baseName, pathMode, options2) {
74
- const root = _path2.default.resolve(this.config.root, this.config.output.path);
75
- const mode = _nullishCoalesce(pathMode, () => ( _core.FileManager.getMode(_path2.default.resolve(root, output.path))));
76
+ const root = path__default.default.resolve(this.config.root, this.config.output.path);
77
+ const mode = pathMode ?? core.FileManager.getMode(path__default.default.resolve(root, output.path));
76
78
  if (mode === "single") {
77
- return _path2.default.resolve(root, output.path);
79
+ return path__default.default.resolve(root, output.path);
78
80
  }
79
- if (_optionalChain([options2, 'optionalAccess', _4 => _4.tag]) && _optionalChain([group, 'optionalAccess', _5 => _5.type]) === "tag") {
80
- const tag = _transformers.camelCase.call(void 0, options2.tag);
81
- return _path2.default.resolve(root, _utils.renderTemplate.call(void 0, template, { tag }), baseName);
81
+ if (options2?.tag && group?.type === "tag") {
82
+ const tag = transformers.camelCase(options2.tag);
83
+ return path__default.default.resolve(root, utils.renderTemplate(template, { tag }), baseName);
82
84
  }
83
- return _path2.default.resolve(root, output.path, baseName);
85
+ return path__default.default.resolve(root, output.path, baseName);
84
86
  },
85
87
  resolveName(name, type) {
86
- const resolvedName = _transformers.camelCase.call(void 0, name, {
88
+ const resolvedName = transformers.camelCase(name, {
87
89
  suffix: type ? "handler" : void 0,
88
90
  isFile: type === "file"
89
91
  });
90
92
  if (type) {
91
- return _optionalChain([transformers, 'optionalAccess', _6 => _6.name, 'optionalCall', _7 => _7(resolvedName, type)]) || resolvedName;
93
+ return transformers$1?.name?.(resolvedName, type) || resolvedName;
92
94
  }
93
95
  return resolvedName;
94
96
  },
95
- async writeFile(path2, source) {
96
- if (!path2.endsWith(".ts") || !source) {
97
- return;
98
- }
99
- return this.fileManager.write(path2, source, { sanity: false });
100
- },
101
97
  async buildStart() {
102
- const [swaggerPlugin] = _core.PluginManager.getDependedPlugins(this.plugins, [_pluginoas.pluginOasName]);
103
- const oas = await swaggerPlugin.api.getOas();
104
- const root = _path2.default.resolve(this.config.root, this.config.output.path);
105
- const mode = _core.FileManager.getMode(_path2.default.resolve(root, output.path));
98
+ const [swaggerPlugin] = core.PluginManager.getDependedPlugins(this.plugins, [pluginOas.pluginOasName]);
99
+ const oas = await swaggerPlugin.context.getOas();
100
+ const root = path__default.default.resolve(this.config.root, this.config.output.path);
101
+ const mode = core.FileManager.getMode(path__default.default.resolve(root, output.path));
106
102
  const operationGenerator = new OperationGenerator(this.plugin.options, {
107
103
  oas,
108
104
  pluginManager: this.pluginManager,
109
105
  plugin: this.plugin,
110
- contentType: swaggerPlugin.api.contentType,
106
+ contentType: swaggerPlugin.context.contentType,
111
107
  exclude,
112
108
  include,
113
109
  override,
@@ -115,35 +111,23 @@ var pluginMsw = _core.createPlugin.call(void 0, (options) => {
115
111
  });
116
112
  const files = await operationGenerator.build();
117
113
  await this.addFile(...files);
118
- },
119
- async buildEnd() {
120
- if (this.config.output.write === false) {
121
- return;
122
- }
123
- const root = _path2.default.resolve(this.config.root, this.config.output.path);
124
- if (_optionalChain([group, 'optionalAccess', _8 => _8.type]) === "tag") {
125
- const rootFiles = await _utils3.getGroupedByTagFiles.call(void 0, {
126
- logger: this.logger,
127
- files: this.fileManager.files,
128
- plugin: this.plugin,
129
- template,
130
- exportAs: group.exportAs || "{{tag}}Handlers",
114
+ if (this.config.output.exportType) {
115
+ const barrelFiles = await this.fileManager.getBarrelFiles({
131
116
  root,
132
- output
117
+ output,
118
+ files: this.fileManager.files,
119
+ meta: {
120
+ pluginKey: this.plugin.key
121
+ },
122
+ logger: this.logger
133
123
  });
134
- await this.addFile(...rootFiles);
124
+ await this.addFile(...barrelFiles);
135
125
  }
136
- await this.fileManager.addIndexes({
137
- root,
138
- output,
139
- meta: { pluginKey: this.plugin.key },
140
- logger: this.logger
141
- });
142
126
  }
143
127
  };
144
128
  });
145
129
 
146
-
147
-
148
- exports.pluginMsw = pluginMsw; exports.pluginMswName = pluginMswName;
130
+ exports.pluginMsw = pluginMsw;
131
+ exports.pluginMswName = pluginMswName;
132
+ //# sourceMappingURL=index.cjs.map
149
133
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/kubb/kubb/packages/plugin-msw/dist/index.cjs","../src/plugin.ts","../src/OperationGenerator.tsx"],"names":[],"mappings":"AAAA;AACE;AACA;AACF,wDAA6B;AAC7B;AACA;ACLA,wEAAiB;AAEjB,kCAAyD;AACzD,uDAA0B;AAC1B,yCAA+B;AAC/B,6CAA8B;AAC9B,gDAAqC;AACrC,iDAAgC;AAChC,2CAA6B;ADM7B;AACA;AEfA;AACA,yDAAoB;AACpB,oCAAgC;AA0BI,qDAAA;AAjB7B,IAAM,mBAAA,EAAN,MAAA,QAAiC,8BAAmD;AAAA,EACzF,MAAM,GAAA,CAAI,UAAA,EAAyB,kBAAA,EAAyE;A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AA;AACzC,IAAA;AACwB,IAAA;AACe,MAAA;AACR,QAAA;AACV,QAAA;AAClB,MAAA;AACS,MAAA;AACkC,QAAA;AAC5C,MAAA;AAEO,MAAA;AACT,IAAA;AAC8B,IAAA;AACU,MAAA;AACpC,QAAA;AACF,MAAA;AAE4C,MAAA;AAC9C,IAAA;AACmB,IAAA;AACqD,MAAA;AAE3B,MAAA;AACC,MAAA;AACN,MAAA;AAEP,MAAA;AAC7B,QAAA;AACoB,QAAA;AACP,QAAA;AACkB,QAAA;AAC/B,QAAA;AACA,QAAA;AACA,QAAA;AACA,QAAA;AACD,MAAA;AAE4C,MAAA;AAClB,MAAA;AAC7B,IAAA;AACiB,IAAA;AACyB,MAAA;AACtC,QAAA;AACF,MAAA;AAE4C,MAAA;AAEjB,MAAA;AACD,QAAA;AACT,UAAA;AACW,UAAA;AACX,UAAA;AACb,UAAA;AAC4B,UAAA;AAC5B,UAAA;AACA,UAAA;AACD,QAAA;AAE8B,QAAA;AACjC,MAAA;AAEkC,MAAA;AAChC,QAAA;AACA,QAAA;AACmC,QAAA;AACtB,QAAA;AACd,MAAA;AACH,IAAA;AACF,EAAA;AACD;ADsBkD;AACA;AACA;AACA","file":"/home/runner/work/kubb/kubb/packages/plugin-msw/dist/index.cjs","sourcesContent":[null,"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 { pluginOasName } from '@kubb/plugin-oas'\nimport { getGroupedByTagFiles } from '@kubb/plugin-oas/utils'\nimport { pluginFakerName } from '@kubb/plugin-faker'\nimport { pluginTsName } from '@kubb/plugin-ts'\n\nimport { OperationGenerator } from './OperationGenerator.tsx'\nimport { Mock, Operations } from './components/index.ts'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'\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 = {}, templates } = options\n const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`\n\n return {\n name: pluginMswName,\n options: {\n extName: output.extName,\n templates: {\n operations: Operations.templates,\n mock: Mock.templates,\n ...templates,\n },\n },\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 writeFile(path, source) {\n if (!path.endsWith('.ts') || !source) {\n return\n }\n\n return this.fileManager.write(path, source, { sanity: false })\n },\n async buildStart() {\n const [swaggerPlugin]: [Plugin<SwaggerPluginOptions>] = PluginManager.getDependedPlugins<SwaggerPluginOptions>(this.plugins, [pluginOasName])\n\n const oas = await swaggerPlugin.api.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.api.contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const files = await operationGenerator.build()\n await this.addFile(...files)\n },\n async buildEnd() {\n if (this.config.output.write === false) {\n return\n }\n\n const root = path.resolve(this.config.root, this.config.output.path)\n\n if (group?.type === 'tag') {\n const rootFiles = await getGroupedByTagFiles({\n logger: this.logger,\n files: this.fileManager.files,\n plugin: this.plugin,\n template,\n exportAs: group.exportAs || '{{tag}}Handlers',\n root,\n output,\n })\n\n await this.addFile(...rootFiles)\n }\n\n await this.fileManager.addIndexes({\n root,\n output,\n meta: { pluginKey: this.plugin.key },\n logger: this.logger,\n })\n },\n }\n})\n","import { OperationGenerator as Generator } from '@kubb/plugin-oas'\nimport { Oas } from '@kubb/plugin-oas/components'\nimport { App, createRoot } from '@kubb/react'\n\nimport { Mock } from './components/Mock.tsx'\nimport { Operations } from './components/Operations.tsx'\n\nimport type { Operation } from '@kubb/oas'\nimport type { OperationMethodResult, OperationsByMethod } from '@kubb/plugin-oas'\nimport type { FileMeta, PluginMsw } from './types.ts'\n\nexport class OperationGenerator extends Generator<PluginMsw['resolvedOptions'], PluginMsw> {\n async all(operations: Operation[], operationsByMethod: OperationsByMethod): OperationMethodResult<FileMeta> {\n const { oas, pluginManager, plugin, mode } = this.context\n\n const root = createRoot({\n logger: pluginManager.logger,\n })\n\n const templates = {\n operations: Operations.templates,\n mock: Mock.templates,\n ...this.options.templates,\n }\n\n root.render(\n <App pluginManager={pluginManager} plugin={plugin} mode={mode}>\n <Oas oas={oas} operations={operations} generator={this}>\n {templates?.operations && <Operations.File templates={templates.operations} />}\n </Oas>\n </App>,\n )\n\n return root.files\n }\n\n async operation(operation: Operation, options: PluginMsw['resolvedOptions']): OperationMethodResult<FileMeta> {\n const { oas, pluginManager, plugin, mode } = this.context\n\n const root = createRoot({\n logger: pluginManager.logger,\n })\n\n const templates = {\n handlers: Operations.templates,\n mock: Mock.templates,\n ...options.templates,\n }\n\n if (!templates?.mock) {\n return []\n }\n\n root.render(\n <App pluginManager={pluginManager} plugin={{ ...plugin, options }} mode={mode}>\n <Oas oas={oas} operations={[operation]} generator={this}>\n <Oas.Operation operation={operation}>\n <Mock.File templates={templates.mock} />\n </Oas.Operation>\n </Oas>\n </App>,\n )\n\n return root.files\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/OperationGenerator.tsx","../src/plugin.ts"],"names":["Generator","createRoot","Operations","Mock","jsx","App","Oas","createPlugin","transformers","pluginOasName","pluginTsName","pluginFakerName","options","path","FileManager","camelCase","renderTemplate","PluginManager"],"mappings":";;;;;;;;;;;;;;;;;;AAWO,IAAM,kBAAA,GAAN,cAAiCA,4BAAmD,CAAA;AAAA,EACzF,MAAM,GAAI,CAAA,UAAA,EAAyB,kBAAyE,EAAA;AAC1G,IAAA,MAAM,EAAE,GAAK,EAAA,aAAA,EAAe,MAAQ,EAAA,IAAA,KAAS,IAAK,CAAA,OAAA,CAAA;AAElD,IAAA,MAAM,OAAOC,gBAAW,CAAA;AAAA,MACtB,QAAQ,aAAc,CAAA,MAAA;AAAA,KACvB,CAAA,CAAA;AAED,IAAA,MAAM,SAAY,GAAA;AAAA,MAChB,YAAYC,4BAAW,CAAA,SAAA;AAAA,MACvB,MAAMC,sBAAK,CAAA,SAAA;AAAA,MACX,GAAG,KAAK,OAAQ,CAAA,SAAA;AAAA,KAClB,CAAA;AAEA,IAAK,IAAA,CAAA,MAAA;AAAA,sBACHC,cAAA,CAACC,aAAI,aAA8B,EAAA,MAAA,EAAgB,MACjD,QAAC,kBAAAD,cAAA,CAAAE,cAAA,EAAA,EAAI,KAAU,UAAwB,EAAA,SAAA,EAAW,MAC/C,QAAW,EAAA,SAAA,EAAA,UAAA,mCAAeJ,4BAAW,CAAA,IAAA,EAAX,EAAgB,SAAW,EAAA,SAAA,CAAU,UAAY,EAAA,CAAA,EAC9E,CACF,EAAA,CAAA;AAAA,KACF,CAAA;AAEA,IAAA,OAAO,IAAK,CAAA,KAAA,CAAA;AAAA,GACd;AAAA,EAEA,MAAM,SAAU,CAAA,SAAA,EAAsB,OAAwE,EAAA;AAC5G,IAAA,MAAM,EAAE,GAAK,EAAA,aAAA,EAAe,MAAQ,EAAA,IAAA,KAAS,IAAK,CAAA,OAAA,CAAA;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QACA,IAAA;AAAA,OACD,CAAA,CAAA;AAED,MAAM,MAAA,KAAA,GAAQ,MAAM,kBAAA,CAAmB,KAAM,EAAA,CAAA;AAC7C,MAAM,MAAA,IAAA,CAAK,OAAQ,CAAA,GAAG,KAAK,CAAA,CAAA;AAE3B,MAAI,IAAA,IAAA,CAAK,MAAO,CAAA,MAAA,CAAO,UAAY,EAAA;AACjC,QAAA,MAAM,WAAc,GAAA,MAAM,IAAK,CAAA,WAAA,CAAY,cAAe,CAAA;AAAA,UACxD,IAAA;AAAA,UACA,MAAA;AAAA,UACA,KAAA,EAAO,KAAK,WAAY,CAAA,KAAA;AAAA,UACxB,IAAM,EAAA;AAAA,YACJ,SAAA,EAAW,KAAK,MAAO,CAAA,GAAA;AAAA,WACzB;AAAA,UACA,QAAQ,IAAK,CAAA,MAAA;AAAA,SACd,CAAA,CAAA;AAED,QAAM,MAAA,IAAA,CAAK,OAAQ,CAAA,GAAG,WAAW,CAAA,CAAA;AAAA,OACnC;AAAA,KACF;AAAA,GACF,CAAA;AACF,CAAC","file":"index.cjs","sourcesContent":["import { OperationGenerator as Generator } from '@kubb/plugin-oas'\nimport { Oas } from '@kubb/plugin-oas/components'\nimport { App, createRoot } from '@kubb/react'\n\nimport { Mock } from './components/Mock.tsx'\nimport { Operations } from './components/Operations.tsx'\n\nimport type { Operation } from '@kubb/oas'\nimport type { OperationMethodResult, OperationsByMethod } from '@kubb/plugin-oas'\nimport type { FileMeta, PluginMsw } from './types.ts'\n\nexport class OperationGenerator extends Generator<PluginMsw['resolvedOptions'], PluginMsw> {\n async all(operations: Operation[], operationsByMethod: OperationsByMethod): OperationMethodResult<FileMeta> {\n const { oas, pluginManager, plugin, mode } = this.context\n\n const root = createRoot({\n logger: pluginManager.logger,\n })\n\n const templates = {\n operations: Operations.templates,\n mock: Mock.templates,\n ...this.options.templates,\n }\n\n root.render(\n <App pluginManager={pluginManager} plugin={plugin} mode={mode}>\n <Oas oas={oas} operations={operations} generator={this}>\n {templates?.operations && <Operations.File templates={templates.operations} />}\n </Oas>\n </App>,\n )\n\n return root.files\n }\n\n async operation(operation: Operation, options: PluginMsw['resolvedOptions']): OperationMethodResult<FileMeta> {\n const { oas, pluginManager, plugin, mode } = this.context\n\n const root = createRoot({\n logger: pluginManager.logger,\n })\n\n const templates = {\n handlers: Operations.templates,\n mock: Mock.templates,\n ...options.templates,\n }\n\n if (!templates?.mock) {\n return []\n }\n\n root.render(\n <App pluginManager={pluginManager} plugin={{ ...plugin, options }} mode={mode}>\n <Oas oas={oas} operations={[operation]} generator={this}>\n <Oas.Operation operation={operation}>\n <Mock.File templates={templates.mock} />\n </Oas.Operation>\n </Oas>\n </App>,\n )\n\n return root.files\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 { pluginOasName } from '@kubb/plugin-oas'\n\nimport { pluginFakerName } from '@kubb/plugin-faker'\nimport { pluginTsName } from '@kubb/plugin-ts'\n\nimport { OperationGenerator } from './OperationGenerator.tsx'\nimport { Mock, Operations } from './components/index.ts'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'\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 = {}, templates } = 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 extName: output.extName,\n templates: {\n operations: Operations.templates,\n mock: Mock.templates,\n ...templates,\n },\n },\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()\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"]}
package/dist/index.d.cts CHANGED
@@ -6,7 +6,7 @@ import { Operations, Mock } from './components.cjs';
6
6
  import '@kubb/core/utils';
7
7
  import '@kubb/oas';
8
8
  import 'react';
9
- import '@kubb/react';
9
+ import '@kubb/react/types';
10
10
 
11
11
  type Templates = {
12
12
  operations?: typeof Operations.templates | false;
package/dist/index.d.ts CHANGED
@@ -6,7 +6,7 @@ import { Operations, Mock } from './components.js';
6
6
  import '@kubb/core/utils';
7
7
  import '@kubb/oas';
8
8
  import 'react';
9
- import '@kubb/react';
9
+ import '@kubb/react/types';
10
10
 
11
11
  type Templates = {
12
12
  operations?: typeof Operations.templates | false;
package/dist/index.js CHANGED
@@ -1,24 +1,16 @@
1
- import {
2
- Mock,
3
- Operations
4
- } from "./chunk-WRIEMCYI.js";
1
+ import { Operations, Mock } from './chunk-3KHLTEUD.js';
2
+ import path from 'node:path';
3
+ import { createPlugin, FileManager, PluginManager } from '@kubb/core';
4
+ import { camelCase } from '@kubb/core/transformers';
5
+ import { renderTemplate } from '@kubb/core/utils';
6
+ import { pluginOasName, OperationGenerator as OperationGenerator$1 } from '@kubb/plugin-oas';
7
+ import { pluginFakerName } from '@kubb/plugin-faker';
8
+ import { pluginTsName } from '@kubb/plugin-ts';
9
+ import { Oas } from '@kubb/plugin-oas/components';
10
+ import { createRoot, App } from '@kubb/react';
11
+ import { jsx } from '@kubb/react/jsx-runtime';
5
12
 
6
- // src/plugin.ts
7
- import path from "path";
8
- import { FileManager, PluginManager, createPlugin } from "@kubb/core";
9
- import { camelCase } from "@kubb/core/transformers";
10
- import { renderTemplate } from "@kubb/core/utils";
11
- import { pluginOasName } from "@kubb/plugin-oas";
12
- import { getGroupedByTagFiles } from "@kubb/plugin-oas/utils";
13
- import { pluginFakerName } from "@kubb/plugin-faker";
14
- import { pluginTsName } from "@kubb/plugin-ts";
15
-
16
- // src/OperationGenerator.tsx
17
- import { OperationGenerator as Generator } from "@kubb/plugin-oas";
18
- import { Oas } from "@kubb/plugin-oas/components";
19
- import { App, createRoot } from "@kubb/react";
20
- import { jsx } from "@kubb/react/jsx-runtime";
21
- var OperationGenerator = class extends Generator {
13
+ var OperationGenerator = class extends OperationGenerator$1 {
22
14
  async all(operations, operationsByMethod) {
23
15
  const { oas, pluginManager, plugin, mode } = this.context;
24
16
  const root = createRoot({
@@ -61,6 +53,10 @@ var pluginMsw = createPlugin((options) => {
61
53
  const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`;
62
54
  return {
63
55
  name: pluginMswName,
56
+ output: {
57
+ exportType: "barrelNamed",
58
+ ...output
59
+ },
64
60
  options: {
65
61
  extName: output.extName,
66
62
  templates: {
@@ -92,22 +88,16 @@ var pluginMsw = createPlugin((options) => {
92
88
  }
93
89
  return resolvedName;
94
90
  },
95
- async writeFile(path2, source) {
96
- if (!path2.endsWith(".ts") || !source) {
97
- return;
98
- }
99
- return this.fileManager.write(path2, source, { sanity: false });
100
- },
101
91
  async buildStart() {
102
92
  const [swaggerPlugin] = PluginManager.getDependedPlugins(this.plugins, [pluginOasName]);
103
- const oas = await swaggerPlugin.api.getOas();
93
+ const oas = await swaggerPlugin.context.getOas();
104
94
  const root = path.resolve(this.config.root, this.config.output.path);
105
95
  const mode = FileManager.getMode(path.resolve(root, output.path));
106
96
  const operationGenerator = new OperationGenerator(this.plugin.options, {
107
97
  oas,
108
98
  pluginManager: this.pluginManager,
109
99
  plugin: this.plugin,
110
- contentType: swaggerPlugin.api.contentType,
100
+ contentType: swaggerPlugin.context.contentType,
111
101
  exclude,
112
102
  include,
113
103
  override,
@@ -115,35 +105,22 @@ var pluginMsw = createPlugin((options) => {
115
105
  });
116
106
  const files = await operationGenerator.build();
117
107
  await this.addFile(...files);
118
- },
119
- async buildEnd() {
120
- if (this.config.output.write === false) {
121
- return;
122
- }
123
- const root = path.resolve(this.config.root, this.config.output.path);
124
- if (group?.type === "tag") {
125
- const rootFiles = await getGroupedByTagFiles({
126
- logger: this.logger,
127
- files: this.fileManager.files,
128
- plugin: this.plugin,
129
- template,
130
- exportAs: group.exportAs || "{{tag}}Handlers",
108
+ if (this.config.output.exportType) {
109
+ const barrelFiles = await this.fileManager.getBarrelFiles({
131
110
  root,
132
- output
111
+ output,
112
+ files: this.fileManager.files,
113
+ meta: {
114
+ pluginKey: this.plugin.key
115
+ },
116
+ logger: this.logger
133
117
  });
134
- await this.addFile(...rootFiles);
118
+ await this.addFile(...barrelFiles);
135
119
  }
136
- await this.fileManager.addIndexes({
137
- root,
138
- output,
139
- meta: { pluginKey: this.plugin.key },
140
- logger: this.logger
141
- });
142
120
  }
143
121
  };
144
122
  });
145
- export {
146
- pluginMsw,
147
- pluginMswName
148
- };
123
+
124
+ export { pluginMsw, pluginMswName };
125
+ //# sourceMappingURL=index.js.map
149
126
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/plugin.ts","../src/OperationGenerator.tsx"],"sourcesContent":["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 { pluginOasName } from '@kubb/plugin-oas'\nimport { getGroupedByTagFiles } from '@kubb/plugin-oas/utils'\nimport { pluginFakerName } from '@kubb/plugin-faker'\nimport { pluginTsName } from '@kubb/plugin-ts'\n\nimport { OperationGenerator } from './OperationGenerator.tsx'\nimport { Mock, Operations } from './components/index.ts'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'\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 = {}, templates } = options\n const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`\n\n return {\n name: pluginMswName,\n options: {\n extName: output.extName,\n templates: {\n operations: Operations.templates,\n mock: Mock.templates,\n ...templates,\n },\n },\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 writeFile(path, source) {\n if (!path.endsWith('.ts') || !source) {\n return\n }\n\n return this.fileManager.write(path, source, { sanity: false })\n },\n async buildStart() {\n const [swaggerPlugin]: [Plugin<SwaggerPluginOptions>] = PluginManager.getDependedPlugins<SwaggerPluginOptions>(this.plugins, [pluginOasName])\n\n const oas = await swaggerPlugin.api.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.api.contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const files = await operationGenerator.build()\n await this.addFile(...files)\n },\n async buildEnd() {\n if (this.config.output.write === false) {\n return\n }\n\n const root = path.resolve(this.config.root, this.config.output.path)\n\n if (group?.type === 'tag') {\n const rootFiles = await getGroupedByTagFiles({\n logger: this.logger,\n files: this.fileManager.files,\n plugin: this.plugin,\n template,\n exportAs: group.exportAs || '{{tag}}Handlers',\n root,\n output,\n })\n\n await this.addFile(...rootFiles)\n }\n\n await this.fileManager.addIndexes({\n root,\n output,\n meta: { pluginKey: this.plugin.key },\n logger: this.logger,\n })\n },\n }\n})\n","import { OperationGenerator as Generator } from '@kubb/plugin-oas'\nimport { Oas } from '@kubb/plugin-oas/components'\nimport { App, createRoot } from '@kubb/react'\n\nimport { Mock } from './components/Mock.tsx'\nimport { Operations } from './components/Operations.tsx'\n\nimport type { Operation } from '@kubb/oas'\nimport type { OperationMethodResult, OperationsByMethod } from '@kubb/plugin-oas'\nimport type { FileMeta, PluginMsw } from './types.ts'\n\nexport class OperationGenerator extends Generator<PluginMsw['resolvedOptions'], PluginMsw> {\n async all(operations: Operation[], operationsByMethod: OperationsByMethod): OperationMethodResult<FileMeta> {\n const { oas, pluginManager, plugin, mode } = this.context\n\n const root = createRoot({\n logger: pluginManager.logger,\n })\n\n const templates = {\n operations: Operations.templates,\n mock: Mock.templates,\n ...this.options.templates,\n }\n\n root.render(\n <App pluginManager={pluginManager} plugin={plugin} mode={mode}>\n <Oas oas={oas} operations={operations} generator={this}>\n {templates?.operations && <Operations.File templates={templates.operations} />}\n </Oas>\n </App>,\n )\n\n return root.files\n }\n\n async operation(operation: Operation, options: PluginMsw['resolvedOptions']): OperationMethodResult<FileMeta> {\n const { oas, pluginManager, plugin, mode } = this.context\n\n const root = createRoot({\n logger: pluginManager.logger,\n })\n\n const templates = {\n handlers: Operations.templates,\n mock: Mock.templates,\n ...options.templates,\n }\n\n if (!templates?.mock) {\n return []\n }\n\n root.render(\n <App pluginManager={pluginManager} plugin={{ ...plugin, options }} mode={mode}>\n <Oas oas={oas} operations={[operation]} generator={this}>\n <Oas.Operation operation={operation}>\n <Mock.File templates={templates.mock} />\n </Oas.Operation>\n </Oas>\n </App>,\n )\n\n return root.files\n }\n}\n"],"mappings":";;;;;;AAAA,OAAO,UAAU;AAEjB,SAAS,aAAa,eAAe,oBAAoB;AACzD,SAAS,iBAAiB;AAC1B,SAAS,sBAAsB;AAC/B,SAAS,qBAAqB;AAC9B,SAAS,4BAA4B;AACrC,SAAS,uBAAuB;AAChC,SAAS,oBAAoB;;;ACR7B,SAAS,sBAAsB,iBAAiB;AAChD,SAAS,WAAW;AACpB,SAAS,KAAK,kBAAkB;AA0BI;AAjB7B,IAAM,qBAAN,cAAiC,UAAmD;AAAA,EACzF,MAAM,IAAI,YAAyB,oBAAyE;AAC1G,UAAM,EAAE,KAAK,eAAe,QAAQ,KAAK,IAAI,KAAK;AAElD,UAAM,OAAO,WAAW;AAAA,MACtB,QAAQ,cAAc;AAAA,IACxB,CAAC;AAED,UAAM,YAAY;AAAA,MAChB,YAAY,WAAW;AAAA,MACvB,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nE,YAAM,OAAO,YAAY,QAAQ,KAAK,QAAQ,MAAM,OAAO,IAAI,CAAC;AAEhE,YAAM,qBAAqB,IAAI,mBAAmB,KAAK,OAAO,SAAS;AAAA,QACrE;AAAA,QACA,eAAe,KAAK;AAAA,QACpB,QAAQ,KAAK;AAAA,QACb,aAAa,cAAc,IAAI;AAAA,QAC/B;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF,CAAC;AAED,YAAM,QAAQ,MAAM,mBAAmB,MAAM;AAC7C,YAAM,KAAK,QAAQ,GAAG,KAAK;AAAA,IAC7B;AAAA,IACA,MAAM,WAAW;AACf,UAAI,KAAK,OAAO,OAAO,UAAU,OAAO;AACtC;AAAA,MACF;AAEA,YAAM,OAAO,KAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,IAAI;AAEnE,UAAI,OAAO,SAAS,OAAO;AACzB,cAAM,YAAY,MAAM,qBAAqB;AAAA,UAC3C,QAAQ,KAAK;AAAA,UACb,OAAO,KAAK,YAAY;AAAA,UACxB,QAAQ,KAAK;AAAA,UACb;AAAA,UACA,UAAU,MAAM,YAAY;AAAA,UAC5B;AAAA,UACA;AAAA,QACF,CAAC;AAED,cAAM,KAAK,QAAQ,GAAG,SAAS;AAAA,MACjC;AAEA,YAAM,KAAK,YAAY,WAAW;AAAA,QAChC;AAAA,QACA;AAAA,QACA,MAAM,EAAE,WAAW,KAAK,OAAO,IAAI;AAAA,QACnC,QAAQ,KAAK;AAAA,MACf,CAAC;AAAA,IACH;AAAA,EACF;AACF,CAAC;","names":["options","path"]}
1
+ {"version":3,"sources":["../src/OperationGenerator.tsx","../src/plugin.ts"],"names":["Generator","options"],"mappings":";;;;;;;;;;;;AAWO,IAAM,kBAAA,GAAN,cAAiCA,oBAAmD,CAAA;AAAA,EACzF,MAAM,GAAI,CAAA,UAAA,EAAyB,kBAAyE,EAAA;AAC1G,IAAA,MAAM,EAAE,GAAK,EAAA,aAAA,EAAe,MAAQ,EAAA,IAA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,WACzB;AAAA,UACA,QAAQ,IAAK,CAAA,MAAA;AAAA,SACd,CAAA,CAAA;AAED,QAAM,MAAA,IAAA,CAAK,OAAQ,CAAA,GAAG,WAAW,CAAA,CAAA;AAAA,OACnC;AAAA,KACF;AAAA,GACF,CAAA;AACF,CAAC","file":"index.js","sourcesContent":["import { OperationGenerator as Generator } from '@kubb/plugin-oas'\nimport { Oas } from '@kubb/plugin-oas/components'\nimport { App, createRoot } from '@kubb/react'\n\nimport { Mock } from './components/Mock.tsx'\nimport { Operations } from './components/Operations.tsx'\n\nimport type { Operation } from '@kubb/oas'\nimport type { OperationMethodResult, OperationsByMethod } from '@kubb/plugin-oas'\nimport type { FileMeta, PluginMsw } from './types.ts'\n\nexport class OperationGenerator extends Generator<PluginMsw['resolvedOptions'], PluginMsw> {\n async all(operations: Operation[], operationsByMethod: OperationsByMethod): OperationMethodResult<FileMeta> {\n const { oas, pluginManager, plugin, mode } = this.context\n\n const root = createRoot({\n logger: pluginManager.logger,\n })\n\n const templates = {\n operations: Operations.templates,\n mock: Mock.templates,\n ...this.options.templates,\n }\n\n root.render(\n <App pluginManager={pluginManager} plugin={plugin} mode={mode}>\n <Oas oas={oas} operations={operations} generator={this}>\n {templates?.operations && <Operations.File templates={templates.operations} />}\n </Oas>\n </App>,\n )\n\n return root.files\n }\n\n async operation(operation: Operation, options: PluginMsw['resolvedOptions']): OperationMethodResult<FileMeta> {\n const { oas, pluginManager, plugin, mode } = this.context\n\n const root = createRoot({\n logger: pluginManager.logger,\n })\n\n const templates = {\n handlers: Operations.templates,\n mock: Mock.templates,\n ...options.templates,\n }\n\n if (!templates?.mock) {\n return []\n }\n\n root.render(\n <App pluginManager={pluginManager} plugin={{ ...plugin, options }} mode={mode}>\n <Oas oas={oas} operations={[operation]} generator={this}>\n <Oas.Operation operation={operation}>\n <Mock.File templates={templates.mock} />\n </Oas.Operation>\n </Oas>\n </App>,\n )\n\n return root.files\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 { pluginOasName } from '@kubb/plugin-oas'\n\nimport { pluginFakerName } from '@kubb/plugin-faker'\nimport { pluginTsName } from '@kubb/plugin-ts'\n\nimport { OperationGenerator } from './OperationGenerator.tsx'\nimport { Mock, Operations } from './components/index.ts'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'\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 = {}, templates } = 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 extName: output.extName,\n templates: {\n operations: Operations.templates,\n mock: Mock.templates,\n ...templates,\n },\n },\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()\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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-msw",
3
- "version": "3.0.0-alpha.1",
3
+ "version": "3.0.0-alpha.11",
4
4
  "description": "Generator swagger",
5
5
  "keywords": [
6
6
  "typescript",
@@ -66,27 +66,27 @@
66
66
  "!/**/__tests__/**"
67
67
  ],
68
68
  "dependencies": {
69
- "@kubb/core": "3.0.0-alpha.1",
70
- "@kubb/fs": "3.0.0-alpha.1",
71
- "@kubb/oas": "3.0.0-alpha.1",
72
- "@kubb/parser-ts": "3.0.0-alpha.1",
73
- "@kubb/plugin-faker": "3.0.0-alpha.1",
74
- "@kubb/plugin-oas": "3.0.0-alpha.1",
75
- "@kubb/plugin-ts": "3.0.0-alpha.1",
76
- "@kubb/react": "3.0.0-alpha.1"
69
+ "@kubb/core": "3.0.0-alpha.11",
70
+ "@kubb/fs": "3.0.0-alpha.11",
71
+ "@kubb/oas": "3.0.0-alpha.11",
72
+ "@kubb/parser-ts": "3.0.0-alpha.11",
73
+ "@kubb/plugin-faker": "3.0.0-alpha.11",
74
+ "@kubb/plugin-oas": "3.0.0-alpha.11",
75
+ "@kubb/plugin-ts": "3.0.0-alpha.11",
76
+ "@kubb/react": "3.0.0-alpha.11"
77
77
  },
78
78
  "devDependencies": {
79
- "@types/react": "^18.3.4",
79
+ "@types/react": "^18.3.5",
80
80
  "@types/react-dom": "^18.3.0",
81
81
  "react": "^18.3.1",
82
82
  "tsup": "^8.2.4",
83
83
  "typescript": "^5.5.4",
84
- "@kubb/config-biome": "3.0.0-alpha.1",
85
- "@kubb/config-ts": "3.0.0-alpha.1",
86
- "@kubb/config-tsup": "3.0.0-alpha.1"
84
+ "@kubb/config-biome": "3.0.0-alpha.11",
85
+ "@kubb/config-ts": "3.0.0-alpha.11",
86
+ "@kubb/config-tsup": "3.0.0-alpha.11"
87
87
  },
88
88
  "peerDependencies": {
89
- "@kubb/react": "3.0.0-alpha.1"
89
+ "@kubb/react": "3.0.0-alpha.11"
90
90
  },
91
91
  "engines": {
92
92
  "node": ">=20"
@@ -1,6 +1,5 @@
1
- import { PackageManager } from '@kubb/core'
2
1
  import { URLPath } from '@kubb/core/utils'
3
- import { Parser, File, useApp } from '@kubb/react'
2
+ import { File, useApp } from '@kubb/react'
4
3
  import { pluginFakerName } from '@kubb/plugin-faker'
5
4
  import { useOperation, useOperationManager } from '@kubb/plugin-oas/hooks'
6
5
 
@@ -30,7 +29,7 @@ type TemplateProps = {
30
29
 
31
30
  function Template({ name, method, path, responseName }: TemplateProps): ReactNode {
32
31
  return (
33
- <>
32
+ <File.Source name={name} isExportable isIndexable>
34
33
  {`
35
34
  export const ${name} = http.${method}('*${path.toURLPath()}', function handler(info) {
36
35
  return new Response(JSON.stringify(${responseName}()), {
@@ -40,7 +39,7 @@ function Template({ name, method, path, responseName }: TemplateProps): ReactNod
40
39
  })
41
40
  })
42
41
  `}
43
- </>
42
+ </File.Source>
44
43
  )
45
44
  }
46
45
 
@@ -98,15 +97,11 @@ Mock.File = function ({ templates = defaultTemplates }: FileProps): ReactNode {
98
97
  const Template = templates.default
99
98
 
100
99
  return (
101
- <Parser language="typescript">
102
- <File<FileMeta> baseName={file.baseName} path={file.path} meta={file.meta}>
103
- <File.Import name={['http']} path={'msw'} />
104
- {fileFaker && responseName && <File.Import extName={extName} name={[responseName]} root={file.path} path={fileFaker.path} />}
105
- <File.Source>
106
- <Mock Template={Template} />
107
- </File.Source>
108
- </File>
109
- </Parser>
100
+ <File<FileMeta> baseName={file.baseName} path={file.path} meta={file.meta}>
101
+ <File.Import name={['http']} path={'msw'} />
102
+ {fileFaker && responseName && <File.Import name={[responseName]} root={file.path} path={fileFaker.path} />}
103
+ <Mock Template={Template} />
104
+ </File>
110
105
  )
111
106
  }
112
107
 
@@ -1,7 +1,7 @@
1
- import { Parser, File, useApp } from '@kubb/react'
2
1
  import { useOperationManager, useOperations } from '@kubb/plugin-oas/hooks'
2
+ import { File, useApp } from '@kubb/react'
3
3
 
4
- import type { KubbNode } from '@kubb/react'
4
+ import type { KubbNode } from '@kubb/react/types'
5
5
  import type { ReactNode } from 'react'
6
6
  import type { FileMeta, PluginMsw } from '../types.ts'
7
7
 
@@ -14,7 +14,7 @@ type TemplateProps = {
14
14
  }
15
15
 
16
16
  function Template({ name, handlers }: TemplateProps): ReactNode {
17
- return <>{`export const ${name} = ${JSON.stringify(handlers).replaceAll(`"`, '')} as const`}</>
17
+ return <File.Source name={name} isExportable isIndexable>{`export const ${name} = ${JSON.stringify(handlers).replaceAll(`"`, '')} as const`}</File.Source>
18
18
  }
19
19
 
20
20
  type ParserTemplateProps = {
@@ -42,12 +42,10 @@ function RootTemplate({ children }: ParserTemplateProps) {
42
42
  .filter(Boolean)
43
43
 
44
44
  return (
45
- <Parser language="typescript">
46
- <File<FileMeta> baseName={file.baseName} path={file.path} meta={file.meta}>
47
- {imports}
48
- <File.Source>{children}</File.Source>
49
- </File>
50
- </Parser>
45
+ <File<FileMeta> baseName={file.baseName} path={file.path} meta={file.meta}>
46
+ {imports}
47
+ {children}
48
+ </File>
51
49
  )
52
50
  }
53
51
 
@@ -1,7 +1,7 @@
1
1
  export const createPets = http.post('*/pets', function handler(info) {
2
- return new Response(JSON.stringify(CreatePetsMutationResponse()), {
3
- headers: {
4
- 'Content-Type': 'application/json',
5
- },
6
- })
7
- })
2
+ return new Response(JSON.stringify(CreatePetsMutationResponse()), {
3
+ headers: {
4
+ 'Content-Type': 'application/json',
5
+ },
6
+ })
7
+ })
@@ -1,7 +1,7 @@
1
1
  export const showPetById = http.get('*/pets/:petId', function handler(info) {
2
- return new Response(JSON.stringify(ShowPetByIdQueryResponse()), {
3
- headers: {
4
- 'Content-Type': 'application/json',
5
- },
6
- })
7
- })
2
+ return new Response(JSON.stringify(ShowPetByIdQueryResponse()), {
3
+ headers: {
4
+ 'Content-Type': 'application/json',
5
+ },
6
+ })
7
+ })
package/src/plugin.ts CHANGED
@@ -4,7 +4,7 @@ import { FileManager, PluginManager, createPlugin } from '@kubb/core'
4
4
  import { camelCase } from '@kubb/core/transformers'
5
5
  import { renderTemplate } from '@kubb/core/utils'
6
6
  import { pluginOasName } from '@kubb/plugin-oas'
7
- import { getGroupedByTagFiles } from '@kubb/plugin-oas/utils'
7
+
8
8
  import { pluginFakerName } from '@kubb/plugin-faker'
9
9
  import { pluginTsName } from '@kubb/plugin-ts'
10
10
 
@@ -23,6 +23,10 @@ export const pluginMsw = createPlugin<PluginMsw>((options) => {
23
23
 
24
24
  return {
25
25
  name: pluginMswName,
26
+ output: {
27
+ exportType: 'barrelNamed',
28
+ ...output,
29
+ },
26
30
  options: {
27
31
  extName: output.extName,
28
32
  templates: {
@@ -63,17 +67,10 @@ export const pluginMsw = createPlugin<PluginMsw>((options) => {
63
67
 
64
68
  return resolvedName
65
69
  },
66
- async writeFile(path, source) {
67
- if (!path.endsWith('.ts') || !source) {
68
- return
69
- }
70
-
71
- return this.fileManager.write(path, source, { sanity: false })
72
- },
73
70
  async buildStart() {
74
71
  const [swaggerPlugin]: [Plugin<SwaggerPluginOptions>] = PluginManager.getDependedPlugins<SwaggerPluginOptions>(this.plugins, [pluginOasName])
75
72
 
76
- const oas = await swaggerPlugin.api.getOas()
73
+ const oas = await swaggerPlugin.context.getOas()
77
74
  const root = path.resolve(this.config.root, this.config.output.path)
78
75
  const mode = FileManager.getMode(path.resolve(root, output.path))
79
76
 
@@ -81,7 +78,7 @@ export const pluginMsw = createPlugin<PluginMsw>((options) => {
81
78
  oas,
82
79
  pluginManager: this.pluginManager,
83
80
  plugin: this.plugin,
84
- contentType: swaggerPlugin.api.contentType,
81
+ contentType: swaggerPlugin.context.contentType,
85
82
  exclude,
86
83
  include,
87
84
  override,
@@ -90,34 +87,20 @@ export const pluginMsw = createPlugin<PluginMsw>((options) => {
90
87
 
91
88
  const files = await operationGenerator.build()
92
89
  await this.addFile(...files)
93
- },
94
- async buildEnd() {
95
- if (this.config.output.write === false) {
96
- return
97
- }
98
90
 
99
- const root = path.resolve(this.config.root, this.config.output.path)
100
-
101
- if (group?.type === 'tag') {
102
- const rootFiles = await getGroupedByTagFiles({
103
- logger: this.logger,
104
- files: this.fileManager.files,
105
- plugin: this.plugin,
106
- template,
107
- exportAs: group.exportAs || '{{tag}}Handlers',
91
+ if (this.config.output.exportType) {
92
+ const barrelFiles = await this.fileManager.getBarrelFiles({
108
93
  root,
109
94
  output,
95
+ files: this.fileManager.files,
96
+ meta: {
97
+ pluginKey: this.plugin.key,
98
+ },
99
+ logger: this.logger,
110
100
  })
111
101
 
112
- await this.addFile(...rootFiles)
102
+ await this.addFile(...barrelFiles)
113
103
  }
114
-
115
- await this.fileManager.addIndexes({
116
- root,
117
- output,
118
- meta: { pluginKey: this.plugin.key },
119
- logger: this.logger,
120
- })
121
104
  },
122
105
  }
123
106
  })
@@ -1,105 +0,0 @@
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
@@ -1 +0,0 @@
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,EAAA,CAOjD,CAAA;AAEJ;AAEA,IAAM,iBAAA,EAAmB,EAAE,OAAA,EAAS,SAAS,CAAA;AAStC,SAAS,IAAA,CAAK,EAAE,QAAA,EAAAA,UAAAA,EAAW,gBAAA,CAAiB,QAAQ,CAAA,EAAqB;AAC9E,EAAA,MAAM,EAAE,cAAc,EAAA,EAAI,2BAAA,CAAkB;AAC5C,EAAA,MAAM,EAAE,UAAA,EAAY,QAAQ,EAAA,EAAI,wCAAA,CAAoB;AACpD,EAAA,MAAM,UAAA,EAAY,iCAAA,CAAa;A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'@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"]}
@@ -1 +0,0 @@
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;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