@kubb/plugin-msw 3.0.0-alpha.0 → 3.0.0-alpha.10

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,11 @@
1
1
  // src/components/Mock.tsx
2
- import "@kubb/core";
3
2
  import { URLPath } from "@kubb/core/utils";
4
- import { Parser, File, useApp } from "@kubb/react";
3
+ import { File, useApp } from "@kubb/react";
5
4
  import { pluginFakerName } from "@kubb/plugin-faker";
6
5
  import { useOperation, useOperationManager } from "@kubb/plugin-oas/hooks";
7
- import { Fragment, jsx, jsxs } from "@kubb/react/jsx-runtime";
6
+ import { jsx, jsxs } from "@kubb/react/jsx-runtime";
8
7
  function Template({ name, method, path, responseName }) {
9
- return /* @__PURE__ */ jsx(Fragment, { children: `
8
+ return /* @__PURE__ */ jsx(File.Source, { name, isExportable: true, isIndexable: true, children: `
10
9
  export const ${name} = http.${method}('*${path.toURLPath()}', function handler(info) {
11
10
  return new Response(JSON.stringify(${responseName}()), {
12
11
  headers: {
@@ -48,20 +47,20 @@ Mock.File = function({ templates = defaultTemplates }) {
48
47
  type: "function"
49
48
  });
50
49
  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: [
50
+ return /* @__PURE__ */ jsxs(File, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
52
51
  /* @__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
- ] }) });
52
+ fileFaker && responseName && /* @__PURE__ */ jsx(File.Import, { name: [responseName], root: file.path, path: fileFaker.path }),
53
+ /* @__PURE__ */ jsx(Mock, { Template: Template3 })
54
+ ] });
56
55
  };
57
56
  Mock.templates = defaultTemplates;
58
57
 
59
58
  // src/components/Operations.tsx
60
- import { Parser as Parser2, File as File2, useApp as useApp2 } from "@kubb/react";
61
59
  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";
60
+ import { File as File2, useApp as useApp2 } from "@kubb/react";
61
+ import { jsx as jsx2, jsxs as jsxs2 } from "@kubb/react/jsx-runtime";
63
62
  function Template2({ name, handlers }) {
64
- return /* @__PURE__ */ jsx2(Fragment2, { children: `export const ${name} = ${JSON.stringify(handlers).replaceAll(`"`, "")} as const` });
63
+ return /* @__PURE__ */ jsx2(File2.Source, { name, isExportable: true, isIndexable: true, children: `export const ${name} = ${JSON.stringify(handlers).replaceAll(`"`, "")} as const` });
65
64
  }
66
65
  function RootTemplate({ children }) {
67
66
  const {
@@ -76,10 +75,10 @@ function RootTemplate({ children }) {
76
75
  const operationName = getName(operation, { pluginKey, type: "function" });
77
76
  return /* @__PURE__ */ jsx2(File2.Import, { name: [operationName], root: file.path, path: operationFile.path }, operationFile.path);
78
77
  }).filter(Boolean);
79
- return /* @__PURE__ */ jsx2(Parser2, { language: "typescript", children: /* @__PURE__ */ jsxs2(File2, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
78
+ return /* @__PURE__ */ jsxs2(File2, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
80
79
  imports,
81
- /* @__PURE__ */ jsx2(File2.Source, { children })
82
- ] }) });
80
+ children
81
+ ] });
83
82
  }
84
83
  var defaultTemplates2 = { default: Template2, root: RootTemplate };
85
84
  function Operations({ Template: Template3 = defaultTemplates2.default }) {
@@ -102,4 +101,4 @@ export {
102
101
  Mock,
103
102
  Operations
104
103
  };
105
- //# sourceMappingURL=chunk-WRIEMCYI.js.map
104
+ //# sourceMappingURL=chunk-3KHLTEUD.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/Mock.tsx","../src/components/Operations.tsx"],"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"],"mappings":";AAAA,SAAS,eAAe;AACxB,SAAS,MAAM,cAAc;AAC7B,SAAS,uBAAuB;AAChC,SAAS,cAAc,2BAA2B;AA4B9C,cAoEA,YApEA;AAFJ,SAAS,SAAS,EAAE,MAAM,QAAQ,MAAM,aAAa,GAA6B;AAChF,SACE,oBAAC,KAAK,QAAL,EAAY,MAAY,cAAY,MAAC,aAAW,MAC9C;AAAA,iBACU,IAAI,WAAW,MAAM,MAAM,KAAK,UAAU,CAAC;AAAA,yCACnB,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KAOjD;AAEJ;AAEA,IAAM,mBAAmB,EAAE,SAAS,SAAS;AAStC,SAAS,KAAK,EAAE,UAAAA,YAAW,iBAAiB,QAAQ,GAAqB;AAC9E,QAAM,EAAE,cAAc,IAAI,OAAkB;AAC5C,QAAM,EAAE,YAAY,QAAQ,IAAI,oBAAoB;AACpD,QAAM,YAAY,aAAa;AAE/B,QAAM,UAAU,WAAW,SAAS;AACpC,QAAM,OAAO,QAAQ,WAAW,EAAE,MAAM,WAAW,CAAC;AACpD,QAAM,eAAe,cAAc,YAAY;AAAA,IAC7C,WAAW,CAAC,eAAe;AAAA,IAC3B,MAAM,QAAQ,SAAS;AAAA,IACvB,MAAM;AAAA,EACR,CAAC;AAED,SAAO,oBAACA,WAAA,EAAS,MAAY,cAA4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3B,QAAME,gBAAe,UAAU;AAE/B,SACE,gBAAAJ,KAACI,eAAA,EACC,0BAAAJ,KAAC,cAAW,UAAUE,WAAU,GAClC;AAEJ;AAEA,WAAW,YAAYC;","names":["Template","useOperationManager","File","useApp","jsx","jsxs","Template","defaultTemplates","RootTemplate"]}
@@ -1,12 +1,11 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/components/Mock.tsx
2
- require('@kubb/core');
3
2
  var _utils = require('@kubb/core/utils');
4
3
  var _react = require('@kubb/react');
5
4
  var _pluginfaker = require('@kubb/plugin-faker');
6
5
  var _hooks = require('@kubb/plugin-oas/hooks');
7
6
  var _jsxruntime = require('@kubb/react/jsx-runtime');
8
7
  function Template({ name, method, path, responseName }) {
9
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, { children: `
8
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Source, { name, isExportable: true, isIndexable: true, children: `
10
9
  export const ${name} = http.${method}('*${path.toURLPath()}', function handler(info) {
11
10
  return new Response(JSON.stringify(${responseName}()), {
12
11
  headers: {
@@ -48,11 +47,11 @@ Mock.File = function({ templates = defaultTemplates }) {
48
47
  type: "function"
49
48
  });
50
49
  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: [
50
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _react.File, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
52
51
  /* @__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
- ] }) });
52
+ fileFaker && responseName && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Import, { name: [responseName], root: file.path, path: fileFaker.path }),
53
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Mock, { Template: Template3 })
54
+ ] });
56
55
  };
57
56
  Mock.templates = defaultTemplates;
58
57
 
@@ -61,7 +60,7 @@ Mock.templates = defaultTemplates;
61
60
 
62
61
 
63
62
  function Template2({ name, handlers }) {
64
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, { children: `export const ${name} = ${JSON.stringify(handlers).replaceAll(`"`, "")} as const` });
63
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Source, { name, isExportable: true, isIndexable: true, children: `export const ${name} = ${JSON.stringify(handlers).replaceAll(`"`, "")} as const` });
65
64
  }
66
65
  function RootTemplate({ children }) {
67
66
  const {
@@ -76,10 +75,10 @@ function RootTemplate({ children }) {
76
75
  const operationName = getName(operation, { pluginKey, type: "function" });
77
76
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Import, { name: [operationName], root: file.path, path: operationFile.path }, operationFile.path);
78
77
  }).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: [
78
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _react.File, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
80
79
  imports,
81
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Source, { children })
82
- ] }) });
80
+ children
81
+ ] });
83
82
  }
84
83
  var defaultTemplates2 = { default: Template2, root: RootTemplate };
85
84
  function Operations({ Template: Template3 = defaultTemplates2.default }) {
@@ -102,4 +101,4 @@ Operations.templates = defaultTemplates2;
102
101
 
103
102
 
104
103
  exports.Mock = Mock; exports.Operations = Operations;
105
- //# sourceMappingURL=chunk-S4P5XPFN.cjs.map
104
+ //# sourceMappingURL=chunk-BD7UJBXM.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/kubb/kubb/packages/plugin-msw/dist/chunk-BD7UJBXM.cjs","../src/components/Mock.tsx","../src/components/Operations.tsx"],"names":["Template","jsx","File","useApp","useOperationManager","jsxs","defaultTemplates","RootTemplate"],"mappings":"AAAA;ACAA,yCAAwB;AACxB,oCAA6B;AAC7B,iDAAgC;AAChC,+CAAkD;AA4B9C,qDAAA;AAFJ,SAAS,QAAA,CAAS,EAAE,IAAA,EAAM,MAAA,EAAQ,IAAA,EAAM,aAAa,CAAA,EAA6B;AAChF,EAAA,uBACE,6BAAA,WAAC,CAAK,MAAA,EAAL,EAAY,IAAA,EAAY,YAAA,EAAY,IAAA,EAAC,WAAA,EAAW,IAAA,EAC9C,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;AAE/B,EAAA,MAAM,QAAA,EAAU,UAAA,CAAW,SAAS,CAAA;AACpC,EAAA,MAAM,KAAA,EAAO,OAAA,CAAQ,SAAA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BAAAA,CAAkB;AAEtB,EAAA,MAAM,WAAA,EAAa,kCAAA,CAAc;AACjC,EAAA,MAAM,EAAE,QAAQ,EAAA,EAAIC,wCAAAA,CAAoB;AAExC,EAAA,uBAAOH,6BAAAA,SAACD,EAAA,EAAS,IAAA,EAAK,UAAA,EAAW,QAAA,EAAU,UAAA,CAAW,GAAA,CAAI,CAAC,SAAA,EAAA,GAAc,OAAA,CAAQ,SAAA,EAAW,EAAE,IAAA,EAAM,UAAA,EAAY,UAAU,CAAC,CAAC,EAAA,CAAG,CAAA;AACjI;AASA,UAAA,CAAW,KAAA,EAAO,QAAA,CAAU,KAAA,EAA4B;AACtD,EAAA,MAAM,UAAA,EAAY,EAAE,GAAGM,iBAAAA,EAAkB,GAAG,KAAA,CAAM,UAAU,CAAA;AAE5D,EAAA,MAAMN,UAAAA,EAAW,SAAA,CAAU,OAAA;AAC3B,EAAA,MAAMO,cAAAA,EAAe,SAAA,CAAU,IAAA;AAE/B,EAAA,uBACEN,6BAAAA,aAACM,EAAA,EACC,QAAA,kBAAAN,6BAAAA,UAAC,EAAA,EAAW,QAAA,EAAUD,UAAAA,CAAU,EAAA,CAClC,CAAA;AAEJ,CAAA;AAEA,UAAA,CAAW,UAAA,EAAYM,iBAAAA;AFKvB;AACA;AACE;AACA;AACF,qDAAC","file":"/home/runner/work/kubb/kubb/packages/plugin-msw/dist/chunk-BD7UJBXM.cjs","sourcesContent":[null,"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"]}
@@ -1,9 +1,9 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
3
 
4
- var _chunkS4P5XPFNcjs = require('./chunk-S4P5XPFN.cjs');
4
+ var _chunkBD7UJBXMcjs = require('./chunk-BD7UJBXM.cjs');
5
5
 
6
6
 
7
7
 
8
- exports.Mock = _chunkS4P5XPFNcjs.Mock; exports.Operations = _chunkS4P5XPFNcjs.Operations;
8
+ exports.Mock = _chunkBD7UJBXMcjs.Mock; exports.Operations = _chunkBD7UJBXMcjs.Operations;
9
9
  //# sourceMappingURL=components.cjs.map
@@ -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,7 +1,7 @@
1
1
  import {
2
2
  Mock,
3
3
  Operations
4
- } from "./chunk-WRIEMCYI.js";
4
+ } from "./chunk-3KHLTEUD.js";
5
5
  export {
6
6
  Mock,
7
7
  Operations
package/dist/index.cjs CHANGED
@@ -1,7 +1,7 @@
1
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; }
2
2
 
3
3
 
4
- var _chunkS4P5XPFNcjs = require('./chunk-S4P5XPFN.cjs');
4
+ var _chunkBD7UJBXMcjs = require('./chunk-BD7UJBXM.cjs');
5
5
 
6
6
  // src/plugin.ts
7
7
  var _path = require('path'); var _path2 = _interopRequireDefault(_path);
@@ -9,7 +9,6 @@ var _core = require('@kubb/core');
9
9
  var _transformers = require('@kubb/core/transformers');
10
10
  var _utils = require('@kubb/core/utils');
11
11
  var _pluginoas = require('@kubb/plugin-oas');
12
- var _utils3 = require('@kubb/plugin-oas/utils');
13
12
  var _pluginfaker = require('@kubb/plugin-faker');
14
13
  var _plugints = require('@kubb/plugin-ts');
15
14
 
@@ -25,12 +24,12 @@ var OperationGenerator = class extends _pluginoas.OperationGenerator {
25
24
  logger: pluginManager.logger
26
25
  });
27
26
  const templates = {
28
- operations: _chunkS4P5XPFNcjs.Operations.templates,
29
- mock: _chunkS4P5XPFNcjs.Mock.templates,
27
+ operations: _chunkBD7UJBXMcjs.Operations.templates,
28
+ mock: _chunkBD7UJBXMcjs.Mock.templates,
30
29
  ...this.options.templates
31
30
  };
32
31
  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 }) }) })
32
+ /* @__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, _chunkBD7UJBXMcjs.Operations.File, { templates: templates.operations }) }) })
34
33
  );
35
34
  return root.files;
36
35
  }
@@ -40,15 +39,15 @@ var OperationGenerator = class extends _pluginoas.OperationGenerator {
40
39
  logger: pluginManager.logger
41
40
  });
42
41
  const templates = {
43
- handlers: _chunkS4P5XPFNcjs.Operations.templates,
44
- mock: _chunkS4P5XPFNcjs.Mock.templates,
42
+ handlers: _chunkBD7UJBXMcjs.Operations.templates,
43
+ mock: _chunkBD7UJBXMcjs.Mock.templates,
45
44
  ...options.templates
46
45
  };
47
46
  if (!_optionalChain([templates, 'optionalAccess', _2 => _2.mock])) {
48
47
  return [];
49
48
  }
50
49
  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 }) }) }) })
50
+ /* @__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, _chunkBD7UJBXMcjs.Mock.File, { templates: templates.mock }) }) }) })
52
51
  );
53
52
  return root.files;
54
53
  }
@@ -61,11 +60,15 @@ var pluginMsw = _core.createPlugin.call(void 0, (options) => {
61
60
  const template = _optionalChain([group, 'optionalAccess', _3 => _3.output]) ? group.output : `${output.path}/{{tag}}Controller`;
62
61
  return {
63
62
  name: pluginMswName,
63
+ output: {
64
+ exportType: "barrelNamed",
65
+ ...output
66
+ },
64
67
  options: {
65
68
  extName: output.extName,
66
69
  templates: {
67
- operations: _chunkS4P5XPFNcjs.Operations.templates,
68
- mock: _chunkS4P5XPFNcjs.Mock.templates,
70
+ operations: _chunkBD7UJBXMcjs.Operations.templates,
71
+ mock: _chunkBD7UJBXMcjs.Mock.templates,
69
72
  ...templates
70
73
  }
71
74
  },
@@ -92,22 +95,16 @@ var pluginMsw = _core.createPlugin.call(void 0, (options) => {
92
95
  }
93
96
  return resolvedName;
94
97
  },
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
98
  async buildStart() {
102
99
  const [swaggerPlugin] = _core.PluginManager.getDependedPlugins(this.plugins, [_pluginoas.pluginOasName]);
103
- const oas = await swaggerPlugin.api.getOas();
100
+ const oas = await swaggerPlugin.context.getOas();
104
101
  const root = _path2.default.resolve(this.config.root, this.config.output.path);
105
102
  const mode = _core.FileManager.getMode(_path2.default.resolve(root, output.path));
106
103
  const operationGenerator = new OperationGenerator(this.plugin.options, {
107
104
  oas,
108
105
  pluginManager: this.pluginManager,
109
106
  plugin: this.plugin,
110
- contentType: swaggerPlugin.api.contentType,
107
+ contentType: swaggerPlugin.context.contentType,
111
108
  exclude,
112
109
  include,
113
110
  override,
@@ -115,30 +112,18 @@ var pluginMsw = _core.createPlugin.call(void 0, (options) => {
115
112
  });
116
113
  const files = await operationGenerator.build();
117
114
  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",
115
+ if (this.config.output.exportType) {
116
+ const barrelFiles = await this.fileManager.getBarrelFiles({
131
117
  root,
132
- output
118
+ output,
119
+ files: this.fileManager.files,
120
+ meta: {
121
+ pluginKey: this.plugin.key
122
+ },
123
+ logger: this.logger
133
124
  });
134
- await this.addFile(...rootFiles);
125
+ await this.addFile(...barrelFiles);
135
126
  }
136
- await this.fileManager.addIndexes({
137
- root,
138
- output,
139
- meta: { pluginKey: this.plugin.key },
140
- logger: this.logger
141
- });
142
127
  }
143
128
  };
144
129
  });
@@ -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;AAC1G,IAAA,MAAM,EAAE,GAAA,EAAK,aAAA,EAAe,MAAA,EAAQ,KAAK,EAAA,EAAI,IAAA,CAAK,OAAA;AAElD,IAAA,MAAM,KAAA,EAAO,+BAAA;AAAW,MACtB,MAAA,EAAQ,aAAA,CAAc;AAAA,IACxB,CAAC,CAAA;AAED,IAAA,MAAM,UAAA,EAAY;AAAA,MAChB,UAAA,EAAY,4BAAA,CAAW,SAAA;AAAA,MACvB,IAAA,EAAM,sBAAA,CAAK,SAAA;AAAA,MACX,GAAG,IAAA,CAAK,OAAA,CAAQ;AAAA,IAClB,CAAA;AAEA,IAAA,IAAA,CAAK,MAAA;AAAA,sBACH,6BAAA,UAAC,EAAA,EAAI,aAAA,EAA8B,MAAA,EAAgB,IAAA,EACjD,QAAA,kBAA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AA;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":["/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;AAE9B,iDAAgC;AAChC,2CAA6B;ADK7B;AACA;AEdA;AACA,yDAAoB;AACpB,oCAAgC;AA0BI,qDAAA;AAjB7B,IAAM,mBAAA,EAAN,MAAA,QAAiC,8BAAmD;AAAA,EACzF,MAAM,GAAA,CAAI,UAAA,EAAyB,kBAAA,EAAyE;AAC1G,IAAA,MAAM,EAAE,GAAA,EAAK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AEuC,MAAA;AACzC,IAAA;AACwB,IAAA;AACe,MAAA;AACR,QAAA;AACV,QAAA;AAClB,MAAA;AACS,MAAA;AACkC,QAAA;AAC5C,MAAA;AAEO,MAAA;AACT,IAAA;AACmB,IAAA;AACqD,MAAA;AAE9B,MAAA;AACI,MAAA;AACN,MAAA;AAEP,MAAA;AAC7B,QAAA;AACoB,QAAA;AACP,QAAA;AACsB,QAAA;AACnC,QAAA;AACA,QAAA;AACA,QAAA;AACA,QAAA;AACD,MAAA;AAE4C,MAAA;AAClB,MAAA;AAEQ,MAAA;AACU,QAAA;AACzC,UAAA;AACA,UAAA;AACwB,UAAA;AAClB,UAAA;AACmB,YAAA;AACzB,UAAA;AACa,UAAA;AACd,QAAA;AAEgC,QAAA;AACnC,MAAA;AACF,IAAA;AACF,EAAA;AACD;ADwBkD;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'\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","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"]}
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;
@@ -84,11 +84,6 @@ type ResolvedOptions = {
84
84
  templates: NonNullable<Templates>;
85
85
  };
86
86
  type PluginMsw = PluginFactoryOptions<'plugin-msw', Options, ResolvedOptions, never, ResolvePathOptions>;
87
- declare module '@kubb/core' {
88
- interface _Register {
89
- ['@kubb/plugin-msw']: PluginMsw;
90
- }
91
- }
92
87
 
93
88
  declare const pluginMswName = "plugin-msw";
94
89
  declare const pluginMsw: (options?: Options | undefined) => _kubb_core.UserPluginWithLifeCycle<PluginMsw>;
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;
@@ -84,11 +84,6 @@ type ResolvedOptions = {
84
84
  templates: NonNullable<Templates>;
85
85
  };
86
86
  type PluginMsw = PluginFactoryOptions<'plugin-msw', Options, ResolvedOptions, never, ResolvePathOptions>;
87
- declare module '@kubb/core' {
88
- interface _Register {
89
- ['@kubb/plugin-msw']: PluginMsw;
90
- }
91
- }
92
87
 
93
88
  declare const pluginMswName = "plugin-msw";
94
89
  declare const pluginMsw: (options?: Options | undefined) => _kubb_core.UserPluginWithLifeCycle<PluginMsw>;
package/dist/index.js CHANGED
@@ -1,15 +1,14 @@
1
1
  import {
2
2
  Mock,
3
3
  Operations
4
- } from "./chunk-WRIEMCYI.js";
4
+ } from "./chunk-3KHLTEUD.js";
5
5
 
6
6
  // src/plugin.ts
7
- import path from "path";
7
+ import path from "node:path";
8
8
  import { FileManager, PluginManager, createPlugin } from "@kubb/core";
9
9
  import { camelCase } from "@kubb/core/transformers";
10
10
  import { renderTemplate } from "@kubb/core/utils";
11
11
  import { pluginOasName } from "@kubb/plugin-oas";
12
- import { getGroupedByTagFiles } from "@kubb/plugin-oas/utils";
13
12
  import { pluginFakerName } from "@kubb/plugin-faker";
14
13
  import { pluginTsName } from "@kubb/plugin-ts";
15
14
 
@@ -61,6 +60,10 @@ var pluginMsw = createPlugin((options) => {
61
60
  const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`;
62
61
  return {
63
62
  name: pluginMswName,
63
+ output: {
64
+ exportType: "barrelNamed",
65
+ ...output
66
+ },
64
67
  options: {
65
68
  extName: output.extName,
66
69
  templates: {
@@ -92,22 +95,16 @@ var pluginMsw = createPlugin((options) => {
92
95
  }
93
96
  return resolvedName;
94
97
  },
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
98
  async buildStart() {
102
99
  const [swaggerPlugin] = PluginManager.getDependedPlugins(this.plugins, [pluginOasName]);
103
- const oas = await swaggerPlugin.api.getOas();
100
+ const oas = await swaggerPlugin.context.getOas();
104
101
  const root = path.resolve(this.config.root, this.config.output.path);
105
102
  const mode = FileManager.getMode(path.resolve(root, output.path));
106
103
  const operationGenerator = new OperationGenerator(this.plugin.options, {
107
104
  oas,
108
105
  pluginManager: this.pluginManager,
109
106
  plugin: this.plugin,
110
- contentType: swaggerPlugin.api.contentType,
107
+ contentType: swaggerPlugin.context.contentType,
111
108
  exclude,
112
109
  include,
113
110
  override,
@@ -115,30 +112,18 @@ var pluginMsw = createPlugin((options) => {
115
112
  });
116
113
  const files = await operationGenerator.build();
117
114
  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",
115
+ if (this.config.output.exportType) {
116
+ const barrelFiles = await this.fileManager.getBarrelFiles({
131
117
  root,
132
- output
118
+ output,
119
+ files: this.fileManager.files,
120
+ meta: {
121
+ pluginKey: this.plugin.key
122
+ },
123
+ logger: this.logger
133
124
  });
134
- await this.addFile(...rootFiles);
125
+ await this.addFile(...barrelFiles);
135
126
  }
136
- await this.fileManager.addIndexes({
137
- root,
138
- output,
139
- meta: { pluginKey: this.plugin.key },
140
- logger: this.logger
141
- });
142
127
  }
143
128
  };
144
129
  });
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,MAAM,KAAK;AAAA,MACX,GAAG,KAAK,QAAQ;AAAA,IAClB;AAEA,SAAK;AAAA,MACH,oBAAC,OAAI,eAA8B,QAAgB,MACjD,8BAAC,OAAI,KAAU,YAAwB,WAAW,MAC/C,qBAAW,cAAc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ACpB,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/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'\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","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;AAE9B,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AAEA,aAAO;AAAA,IACT;AAAA,IACA,MAAM,aAAa;AACjB,YAAM,CAAC,aAAa,IAAoC,cAAc,mBAAyC,KAAK,SAAS,CAAC,aAAa,CAAC;AAE5I,YAAM,MAAM,MAAM,cAAc,QAAQ,OAAO;AAC/C,YAAM,OAAO,KAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,IAAI;AACnE,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,QAAQ;AAAA,QACnC;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF,CAAC;AAED,YAAM,QAAQ,MAAM,mBAAmB,MAAM;AAC7C,YAAM,KAAK,QAAQ,GAAG,KAAK;AAE3B,UAAI,KAAK,OAAO,OAAO,YAAY;AACjC,cAAM,cAAc,MAAM,KAAK,YAAY,eAAe;AAAA,UACxD;AAAA,UACA;AAAA,UACA,OAAO,KAAK,YAAY;AAAA,UACxB,MAAM;AAAA,YACJ,WAAW,KAAK,OAAO;AAAA,UACzB;AAAA,UACA,QAAQ,KAAK;AAAA,QACf,CAAC;AAED,cAAM,KAAK,QAAQ,GAAG,WAAW;AAAA,MACnC;AAAA,IACF;AAAA,EACF;AACF,CAAC;","names":["options"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-msw",
3
- "version": "3.0.0-alpha.0",
3
+ "version": "3.0.0-alpha.10",
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.0",
70
- "@kubb/fs": "3.0.0-alpha.0",
71
- "@kubb/oas": "3.0.0-alpha.0",
72
- "@kubb/parser-ts": "3.0.0-alpha.0",
73
- "@kubb/plugin-faker": "3.0.0-alpha.0",
74
- "@kubb/plugin-oas": "3.0.0-alpha.0",
75
- "@kubb/plugin-ts": "3.0.0-alpha.0",
76
- "@kubb/react": "3.0.0-alpha.0"
69
+ "@kubb/core": "3.0.0-alpha.10",
70
+ "@kubb/fs": "3.0.0-alpha.10",
71
+ "@kubb/oas": "3.0.0-alpha.10",
72
+ "@kubb/parser-ts": "3.0.0-alpha.10",
73
+ "@kubb/plugin-faker": "3.0.0-alpha.10",
74
+ "@kubb/plugin-oas": "3.0.0-alpha.10",
75
+ "@kubb/plugin-ts": "3.0.0-alpha.10",
76
+ "@kubb/react": "3.0.0-alpha.10"
77
77
  },
78
78
  "devDependencies": {
79
- "@types/react": "^18.3.3",
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.0",
85
- "@kubb/config-ts": "3.0.0-alpha.0",
86
- "@kubb/config-tsup": "3.0.0-alpha.0"
84
+ "@kubb/config-biome": "3.0.0-alpha.10",
85
+ "@kubb/config-ts": "3.0.0-alpha.10",
86
+ "@kubb/config-tsup": "3.0.0-alpha.10"
87
87
  },
88
88
  "peerDependencies": {
89
- "@kubb/react": "3.0.0-alpha.0"
89
+ "@kubb/react": "3.0.0-alpha.10"
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
  })
package/src/types.ts CHANGED
@@ -87,9 +87,3 @@ export type FileMeta = {
87
87
  }
88
88
 
89
89
  export type PluginMsw = PluginFactoryOptions<'plugin-msw', Options, ResolvedOptions, never, ResolvePathOptions>
90
-
91
- declare module '@kubb/core' {
92
- export interface _Register {
93
- ['@kubb/plugin-msw']: PluginMsw
94
- }
95
- }
@@ -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,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/home/runner/work/kubb/kubb/packages/plugin-msw/dist/chunk-S4P5XPFN.cjs","sourcesContent":[null,"import { PackageManager } from '@kubb/core'\nimport { URLPath } from '@kubb/core/utils'\nimport { Parser, File, useApp } from '@kubb/react'\nimport { pluginFakerName } from '@kubb/plugin-faker'\nimport { useOperation, useOperationManager } from '@kubb/plugin-oas/hooks'\n\nimport type { HttpMethod } from '@kubb/oas'\nimport type { ReactNode } from 'react'\nimport type { FileMeta, PluginMsw } from '../types.ts'\n\ntype TemplateProps = {\n /**\n * Name of the function\n */\n name: string\n /**\n * Method of the current operation, see useOperation.\n */\n method: HttpMethod\n /**\n * Path of the mock\n */\n path: URLPath\n /**\n * Name of the import for the mock(this is a function).\n * @example createPet\n */\n responseName: string\n}\n\nfunction Template({ name, method, path, responseName }: TemplateProps): ReactNode {\n return (\n <>\n {`\n export const ${name} = http.${method}('*${path.toURLPath()}', function handler(info) {\n return new Response(JSON.stringify(${responseName}()), {\n headers: {\n 'Content-Type': 'application/json',\n },\n })\n })\n `}\n </>\n )\n}\n\nconst defaultTemplates = { default: Template } as const\n\ntype Props = {\n /**\n * This will make it possible to override the default behaviour.\n */\n Template?: React.ComponentType<React.ComponentProps<typeof Template>>\n}\n\nexport function Mock({ Template = defaultTemplates.default }: Props): ReactNode {\n const { pluginManager } = useApp<PluginMsw>()\n const { getSchemas, getName } = useOperationManager()\n const operation = useOperation()\n\n const schemas = getSchemas(operation)\n const name = getName(operation, { type: 'function' })\n const responseName = pluginManager.resolveName({\n pluginKey: [pluginFakerName],\n name: schemas.response.name,\n type: 'type',\n })\n\n return <Template name={name} responseName={responseName} method={operation.method} path={new URLPath(operation.path)} />\n}\n\ntype FileProps = {\n /**\n * This will make it possible to override the default behaviour.\n */\n templates?: typeof defaultTemplates\n}\n\nMock.File = function ({ templates = defaultTemplates }: FileProps): ReactNode {\n const {\n pluginManager,\n plugin: {\n options: { extName },\n },\n } = useApp<PluginMsw>()\n const { getSchemas, getFile } = useOperationManager()\n const operation = useOperation()\n\n const schemas = getSchemas(operation)\n const file = getFile(operation)\n const fileFaker = getFile(operation, { pluginKey: [pluginFakerName] })\n const responseName = pluginManager.resolveName({\n pluginKey: [pluginFakerName],\n name: schemas.response.name,\n type: 'function',\n })\n\n const Template = templates.default\n\n return (\n <Parser language=\"typescript\">\n <File<FileMeta> baseName={file.baseName} path={file.path} meta={file.meta}>\n <File.Import name={['http']} path={'msw'} />\n {fileFaker && responseName && <File.Import extName={extName} name={[responseName]} root={file.path} path={fileFaker.path} />}\n <File.Source>\n <Mock Template={Template} />\n </File.Source>\n </File>\n </Parser>\n )\n}\n\nMock.templates = defaultTemplates\n","import { Parser, File, useApp } from '@kubb/react'\nimport { useOperationManager, useOperations } from '@kubb/plugin-oas/hooks'\n\nimport type { KubbNode } from '@kubb/react'\nimport type { ReactNode } from 'react'\nimport type { FileMeta, PluginMsw } from '../types.ts'\n\ntype TemplateProps = {\n /**\n * Name of the function\n */\n name: string\n handlers: string[]\n}\n\nfunction Template({ name, handlers }: TemplateProps): ReactNode {\n return <>{`export const ${name} = ${JSON.stringify(handlers).replaceAll(`\"`, '')} as const`}</>\n}\n\ntype ParserTemplateProps = {\n children?: React.ReactNode\n}\n\nfunction RootTemplate({ children }: ParserTemplateProps) {\n const {\n pluginManager,\n plugin: { key: pluginKey },\n } = useApp<PluginMsw>()\n\n const { getName, getFile } = useOperationManager()\n\n const file = pluginManager.getFile({ name: 'handlers', extName: '.ts', pluginKey })\n const operations = useOperations()\n\n const imports = operations\n .map((operation) => {\n const operationFile = getFile(operation, { pluginKey })\n const operationName = getName(operation, { pluginKey, type: 'function' })\n\n return <File.Import key={operationFile.path} name={[operationName]} root={file.path} path={operationFile.path} />\n })\n .filter(Boolean)\n\n return (\n <Parser language=\"typescript\">\n <File<FileMeta> baseName={file.baseName} path={file.path} meta={file.meta}>\n {imports}\n <File.Source>{children}</File.Source>\n </File>\n </Parser>\n )\n}\n\nconst defaultTemplates = { default: Template, root: RootTemplate } as const\n\ntype Templates = Partial<typeof defaultTemplates>\n\ntype Props = {\n /**\n * This will make it possible to override the default behaviour.\n */\n Template?: React.ComponentType<React.ComponentProps<typeof Template>>\n}\n\nexport function Operations({ Template = defaultTemplates.default }: Props): ReactNode {\n const {\n plugin: { key: pluginKey },\n } = useApp<PluginMsw>()\n\n const operations = useOperations()\n const { getName } = useOperationManager()\n\n return <Template name=\"handlers\" handlers={operations.map((operation) => getName(operation, { type: 'function', pluginKey }))} />\n}\n\ntype FileProps = {\n /**\n * This will make it possible to override the default behaviour.\n */\n templates?: Templates\n}\n\nOperations.File = function (props: FileProps): KubbNode {\n const templates = { ...defaultTemplates, ...props.templates }\n\n const Template = templates.default\n const RootTemplate = templates.root\n\n return (\n <RootTemplate>\n <Operations Template={Template} />\n </RootTemplate>\n )\n}\n\nOperations.templates = defaultTemplates\n"]}
@@ -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;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