@kubb/plugin-msw 3.0.0-alpha.8 → 3.0.0-beta.1

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.
Files changed (51) hide show
  1. package/README.md +14 -5
  2. package/dist/chunk-6F4YUN2R.cjs +138 -0
  3. package/dist/chunk-6F4YUN2R.cjs.map +1 -0
  4. package/dist/chunk-6M2QU6UL.js +22 -0
  5. package/dist/chunk-6M2QU6UL.js.map +1 -0
  6. package/dist/chunk-GODA4G5K.cjs +25 -0
  7. package/dist/chunk-GODA4G5K.cjs.map +1 -0
  8. package/dist/chunk-TW2VMA3H.js +129 -0
  9. package/dist/chunk-TW2VMA3H.js.map +1 -0
  10. package/dist/components.cjs +11 -4
  11. package/dist/components.cjs.map +1 -1
  12. package/dist/components.d.cts +7 -70
  13. package/dist/components.d.ts +7 -70
  14. package/dist/components.js +2 -8
  15. package/dist/components.js.map +1 -1
  16. package/dist/generators.cjs +17 -0
  17. package/dist/generators.cjs.map +1 -0
  18. package/dist/generators.d.cts +9 -0
  19. package/dist/generators.d.ts +9 -0
  20. package/dist/generators.js +4 -0
  21. package/dist/generators.js.map +1 -0
  22. package/dist/index.cjs +11 -128
  23. package/dist/index.cjs.map +1 -1
  24. package/dist/index.d.cts +3 -86
  25. package/dist/index.d.ts +3 -86
  26. package/dist/index.js +3 -133
  27. package/dist/index.js.map +1 -1
  28. package/dist/types-B3_ksuJz.d.cts +46 -0
  29. package/dist/types-B3_ksuJz.d.ts +46 -0
  30. package/package.json +22 -17
  31. package/src/components/Handlers.tsx +19 -0
  32. package/src/components/Mock.tsx +8 -86
  33. package/src/components/index.ts +1 -1
  34. package/src/generators/__snapshots__/createPet.ts +9 -0
  35. package/src/generators/__snapshots__/deletePet.ts +9 -0
  36. package/src/generators/__snapshots__/getPets.ts +9 -0
  37. package/src/generators/__snapshots__/handlers.ts +3 -0
  38. package/src/generators/__snapshots__/showPetById.ts +9 -0
  39. package/src/generators/handlersGenerator.tsx +32 -0
  40. package/src/generators/index.ts +2 -0
  41. package/src/generators/mswGenerator.tsx +38 -0
  42. package/src/plugin.ts +34 -37
  43. package/src/types.ts +15 -58
  44. package/dist/chunk-3KHLTEUD.js +0 -104
  45. package/dist/chunk-3KHLTEUD.js.map +0 -1
  46. package/dist/chunk-BD7UJBXM.cjs +0 -104
  47. package/dist/chunk-BD7UJBXM.cjs.map +0 -1
  48. package/src/OperationGenerator.tsx +0 -66
  49. package/src/components/Operations.tsx +0 -94
  50. package/src/components/__snapshots__/Mock/Pets.ts +0 -7
  51. package/src/components/__snapshots__/Mock/showPetsById.ts +0 -7
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+
3
+ var chunk6F4YUN2R_cjs = require('./chunk-6F4YUN2R.cjs');
4
+ require('./chunk-GODA4G5K.cjs');
5
+
6
+
7
+
8
+ Object.defineProperty(exports, "handlersGenerator", {
9
+ enumerable: true,
10
+ get: function () { return chunk6F4YUN2R_cjs.handlersGenerator; }
11
+ });
12
+ Object.defineProperty(exports, "mswGenerator", {
13
+ enumerable: true,
14
+ get: function () { return chunk6F4YUN2R_cjs.mswGenerator; }
15
+ });
16
+ //# sourceMappingURL=generators.cjs.map
17
+ //# sourceMappingURL=generators.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"generators.cjs"}
@@ -0,0 +1,9 @@
1
+ import * as _kubb_plugin_oas from '@kubb/plugin-oas';
2
+ import { P as PluginMsw } from './types-B3_ksuJz.cjs';
3
+ import '@kubb/core';
4
+
5
+ declare const mswGenerator: _kubb_plugin_oas.Generator<PluginMsw>;
6
+
7
+ declare const handlersGenerator: _kubb_plugin_oas.Generator<PluginMsw>;
8
+
9
+ export { handlersGenerator, mswGenerator };
@@ -0,0 +1,9 @@
1
+ import * as _kubb_plugin_oas from '@kubb/plugin-oas';
2
+ import { P as PluginMsw } from './types-B3_ksuJz.js';
3
+ import '@kubb/core';
4
+
5
+ declare const mswGenerator: _kubb_plugin_oas.Generator<PluginMsw>;
6
+
7
+ declare const handlersGenerator: _kubb_plugin_oas.Generator<PluginMsw>;
8
+
9
+ export { handlersGenerator, mswGenerator };
@@ -0,0 +1,4 @@
1
+ export { handlersGenerator, mswGenerator } from './chunk-TW2VMA3H.js';
2
+ import './chunk-6M2QU6UL.js';
3
+ //# sourceMappingURL=generators.js.map
4
+ //# sourceMappingURL=generators.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"generators.js"}
package/dist/index.cjs CHANGED
@@ -1,134 +1,17 @@
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 chunk6F4YUN2R_cjs = require('./chunk-6F4YUN2R.cjs');
4
+ require('./chunk-GODA4G5K.cjs');
3
5
 
4
- var _chunkBD7UJBXMcjs = require('./chunk-BD7UJBXM.cjs');
5
6
 
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 _pluginfaker = require('@kubb/plugin-faker');
13
- var _plugints = require('@kubb/plugin-ts');
14
7
 
15
- // src/OperationGenerator.tsx
16
-
17
- var _components = require('@kubb/plugin-oas/components');
18
- var _react = require('@kubb/react');
19
- var _jsxruntime = require('@kubb/react/jsx-runtime');
20
- var OperationGenerator = class extends _pluginoas.OperationGenerator {
21
- async all(operations, operationsByMethod) {
22
- const { oas, pluginManager, plugin, mode } = this.context;
23
- const root = _react.createRoot.call(void 0, {
24
- logger: pluginManager.logger
25
- });
26
- const templates = {
27
- operations: _chunkBD7UJBXMcjs.Operations.templates,
28
- mock: _chunkBD7UJBXMcjs.Mock.templates,
29
- ...this.options.templates
30
- };
31
- root.render(
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 }) }) })
33
- );
34
- return root.files;
35
- }
36
- async operation(operation, options) {
37
- const { oas, pluginManager, plugin, mode } = this.context;
38
- const root = _react.createRoot.call(void 0, {
39
- logger: pluginManager.logger
40
- });
41
- const templates = {
42
- handlers: _chunkBD7UJBXMcjs.Operations.templates,
43
- mock: _chunkBD7UJBXMcjs.Mock.templates,
44
- ...options.templates
45
- };
46
- if (!_optionalChain([templates, 'optionalAccess', _2 => _2.mock])) {
47
- return [];
48
- }
49
- root.render(
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 }) }) }) })
51
- );
52
- return root.files;
53
- }
54
- };
55
-
56
- // src/plugin.ts
57
- var pluginMswName = "plugin-msw";
58
- var pluginMsw = _core.createPlugin.call(void 0, (options) => {
59
- const { output = { path: "handlers" }, group, exclude = [], include, override = [], transformers = {}, templates } = options;
60
- const template = _optionalChain([group, 'optionalAccess', _3 => _3.output]) ? group.output : `${output.path}/{{tag}}Controller`;
61
- return {
62
- name: pluginMswName,
63
- output: {
64
- exportType: "barrelNamed",
65
- ...output
66
- },
67
- options: {
68
- extName: output.extName,
69
- templates: {
70
- operations: _chunkBD7UJBXMcjs.Operations.templates,
71
- mock: _chunkBD7UJBXMcjs.Mock.templates,
72
- ...templates
73
- }
74
- },
75
- pre: [_pluginoas.pluginOasName, _plugints.pluginTsName, _pluginfaker.pluginFakerName],
76
- resolvePath(baseName, pathMode, options2) {
77
- const root = _path2.default.resolve(this.config.root, this.config.output.path);
78
- const mode = _nullishCoalesce(pathMode, () => ( _core.FileManager.getMode(_path2.default.resolve(root, output.path))));
79
- if (mode === "single") {
80
- return _path2.default.resolve(root, output.path);
81
- }
82
- if (_optionalChain([options2, 'optionalAccess', _4 => _4.tag]) && _optionalChain([group, 'optionalAccess', _5 => _5.type]) === "tag") {
83
- const tag = _transformers.camelCase.call(void 0, options2.tag);
84
- return _path2.default.resolve(root, _utils.renderTemplate.call(void 0, template, { tag }), baseName);
85
- }
86
- return _path2.default.resolve(root, output.path, baseName);
87
- },
88
- resolveName(name, type) {
89
- const resolvedName = _transformers.camelCase.call(void 0, name, {
90
- suffix: type ? "handler" : void 0,
91
- isFile: type === "file"
92
- });
93
- if (type) {
94
- return _optionalChain([transformers, 'optionalAccess', _6 => _6.name, 'optionalCall', _7 => _7(resolvedName, type)]) || resolvedName;
95
- }
96
- return resolvedName;
97
- },
98
- async buildStart() {
99
- const [swaggerPlugin] = _core.PluginManager.getDependedPlugins(this.plugins, [_pluginoas.pluginOasName]);
100
- const oas = await swaggerPlugin.context.getOas();
101
- const root = _path2.default.resolve(this.config.root, this.config.output.path);
102
- const mode = _core.FileManager.getMode(_path2.default.resolve(root, output.path));
103
- const operationGenerator = new OperationGenerator(this.plugin.options, {
104
- oas,
105
- pluginManager: this.pluginManager,
106
- plugin: this.plugin,
107
- contentType: swaggerPlugin.context.contentType,
108
- exclude,
109
- include,
110
- override,
111
- mode
112
- });
113
- const files = await operationGenerator.build();
114
- await this.addFile(...files);
115
- if (this.config.output.exportType) {
116
- const barrelFiles = await this.fileManager.getBarrelFiles({
117
- root,
118
- output,
119
- files: this.fileManager.files,
120
- meta: {
121
- pluginKey: this.plugin.key
122
- },
123
- logger: this.logger
124
- });
125
- await this.addFile(...barrelFiles);
126
- }
127
- }
128
- };
8
+ Object.defineProperty(exports, "pluginMsw", {
9
+ enumerable: true,
10
+ get: function () { return chunk6F4YUN2R_cjs.pluginMsw; }
129
11
  });
130
-
131
-
132
-
133
- exports.pluginMsw = pluginMsw; exports.pluginMswName = pluginMswName;
12
+ Object.defineProperty(exports, "pluginMswName", {
13
+ enumerable: true,
14
+ get: function () { return chunk6F4YUN2R_cjs.pluginMswName; }
15
+ });
16
+ //# sourceMappingURL=index.cjs.map
134
17
  //# 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;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,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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AA;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"]}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
package/dist/index.d.cts CHANGED
@@ -1,91 +1,8 @@
1
1
  import * as _kubb_core from '@kubb/core';
2
- import { PluginFactoryOptions, ResolveNameParams } from '@kubb/core';
3
- import * as KubbFile from '@kubb/fs/types';
4
- import { ResolvePathOptions, Exclude, Include, Override } from '@kubb/plugin-oas';
5
- import { Operations, Mock } from './components.cjs';
6
- import '@kubb/core/utils';
7
- import '@kubb/oas';
8
- import 'react';
9
- import '@kubb/react/types';
10
-
11
- type Templates = {
12
- operations?: typeof Operations.templates | false;
13
- mock?: typeof Mock.templates | false;
14
- };
15
- type Options = {
16
- output?: {
17
- /**
18
- * Relative path to save the MSW mocks.
19
- * When output is a file it will save all models inside that file else it will create a file per schema item.
20
- * @default 'mocks'
21
- */
22
- path: string;
23
- /**
24
- * Name to be used for the `export * as {{exportAs}} from './'`
25
- */
26
- exportAs?: string;
27
- /**
28
- * Add an extension to the generated imports and exports, default it will not use an extension
29
- */
30
- extName?: KubbFile.Extname;
31
- /**
32
- * Define what needs to exported, here you can also disable the export of barrel files
33
- * @default `'barrel'`
34
- */
35
- exportType?: 'barrel' | 'barrelNamed' | false;
36
- };
37
- /**
38
- * Group the MSW mocks based on the provided name.
39
- */
40
- group?: {
41
- /**
42
- * Tag will group based on the operation tag inside the Swagger file
43
- */
44
- type: 'tag';
45
- /**
46
- * Relative path to save the grouped MSW mocks.
47
- *
48
- * `{{tag}}` will be replaced by the current tagName.
49
- * @example `${output}/{{tag}}Controller` => `mocks/PetController`
50
- * @default `${output}/{{tag}}Controller`
51
- */
52
- output?: string;
53
- /**
54
- * Name to be used for the `export * as {{exportAs}} from './`
55
- * @default `"{{tag}}Handlers"`
56
- */
57
- exportAs?: string;
58
- };
59
- /**
60
- * Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
61
- */
62
- exclude?: Array<Exclude>;
63
- /**
64
- * Array containing include parameters to include tags/operations/methods/paths.
65
- */
66
- include?: Array<Include>;
67
- /**
68
- * Array containing override parameters to override `options` based on tags/operations/methods/paths.
69
- */
70
- override?: Array<Override<ResolvedOptions>>;
71
- transformers?: {
72
- /**
73
- * Customize the names based on the type that is provided by the plugin.
74
- */
75
- name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
76
- };
77
- /**
78
- * Make it possible to override one of the templates
79
- */
80
- templates?: Partial<Templates>;
81
- };
82
- type ResolvedOptions = {
83
- extName: KubbFile.Extname | undefined;
84
- templates: NonNullable<Templates>;
85
- };
86
- type PluginMsw = PluginFactoryOptions<'plugin-msw', Options, ResolvedOptions, never, ResolvePathOptions>;
2
+ import { O as Options, P as PluginMsw } from './types-B3_ksuJz.cjs';
3
+ import '@kubb/plugin-oas';
87
4
 
88
5
  declare const pluginMswName = "plugin-msw";
89
6
  declare const pluginMsw: (options?: Options | undefined) => _kubb_core.UserPluginWithLifeCycle<PluginMsw>;
90
7
 
91
- export { type PluginMsw, pluginMsw, pluginMswName };
8
+ export { PluginMsw, pluginMsw, pluginMswName };
package/dist/index.d.ts CHANGED
@@ -1,91 +1,8 @@
1
1
  import * as _kubb_core from '@kubb/core';
2
- import { PluginFactoryOptions, ResolveNameParams } from '@kubb/core';
3
- import * as KubbFile from '@kubb/fs/types';
4
- import { ResolvePathOptions, Exclude, Include, Override } from '@kubb/plugin-oas';
5
- import { Operations, Mock } from './components.js';
6
- import '@kubb/core/utils';
7
- import '@kubb/oas';
8
- import 'react';
9
- import '@kubb/react/types';
10
-
11
- type Templates = {
12
- operations?: typeof Operations.templates | false;
13
- mock?: typeof Mock.templates | false;
14
- };
15
- type Options = {
16
- output?: {
17
- /**
18
- * Relative path to save the MSW mocks.
19
- * When output is a file it will save all models inside that file else it will create a file per schema item.
20
- * @default 'mocks'
21
- */
22
- path: string;
23
- /**
24
- * Name to be used for the `export * as {{exportAs}} from './'`
25
- */
26
- exportAs?: string;
27
- /**
28
- * Add an extension to the generated imports and exports, default it will not use an extension
29
- */
30
- extName?: KubbFile.Extname;
31
- /**
32
- * Define what needs to exported, here you can also disable the export of barrel files
33
- * @default `'barrel'`
34
- */
35
- exportType?: 'barrel' | 'barrelNamed' | false;
36
- };
37
- /**
38
- * Group the MSW mocks based on the provided name.
39
- */
40
- group?: {
41
- /**
42
- * Tag will group based on the operation tag inside the Swagger file
43
- */
44
- type: 'tag';
45
- /**
46
- * Relative path to save the grouped MSW mocks.
47
- *
48
- * `{{tag}}` will be replaced by the current tagName.
49
- * @example `${output}/{{tag}}Controller` => `mocks/PetController`
50
- * @default `${output}/{{tag}}Controller`
51
- */
52
- output?: string;
53
- /**
54
- * Name to be used for the `export * as {{exportAs}} from './`
55
- * @default `"{{tag}}Handlers"`
56
- */
57
- exportAs?: string;
58
- };
59
- /**
60
- * Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
61
- */
62
- exclude?: Array<Exclude>;
63
- /**
64
- * Array containing include parameters to include tags/operations/methods/paths.
65
- */
66
- include?: Array<Include>;
67
- /**
68
- * Array containing override parameters to override `options` based on tags/operations/methods/paths.
69
- */
70
- override?: Array<Override<ResolvedOptions>>;
71
- transformers?: {
72
- /**
73
- * Customize the names based on the type that is provided by the plugin.
74
- */
75
- name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
76
- };
77
- /**
78
- * Make it possible to override one of the templates
79
- */
80
- templates?: Partial<Templates>;
81
- };
82
- type ResolvedOptions = {
83
- extName: KubbFile.Extname | undefined;
84
- templates: NonNullable<Templates>;
85
- };
86
- type PluginMsw = PluginFactoryOptions<'plugin-msw', Options, ResolvedOptions, never, ResolvePathOptions>;
2
+ import { O as Options, P as PluginMsw } from './types-B3_ksuJz.js';
3
+ import '@kubb/plugin-oas';
87
4
 
88
5
  declare const pluginMswName = "plugin-msw";
89
6
  declare const pluginMsw: (options?: Options | undefined) => _kubb_core.UserPluginWithLifeCycle<PluginMsw>;
90
7
 
91
- export { type PluginMsw, pluginMsw, pluginMswName };
8
+ export { PluginMsw, pluginMsw, pluginMswName };
package/dist/index.js CHANGED
@@ -1,134 +1,4 @@
1
- import {
2
- Mock,
3
- Operations
4
- } from "./chunk-3KHLTEUD.js";
5
-
6
- // src/plugin.ts
7
- import path from "node: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 { pluginFakerName } from "@kubb/plugin-faker";
13
- import { pluginTsName } from "@kubb/plugin-ts";
14
-
15
- // src/OperationGenerator.tsx
16
- import { OperationGenerator as Generator } from "@kubb/plugin-oas";
17
- import { Oas } from "@kubb/plugin-oas/components";
18
- import { App, createRoot } from "@kubb/react";
19
- import { jsx } from "@kubb/react/jsx-runtime";
20
- var OperationGenerator = class extends Generator {
21
- async all(operations, operationsByMethod) {
22
- const { oas, pluginManager, plugin, mode } = this.context;
23
- const root = createRoot({
24
- logger: pluginManager.logger
25
- });
26
- const templates = {
27
- operations: Operations.templates,
28
- mock: Mock.templates,
29
- ...this.options.templates
30
- };
31
- root.render(
32
- /* @__PURE__ */ jsx(App, { pluginManager, plugin, mode, children: /* @__PURE__ */ jsx(Oas, { oas, operations, generator: this, children: templates?.operations && /* @__PURE__ */ jsx(Operations.File, { templates: templates.operations }) }) })
33
- );
34
- return root.files;
35
- }
36
- async operation(operation, options) {
37
- const { oas, pluginManager, plugin, mode } = this.context;
38
- const root = createRoot({
39
- logger: pluginManager.logger
40
- });
41
- const templates = {
42
- handlers: Operations.templates,
43
- mock: Mock.templates,
44
- ...options.templates
45
- };
46
- if (!templates?.mock) {
47
- return [];
48
- }
49
- root.render(
50
- /* @__PURE__ */ jsx(App, { pluginManager, plugin: { ...plugin, options }, mode, children: /* @__PURE__ */ jsx(Oas, { oas, operations: [operation], generator: this, children: /* @__PURE__ */ jsx(Oas.Operation, { operation, children: /* @__PURE__ */ jsx(Mock.File, { templates: templates.mock }) }) }) })
51
- );
52
- return root.files;
53
- }
54
- };
55
-
56
- // src/plugin.ts
57
- var pluginMswName = "plugin-msw";
58
- var pluginMsw = createPlugin((options) => {
59
- const { output = { path: "handlers" }, group, exclude = [], include, override = [], transformers = {}, templates } = options;
60
- const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`;
61
- return {
62
- name: pluginMswName,
63
- output: {
64
- exportType: "barrelNamed",
65
- ...output
66
- },
67
- options: {
68
- extName: output.extName,
69
- templates: {
70
- operations: Operations.templates,
71
- mock: Mock.templates,
72
- ...templates
73
- }
74
- },
75
- pre: [pluginOasName, pluginTsName, pluginFakerName],
76
- resolvePath(baseName, pathMode, options2) {
77
- const root = path.resolve(this.config.root, this.config.output.path);
78
- const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path));
79
- if (mode === "single") {
80
- return path.resolve(root, output.path);
81
- }
82
- if (options2?.tag && group?.type === "tag") {
83
- const tag = camelCase(options2.tag);
84
- return path.resolve(root, renderTemplate(template, { tag }), baseName);
85
- }
86
- return path.resolve(root, output.path, baseName);
87
- },
88
- resolveName(name, type) {
89
- const resolvedName = camelCase(name, {
90
- suffix: type ? "handler" : void 0,
91
- isFile: type === "file"
92
- });
93
- if (type) {
94
- return transformers?.name?.(resolvedName, type) || resolvedName;
95
- }
96
- return resolvedName;
97
- },
98
- async buildStart() {
99
- const [swaggerPlugin] = PluginManager.getDependedPlugins(this.plugins, [pluginOasName]);
100
- const oas = await swaggerPlugin.context.getOas();
101
- const root = path.resolve(this.config.root, this.config.output.path);
102
- const mode = FileManager.getMode(path.resolve(root, output.path));
103
- const operationGenerator = new OperationGenerator(this.plugin.options, {
104
- oas,
105
- pluginManager: this.pluginManager,
106
- plugin: this.plugin,
107
- contentType: swaggerPlugin.context.contentType,
108
- exclude,
109
- include,
110
- override,
111
- mode
112
- });
113
- const files = await operationGenerator.build();
114
- await this.addFile(...files);
115
- if (this.config.output.exportType) {
116
- const barrelFiles = await this.fileManager.getBarrelFiles({
117
- root,
118
- output,
119
- files: this.fileManager.files,
120
- meta: {
121
- pluginKey: this.plugin.key
122
- },
123
- logger: this.logger
124
- });
125
- await this.addFile(...barrelFiles);
126
- }
127
- }
128
- };
129
- });
130
- export {
131
- pluginMsw,
132
- pluginMswName
133
- };
1
+ export { pluginMsw, pluginMswName } from './chunk-TW2VMA3H.js';
2
+ import './chunk-6M2QU6UL.js';
3
+ //# sourceMappingURL=index.js.map
134
4
  //# 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'\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,OAA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AAA,QAC3B,QAAQ,SAAS;AAAA,MACnB,CAAC;AACD,UAAI,MAAM;AACR,eAAO,cAAc,OAAO,cAAc,IAAI,KAAK;AAAA,MACrD;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"]}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
@@ -0,0 +1,46 @@
1
+ import { PluginFactoryOptions, Output, Group, ResolveNameParams } from '@kubb/core';
2
+ import { ResolvePathOptions, Exclude, Include, Override, Generator } from '@kubb/plugin-oas';
3
+
4
+ type Options = {
5
+ /**
6
+ * @default 'mocks'
7
+ */
8
+ output?: Output;
9
+ /**
10
+ * Group the MSW mocks based on the provided name.
11
+ */
12
+ group?: Group;
13
+ /**
14
+ * Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
15
+ */
16
+ exclude?: Array<Exclude>;
17
+ /**
18
+ * Array containing include parameters to include tags/operations/methods/paths.
19
+ */
20
+ include?: Array<Include>;
21
+ /**
22
+ * Array containing override parameters to override `options` based on tags/operations/methods/paths.
23
+ */
24
+ override?: Array<Override<ResolvedOptions>>;
25
+ transformers?: {
26
+ /**
27
+ * Customize the names based on the type that is provided by the plugin.
28
+ */
29
+ name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
30
+ };
31
+ /**
32
+ * Create `handlers.ts` file with all handlers grouped by methods.
33
+ * @default `false`
34
+ */
35
+ handlers?: boolean;
36
+ /**
37
+ * Define some generators next to the msw generators
38
+ */
39
+ generators?: Array<Generator<PluginMsw>>;
40
+ };
41
+ type ResolvedOptions = {
42
+ output: Output;
43
+ };
44
+ type PluginMsw = PluginFactoryOptions<'plugin-msw', Options, ResolvedOptions, never, ResolvePathOptions>;
45
+
46
+ export type { Options as O, PluginMsw as P };
@@ -0,0 +1,46 @@
1
+ import { PluginFactoryOptions, Output, Group, ResolveNameParams } from '@kubb/core';
2
+ import { ResolvePathOptions, Exclude, Include, Override, Generator } from '@kubb/plugin-oas';
3
+
4
+ type Options = {
5
+ /**
6
+ * @default 'mocks'
7
+ */
8
+ output?: Output;
9
+ /**
10
+ * Group the MSW mocks based on the provided name.
11
+ */
12
+ group?: Group;
13
+ /**
14
+ * Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
15
+ */
16
+ exclude?: Array<Exclude>;
17
+ /**
18
+ * Array containing include parameters to include tags/operations/methods/paths.
19
+ */
20
+ include?: Array<Include>;
21
+ /**
22
+ * Array containing override parameters to override `options` based on tags/operations/methods/paths.
23
+ */
24
+ override?: Array<Override<ResolvedOptions>>;
25
+ transformers?: {
26
+ /**
27
+ * Customize the names based on the type that is provided by the plugin.
28
+ */
29
+ name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
30
+ };
31
+ /**
32
+ * Create `handlers.ts` file with all handlers grouped by methods.
33
+ * @default `false`
34
+ */
35
+ handlers?: boolean;
36
+ /**
37
+ * Define some generators next to the msw generators
38
+ */
39
+ generators?: Array<Generator<PluginMsw>>;
40
+ };
41
+ type ResolvedOptions = {
42
+ output: Output;
43
+ };
44
+ type PluginMsw = PluginFactoryOptions<'plugin-msw', Options, ResolvedOptions, never, ResolvePathOptions>;
45
+
46
+ export type { Options as O, PluginMsw as P };