@kubb/plugin-msw 5.0.0-alpha.34 → 5.0.0-alpha.35
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/index.cjs +4 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
- package/src/plugin.ts +4 -4
package/dist/index.cjs
CHANGED
|
@@ -2,13 +2,13 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
const require_components = require("./components-DIL8YDQs.cjs");
|
|
3
3
|
const require_generators = require("./generators-D0brB1gc.cjs");
|
|
4
4
|
let node_path = require("node:path");
|
|
5
|
-
node_path = require_components.__toESM(node_path);
|
|
5
|
+
node_path = require_components.__toESM(node_path, 1);
|
|
6
6
|
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
10
|
//#region package.json
|
|
11
|
-
var version = "5.0.0-alpha.
|
|
11
|
+
var version = "5.0.0-alpha.35";
|
|
12
12
|
//#endregion
|
|
13
13
|
//#region src/plugin.ts
|
|
14
14
|
const pluginMswName = "plugin-msw";
|
|
@@ -29,7 +29,7 @@ const pluginMsw = (0, _kubb_core.createPlugin)((options) => {
|
|
|
29
29
|
include,
|
|
30
30
|
override
|
|
31
31
|
},
|
|
32
|
-
|
|
32
|
+
dependencies: [
|
|
33
33
|
_kubb_plugin_oas.pluginOasName,
|
|
34
34
|
_kubb_plugin_ts.pluginTsName,
|
|
35
35
|
parser === "faker" ? _kubb_plugin_faker.pluginFakerName : void 0
|
|
@@ -66,7 +66,7 @@ const pluginMsw = (0, _kubb_core.createPlugin)((options) => {
|
|
|
66
66
|
const files = await new _kubb_plugin_oas.OperationGenerator(this.plugin.options, {
|
|
67
67
|
oas,
|
|
68
68
|
driver: this.driver,
|
|
69
|
-
|
|
69
|
+
hooks: this.hooks,
|
|
70
70
|
plugin: this.plugin,
|
|
71
71
|
contentType,
|
|
72
72
|
exclude,
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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 type {
|
|
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 type { ast } from '@kubb/core'\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 dependencies: [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 oas,\n driver: this.driver,\n hooks: this.hooks,\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.driver.fileManager.files as unknown as ast.FileNode[], {\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":";;;;;;;;;;;;;ACWA,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,Y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AAIE,iBAAAA,mBAAmB,KAAK,OAAO,SAAS;IACrE;IACA,QAAQ,KAAK;IACb,OAAO,KAAK;IACZ,QAAQ,KAAK;IACb;IACA;IACA;IACA;IACA;IACD,CAAC,CAEqC,MAAM,GAAG,WAAW;AAC3D,SAAM,KAAK,WAAW,GAAG,MAAM;GAE/B,MAAM,cAAc,OAAA,GAAA,WAAA,gBAAqB,KAAK,OAAO,YAAY,OAAoC;IACnG,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,YAAY,KAAK,OAAO,MACzB;IACF,CAAC;AAEF,SAAM,KAAK,WAAW,GAAG,YAAY;;EAExC;EACD"}
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import { pluginFakerName } from "@kubb/plugin-faker";
|
|
|
7
7
|
import { OperationGenerator, pluginOasName } from "@kubb/plugin-oas";
|
|
8
8
|
import { pluginTsName } from "@kubb/plugin-ts";
|
|
9
9
|
//#region package.json
|
|
10
|
-
var version = "5.0.0-alpha.
|
|
10
|
+
var version = "5.0.0-alpha.35";
|
|
11
11
|
//#endregion
|
|
12
12
|
//#region src/plugin.ts
|
|
13
13
|
const pluginMswName = "plugin-msw";
|
|
@@ -28,7 +28,7 @@ const pluginMsw = createPlugin((options) => {
|
|
|
28
28
|
include,
|
|
29
29
|
override
|
|
30
30
|
},
|
|
31
|
-
|
|
31
|
+
dependencies: [
|
|
32
32
|
pluginOasName,
|
|
33
33
|
pluginTsName,
|
|
34
34
|
parser === "faker" ? pluginFakerName : void 0
|
|
@@ -65,7 +65,7 @@ const pluginMsw = createPlugin((options) => {
|
|
|
65
65
|
const files = await new OperationGenerator(this.plugin.options, {
|
|
66
66
|
oas,
|
|
67
67
|
driver: this.driver,
|
|
68
|
-
|
|
68
|
+
hooks: this.hooks,
|
|
69
69
|
plugin: this.plugin,
|
|
70
70
|
contentType,
|
|
71
71
|
exclude,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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 type {
|
|
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 type { ast } from '@kubb/core'\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 dependencies: [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 oas,\n driver: this.driver,\n hooks: this.hooks,\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.driver.fileManager.files as unknown as ast.FileNode[], {\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":";;;;;;;;;;;;ACWA,MAAa,gBAAgB;AAE7B,MAAa,YAAY,cAAyB,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,CAAC,cAAc,WAAW,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,cAAc;GAAC;GAAe;GAAc,WAAW,UAAU,kBAAkB,KAAA;GAAU,CAAC,OAAO,QAAQ;EAC7G,YAAY,UAAU,UAAU,SAAS;GACvC,MAAM,OAAO,KAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,KAAK;AAGpE,QAFa,YAAY,KAAK,QAAQ,OAAO,MAEhC;;;;;AAKX,UAAO,KAAK,QAAQ,MAAM,OAAO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
2
2
|
"name": "@kubb/plugin-msw",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.35",
|
|
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",
|
|
@@ -76,12 +76,12 @@
|
|
|
76
76
|
}
|
|
77
77
|
],
|
|
78
78
|
"dependencies": {
|
|
79
|
-
"@kubb/core": "5.0.0-alpha.
|
|
80
|
-
"@kubb/oas": "5.0.0-alpha.
|
|
81
|
-
"@kubb/plugin-faker": "5.0.0-alpha.
|
|
82
|
-
"@kubb/plugin-oas": "5.0.0-alpha.
|
|
83
|
-
"@kubb/plugin-ts": "5.0.0-alpha.
|
|
84
|
-
"@kubb/renderer-jsx": "5.0.0-alpha.
|
|
79
|
+
"@kubb/core": "5.0.0-alpha.35",
|
|
80
|
+
"@kubb/oas": "5.0.0-alpha.35",
|
|
81
|
+
"@kubb/plugin-faker": "5.0.0-alpha.35",
|
|
82
|
+
"@kubb/plugin-oas": "5.0.0-alpha.35",
|
|
83
|
+
"@kubb/plugin-ts": "5.0.0-alpha.35",
|
|
84
|
+
"@kubb/renderer-jsx": "5.0.0-alpha.35"
|
|
85
85
|
},
|
|
86
86
|
"devDependencies": {
|
|
87
87
|
"@internals/utils": "0.0.0"
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
"main": "./dist/index.cjs",
|
|
97
97
|
"module": "./dist/index.js",
|
|
98
98
|
"peerDependencies": {
|
|
99
|
-
"@kubb/renderer-jsx": "5.0.0-alpha.
|
|
99
|
+
"@kubb/renderer-jsx": "5.0.0-alpha.35"
|
|
100
100
|
},
|
|
101
101
|
"scripts": {
|
|
102
102
|
"build": "tsdown && size-limit",
|
package/src/plugin.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import path from 'node:path'
|
|
2
2
|
import { camelCase } from '@internals/utils'
|
|
3
|
-
import type {
|
|
3
|
+
import type { ast } from '@kubb/core'
|
|
4
4
|
import { createPlugin, getBarrelFiles, type UserGroup } from '@kubb/core'
|
|
5
5
|
import { pluginFakerName } from '@kubb/plugin-faker'
|
|
6
6
|
import { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'
|
|
@@ -38,7 +38,7 @@ export const pluginMsw = createPlugin<PluginMsw>((options) => {
|
|
|
38
38
|
include,
|
|
39
39
|
override,
|
|
40
40
|
},
|
|
41
|
-
|
|
41
|
+
dependencies: [pluginOasName, pluginTsName, parser === 'faker' ? pluginFakerName : undefined].filter(Boolean),
|
|
42
42
|
resolvePath(baseName, pathMode, options) {
|
|
43
43
|
const root = path.resolve(this.config.root, this.config.output.path)
|
|
44
44
|
const mode = pathMode ?? this.getMode(output)
|
|
@@ -93,7 +93,7 @@ export const pluginMsw = createPlugin<PluginMsw>((options) => {
|
|
|
93
93
|
const operationGenerator = new OperationGenerator(this.plugin.options, {
|
|
94
94
|
oas,
|
|
95
95
|
driver: this.driver,
|
|
96
|
-
|
|
96
|
+
hooks: this.hooks,
|
|
97
97
|
plugin: this.plugin,
|
|
98
98
|
contentType,
|
|
99
99
|
exclude,
|
|
@@ -105,7 +105,7 @@ export const pluginMsw = createPlugin<PluginMsw>((options) => {
|
|
|
105
105
|
const files = await operationGenerator.build(...generators)
|
|
106
106
|
await this.upsertFile(...files)
|
|
107
107
|
|
|
108
|
-
const barrelFiles = await getBarrelFiles(this.driver.fileManager.files as unknown as FileNode[], {
|
|
108
|
+
const barrelFiles = await getBarrelFiles(this.driver.fileManager.files as unknown as ast.FileNode[], {
|
|
109
109
|
type: output.barrelType ?? 'named',
|
|
110
110
|
root,
|
|
111
111
|
output,
|