@kubb/plugin-msw 4.5.1 → 4.5.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.d.cts +1 -1
- package/dist/components.d.ts +1 -1
- package/dist/generators.d.cts +2 -2
- package/dist/generators.d.ts +2 -2
- package/dist/{types-DSnvepCr.d.ts → index-DR442nn_.d.cts} +51 -542
- package/dist/{types-C9Jm40mM.d.cts → index-DvEPuQDh.d.ts} +51 -542
- package/dist/index.cjs +4 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +5 -6
- package/dist/index.js.map +1 -1
- package/dist/types-DpAB0bEq.d.cts +511 -0
- package/dist/types-Y4PSmxId.d.ts +511 -0
- package/package.json +8 -8
- package/src/plugin.ts +5 -8
- package/dist/types-8ZXwr93_.d.cts +0 -13
- package/dist/types-D0JuaurR.d.ts +0 -13
package/dist/index.cjs
CHANGED
|
@@ -15,7 +15,7 @@ __kubb_plugin_ts = require_components.__toESM(__kubb_plugin_ts);
|
|
|
15
15
|
|
|
16
16
|
//#region src/plugin.ts
|
|
17
17
|
const pluginMswName = "plugin-msw";
|
|
18
|
-
const pluginMsw = (0, __kubb_core.
|
|
18
|
+
const pluginMsw = (0, __kubb_core.definePlugin)((options) => {
|
|
19
19
|
const { output = {
|
|
20
20
|
path: "handlers",
|
|
21
21
|
barrelType: "named"
|
|
@@ -58,11 +58,10 @@ const pluginMsw = (0, __kubb_core.createPlugin)((options) => {
|
|
|
58
58
|
if (type) return transformers?.name?.(resolvedName, type) || resolvedName;
|
|
59
59
|
return resolvedName;
|
|
60
60
|
},
|
|
61
|
-
async
|
|
62
|
-
const [swaggerPlugin] = __kubb_core.PluginManager.getDependedPlugins(this.plugins, [__kubb_plugin_oas.pluginOasName]);
|
|
63
|
-
const oas = await swaggerPlugin.context.getOas();
|
|
61
|
+
async install() {
|
|
64
62
|
const root = node_path.default.resolve(this.config.root, this.config.output.path);
|
|
65
63
|
const mode = (0, __kubb_core.getMode)(node_path.default.resolve(root, output.path));
|
|
64
|
+
const oas = await this.getOas();
|
|
66
65
|
const files = await new __kubb_plugin_oas.OperationGenerator(this.plugin.options, {
|
|
67
66
|
fabric: this.fabric,
|
|
68
67
|
oas,
|
|
@@ -75,7 +74,7 @@ const pluginMsw = (0, __kubb_core.createPlugin)((options) => {
|
|
|
75
74
|
mode
|
|
76
75
|
}).build(...generators);
|
|
77
76
|
await this.addFile(...files);
|
|
78
|
-
const barrelFiles = await (0, __kubb_core.getBarrelFiles)(this.
|
|
77
|
+
const barrelFiles = await (0, __kubb_core.getBarrelFiles)(this.fabric.files, {
|
|
79
78
|
type: output.barrelType ?? "named",
|
|
80
79
|
root,
|
|
81
80
|
output,
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["mswGenerator","handlersGenerator","pluginOasName","pluginTsName","pluginFakerName","path","options","groupName: Group['name']","
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["mswGenerator","handlersGenerator","pluginOasName","pluginTsName","pluginFakerName","path","options","groupName: Group['name']","OperationGenerator"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { definePlugin, type Group, getBarrelFiles, getMode } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\n\nimport { pluginFakerName } from '@kubb/plugin-faker'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { handlersGenerator, mswGenerator } from './generators'\nimport type { PluginMsw } from './types.ts'\n\nexport const pluginMswName = 'plugin-msw' satisfies PluginMsw['name']\n\nexport const pluginMsw = definePlugin<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 ?? 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 install() {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = getMode(path.resolve(root, output.path))\n const oas = await this.getOas()\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n fabric: this.fabric,\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 getBarrelFiles(this.fabric.files, {\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":";;;;;;;;;;;;;;;;AAUA,MAAa,gBAAgB;AAE7B,MAAa,2CAAqC,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,iCAAc,WAAWC,uCAAoB,OAAU,CAAC,OAAO,QAAQ,EACrF,aACA,YACE;AAEJ,QAAO;EACL,MAAM;EACN,SAAS;GACP;GACA;GACA;GACA;GACD;EACD,KAAK;GAACC;GAAeC;GAAc,WAAW,UAAUC,sCAAkB;GAAU,CAAC,OAAO,QAAQ;EACpG,YAAY,UAAU,UAAU,WAAS;GACvC,MAAM,OAAOC,kBAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,KAAK;AAGpE,QAFa,qCAAoBA,kBAAK,QAAQ,MAAM,OAAO,KAAK,CAAC,MAEpD;;;;;AAKX,UAAOA,kBAAK,QAAQ,MAAM,OAAO,KAAK;AAGxC,OAAI,UAAUC,WAAS,OAAO,QAAQA,WAAS,OAAO,MAAM;IAC1D,MAAMC,YAA2B,OAAO,OACpC,MAAM,QACL,QAAQ;AACP,SAAI,OAAO,SAAS,OAClB,QAAO,GAAG,IAAI,MAAM,MAAM,IAAI,CAAC;AAEjC,YAAO,2CAAa,IAAI,MAAM,CAAC;;AAGrC,WAAOF,kBAAK,QACV,MACA,OAAO,MACP,UAAU,EACR,OAAO,MAAM,SAAS,SAASC,UAAQ,MAAM,OAAQA,UAAQ,MAAM,KACpE,CAAC,EACF,SACD;;AAGH,UAAOD,kBAAK,QAAQ,MAAM,OAAO,MAAM,SAAS;;EAElD,YAAY,MAAM,MAAM;GACtB,MAAM,uDAAyB,MAAM;IACnC,QAAQ,OAAO,YAAY;IAC3B,QAAQ,SAAS;IAClB,CAAC;AAEF,OAAI,KACF,QAAO,cAAc,OAAO,cAAc,KAAK,IAAI;AAGrD,UAAO;;EAET,MAAM,UAAU;GACd,MAAM,OAAOA,kBAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,KAAK;GACpE,MAAM,gCAAeA,kBAAK,QAAQ,MAAM,OAAO,KAAK,CAAC;GACrD,MAAM,MAAM,MAAM,KAAK,QAAQ;GAc/B,MAAM,QAAQ,MAZa,IAAIG,qCAAmB,KAAK,OAAO,SAAS;IACrE,QAAQ,KAAK;IACb;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb;IACA;IACA;IACA;IACA;IACD,CAAC,CAEqC,MAAM,GAAG,WAAW;AAC3D,SAAM,KAAK,QAAQ,GAAG,MAAM;GAE5B,MAAM,cAAc,sCAAqB,KAAK,OAAO,OAAO;IAC1D,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,WAAW,KAAK,OAAO,KACxB;IACD,QAAQ,KAAK;IACd,CAAC;AAEF,SAAM,KAAK,QAAQ,GAAG,YAAY;;EAErC;EACD"}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import {
|
|
1
|
+
import { l as UserPluginWithLifeCycle } from "./index-DR442nn_.cjs";
|
|
2
|
+
import { n as PluginMsw, t as Options } from "./types-DpAB0bEq.cjs";
|
|
3
3
|
|
|
4
4
|
//#region src/plugin.d.ts
|
|
5
5
|
declare const pluginMswName = "plugin-msw";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import {
|
|
1
|
+
import { l as UserPluginWithLifeCycle } from "./index-DvEPuQDh.js";
|
|
2
|
+
import { n as PluginMsw, t as Options } from "./types-Y4PSmxId.js";
|
|
3
3
|
|
|
4
4
|
//#region src/plugin.d.ts
|
|
5
5
|
declare const pluginMswName = "plugin-msw";
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "./components-IvRPRy3j.js";
|
|
2
2
|
import { n as handlersGenerator, t as mswGenerator } from "./generators-ubi6QbfX.js";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import {
|
|
4
|
+
import { definePlugin, getBarrelFiles, getMode } from "@kubb/core";
|
|
5
5
|
import { camelCase } from "@kubb/core/transformers";
|
|
6
6
|
import { pluginFakerName } from "@kubb/plugin-faker";
|
|
7
7
|
import { OperationGenerator, pluginOasName } from "@kubb/plugin-oas";
|
|
@@ -9,7 +9,7 @@ import { pluginTsName } from "@kubb/plugin-ts";
|
|
|
9
9
|
|
|
10
10
|
//#region src/plugin.ts
|
|
11
11
|
const pluginMswName = "plugin-msw";
|
|
12
|
-
const pluginMsw =
|
|
12
|
+
const pluginMsw = definePlugin((options) => {
|
|
13
13
|
const { output = {
|
|
14
14
|
path: "handlers",
|
|
15
15
|
barrelType: "named"
|
|
@@ -52,11 +52,10 @@ const pluginMsw = createPlugin((options) => {
|
|
|
52
52
|
if (type) return transformers?.name?.(resolvedName, type) || resolvedName;
|
|
53
53
|
return resolvedName;
|
|
54
54
|
},
|
|
55
|
-
async
|
|
56
|
-
const [swaggerPlugin] = PluginManager.getDependedPlugins(this.plugins, [pluginOasName]);
|
|
57
|
-
const oas = await swaggerPlugin.context.getOas();
|
|
55
|
+
async install() {
|
|
58
56
|
const root = path.resolve(this.config.root, this.config.output.path);
|
|
59
57
|
const mode = getMode(path.resolve(root, output.path));
|
|
58
|
+
const oas = await this.getOas();
|
|
60
59
|
const files = await new OperationGenerator(this.plugin.options, {
|
|
61
60
|
fabric: this.fabric,
|
|
62
61
|
oas,
|
|
@@ -69,7 +68,7 @@ const pluginMsw = createPlugin((options) => {
|
|
|
69
68
|
mode
|
|
70
69
|
}).build(...generators);
|
|
71
70
|
await this.addFile(...files);
|
|
72
|
-
const barrelFiles = await getBarrelFiles(this.
|
|
71
|
+
const barrelFiles = await getBarrelFiles(this.fabric.files, {
|
|
73
72
|
type: output.barrelType ?? "named",
|
|
74
73
|
root,
|
|
75
74
|
output,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["options","groupName: Group['name']"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport {
|
|
1
|
+
{"version":3,"file":"index.js","names":["options","groupName: Group['name']"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { definePlugin, type Group, getBarrelFiles, getMode } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\n\nimport { pluginFakerName } from '@kubb/plugin-faker'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { handlersGenerator, mswGenerator } from './generators'\nimport type { PluginMsw } from './types.ts'\n\nexport const pluginMswName = 'plugin-msw' satisfies PluginMsw['name']\n\nexport const pluginMsw = definePlugin<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 ?? 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 install() {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = getMode(path.resolve(root, output.path))\n const oas = await this.getOas()\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n fabric: this.fabric,\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 getBarrelFiles(this.fabric.files, {\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":";;;;;;;;;;AAUA,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,OAAU,CAAC,OAAO,QAAQ,EACrF,aACA,YACE;AAEJ,QAAO;EACL,MAAM;EACN,SAAS;GACP;GACA;GACA;GACA;GACD;EACD,KAAK;GAAC;GAAe;GAAc,WAAW,UAAU,kBAAkB;GAAU,CAAC,OAAO,QAAQ;EACpG,YAAY,UAAU,UAAU,WAAS;GACvC,MAAM,OAAO,KAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,KAAK;AAGpE,QAFa,YAAY,QAAQ,KAAK,QAAQ,MAAM,OAAO,KAAK,CAAC,MAEpD;;;;;AAKX,UAAO,KAAK,QAAQ,MAAM,OAAO,KAAK;AAGxC,OAAI,UAAUA,WAAS,OAAO,QAAQA,WAAS,OAAO,MAAM;IAC1D,MAAMC,YAA2B,OAAO,OACpC,MAAM,QACL,QAAQ;AACP,SAAI,OAAO,SAAS,OAClB,QAAO,GAAG,IAAI,MAAM,MAAM,IAAI,CAAC;AAEjC,YAAO,GAAG,UAAU,IAAI,MAAM,CAAC;;AAGrC,WAAO,KAAK,QACV,MACA,OAAO,MACP,UAAU,EACR,OAAO,MAAM,SAAS,SAASD,UAAQ,MAAM,OAAQA,UAAQ,MAAM,KACpE,CAAC,EACF,SACD;;AAGH,UAAO,KAAK,QAAQ,MAAM,OAAO,MAAM,SAAS;;EAElD,YAAY,MAAM,MAAM;GACtB,MAAM,eAAe,UAAU,MAAM;IACnC,QAAQ,OAAO,YAAY;IAC3B,QAAQ,SAAS;IAClB,CAAC;AAEF,OAAI,KACF,QAAO,cAAc,OAAO,cAAc,KAAK,IAAI;AAGrD,UAAO;;EAET,MAAM,UAAU;GACd,MAAM,OAAO,KAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,KAAK;GACpE,MAAM,OAAO,QAAQ,KAAK,QAAQ,MAAM,OAAO,KAAK,CAAC;GACrD,MAAM,MAAM,MAAM,KAAK,QAAQ;GAc/B,MAAM,QAAQ,MAZa,IAAI,mBAAmB,KAAK,OAAO,SAAS;IACrE,QAAQ,KAAK;IACb;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb;IACA;IACA;IACA;IACA;IACD,CAAC,CAEqC,MAAM,GAAG,WAAW;AAC3D,SAAM,KAAK,QAAQ,GAAG,MAAM;GAE5B,MAAM,cAAc,MAAM,eAAe,KAAK,OAAO,OAAO;IAC1D,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,WAAW,KAAK,OAAO,KACxB;IACD,QAAQ,KAAK;IACd,CAAC;AAEF,SAAM,KAAK,QAAQ,GAAG,YAAY;;EAErC;EACD"}
|
|
@@ -0,0 +1,511 @@
|
|
|
1
|
+
import { a as Output, c as ResolveNameParams, d as Oas, f as HttpMethod, h as contentType, i as Group, m as SchemaObject, n as PluginManager, o as Plugin, p as Operation, r as Config, s as PluginFactoryOptions, t as FileMetaBase, u as BaseGenerator } from "./index-DR442nn_.cjs";
|
|
2
|
+
import { KubbNode } from "@kubb/react-fabric/types";
|
|
3
|
+
import { KubbFile } from "@kubb/fabric-core/types";
|
|
4
|
+
import { Fabric } from "@kubb/react-fabric";
|
|
5
|
+
|
|
6
|
+
//#region ../plugin-oas/src/types.d.ts
|
|
7
|
+
type Context$2 = {
|
|
8
|
+
getOas(): Promise<Oas>;
|
|
9
|
+
getBaseURL(): Promise<string | undefined>;
|
|
10
|
+
};
|
|
11
|
+
declare global {
|
|
12
|
+
namespace Kubb {
|
|
13
|
+
interface PluginContext extends Context$2 {}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
type ResolvePathOptions = {
|
|
17
|
+
pluginKey?: Plugin['key'];
|
|
18
|
+
group?: {
|
|
19
|
+
tag?: string;
|
|
20
|
+
path?: string;
|
|
21
|
+
};
|
|
22
|
+
type?: ResolveNameParams['type'];
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* `propertyName` is the ref name + resolved with the nameResolver
|
|
26
|
+
* @example import { Pet } from './Pet'
|
|
27
|
+
*
|
|
28
|
+
* `originalName` is the original name used(in PascalCase), only used to remove duplicates
|
|
29
|
+
*
|
|
30
|
+
* `pluginKey` can be used to override the current plugin being used, handy when you want to import a type/schema out of another plugin
|
|
31
|
+
* @example import a type(plugin-ts) for a mock file(swagger-faker)
|
|
32
|
+
*/
|
|
33
|
+
type Ref = {
|
|
34
|
+
propertyName: string;
|
|
35
|
+
originalName: string;
|
|
36
|
+
path: KubbFile.Path;
|
|
37
|
+
pluginKey?: Plugin['key'];
|
|
38
|
+
};
|
|
39
|
+
type Refs = Record<string, Ref>;
|
|
40
|
+
type OperationSchema = {
|
|
41
|
+
/**
|
|
42
|
+
* Converted name, contains already `PathParams`, `QueryParams`, ...
|
|
43
|
+
*/
|
|
44
|
+
name: string;
|
|
45
|
+
schema: SchemaObject;
|
|
46
|
+
operation?: Operation;
|
|
47
|
+
/**
|
|
48
|
+
* OperationName in PascalCase, only being used in OperationGenerator
|
|
49
|
+
*/
|
|
50
|
+
operationName: string;
|
|
51
|
+
description?: string;
|
|
52
|
+
statusCode?: number;
|
|
53
|
+
keys?: string[];
|
|
54
|
+
keysToOmit?: string[];
|
|
55
|
+
withData?: boolean;
|
|
56
|
+
};
|
|
57
|
+
type OperationSchemas = {
|
|
58
|
+
pathParams?: OperationSchema & {
|
|
59
|
+
keysToOmit?: never;
|
|
60
|
+
};
|
|
61
|
+
queryParams?: OperationSchema & {
|
|
62
|
+
keysToOmit?: never;
|
|
63
|
+
};
|
|
64
|
+
headerParams?: OperationSchema & {
|
|
65
|
+
keysToOmit?: never;
|
|
66
|
+
};
|
|
67
|
+
request?: OperationSchema;
|
|
68
|
+
response: OperationSchema;
|
|
69
|
+
responses: Array<OperationSchema>;
|
|
70
|
+
statusCodes?: Array<OperationSchema>;
|
|
71
|
+
errors?: Array<OperationSchema>;
|
|
72
|
+
};
|
|
73
|
+
type ByTag = {
|
|
74
|
+
type: 'tag';
|
|
75
|
+
pattern: string | RegExp;
|
|
76
|
+
};
|
|
77
|
+
type ByOperationId = {
|
|
78
|
+
type: 'operationId';
|
|
79
|
+
pattern: string | RegExp;
|
|
80
|
+
};
|
|
81
|
+
type ByPath = {
|
|
82
|
+
type: 'path';
|
|
83
|
+
pattern: string | RegExp;
|
|
84
|
+
};
|
|
85
|
+
type ByMethod = {
|
|
86
|
+
type: 'method';
|
|
87
|
+
pattern: HttpMethod | RegExp;
|
|
88
|
+
};
|
|
89
|
+
type BySchemaName = {
|
|
90
|
+
type: 'schemaName';
|
|
91
|
+
pattern: string | RegExp;
|
|
92
|
+
};
|
|
93
|
+
type ByContentType = {
|
|
94
|
+
type: 'contentType';
|
|
95
|
+
pattern: string | RegExp;
|
|
96
|
+
};
|
|
97
|
+
type Exclude = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
|
|
98
|
+
type Include = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
|
|
99
|
+
type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName | ByContentType) & {
|
|
100
|
+
options: Partial<TOptions>;
|
|
101
|
+
};
|
|
102
|
+
//#endregion
|
|
103
|
+
//#region ../plugin-oas/src/OperationGenerator.d.ts
|
|
104
|
+
type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
105
|
+
fabric: Fabric;
|
|
106
|
+
oas: Oas;
|
|
107
|
+
exclude: Array<Exclude> | undefined;
|
|
108
|
+
include: Array<Include> | undefined;
|
|
109
|
+
override: Array<Override<TOptions>> | undefined;
|
|
110
|
+
contentType: contentType | undefined;
|
|
111
|
+
pluginManager: PluginManager;
|
|
112
|
+
/**
|
|
113
|
+
* Current plugin
|
|
114
|
+
*/
|
|
115
|
+
plugin: Plugin<TPluginOptions>;
|
|
116
|
+
mode: KubbFile.Mode;
|
|
117
|
+
};
|
|
118
|
+
declare class OperationGenerator<TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TPluginOptions['resolvedOptions'], Context$1<TPluginOptions['resolvedOptions'], TPluginOptions>> {
|
|
119
|
+
#private;
|
|
120
|
+
getSchemas(operation: Operation, {
|
|
121
|
+
resolveName
|
|
122
|
+
}?: {
|
|
123
|
+
resolveName?: (name: string) => string;
|
|
124
|
+
}): OperationSchemas;
|
|
125
|
+
getOperations(): Promise<Array<{
|
|
126
|
+
path: string;
|
|
127
|
+
method: HttpMethod;
|
|
128
|
+
operation: Operation;
|
|
129
|
+
}>>;
|
|
130
|
+
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
131
|
+
}
|
|
132
|
+
//#endregion
|
|
133
|
+
//#region ../plugin-oas/src/SchemaMapper.d.ts
|
|
134
|
+
type SchemaKeywordMapper = {
|
|
135
|
+
object: {
|
|
136
|
+
keyword: 'object';
|
|
137
|
+
args: {
|
|
138
|
+
properties: {
|
|
139
|
+
[x: string]: Schema[];
|
|
140
|
+
};
|
|
141
|
+
additionalProperties: Schema[];
|
|
142
|
+
strict?: boolean;
|
|
143
|
+
};
|
|
144
|
+
};
|
|
145
|
+
url: {
|
|
146
|
+
keyword: 'url';
|
|
147
|
+
};
|
|
148
|
+
readOnly: {
|
|
149
|
+
keyword: 'readOnly';
|
|
150
|
+
};
|
|
151
|
+
writeOnly: {
|
|
152
|
+
keyword: 'writeOnly';
|
|
153
|
+
};
|
|
154
|
+
uuid: {
|
|
155
|
+
keyword: 'uuid';
|
|
156
|
+
};
|
|
157
|
+
email: {
|
|
158
|
+
keyword: 'email';
|
|
159
|
+
};
|
|
160
|
+
firstName: {
|
|
161
|
+
keyword: 'firstName';
|
|
162
|
+
};
|
|
163
|
+
lastName: {
|
|
164
|
+
keyword: 'lastName';
|
|
165
|
+
};
|
|
166
|
+
phone: {
|
|
167
|
+
keyword: 'phone';
|
|
168
|
+
};
|
|
169
|
+
password: {
|
|
170
|
+
keyword: 'password';
|
|
171
|
+
};
|
|
172
|
+
date: {
|
|
173
|
+
keyword: 'date';
|
|
174
|
+
args: {
|
|
175
|
+
type?: 'date' | 'string';
|
|
176
|
+
};
|
|
177
|
+
};
|
|
178
|
+
time: {
|
|
179
|
+
keyword: 'time';
|
|
180
|
+
args: {
|
|
181
|
+
type?: 'date' | 'string';
|
|
182
|
+
};
|
|
183
|
+
};
|
|
184
|
+
datetime: {
|
|
185
|
+
keyword: 'datetime';
|
|
186
|
+
args: {
|
|
187
|
+
offset?: boolean;
|
|
188
|
+
local?: boolean;
|
|
189
|
+
};
|
|
190
|
+
};
|
|
191
|
+
tuple: {
|
|
192
|
+
keyword: 'tuple';
|
|
193
|
+
args: {
|
|
194
|
+
items: Schema[];
|
|
195
|
+
min?: number;
|
|
196
|
+
max?: number;
|
|
197
|
+
rest?: Schema;
|
|
198
|
+
};
|
|
199
|
+
};
|
|
200
|
+
array: {
|
|
201
|
+
keyword: 'array';
|
|
202
|
+
args: {
|
|
203
|
+
items: Schema[];
|
|
204
|
+
min?: number;
|
|
205
|
+
max?: number;
|
|
206
|
+
unique?: boolean;
|
|
207
|
+
};
|
|
208
|
+
};
|
|
209
|
+
enum: {
|
|
210
|
+
keyword: 'enum';
|
|
211
|
+
args: {
|
|
212
|
+
name: string;
|
|
213
|
+
typeName: string;
|
|
214
|
+
asConst: boolean;
|
|
215
|
+
items: Array<{
|
|
216
|
+
name: string | number;
|
|
217
|
+
format: 'string' | 'number' | 'boolean';
|
|
218
|
+
value?: string | number | boolean;
|
|
219
|
+
}>;
|
|
220
|
+
};
|
|
221
|
+
};
|
|
222
|
+
and: {
|
|
223
|
+
keyword: 'and';
|
|
224
|
+
args: Schema[];
|
|
225
|
+
};
|
|
226
|
+
const: {
|
|
227
|
+
keyword: 'const';
|
|
228
|
+
args: {
|
|
229
|
+
name: string | number;
|
|
230
|
+
format: 'string' | 'number' | 'boolean';
|
|
231
|
+
value?: string | number | boolean;
|
|
232
|
+
};
|
|
233
|
+
};
|
|
234
|
+
union: {
|
|
235
|
+
keyword: 'union';
|
|
236
|
+
args: Schema[];
|
|
237
|
+
};
|
|
238
|
+
ref: {
|
|
239
|
+
keyword: 'ref';
|
|
240
|
+
args: {
|
|
241
|
+
name: string;
|
|
242
|
+
$ref: string;
|
|
243
|
+
/**
|
|
244
|
+
* Full qualified path.
|
|
245
|
+
*/
|
|
246
|
+
path: KubbFile.Path;
|
|
247
|
+
/**
|
|
248
|
+
* When true `File.Import` will be used.
|
|
249
|
+
* When false a reference will be used inside the current file.
|
|
250
|
+
*/
|
|
251
|
+
isImportable: boolean;
|
|
252
|
+
};
|
|
253
|
+
};
|
|
254
|
+
matches: {
|
|
255
|
+
keyword: 'matches';
|
|
256
|
+
args?: string;
|
|
257
|
+
};
|
|
258
|
+
boolean: {
|
|
259
|
+
keyword: 'boolean';
|
|
260
|
+
};
|
|
261
|
+
default: {
|
|
262
|
+
keyword: 'default';
|
|
263
|
+
args: string | number | boolean;
|
|
264
|
+
};
|
|
265
|
+
string: {
|
|
266
|
+
keyword: 'string';
|
|
267
|
+
};
|
|
268
|
+
integer: {
|
|
269
|
+
keyword: 'integer';
|
|
270
|
+
};
|
|
271
|
+
number: {
|
|
272
|
+
keyword: 'number';
|
|
273
|
+
};
|
|
274
|
+
max: {
|
|
275
|
+
keyword: 'max';
|
|
276
|
+
args: number;
|
|
277
|
+
};
|
|
278
|
+
min: {
|
|
279
|
+
keyword: 'min';
|
|
280
|
+
args: number;
|
|
281
|
+
};
|
|
282
|
+
exclusiveMaximum: {
|
|
283
|
+
keyword: 'exclusiveMaximum';
|
|
284
|
+
args: number;
|
|
285
|
+
};
|
|
286
|
+
exclusiveMinimum: {
|
|
287
|
+
keyword: 'exclusiveMinimum';
|
|
288
|
+
args: number;
|
|
289
|
+
};
|
|
290
|
+
describe: {
|
|
291
|
+
keyword: 'describe';
|
|
292
|
+
args: string;
|
|
293
|
+
};
|
|
294
|
+
example: {
|
|
295
|
+
keyword: 'example';
|
|
296
|
+
args: string;
|
|
297
|
+
};
|
|
298
|
+
deprecated: {
|
|
299
|
+
keyword: 'deprecated';
|
|
300
|
+
};
|
|
301
|
+
optional: {
|
|
302
|
+
keyword: 'optional';
|
|
303
|
+
};
|
|
304
|
+
undefined: {
|
|
305
|
+
keyword: 'undefined';
|
|
306
|
+
};
|
|
307
|
+
nullish: {
|
|
308
|
+
keyword: 'nullish';
|
|
309
|
+
};
|
|
310
|
+
nullable: {
|
|
311
|
+
keyword: 'nullable';
|
|
312
|
+
};
|
|
313
|
+
null: {
|
|
314
|
+
keyword: 'null';
|
|
315
|
+
};
|
|
316
|
+
any: {
|
|
317
|
+
keyword: 'any';
|
|
318
|
+
};
|
|
319
|
+
unknown: {
|
|
320
|
+
keyword: 'unknown';
|
|
321
|
+
};
|
|
322
|
+
void: {
|
|
323
|
+
keyword: 'void';
|
|
324
|
+
};
|
|
325
|
+
blob: {
|
|
326
|
+
keyword: 'blob';
|
|
327
|
+
};
|
|
328
|
+
schema: {
|
|
329
|
+
keyword: 'schema';
|
|
330
|
+
args: {
|
|
331
|
+
type: 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'object';
|
|
332
|
+
format?: string;
|
|
333
|
+
};
|
|
334
|
+
};
|
|
335
|
+
name: {
|
|
336
|
+
keyword: 'name';
|
|
337
|
+
args: string;
|
|
338
|
+
};
|
|
339
|
+
catchall: {
|
|
340
|
+
keyword: 'catchall';
|
|
341
|
+
};
|
|
342
|
+
interface: {
|
|
343
|
+
keyword: 'interface';
|
|
344
|
+
};
|
|
345
|
+
};
|
|
346
|
+
type Schema = {
|
|
347
|
+
keyword: string;
|
|
348
|
+
} | SchemaKeywordMapper[keyof SchemaKeywordMapper];
|
|
349
|
+
//#endregion
|
|
350
|
+
//#region ../plugin-oas/src/SchemaGenerator.d.ts
|
|
351
|
+
type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
352
|
+
fabric: Fabric;
|
|
353
|
+
oas: Oas;
|
|
354
|
+
pluginManager: PluginManager;
|
|
355
|
+
/**
|
|
356
|
+
* Current plugin
|
|
357
|
+
*/
|
|
358
|
+
plugin: Plugin<TPluginOptions>;
|
|
359
|
+
mode: KubbFile.Mode;
|
|
360
|
+
include?: Array<'schemas' | 'responses' | 'requestBodies'>;
|
|
361
|
+
override: Array<Override<TOptions>> | undefined;
|
|
362
|
+
contentType?: contentType;
|
|
363
|
+
output?: string;
|
|
364
|
+
};
|
|
365
|
+
type SchemaGeneratorOptions = {
|
|
366
|
+
dateType: false | 'string' | 'stringOffset' | 'stringLocal' | 'date';
|
|
367
|
+
unknownType: 'any' | 'unknown' | 'void';
|
|
368
|
+
emptySchemaType: 'any' | 'unknown' | 'void';
|
|
369
|
+
enumType?: 'enum' | 'asConst' | 'asPascalConst' | 'constEnum' | 'literal';
|
|
370
|
+
enumSuffix?: string;
|
|
371
|
+
usedEnumNames?: Record<string, number>;
|
|
372
|
+
mapper?: Record<string, string>;
|
|
373
|
+
typed?: boolean;
|
|
374
|
+
transformers: {
|
|
375
|
+
/**
|
|
376
|
+
* Customize the names based on the type that is provided by the plugin.
|
|
377
|
+
*/
|
|
378
|
+
name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
379
|
+
/**
|
|
380
|
+
* Receive schema and name(propertName) and return FakerMeta array
|
|
381
|
+
* TODO TODO add docs
|
|
382
|
+
* @beta
|
|
383
|
+
*/
|
|
384
|
+
schema?: (schemaProps: SchemaProps$1, defaultSchemas: Schema[]) => Schema[] | undefined;
|
|
385
|
+
};
|
|
386
|
+
};
|
|
387
|
+
type SchemaProps$1 = {
|
|
388
|
+
schemaObject?: SchemaObject;
|
|
389
|
+
name?: string;
|
|
390
|
+
parentName?: string;
|
|
391
|
+
};
|
|
392
|
+
declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions, Context<TOptions, TPluginOptions>> {
|
|
393
|
+
#private;
|
|
394
|
+
refs: Refs;
|
|
395
|
+
/**
|
|
396
|
+
* Creates a type node from a given schema.
|
|
397
|
+
* Delegates to getBaseTypeFromSchema internally and
|
|
398
|
+
* optionally adds a union with null.
|
|
399
|
+
*/
|
|
400
|
+
parse(props: SchemaProps$1): Schema[];
|
|
401
|
+
static deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
|
|
402
|
+
static find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
403
|
+
static combineObjects(tree: Schema[] | undefined): Schema[];
|
|
404
|
+
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
405
|
+
}
|
|
406
|
+
//#endregion
|
|
407
|
+
//#region ../plugin-oas/src/generators/createGenerator.d.ts
|
|
408
|
+
type CoreGenerator<TOptions extends PluginFactoryOptions> = {
|
|
409
|
+
name: string;
|
|
410
|
+
type: 'core';
|
|
411
|
+
operations: (props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
412
|
+
operation: (props: OperationProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
413
|
+
schema: (props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
414
|
+
};
|
|
415
|
+
//#endregion
|
|
416
|
+
//#region ../plugin-oas/src/generators/types.d.ts
|
|
417
|
+
type OperationsProps<TOptions extends PluginFactoryOptions> = {
|
|
418
|
+
config: Config;
|
|
419
|
+
generator: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
420
|
+
plugin: Plugin<TOptions>;
|
|
421
|
+
operations: Array<Operation>;
|
|
422
|
+
};
|
|
423
|
+
type OperationProps<TOptions extends PluginFactoryOptions> = {
|
|
424
|
+
config: Config;
|
|
425
|
+
generator: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
426
|
+
plugin: Plugin<TOptions>;
|
|
427
|
+
operation: Operation;
|
|
428
|
+
};
|
|
429
|
+
type SchemaProps<TOptions extends PluginFactoryOptions> = {
|
|
430
|
+
config: Config;
|
|
431
|
+
generator: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>;
|
|
432
|
+
plugin: Plugin<TOptions>;
|
|
433
|
+
schema: {
|
|
434
|
+
name: string;
|
|
435
|
+
tree: Array<Schema>;
|
|
436
|
+
value: SchemaObject;
|
|
437
|
+
};
|
|
438
|
+
};
|
|
439
|
+
type Generator<TOptions extends PluginFactoryOptions> = CoreGenerator<TOptions> | ReactGenerator<TOptions>;
|
|
440
|
+
//#endregion
|
|
441
|
+
//#region ../plugin-oas/src/generators/createReactGenerator.d.ts
|
|
442
|
+
type ReactGenerator<TOptions extends PluginFactoryOptions> = {
|
|
443
|
+
name: string;
|
|
444
|
+
type: 'react';
|
|
445
|
+
Operations: (props: OperationsProps<TOptions>) => KubbNode;
|
|
446
|
+
Operation: (props: OperationProps<TOptions>) => KubbNode;
|
|
447
|
+
Schema: (props: SchemaProps<TOptions>) => KubbNode;
|
|
448
|
+
};
|
|
449
|
+
//#endregion
|
|
450
|
+
//#region src/types.d.ts
|
|
451
|
+
type Options$1 = {
|
|
452
|
+
/**
|
|
453
|
+
* Specify the export location for the files and define the behavior of the output
|
|
454
|
+
* @default { path: 'mocks', barrelType: 'named' }
|
|
455
|
+
*/
|
|
456
|
+
output?: Output<Oas>;
|
|
457
|
+
/**
|
|
458
|
+
* Define which contentType should be used.
|
|
459
|
+
* By default, the first JSON valid mediaType will be used
|
|
460
|
+
*/
|
|
461
|
+
contentType?: contentType;
|
|
462
|
+
baseURL?: string;
|
|
463
|
+
/**
|
|
464
|
+
* Group the MSW mocks based on the provided name.
|
|
465
|
+
*/
|
|
466
|
+
group?: Group;
|
|
467
|
+
/**
|
|
468
|
+
* Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
|
|
469
|
+
*/
|
|
470
|
+
exclude?: Array<Exclude>;
|
|
471
|
+
/**
|
|
472
|
+
* Array containing include parameters to include tags/operations/methods/paths.
|
|
473
|
+
*/
|
|
474
|
+
include?: Array<Include>;
|
|
475
|
+
/**
|
|
476
|
+
* Array containing override parameters to override `options` based on tags/operations/methods/paths.
|
|
477
|
+
*/
|
|
478
|
+
override?: Array<Override<ResolvedOptions>>;
|
|
479
|
+
transformers?: {
|
|
480
|
+
/**
|
|
481
|
+
* Customize the names based on the type that is provided by the plugin.
|
|
482
|
+
*/
|
|
483
|
+
name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
484
|
+
};
|
|
485
|
+
/**
|
|
486
|
+
* Create `handlers.ts` file with all handlers grouped by methods.
|
|
487
|
+
* @default false
|
|
488
|
+
*/
|
|
489
|
+
handlers?: boolean;
|
|
490
|
+
/**
|
|
491
|
+
* Which parser should be used before returning the data to the `Response` of MSW.
|
|
492
|
+
* - `'faker'` will use `@kubb/plugin-faker` to generate the data for the response
|
|
493
|
+
* - `'data'` will use your custom data to generate the data for the response
|
|
494
|
+
* @default 'data'
|
|
495
|
+
*/
|
|
496
|
+
parser?: 'data' | 'faker';
|
|
497
|
+
/**
|
|
498
|
+
* Define some generators next to the msw generators
|
|
499
|
+
*/
|
|
500
|
+
generators?: Array<Generator<PluginMsw>>;
|
|
501
|
+
};
|
|
502
|
+
type ResolvedOptions = {
|
|
503
|
+
output: Output<Oas>;
|
|
504
|
+
group: Options$1['group'];
|
|
505
|
+
parser: NonNullable<Options$1['parser']>;
|
|
506
|
+
baseURL: Options$1['baseURL'] | undefined;
|
|
507
|
+
};
|
|
508
|
+
type PluginMsw = PluginFactoryOptions<'plugin-msw', Options$1, ResolvedOptions, never, ResolvePathOptions>;
|
|
509
|
+
//#endregion
|
|
510
|
+
export { PluginMsw as n, ReactGenerator as r, Options$1 as t };
|
|
511
|
+
//# sourceMappingURL=types-DpAB0bEq.d.cts.map
|