@kubb/plugin-msw 3.16.2 → 3.16.3
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/components-ByUOezvw.js +93 -0
- package/dist/components-ByUOezvw.js.map +1 -0
- package/dist/components-Bz0C7Qrg.cjs +139 -0
- package/dist/components-Bz0C7Qrg.cjs.map +1 -0
- package/dist/components.cjs +4 -19
- package/dist/components.d.cts +47 -33
- package/dist/components.d.ts +47 -33
- package/dist/components.js +3 -3
- package/dist/generators-BjQcx0SS.js +140 -0
- package/dist/generators-BjQcx0SS.js.map +1 -0
- package/dist/generators-DQ6KjdAH.cjs +151 -0
- package/dist/generators-DQ6KjdAH.cjs.map +1 -0
- package/dist/generators.cjs +4 -16
- package/dist/generators.d.cts +9 -8
- package/dist/generators.d.ts +9 -8
- package/dist/generators.js +4 -4
- package/dist/index.cjs +82 -102
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +82 -96
- package/dist/index.js.map +1 -1
- package/dist/types-BOMj2hjt.d.ts +13 -0
- package/dist/types-CxxnBHOU.d.cts +1164 -0
- package/dist/types-DYAniEBx.d.cts +13 -0
- package/dist/types-Dte4R-vh.d.ts +1164 -0
- package/package.json +19 -34
- package/src/components/Mock.tsx +21 -9
- package/src/components/MockWithFaker.tsx +22 -9
- package/src/generators/__snapshots__/createPet.ts +0 -3
- package/src/generators/__snapshots__/createPetFaker.ts +0 -3
- package/src/generators/__snapshots__/deletePet.ts +0 -3
- package/src/generators/mswGenerator.tsx +2 -16
- package/dist/chunk-6ANKBOX6.cjs +0 -113
- package/dist/chunk-6ANKBOX6.cjs.map +0 -1
- package/dist/chunk-FYUFQXX6.cjs +0 -55
- package/dist/chunk-FYUFQXX6.cjs.map +0 -1
- package/dist/chunk-GUSADLEP.js +0 -110
- package/dist/chunk-GUSADLEP.js.map +0 -1
- package/dist/chunk-HL53J5NZ.js +0 -51
- package/dist/chunk-HL53J5NZ.js.map +0 -1
- package/dist/components.cjs.map +0 -1
- package/dist/components.js.map +0 -1
- package/dist/generators.cjs.map +0 -1
- package/dist/generators.js.map +0 -1
- package/dist/types-CzI_io_g.d.cts +0 -64
- package/dist/types-CzI_io_g.d.ts +0 -64
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
const require_components = require('./components-Bz0C7Qrg.cjs');
|
|
2
|
+
const __kubb_plugin_oas = require_components.__toESM(require("@kubb/plugin-oas"));
|
|
3
|
+
const __kubb_plugin_faker = require_components.__toESM(require("@kubb/plugin-faker"));
|
|
4
|
+
const __kubb_plugin_ts = require_components.__toESM(require("@kubb/plugin-ts"));
|
|
5
|
+
const __kubb_plugin_oas_hooks = require_components.__toESM(require("@kubb/plugin-oas/hooks"));
|
|
6
|
+
const __kubb_plugin_oas_utils = require_components.__toESM(require("@kubb/plugin-oas/utils"));
|
|
7
|
+
const __kubb_react = require_components.__toESM(require("@kubb/react"));
|
|
8
|
+
const __kubb_react_jsx_runtime = require_components.__toESM(require("@kubb/react/jsx-runtime"));
|
|
9
|
+
|
|
10
|
+
//#region src/generators/mswGenerator.tsx
|
|
11
|
+
const mswGenerator = (0, __kubb_plugin_oas.createReactGenerator)({
|
|
12
|
+
name: "msw",
|
|
13
|
+
Operation({ operation }) {
|
|
14
|
+
const { pluginManager, plugin: { options: { output, parser, baseURL } } } = (0, __kubb_react.useApp)();
|
|
15
|
+
const oas = (0, __kubb_plugin_oas_hooks.useOas)();
|
|
16
|
+
const { getSchemas, getName, getFile } = (0, __kubb_plugin_oas_hooks.useOperationManager)();
|
|
17
|
+
const mock = {
|
|
18
|
+
name: getName(operation, { type: "function" }),
|
|
19
|
+
file: getFile(operation)
|
|
20
|
+
};
|
|
21
|
+
const faker = {
|
|
22
|
+
file: getFile(operation, { pluginKey: [__kubb_plugin_faker.pluginFakerName] }),
|
|
23
|
+
schemas: getSchemas(operation, {
|
|
24
|
+
pluginKey: [__kubb_plugin_faker.pluginFakerName],
|
|
25
|
+
type: "function"
|
|
26
|
+
})
|
|
27
|
+
};
|
|
28
|
+
const type = {
|
|
29
|
+
file: getFile(operation, { pluginKey: [__kubb_plugin_ts.pluginTsName] }),
|
|
30
|
+
schemas: getSchemas(operation, {
|
|
31
|
+
pluginKey: [__kubb_plugin_ts.pluginTsName],
|
|
32
|
+
type: "type"
|
|
33
|
+
})
|
|
34
|
+
};
|
|
35
|
+
return /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsxs)(__kubb_react.File, {
|
|
36
|
+
baseName: mock.file.baseName,
|
|
37
|
+
path: mock.file.path,
|
|
38
|
+
meta: mock.file.meta,
|
|
39
|
+
banner: (0, __kubb_plugin_oas_utils.getBanner)({
|
|
40
|
+
oas,
|
|
41
|
+
output,
|
|
42
|
+
config: pluginManager.config
|
|
43
|
+
}),
|
|
44
|
+
footer: (0, __kubb_plugin_oas_utils.getFooter)({
|
|
45
|
+
oas,
|
|
46
|
+
output
|
|
47
|
+
}),
|
|
48
|
+
children: [
|
|
49
|
+
/* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Import, {
|
|
50
|
+
name: ["http"],
|
|
51
|
+
path: "msw"
|
|
52
|
+
}),
|
|
53
|
+
/* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Import, {
|
|
54
|
+
name: ["ResponseResolver"],
|
|
55
|
+
isTypeOnly: true,
|
|
56
|
+
path: "msw"
|
|
57
|
+
}),
|
|
58
|
+
/* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Import, {
|
|
59
|
+
name: [type.schemas.response.name],
|
|
60
|
+
path: type.file.path,
|
|
61
|
+
root: mock.file.path,
|
|
62
|
+
isTypeOnly: true
|
|
63
|
+
}),
|
|
64
|
+
parser === "faker" && faker.file && faker.schemas.response && /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Import, {
|
|
65
|
+
name: [faker.schemas.response.name],
|
|
66
|
+
root: mock.file.path,
|
|
67
|
+
path: faker.file.path
|
|
68
|
+
}),
|
|
69
|
+
parser === "faker" && /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(require_components.MockWithFaker, {
|
|
70
|
+
name: mock.name,
|
|
71
|
+
typeName: type.schemas.response.name,
|
|
72
|
+
fakerName: faker.schemas.response.name,
|
|
73
|
+
operation,
|
|
74
|
+
baseURL
|
|
75
|
+
}),
|
|
76
|
+
parser === "data" && /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(require_components.Mock, {
|
|
77
|
+
name: mock.name,
|
|
78
|
+
typeName: type.schemas.response.name,
|
|
79
|
+
fakerName: faker.schemas.response.name,
|
|
80
|
+
operation,
|
|
81
|
+
baseURL
|
|
82
|
+
})
|
|
83
|
+
]
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
//#endregion
|
|
89
|
+
//#region src/generators/handlersGenerator.tsx
|
|
90
|
+
const handlersGenerator = (0, __kubb_plugin_oas.createReactGenerator)({
|
|
91
|
+
name: "plugin-msw",
|
|
92
|
+
Operations({ operations }) {
|
|
93
|
+
const { pluginManager, plugin } = (0, __kubb_react.useApp)();
|
|
94
|
+
const oas = (0, __kubb_plugin_oas_hooks.useOas)();
|
|
95
|
+
const { getName, getFile } = (0, __kubb_plugin_oas_hooks.useOperationManager)();
|
|
96
|
+
const file = pluginManager.getFile({
|
|
97
|
+
name: "handlers",
|
|
98
|
+
extname: ".ts",
|
|
99
|
+
pluginKey: plugin.key
|
|
100
|
+
});
|
|
101
|
+
const imports = operations.map((operation) => {
|
|
102
|
+
const operationFile = getFile(operation, { pluginKey: plugin.key });
|
|
103
|
+
const operationName = getName(operation, {
|
|
104
|
+
pluginKey: plugin.key,
|
|
105
|
+
type: "function"
|
|
106
|
+
});
|
|
107
|
+
return /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Import, {
|
|
108
|
+
name: [operationName],
|
|
109
|
+
root: file.path,
|
|
110
|
+
path: operationFile.path
|
|
111
|
+
}, operationFile.path);
|
|
112
|
+
});
|
|
113
|
+
const handlers = operations.map((operation) => `${getName(operation, {
|
|
114
|
+
type: "function",
|
|
115
|
+
pluginKey: plugin.key
|
|
116
|
+
})}()`);
|
|
117
|
+
return /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsxs)(__kubb_react.File, {
|
|
118
|
+
baseName: file.baseName,
|
|
119
|
+
path: file.path,
|
|
120
|
+
meta: file.meta,
|
|
121
|
+
banner: (0, __kubb_plugin_oas_utils.getBanner)({
|
|
122
|
+
oas,
|
|
123
|
+
output: plugin.options.output,
|
|
124
|
+
config: pluginManager.config
|
|
125
|
+
}),
|
|
126
|
+
footer: (0, __kubb_plugin_oas_utils.getFooter)({
|
|
127
|
+
oas,
|
|
128
|
+
output: plugin.options.output
|
|
129
|
+
}),
|
|
130
|
+
children: [imports, /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(require_components.Handlers, {
|
|
131
|
+
name: "handlers",
|
|
132
|
+
handlers
|
|
133
|
+
})]
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
//#endregion
|
|
139
|
+
Object.defineProperty(exports, 'handlersGenerator', {
|
|
140
|
+
enumerable: true,
|
|
141
|
+
get: function () {
|
|
142
|
+
return handlersGenerator;
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
Object.defineProperty(exports, 'mswGenerator', {
|
|
146
|
+
enumerable: true,
|
|
147
|
+
get: function () {
|
|
148
|
+
return mswGenerator;
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
//# sourceMappingURL=generators-DQ6KjdAH.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generators-DQ6KjdAH.cjs","names":["pluginFakerName","pluginTsName","File","MockWithFaker","Mock","File","Handlers"],"sources":["../src/generators/mswGenerator.tsx","../src/generators/handlersGenerator.tsx"],"sourcesContent":["import { pluginFakerName } from '@kubb/plugin-faker'\nimport { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { File, useApp } from '@kubb/react'\nimport { Mock, MockWithFaker } from '../components'\nimport type { PluginMsw } from '../types'\n\nexport const mswGenerator = createReactGenerator<PluginMsw>({\n name: 'msw',\n Operation({ operation }) {\n const {\n pluginManager,\n plugin: {\n options: { output, parser, baseURL },\n },\n } = useApp<PluginMsw>()\n const oas = useOas()\n const { getSchemas, getName, getFile } = useOperationManager()\n\n const mock = {\n name: getName(operation, { type: 'function' }),\n file: getFile(operation),\n }\n\n const faker = {\n file: getFile(operation, { pluginKey: [pluginFakerName] }),\n schemas: getSchemas(operation, { pluginKey: [pluginFakerName], type: 'function' }),\n }\n\n const type = {\n file: getFile(operation, { pluginKey: [pluginTsName] }),\n schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' }),\n }\n\n return (\n <File\n baseName={mock.file.baseName}\n path={mock.file.path}\n meta={mock.file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n <File.Import name={['http']} path=\"msw\" />\n <File.Import name={['ResponseResolver']} isTypeOnly path=\"msw\" />\n <File.Import name={[type.schemas.response.name]} path={type.file.path} root={mock.file.path} isTypeOnly />\n {parser === 'faker' && faker.file && faker.schemas.response && (\n <File.Import name={[faker.schemas.response.name]} root={mock.file.path} path={faker.file.path} />\n )}\n\n {parser === 'faker' && (\n <MockWithFaker\n name={mock.name}\n typeName={type.schemas.response.name}\n fakerName={faker.schemas.response.name}\n operation={operation}\n baseURL={baseURL}\n />\n )}\n {parser === 'data' && (\n <Mock name={mock.name} typeName={type.schemas.response.name} fakerName={faker.schemas.response.name} operation={operation} baseURL={baseURL} />\n )}\n </File>\n )\n },\n})\n","import { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { File, useApp } from '@kubb/react'\nimport { Handlers } from '../components/Handlers.tsx'\nimport type { PluginMsw } from '../types'\n\nexport const handlersGenerator = createReactGenerator<PluginMsw>({\n name: 'plugin-msw',\n Operations({ operations }) {\n const { pluginManager, plugin } = useApp<PluginMsw>()\n const oas = useOas()\n const { getName, getFile } = useOperationManager()\n\n const file = pluginManager.getFile({ name: 'handlers', extname: '.ts', pluginKey: plugin.key })\n\n const imports = operations.map((operation) => {\n const operationFile = getFile(operation, { pluginKey: plugin.key })\n const operationName = getName(operation, { pluginKey: plugin.key, type: 'function' })\n\n return <File.Import key={operationFile.path} name={[operationName]} root={file.path} path={operationFile.path} />\n })\n\n const handlers = operations.map((operation) => `${getName(operation, { type: 'function', pluginKey: plugin.key })}()`)\n\n return (\n <File\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={getBanner({ oas, output: plugin.options.output, config: pluginManager.config })}\n footer={getFooter({ oas, output: plugin.options.output })}\n >\n {imports}\n <Handlers name={'handlers'} handlers={handlers} />\n </File>\n )\n },\n})\n"],"mappings":";;;;;;;;;;AASA,MAAa,2DAA+C;CAC1D,MAAM;CACN,UAAU,EAAE,WAAW,EAAE;EACvB,MAAM,EACJ,eACA,QAAQ,EACN,SAAS,EAAE,QAAQ,QAAQ,SAAS,EACrC,EACF,6BAAsB;EACvB,MAAM,2CAAc;EACpB,MAAM,EAAE,YAAY,SAAS,SAAS,qDAAwB;EAE9D,MAAM,OAAO;GACX,MAAM,QAAQ,WAAW,EAAE,MAAM,WAAY,EAAC;GAC9C,MAAM,QAAQ,UAAU;EACzB;EAED,MAAM,QAAQ;GACZ,MAAM,QAAQ,WAAW,EAAE,WAAW,CAACA,mCAAgB,EAAE,EAAC;GAC1D,SAAS,WAAW,WAAW;IAAE,WAAW,CAACA,mCAAgB;IAAE,MAAM;GAAY,EA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,SAAS;GAAO,WAAW,OAAO;EAAK,EAAC;EAE/F,MAAM,UAAU,WAAW,IAAI,CAAC,cAAc;GAC5C,MAAM,gBAAgB,QAAQ,WAAW,EAAE,WAAW,OAAO,IAAK,EAAC;GACnE,MAAM,gBAAgB,QAAQ,WAAW;IAAE,WAAW,OAAO;IAAK,MAAM;GAAY,EAAC;AAErF,4DAAQC,kBAAK;IAAgC,MAAM,CAAC,aAAc;IAAE,MAAM,KAAK;IAAM,MAAM,cAAc;MAAhF,cAAc,KAA0E;EAClH,EAAC;EAEF,MAAM,WAAW,WAAW,IAAI,CAAC,cAAc,GAAG,QAAQ,WAAW;GAAE,MAAM;GAAY,WAAW,OAAO;EAAK,EAAC,CAAC,EAAE,CAAC,CAAC;AAEtH,4DACGA;GACC,UAAU,KAAK;GACf,MAAM,KAAK;GACX,MAAM,KAAK;GACX,+CAAkB;IAAE;IAAK,QAAQ,OAAO,QAAQ;IAAQ,QAAQ,cAAc;GAAQ,EAAC;GACvF,+CAAkB;IAAE;IAAK,QAAQ,OAAO,QAAQ;GAAQ,EAAC;cAExD,2DACAC;IAAS,MAAM;IAAsB;KAAY;IAC7C;CAEV;AACF,EAAC"}
|
package/dist/generators.cjs
CHANGED
|
@@ -1,17 +1,5 @@
|
|
|
1
|
-
'
|
|
1
|
+
require('./components-Bz0C7Qrg.cjs');
|
|
2
|
+
const require_generators = require('./generators-DQ6KjdAH.cjs');
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
Object.defineProperty(exports, "handlersGenerator", {
|
|
9
|
-
enumerable: true,
|
|
10
|
-
get: function () { return chunk6ANKBOX6_cjs.handlersGenerator; }
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "mswGenerator", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () { return chunk6ANKBOX6_cjs.mswGenerator; }
|
|
15
|
-
});
|
|
16
|
-
//# sourceMappingURL=generators.cjs.map
|
|
17
|
-
//# sourceMappingURL=generators.cjs.map
|
|
4
|
+
exports.handlersGenerator = require_generators.handlersGenerator;
|
|
5
|
+
exports.mswGenerator = require_generators.mswGenerator;
|
package/dist/generators.d.cts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import '@kubb/core';
|
|
4
|
-
import '@kubb/oas';
|
|
5
|
-
|
|
6
|
-
declare const mswGenerator: _kubb_plugin_oas.Generator<PluginMsw>;
|
|
7
|
-
|
|
8
|
-
declare const handlersGenerator: _kubb_plugin_oas.Generator<PluginMsw>;
|
|
1
|
+
import "./types-DYAniEBx.cjs";
|
|
2
|
+
import { Generator, PluginMsw } from "./types-CxxnBHOU.cjs";
|
|
9
3
|
|
|
4
|
+
//#region src/generators/mswGenerator.d.ts
|
|
5
|
+
declare const mswGenerator: Generator<PluginMsw>;
|
|
6
|
+
//#endregion
|
|
7
|
+
//#region src/generators/handlersGenerator.d.ts
|
|
8
|
+
declare const handlersGenerator: Generator<PluginMsw>;
|
|
9
|
+
//#endregion
|
|
10
10
|
export { handlersGenerator, mswGenerator };
|
|
11
|
+
//# sourceMappingURL=generators.d.cts.map
|
package/dist/generators.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import '@kubb/core';
|
|
4
|
-
import '@kubb/oas';
|
|
5
|
-
|
|
6
|
-
declare const mswGenerator: _kubb_plugin_oas.Generator<PluginMsw>;
|
|
7
|
-
|
|
8
|
-
declare const handlersGenerator: _kubb_plugin_oas.Generator<PluginMsw>;
|
|
1
|
+
import "./types-BOMj2hjt.js";
|
|
2
|
+
import { Generator, PluginMsw } from "./types-Dte4R-vh.js";
|
|
9
3
|
|
|
4
|
+
//#region src/generators/mswGenerator.d.ts
|
|
5
|
+
declare const mswGenerator: Generator<PluginMsw>;
|
|
6
|
+
//#endregion
|
|
7
|
+
//#region src/generators/handlersGenerator.d.ts
|
|
8
|
+
declare const handlersGenerator: Generator<PluginMsw>;
|
|
9
|
+
//#endregion
|
|
10
10
|
export { handlersGenerator, mswGenerator };
|
|
11
|
+
//# sourceMappingURL=generators.d.ts.map
|
package/dist/generators.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import "./components-ByUOezvw.js";
|
|
2
|
+
import { handlersGenerator, mswGenerator } from "./generators-BjQcx0SS.js";
|
|
3
|
+
|
|
4
|
+
export { handlersGenerator, mswGenerator };
|
package/dist/index.cjs
CHANGED
|
@@ -1,108 +1,88 @@
|
|
|
1
|
-
|
|
1
|
+
const require_components = require('./components-Bz0C7Qrg.cjs');
|
|
2
|
+
const require_generators = require('./generators-DQ6KjdAH.cjs');
|
|
3
|
+
const node_path = require_components.__toESM(require("node:path"));
|
|
4
|
+
const __kubb_core = require_components.__toESM(require("@kubb/core"));
|
|
5
|
+
const __kubb_core_transformers = require_components.__toESM(require("@kubb/core/transformers"));
|
|
6
|
+
const __kubb_plugin_oas = require_components.__toESM(require("@kubb/plugin-oas"));
|
|
7
|
+
const __kubb_plugin_faker = require_components.__toESM(require("@kubb/plugin-faker"));
|
|
8
|
+
const __kubb_plugin_ts = require_components.__toESM(require("@kubb/plugin-ts"));
|
|
2
9
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
const oas = await swaggerPlugin.context.getOas();
|
|
77
|
-
const root = path__default.default.resolve(this.config.root, this.config.output.path);
|
|
78
|
-
const mode = core.FileManager.getMode(path__default.default.resolve(root, output.path));
|
|
79
|
-
const operationGenerator = new pluginOas.OperationGenerator(this.plugin.options, {
|
|
80
|
-
oas,
|
|
81
|
-
pluginManager: this.pluginManager,
|
|
82
|
-
plugin: this.plugin,
|
|
83
|
-
contentType,
|
|
84
|
-
exclude,
|
|
85
|
-
include,
|
|
86
|
-
override,
|
|
87
|
-
mode
|
|
88
|
-
});
|
|
89
|
-
const files = await operationGenerator.build(...generators);
|
|
90
|
-
await this.addFile(...files);
|
|
91
|
-
const barrelFiles = await this.fileManager.getBarrelFiles({
|
|
92
|
-
type: output.barrelType ?? "named",
|
|
93
|
-
root,
|
|
94
|
-
output,
|
|
95
|
-
meta: {
|
|
96
|
-
pluginKey: this.plugin.key
|
|
97
|
-
},
|
|
98
|
-
logger: this.logger
|
|
99
|
-
});
|
|
100
|
-
await this.addFile(...barrelFiles);
|
|
101
|
-
}
|
|
102
|
-
};
|
|
10
|
+
//#region src/plugin.ts
|
|
11
|
+
const pluginMswName = "plugin-msw";
|
|
12
|
+
const pluginMsw = (0, __kubb_core.createPlugin)((options) => {
|
|
13
|
+
const { output = {
|
|
14
|
+
path: "handlers",
|
|
15
|
+
barrelType: "named"
|
|
16
|
+
}, 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
|
+
return {
|
|
18
|
+
name: pluginMswName,
|
|
19
|
+
options: {
|
|
20
|
+
output,
|
|
21
|
+
parser,
|
|
22
|
+
group,
|
|
23
|
+
baseURL
|
|
24
|
+
},
|
|
25
|
+
pre: [
|
|
26
|
+
__kubb_plugin_oas.pluginOasName,
|
|
27
|
+
__kubb_plugin_ts.pluginTsName,
|
|
28
|
+
parser === "faker" ? __kubb_plugin_faker.pluginFakerName : void 0
|
|
29
|
+
].filter(Boolean),
|
|
30
|
+
resolvePath(baseName, pathMode, options$1) {
|
|
31
|
+
const root = node_path.default.resolve(this.config.root, this.config.output.path);
|
|
32
|
+
const mode = pathMode ?? __kubb_core.FileManager.getMode(node_path.default.resolve(root, output.path));
|
|
33
|
+
if (mode === "single")
|
|
34
|
+
/**
|
|
35
|
+
* when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend
|
|
36
|
+
* Other plugins then need to call addOrAppend instead of just add from the fileManager class
|
|
37
|
+
*/
|
|
38
|
+
return node_path.default.resolve(root, output.path);
|
|
39
|
+
if (group && (options$1?.group?.path || options$1?.group?.tag)) {
|
|
40
|
+
const groupName = group?.name ? group.name : (ctx) => {
|
|
41
|
+
if (group?.type === "path") return `${ctx.group.split("/")[1]}`;
|
|
42
|
+
return `${(0, __kubb_core_transformers.camelCase)(ctx.group)}Controller`;
|
|
43
|
+
};
|
|
44
|
+
return node_path.default.resolve(root, output.path, groupName({ group: group.type === "path" ? options$1.group.path : options$1.group.tag }), baseName);
|
|
45
|
+
}
|
|
46
|
+
return node_path.default.resolve(root, output.path, baseName);
|
|
47
|
+
},
|
|
48
|
+
resolveName(name, type) {
|
|
49
|
+
const resolvedName = (0, __kubb_core_transformers.camelCase)(name, {
|
|
50
|
+
suffix: type ? "handler" : void 0,
|
|
51
|
+
isFile: type === "file"
|
|
52
|
+
});
|
|
53
|
+
if (type) return transformers?.name?.(resolvedName, type) || resolvedName;
|
|
54
|
+
return resolvedName;
|
|
55
|
+
},
|
|
56
|
+
async buildStart() {
|
|
57
|
+
const [swaggerPlugin] = __kubb_core.PluginManager.getDependedPlugins(this.plugins, [__kubb_plugin_oas.pluginOasName]);
|
|
58
|
+
const oas = await swaggerPlugin.context.getOas();
|
|
59
|
+
const root = node_path.default.resolve(this.config.root, this.config.output.path);
|
|
60
|
+
const mode = __kubb_core.FileManager.getMode(node_path.default.resolve(root, output.path));
|
|
61
|
+
const operationGenerator = new __kubb_plugin_oas.OperationGenerator(this.plugin.options, {
|
|
62
|
+
oas,
|
|
63
|
+
pluginManager: this.pluginManager,
|
|
64
|
+
plugin: this.plugin,
|
|
65
|
+
contentType,
|
|
66
|
+
exclude,
|
|
67
|
+
include,
|
|
68
|
+
override,
|
|
69
|
+
mode
|
|
70
|
+
});
|
|
71
|
+
const files = await operationGenerator.build(...generators);
|
|
72
|
+
await this.addFile(...files);
|
|
73
|
+
const barrelFiles = await this.fileManager.getBarrelFiles({
|
|
74
|
+
type: output.barrelType ?? "named",
|
|
75
|
+
root,
|
|
76
|
+
output,
|
|
77
|
+
meta: { pluginKey: this.plugin.key },
|
|
78
|
+
logger: this.logger
|
|
79
|
+
});
|
|
80
|
+
await this.addFile(...barrelFiles);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
103
83
|
});
|
|
104
84
|
|
|
85
|
+
//#endregion
|
|
105
86
|
exports.pluginMsw = pluginMsw;
|
|
106
87
|
exports.pluginMswName = pluginMswName;
|
|
107
|
-
//# sourceMappingURL=index.cjs.map
|
|
108
88
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["mswGenerator","handlersGenerator","pluginOasName","pluginTsName","pluginFakerName","options","path","FileManager","groupName: Group['name']","PluginManager","OperationGenerator"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\n\nimport { FileManager, type Group, PluginManager, createPlugin } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\n\nimport { pluginFakerName } from '@kubb/plugin-faker'\nimport { pluginTsName } from '@kubb/plugin-ts'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'\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 options: {\n output,\n parser,\n group,\n baseURL,\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 ?? 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 (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: Group['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 [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,\n exclude,\n include,\n override,\n mode,\n })\n\n const files = await operationGenerator.build(...generators)\n await this.addFile(...files)\n\n const barrelFiles = await this.fileManager.getBarrelFiles({\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginKey: this.plugin.key,\n },\n logger: this.logger,\n })\n\n await this.addFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;AAcA,MAAa,gBAAgB;AAE7B,MAAa,0CAAoC,CAAC,YAAY;CAC5D,MAAM,EACJ,SAAS;EAAE,MAAM;EAAY,YAAY;CAAS,GAClD,OACA,UAAU,CAAE,GACZ,SACA,WAAW,CAAE,GACb,eAAe,CAAE,GACjB,WAAW,OACX,SAAS,QACT,aAAa,CAACA,iCAAc,WAAWC,uCAAoB,MAAU,EAAC,OAAO,QAAQ,EACrF,aACA,SACD,GAAG;AAEJ,QAAO;EACL,MAAM;EACN,SAAS;GACP;GACA;GACA;GACA;EACD;EACD,KAAK;GAACC;GAAeC;GAAc,WAAW,UAAUC,sCAAkB;EAAU,EAAC,OAAO,QAAQ;EACpG,YAAY,UAAU,UAAUC,WAAS;GACvC,MAAM,OAAOC,kBAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,KAAK;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;GAC3D,MAAM,KAAK,QAAQ,GAAG,MAAM;GAE5B,MAAM,cAAc,MAAM,KAAK,YAAY,eAAe;IACxD,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,WAAW,KAAK,OAAO,IACxB;IACD,QAAQ,KAAK;GACd,EAAC;GAEF,MAAM,KAAK,QAAQ,GAAG,YAAY;EACnC;CACF;AACF,EAAC"}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import '@kubb/oas';
|
|
4
|
-
import '@kubb/plugin-oas';
|
|
1
|
+
import "./types-DYAniEBx.cjs";
|
|
2
|
+
import { Options, PluginMsw, UserPluginWithLifeCycle } from "./types-CxxnBHOU.cjs";
|
|
5
3
|
|
|
4
|
+
//#region src/plugin.d.ts
|
|
6
5
|
declare const pluginMswName = "plugin-msw";
|
|
7
|
-
declare const pluginMsw: (options?: Options | undefined) =>
|
|
8
|
-
|
|
9
|
-
export { PluginMsw, pluginMsw, pluginMswName };
|
|
6
|
+
declare const pluginMsw: (options?: Options | undefined) => UserPluginWithLifeCycle<PluginMsw>;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { type PluginMsw, pluginMsw, pluginMswName };
|
|
9
|
+
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import '@kubb/oas';
|
|
4
|
-
import '@kubb/plugin-oas';
|
|
1
|
+
import "./types-BOMj2hjt.js";
|
|
2
|
+
import { Options, PluginMsw, UserPluginWithLifeCycle } from "./types-Dte4R-vh.js";
|
|
5
3
|
|
|
4
|
+
//#region src/plugin.d.ts
|
|
6
5
|
declare const pluginMswName = "plugin-msw";
|
|
7
|
-
declare const pluginMsw: (options?: Options | undefined) =>
|
|
8
|
-
|
|
9
|
-
export { PluginMsw, pluginMsw, pluginMswName };
|
|
6
|
+
declare const pluginMsw: (options?: Options | undefined) => UserPluginWithLifeCycle<PluginMsw>;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { type PluginMsw, pluginMsw, pluginMswName };
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|