@kubb/plugin-msw 5.0.0-alpha.29 → 5.0.0-alpha.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/generators.d.ts +1 -1
- package/dist/index.cjs +11 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +12 -5
- package/dist/index.js.map +1 -1
- package/dist/{types-1Fgn2AXp.d.ts → types-CsPPMRKY.d.ts} +11 -1
- package/package.json +6 -6
- package/src/plugin.ts +9 -4
- package/src/types.ts +11 -0
package/dist/generators.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
|
-
import { n as PluginMsw } from "./types-
|
|
2
|
+
import { n as PluginMsw } from "./types-CsPPMRKY.js";
|
|
3
3
|
import * as _$_kubb_plugin_oas_generators0 from "@kubb/plugin-oas/generators";
|
|
4
4
|
|
|
5
5
|
//#region src/generators/handlersGenerator.d.ts
|
package/dist/index.cjs
CHANGED
|
@@ -7,6 +7,9 @@ let _kubb_core = require("@kubb/core");
|
|
|
7
7
|
let _kubb_plugin_faker = require("@kubb/plugin-faker");
|
|
8
8
|
let _kubb_plugin_oas = require("@kubb/plugin-oas");
|
|
9
9
|
let _kubb_plugin_ts = require("@kubb/plugin-ts");
|
|
10
|
+
//#region package.json
|
|
11
|
+
var version = "5.0.0-alpha.30";
|
|
12
|
+
//#endregion
|
|
10
13
|
//#region src/plugin.ts
|
|
11
14
|
const pluginMswName = "plugin-msw";
|
|
12
15
|
const pluginMsw = (0, _kubb_core.createPlugin)((options) => {
|
|
@@ -16,11 +19,15 @@ const pluginMsw = (0, _kubb_core.createPlugin)((options) => {
|
|
|
16
19
|
}, group, exclude = [], include, override = [], transformers = {}, handlers = false, parser = "data", generators = [require_generators.mswGenerator, handlers ? require_generators.handlersGenerator : void 0].filter(Boolean), contentType, baseURL } = options;
|
|
17
20
|
return {
|
|
18
21
|
name: pluginMswName,
|
|
22
|
+
version,
|
|
19
23
|
options: {
|
|
20
24
|
output,
|
|
21
25
|
parser,
|
|
22
26
|
group,
|
|
23
|
-
baseURL
|
|
27
|
+
baseURL,
|
|
28
|
+
exclude,
|
|
29
|
+
include,
|
|
30
|
+
override
|
|
24
31
|
},
|
|
25
32
|
pre: [
|
|
26
33
|
_kubb_plugin_oas.pluginOasName,
|
|
@@ -29,7 +36,7 @@ const pluginMsw = (0, _kubb_core.createPlugin)((options) => {
|
|
|
29
36
|
].filter(Boolean),
|
|
30
37
|
resolvePath(baseName, pathMode, options) {
|
|
31
38
|
const root = node_path.default.resolve(this.config.root, this.config.output.path);
|
|
32
|
-
if ((pathMode ??
|
|
39
|
+
if ((pathMode ?? this.getMode(output)) === "single")
|
|
33
40
|
/**
|
|
34
41
|
* when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend
|
|
35
42
|
* Other plugins then need to call addOrAppend instead of just add from the fileManager class
|
|
@@ -52,9 +59,9 @@ const pluginMsw = (0, _kubb_core.createPlugin)((options) => {
|
|
|
52
59
|
if (type) return transformers?.name?.(resolvedName, type) || resolvedName;
|
|
53
60
|
return resolvedName;
|
|
54
61
|
},
|
|
55
|
-
async
|
|
62
|
+
async buildStart() {
|
|
56
63
|
const root = node_path.default.resolve(this.config.root, this.config.output.path);
|
|
57
|
-
const mode =
|
|
64
|
+
const mode = this.getMode(output);
|
|
58
65
|
const oas = await this.getOas();
|
|
59
66
|
const files = await new _kubb_plugin_oas.OperationGenerator(this.plugin.options, {
|
|
60
67
|
fabric: this.fabric,
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["mswGenerator","handlersGenerator","pluginOasName","pluginTsName","pluginFakerName","path","camelCase","OperationGenerator"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { camelCase } from '@internals/utils'\nimport { createPlugin, getBarrelFiles,
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["mswGenerator","handlersGenerator","pluginOasName","pluginTsName","pluginFakerName","path","camelCase","OperationGenerator"],"sources":["../package.json","../src/plugin.ts"],"sourcesContent":["","import path from 'node:path'\nimport { camelCase } from '@internals/utils'\nimport { createPlugin, getBarrelFiles, type UserGroup } from '@kubb/core'\nimport { pluginFakerName } from '@kubb/plugin-faker'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { version } from '../package.json'\nimport { handlersGenerator, mswGenerator } from './generators'\nimport type { PluginMsw } from './types.ts'\n\nexport const pluginMswName = 'plugin-msw' satisfies PluginMsw['name']\n\nexport const pluginMsw = createPlugin<PluginMsw>((options) => {\n const {\n output = { path: 'handlers', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n transformers = {},\n handlers = false,\n parser = 'data',\n generators = [mswGenerator, handlers ? handlersGenerator : undefined].filter(Boolean),\n contentType,\n baseURL,\n } = options\n\n return {\n name: pluginMswName,\n version,\n options: {\n output,\n parser,\n group,\n baseURL,\n exclude,\n include,\n override,\n },\n pre: [pluginOasName, pluginTsName, parser === 'faker' ? pluginFakerName : undefined].filter(Boolean),\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? this.getMode(output)\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 (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: UserGroup['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Controller`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\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\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async buildStart() {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = this.getMode(output)\n const oas = await this.getOas()\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n driver: this.driver,\n events: this.events,\n plugin: this.plugin,\n contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const files = await operationGenerator.build(...generators)\n await this.upsertFile(...files)\n\n const barrelFiles = await getBarrelFiles(this.fabric.files, {\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginName: this.plugin.name,\n },\n })\n\n await this.upsertFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;;ACUA,MAAa,gBAAgB;AAE7B,MAAa,aAAA,GAAA,WAAA,eAAqC,YAAY;CAC5D,MAAM,EACJ,SAAS;EAAE,MAAM;EAAY,YAAY;EAAS,EAClD,OACA,UAAU,EAAE,EACZ,SACA,WAAW,EAAE,EACb,eAAe,EAAE,EACjB,WAAW,OACX,SAAS,QACT,aAAa,CAACA,mBAAAA,cAAc,WAAWC,mBAAAA,oBAAoB,KAAA,EAAU,CAAC,OAAO,QAAQ,EACrF,aACA,YACE;AAEJ,QAAO;EACL,MAAM;EACN;EACA,SAAS;GACP;GACA;GACA;GACA;GACA;GACA;GACA;GACD;EACD,KAAK;GAACC,iBAAAA;GAAeC,gBAAAA;GAAc,WAAW,UAAUC,mBAAAA,kBAAkB,KAAA;GAAU,CAAC,OAAO,QAAQ;EACpG,YAAY,UAAU,UAAU,SAAS;GACvC,MAAM,OAAOC,UAAAA,QAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,KAAK;AAGpE,QAFa,YAAY,KAAK,QAAQ,OAAO,MAEhC;;;;;AAKX,UAAOA,UAAAA,QAAK,QAAQ,MAAM,OAAO,KAAK;A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AExC;EACD"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -2,10 +2,13 @@ import "./chunk--u3MIqq1.js";
|
|
|
2
2
|
import { a as camelCase } from "./components-Hy13rv6B.js";
|
|
3
3
|
import { n as handlersGenerator, t as mswGenerator } from "./generators-NHFKYOuW.js";
|
|
4
4
|
import path from "node:path";
|
|
5
|
-
import { createPlugin, getBarrelFiles
|
|
5
|
+
import { createPlugin, getBarrelFiles } from "@kubb/core";
|
|
6
6
|
import { pluginFakerName } from "@kubb/plugin-faker";
|
|
7
7
|
import { OperationGenerator, pluginOasName } from "@kubb/plugin-oas";
|
|
8
8
|
import { pluginTsName } from "@kubb/plugin-ts";
|
|
9
|
+
//#region package.json
|
|
10
|
+
var version = "5.0.0-alpha.30";
|
|
11
|
+
//#endregion
|
|
9
12
|
//#region src/plugin.ts
|
|
10
13
|
const pluginMswName = "plugin-msw";
|
|
11
14
|
const pluginMsw = createPlugin((options) => {
|
|
@@ -15,11 +18,15 @@ const pluginMsw = createPlugin((options) => {
|
|
|
15
18
|
}, group, exclude = [], include, override = [], transformers = {}, handlers = false, parser = "data", generators = [mswGenerator, handlers ? handlersGenerator : void 0].filter(Boolean), contentType, baseURL } = options;
|
|
16
19
|
return {
|
|
17
20
|
name: pluginMswName,
|
|
21
|
+
version,
|
|
18
22
|
options: {
|
|
19
23
|
output,
|
|
20
24
|
parser,
|
|
21
25
|
group,
|
|
22
|
-
baseURL
|
|
26
|
+
baseURL,
|
|
27
|
+
exclude,
|
|
28
|
+
include,
|
|
29
|
+
override
|
|
23
30
|
},
|
|
24
31
|
pre: [
|
|
25
32
|
pluginOasName,
|
|
@@ -28,7 +35,7 @@ const pluginMsw = createPlugin((options) => {
|
|
|
28
35
|
].filter(Boolean),
|
|
29
36
|
resolvePath(baseName, pathMode, options) {
|
|
30
37
|
const root = path.resolve(this.config.root, this.config.output.path);
|
|
31
|
-
if ((pathMode ?? getMode(
|
|
38
|
+
if ((pathMode ?? this.getMode(output)) === "single")
|
|
32
39
|
/**
|
|
33
40
|
* when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend
|
|
34
41
|
* Other plugins then need to call addOrAppend instead of just add from the fileManager class
|
|
@@ -51,9 +58,9 @@ const pluginMsw = createPlugin((options) => {
|
|
|
51
58
|
if (type) return transformers?.name?.(resolvedName, type) || resolvedName;
|
|
52
59
|
return resolvedName;
|
|
53
60
|
},
|
|
54
|
-
async
|
|
61
|
+
async buildStart() {
|
|
55
62
|
const root = path.resolve(this.config.root, this.config.output.path);
|
|
56
|
-
const mode = getMode(
|
|
63
|
+
const mode = this.getMode(output);
|
|
57
64
|
const oas = await this.getOas();
|
|
58
65
|
const files = await new OperationGenerator(this.plugin.options, {
|
|
59
66
|
fabric: this.fabric,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { camelCase } from '@internals/utils'\nimport { createPlugin, getBarrelFiles,
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../package.json","../src/plugin.ts"],"sourcesContent":["","import path from 'node:path'\nimport { camelCase } from '@internals/utils'\nimport { createPlugin, getBarrelFiles, type UserGroup } from '@kubb/core'\nimport { pluginFakerName } from '@kubb/plugin-faker'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { version } from '../package.json'\nimport { handlersGenerator, mswGenerator } from './generators'\nimport type { PluginMsw } from './types.ts'\n\nexport const pluginMswName = 'plugin-msw' satisfies PluginMsw['name']\n\nexport const pluginMsw = createPlugin<PluginMsw>((options) => {\n const {\n output = { path: 'handlers', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n transformers = {},\n handlers = false,\n parser = 'data',\n generators = [mswGenerator, handlers ? handlersGenerator : undefined].filter(Boolean),\n contentType,\n baseURL,\n } = options\n\n return {\n name: pluginMswName,\n version,\n options: {\n output,\n parser,\n group,\n baseURL,\n exclude,\n include,\n override,\n },\n pre: [pluginOasName, pluginTsName, parser === 'faker' ? pluginFakerName : undefined].filter(Boolean),\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? this.getMode(output)\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 (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: UserGroup['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Controller`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\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\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async buildStart() {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = this.getMode(output)\n const oas = await this.getOas()\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n driver: this.driver,\n events: this.events,\n plugin: this.plugin,\n contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const files = await operationGenerator.build(...generators)\n await this.upsertFile(...files)\n\n const barrelFiles = await getBarrelFiles(this.fabric.files, {\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginName: this.plugin.name,\n },\n })\n\n await this.upsertFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;ACUA,MAAa,gBAAgB;AAE7B,MAAa,YAAY,cAAyB,YAAY;CAC5D,MAAM,EACJ,SAAS;EAAE,MAAM;EAAY,YAAY;EAAS,EAClD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OAAO;GACjC,MAAM,MAAM,MAAM,KAAK,QAAQ;GAe/B,MAAM,QAAQ,MAba,IAAI,mBAAmB,KAAK,OAAO,SAAS;IACrE,QAAQ,KAAK;IACb;IACA,QAAQ,KAAK;IACb,QAAQ,KAAK;IACb,QAAQ,KAAK;IACb;IACA;IACA;IACA;IACA;IACD,CAAC,CAEqC,MAAM,GAAG,WAAW;AAC3D,SAAM,KAAK,WAAW,GAAG,MAAM;GAE/B,MAAM,cAAc,MAAM,eAAe,KAAK,OAAO,OAAO;IAC1D,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,YAAY,KAAK,OAAO,MACzB;IACF,CAAC;AAEF,SAAM,KAAK,WAAW,GAAG,YAAY;;EAExC;EACD"}
|
|
@@ -59,10 +59,20 @@ type Options = {
|
|
|
59
59
|
type ResolvedOptions = {
|
|
60
60
|
output: Output<Oas>;
|
|
61
61
|
group: Options['group'];
|
|
62
|
+
exclude: NonNullable<Options['exclude']>;
|
|
63
|
+
include: Options['include'];
|
|
64
|
+
override: NonNullable<Options['override']>;
|
|
62
65
|
parser: NonNullable<Options['parser']>;
|
|
63
66
|
baseURL: Options['baseURL'] | undefined;
|
|
64
67
|
};
|
|
65
68
|
type PluginMsw = PluginFactoryOptions<'plugin-msw', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
69
|
+
declare global {
|
|
70
|
+
namespace Kubb {
|
|
71
|
+
interface PluginRegistry {
|
|
72
|
+
'plugin-msw': PluginMsw;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
66
76
|
//#endregion
|
|
67
77
|
export { PluginMsw as n, Options as t };
|
|
68
|
-
//# sourceMappingURL=types-
|
|
78
|
+
//# sourceMappingURL=types-CsPPMRKY.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-msw",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.30",
|
|
4
4
|
"description": "Mock Service Worker (MSW) handlers generator plugin for Kubb, creating API mocks from OpenAPI specifications for frontend development and testing.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"msw",
|
|
@@ -77,11 +77,11 @@
|
|
|
77
77
|
],
|
|
78
78
|
"dependencies": {
|
|
79
79
|
"@kubb/react-fabric": "0.15.1",
|
|
80
|
-
"@kubb/core": "5.0.0-alpha.
|
|
81
|
-
"@kubb/oas": "5.0.0-alpha.
|
|
82
|
-
"@kubb/plugin-faker": "5.0.0-alpha.
|
|
83
|
-
"@kubb/plugin-oas": "5.0.0-alpha.
|
|
84
|
-
"@kubb/plugin-ts": "5.0.0-alpha.
|
|
80
|
+
"@kubb/core": "5.0.0-alpha.30",
|
|
81
|
+
"@kubb/oas": "5.0.0-alpha.30",
|
|
82
|
+
"@kubb/plugin-faker": "5.0.0-alpha.30",
|
|
83
|
+
"@kubb/plugin-oas": "5.0.0-alpha.30",
|
|
84
|
+
"@kubb/plugin-ts": "5.0.0-alpha.30"
|
|
85
85
|
},
|
|
86
86
|
"devDependencies": {
|
|
87
87
|
"@internals/utils": "0.0.0"
|
package/src/plugin.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import path from 'node:path'
|
|
2
2
|
import { camelCase } from '@internals/utils'
|
|
3
|
-
import { createPlugin, getBarrelFiles,
|
|
3
|
+
import { createPlugin, getBarrelFiles, type UserGroup } from '@kubb/core'
|
|
4
4
|
import { pluginFakerName } from '@kubb/plugin-faker'
|
|
5
5
|
import { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'
|
|
6
6
|
import { pluginTsName } from '@kubb/plugin-ts'
|
|
7
|
+
import { version } from '../package.json'
|
|
7
8
|
import { handlersGenerator, mswGenerator } from './generators'
|
|
8
9
|
import type { PluginMsw } from './types.ts'
|
|
9
10
|
|
|
@@ -26,16 +27,20 @@ export const pluginMsw = createPlugin<PluginMsw>((options) => {
|
|
|
26
27
|
|
|
27
28
|
return {
|
|
28
29
|
name: pluginMswName,
|
|
30
|
+
version,
|
|
29
31
|
options: {
|
|
30
32
|
output,
|
|
31
33
|
parser,
|
|
32
34
|
group,
|
|
33
35
|
baseURL,
|
|
36
|
+
exclude,
|
|
37
|
+
include,
|
|
38
|
+
override,
|
|
34
39
|
},
|
|
35
40
|
pre: [pluginOasName, pluginTsName, parser === 'faker' ? pluginFakerName : undefined].filter(Boolean),
|
|
36
41
|
resolvePath(baseName, pathMode, options) {
|
|
37
42
|
const root = path.resolve(this.config.root, this.config.output.path)
|
|
38
|
-
const mode = pathMode ?? getMode(
|
|
43
|
+
const mode = pathMode ?? this.getMode(output)
|
|
39
44
|
|
|
40
45
|
if (mode === 'single') {
|
|
41
46
|
/**
|
|
@@ -79,9 +84,9 @@ export const pluginMsw = createPlugin<PluginMsw>((options) => {
|
|
|
79
84
|
|
|
80
85
|
return resolvedName
|
|
81
86
|
},
|
|
82
|
-
async
|
|
87
|
+
async buildStart() {
|
|
83
88
|
const root = path.resolve(this.config.root, this.config.output.path)
|
|
84
|
-
const mode = getMode(
|
|
89
|
+
const mode = this.getMode(output)
|
|
85
90
|
const oas = await this.getOas()
|
|
86
91
|
|
|
87
92
|
const operationGenerator = new OperationGenerator(this.plugin.options, {
|
package/src/types.ts
CHANGED
|
@@ -58,8 +58,19 @@ export type Options = {
|
|
|
58
58
|
type ResolvedOptions = {
|
|
59
59
|
output: Output<Oas>
|
|
60
60
|
group: Options['group']
|
|
61
|
+
exclude: NonNullable<Options['exclude']>
|
|
62
|
+
include: Options['include']
|
|
63
|
+
override: NonNullable<Options['override']>
|
|
61
64
|
parser: NonNullable<Options['parser']>
|
|
62
65
|
baseURL: Options['baseURL'] | undefined
|
|
63
66
|
}
|
|
64
67
|
|
|
65
68
|
export type PluginMsw = PluginFactoryOptions<'plugin-msw', Options, ResolvedOptions, never, ResolvePathOptions>
|
|
69
|
+
|
|
70
|
+
declare global {
|
|
71
|
+
namespace Kubb {
|
|
72
|
+
interface PluginRegistry {
|
|
73
|
+
'plugin-msw': PluginMsw
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|