@kubb/plugin-cypress 4.12.3 → 4.12.4
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-B0qj_LXl.cjs → components-CNBoaPo0.cjs} +11 -11
- package/dist/{components-B0qj_LXl.cjs.map → components-CNBoaPo0.cjs.map} +1 -1
- package/dist/components.cjs +1 -1
- package/dist/generators-Nkjg7hcp.cjs +75 -0
- package/dist/{generators-CvL7yszV.cjs.map → generators-Nkjg7hcp.cjs.map} +1 -1
- package/dist/generators.cjs +1 -1
- package/dist/index.cjs +13 -13
- package/dist/index.cjs.map +1 -1
- package/package.json +6 -6
- package/dist/generators-CvL7yszV.cjs +0 -75
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
const require_index = require('./index.cjs');
|
|
2
|
-
let
|
|
3
|
-
let
|
|
4
|
-
let
|
|
5
|
-
let
|
|
2
|
+
let _kubb_core_utils = require("@kubb/core/utils");
|
|
3
|
+
let _kubb_react_fabric = require("@kubb/react-fabric");
|
|
4
|
+
let _kubb_oas = require("@kubb/oas");
|
|
5
|
+
let _kubb_react_fabric_jsx_runtime = require("@kubb/react-fabric/jsx-runtime");
|
|
6
6
|
|
|
7
7
|
//#region src/components/Request.tsx
|
|
8
8
|
function Request({ baseURL = "", name, dataReturnType, typeSchemas, url, method }) {
|
|
9
|
-
const params =
|
|
9
|
+
const params = _kubb_react_fabric.FunctionParams.factory({
|
|
10
10
|
data: typeSchemas.request?.name ? {
|
|
11
11
|
type: typeSchemas.request?.name,
|
|
12
|
-
optional: (0,
|
|
12
|
+
optional: (0, _kubb_oas.isOptional)(typeSchemas.request?.schema)
|
|
13
13
|
} : void 0,
|
|
14
14
|
options: {
|
|
15
15
|
type: "Partial<Cypress.RequestOptions>",
|
|
@@ -19,21 +19,21 @@ function Request({ baseURL = "", name, dataReturnType, typeSchemas, url, method
|
|
|
19
19
|
});
|
|
20
20
|
const returnType = dataReturnType === "data" ? `Cypress.Chainable<${typeSchemas.response.name}>` : `Cypress.Chainable<Cypress.Response<${typeSchemas.response.name}>>`;
|
|
21
21
|
const body = typeSchemas.request?.name ? "data" : void 0;
|
|
22
|
-
return /* @__PURE__ */ (0,
|
|
22
|
+
return /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Source, {
|
|
23
23
|
name,
|
|
24
24
|
isIndexable: true,
|
|
25
25
|
isExportable: true,
|
|
26
|
-
children: /* @__PURE__ */ (0,
|
|
26
|
+
children: /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsxs)(_kubb_react_fabric.Function, {
|
|
27
27
|
name,
|
|
28
28
|
export: true,
|
|
29
29
|
params: params.toConstructor(),
|
|
30
30
|
returnType,
|
|
31
31
|
children: [dataReturnType === "data" && `return cy.request({
|
|
32
32
|
method: '${method}',
|
|
33
|
-
url: \`${baseURL ?? ""}${new
|
|
33
|
+
url: \`${baseURL ?? ""}${new _kubb_core_utils.URLPath(url).toURLPath().replace(/([^/]):/g, "$1\\\\:")}\`,
|
|
34
34
|
body: ${body},
|
|
35
35
|
...options,
|
|
36
|
-
}).then((res: Cypress.Response<${typeSchemas.response.name}>) => res.body)`, dataReturnType === "full" && `return cy.request('${method}', '${new
|
|
36
|
+
}).then((res: Cypress.Response<${typeSchemas.response.name}>) => res.body)`, dataReturnType === "full" && `return cy.request('${method}', '${new _kubb_core_utils.URLPath(`${baseURL ?? ""}${url}`).toURLPath()}', ${body})`]
|
|
37
37
|
})
|
|
38
38
|
});
|
|
39
39
|
}
|
|
@@ -45,4 +45,4 @@ Object.defineProperty(exports, 'Request', {
|
|
|
45
45
|
return Request;
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
|
-
//# sourceMappingURL=components-
|
|
48
|
+
//# sourceMappingURL=components-CNBoaPo0.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components-
|
|
1
|
+
{"version":3,"file":"components-CNBoaPo0.cjs","names":["FunctionParams","File","Function","URLPath"],"sources":["../src/components/Request.tsx"],"sourcesContent":["import { URLPath } from '@kubb/core/utils'\nimport { type HttpMethod, isOptional } from '@kubb/oas'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport { File, Function, FunctionParams } from '@kubb/react-fabric'\nimport type { KubbNode } from '@kubb/react-fabric/types'\nimport type { PluginCypress } from '../types.ts'\n\ntype Props = {\n /**\n * Name of the function\n */\n name: string\n typeSchemas: OperationSchemas\n url: string\n baseURL: string | undefined\n dataReturnType: PluginCypress['resolvedOptions']['dataReturnType']\n method: HttpMethod\n}\n\nexport function Request({ baseURL = '', name, dataReturnType, typeSchemas, url, method }: Props): KubbNode {\n const params = FunctionParams.factory({\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n\n options: {\n type: 'Partial<Cypress.RequestOptions>',\n optional: true,\n default: '{}',\n },\n })\n\n const returnType =\n dataReturnType === 'data' ? `Cypress.Chainable<${typeSchemas.response.name}>` : `Cypress.Chainable<Cypress.Response<${typeSchemas.response.name}>>`\n\n const body = typeSchemas.request?.name ? 'data' : undefined\n\n return (\n <File.Source name={name} isIndexable isExportable>\n <Function name={name} export params={params.toConstructor()} returnType={returnType}>\n {dataReturnType === 'data' &&\n `return cy.request({\n method: '${method}', \n url: \\`${baseURL ?? ''}${new URLPath(url).toURLPath().replace(/([^/]):/g, '$1\\\\\\\\:')}\\`, \n body: ${body},\n ...options,\n }).then((res: Cypress.Response<${typeSchemas.response.name}>) => res.body)`}\n {dataReturnType === 'full' && `return cy.request('${method}', '${new URLPath(`${baseURL ?? ''}${url}`).toURLPath()}', ${body})`}\n </Function>\n </File.Source>\n )\n}\n"],"mappings":";;;;;;;AAmBA,SAAgB,QAAQ,EAAE,UAAU,IAAI,MAAM,gBAAgB,aAAa,KAAK,UAA2B;CACzG,MAAM,SAASA,kCAAe,QAAQ;EACpC,MAAM,YAAY,SAAS,OACvB;GACE,MAAM,YAAY,SAAS;GAC3B,oCAAqB,YAAY,SAAS,OAAO;GAClD,GACD;EAEJ,SAAS;GACP,MAAM;GACN,UAAU;GACV,SAAS;GACV;EACF,CAAC;CAEF,MAAM,aACJ,mBAAmB,SAAS,qBAAqB,YAAY,SAAS,KAAK,KAAK,sCAAsC,YAAY,SAAS,KAAK;CAElJ,MAAM,OAAO,YAAY,SAAS,OAAO,SAAS;AAElD,QACE,wDAACC,wBAAK;EAAa;EAAM;EAAY;YACnC,yDAACC;GAAe;GAAM;GAAO,QAAQ,OAAO,eAAe;GAAc;cACtE,mBAAmB,UAClB;uBACa,OAAO;qBACT,WAAW,KAAK,IAAIC,yBAAQ,IAAI,CAAC,WAAW,CAAC,QAAQ,YAAY,UAAU,CAAC;oBAC7E,KAAK;;2CAEkB,YAAY,SAAS,KAAK,kBAC5D,mBAAmB,UAAU,sBAAsB,OAAO,MAAM,IAAIA,yBAAQ,GAAG,WAAW,KAAK,MAAM,CAAC,WAAW,CAAC,KAAK,KAAK;IACpH;GACC"}
|
package/dist/components.cjs
CHANGED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
const require_components = require('./components-CNBoaPo0.cjs');
|
|
2
|
+
const require_index = require('./index.cjs');
|
|
3
|
+
let _kubb_plugin_ts = require("@kubb/plugin-ts");
|
|
4
|
+
let _kubb_core_hooks = require("@kubb/core/hooks");
|
|
5
|
+
let _kubb_core_utils = require("@kubb/core/utils");
|
|
6
|
+
let _kubb_plugin_oas_generators = require("@kubb/plugin-oas/generators");
|
|
7
|
+
let _kubb_plugin_oas_hooks = require("@kubb/plugin-oas/hooks");
|
|
8
|
+
let _kubb_plugin_oas_utils = require("@kubb/plugin-oas/utils");
|
|
9
|
+
let _kubb_react_fabric = require("@kubb/react-fabric");
|
|
10
|
+
let _kubb_react_fabric_jsx_runtime = require("@kubb/react-fabric/jsx-runtime");
|
|
11
|
+
|
|
12
|
+
//#region src/generators/cypressGenerator.tsx
|
|
13
|
+
const cypressGenerator = (0, _kubb_plugin_oas_generators.createReactGenerator)({
|
|
14
|
+
name: "cypress",
|
|
15
|
+
Operation({ operation, generator, plugin }) {
|
|
16
|
+
const { options: { output, baseURL, dataReturnType } } = plugin;
|
|
17
|
+
const pluginManager = (0, _kubb_core_hooks.usePluginManager)();
|
|
18
|
+
const oas = (0, _kubb_plugin_oas_hooks.useOas)();
|
|
19
|
+
const { getSchemas, getName, getFile } = (0, _kubb_plugin_oas_hooks.useOperationManager)(generator);
|
|
20
|
+
const request = {
|
|
21
|
+
name: getName(operation, { type: "function" }),
|
|
22
|
+
file: getFile(operation)
|
|
23
|
+
};
|
|
24
|
+
const type = {
|
|
25
|
+
file: getFile(operation, { pluginKey: [_kubb_plugin_ts.pluginTsName] }),
|
|
26
|
+
schemas: getSchemas(operation, {
|
|
27
|
+
pluginKey: [_kubb_plugin_ts.pluginTsName],
|
|
28
|
+
type: "type"
|
|
29
|
+
})
|
|
30
|
+
};
|
|
31
|
+
return /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsxs)(_kubb_react_fabric.File, {
|
|
32
|
+
baseName: request.file.baseName,
|
|
33
|
+
path: request.file.path,
|
|
34
|
+
meta: request.file.meta,
|
|
35
|
+
banner: (0, _kubb_plugin_oas_utils.getBanner)({
|
|
36
|
+
oas,
|
|
37
|
+
output,
|
|
38
|
+
config: pluginManager.config
|
|
39
|
+
}),
|
|
40
|
+
footer: (0, _kubb_plugin_oas_utils.getFooter)({
|
|
41
|
+
oas,
|
|
42
|
+
output
|
|
43
|
+
}),
|
|
44
|
+
children: [/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
45
|
+
name: [
|
|
46
|
+
type.schemas.request?.name,
|
|
47
|
+
type.schemas.response.name,
|
|
48
|
+
type.schemas.pathParams?.name,
|
|
49
|
+
type.schemas.queryParams?.name,
|
|
50
|
+
type.schemas.headerParams?.name,
|
|
51
|
+
...type.schemas.statusCodes?.map((item) => item.name) || []
|
|
52
|
+
].filter(Boolean),
|
|
53
|
+
root: request.file.path,
|
|
54
|
+
path: type.file.path,
|
|
55
|
+
isTypeOnly: true
|
|
56
|
+
}), /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(require_components.Request, {
|
|
57
|
+
name: request.name,
|
|
58
|
+
dataReturnType,
|
|
59
|
+
typeSchemas: type.schemas,
|
|
60
|
+
method: operation.method,
|
|
61
|
+
baseURL,
|
|
62
|
+
url: new _kubb_core_utils.URLPath(operation.path).toURLPath()
|
|
63
|
+
})]
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
//#endregion
|
|
69
|
+
Object.defineProperty(exports, 'cypressGenerator', {
|
|
70
|
+
enumerable: true,
|
|
71
|
+
get: function () {
|
|
72
|
+
return cypressGenerator;
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
//# sourceMappingURL=generators-Nkjg7hcp.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generators-
|
|
1
|
+
{"version":3,"file":"generators-Nkjg7hcp.cjs","names":["pluginTsName","File","Request","URLPath"],"sources":["../src/generators/cypressGenerator.tsx"],"sourcesContent":["import { usePluginManager } from '@kubb/core/hooks'\nimport { URLPath } from '@kubb/core/utils'\nimport { createReactGenerator } from '@kubb/plugin-oas/generators'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { File } from '@kubb/react-fabric'\nimport { Request } from '../components'\nimport type { PluginCypress } from '../types'\n\nexport const cypressGenerator = createReactGenerator<PluginCypress>({\n name: 'cypress',\n Operation({ operation, generator, plugin }) {\n const {\n options: { output, baseURL, dataReturnType },\n } = plugin\n const pluginManager = usePluginManager()\n\n const oas = useOas()\n const { getSchemas, getName, getFile } = useOperationManager(generator)\n\n const request = {\n name: getName(operation, { type: 'function' }),\n file: getFile(operation),\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={request.file.baseName}\n path={request.file.path}\n meta={request.file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n <File.Import\n name={[\n type.schemas.request?.name,\n type.schemas.response.name,\n type.schemas.pathParams?.name,\n type.schemas.queryParams?.name,\n type.schemas.headerParams?.name,\n ...(type.schemas.statusCodes?.map((item) => item.name) || []),\n ].filter(Boolean)}\n root={request.file.path}\n path={type.file.path}\n isTypeOnly\n />\n <Request\n name={request.name}\n dataReturnType={dataReturnType}\n typeSchemas={type.schemas}\n method={operation.method}\n baseURL={baseURL}\n url={new URLPath(operation.path).toURLPath()}\n />\n </File>\n )\n },\n})\n"],"mappings":";;;;;;;;;;;;AAUA,MAAa,yEAAuD;CAClE,MAAM;CACN,UAAU,EAAE,WAAW,WAAW,UAAU;EAC1C,MAAM,EACJ,SAAS,EAAE,QAAQ,SAAS,qBAC1B;EACJ,MAAM,wDAAkC;EAExC,MAAM,0CAAc;EACpB,MAAM,EAAE,YAAY,SAAS,4DAAgC,UAAU;EAEvE,MAAM,UAAU;GACd,MAAM,QAAQ,WAAW,EAAE,MAAM,YAAY,CAAC;GAC9C,MAAM,QAAQ,UAAU;GACzB;EAED,MAAM,OAAO;GACX,MAAM,QAAQ,WAAW,EAAE,WAAW,CAACA,6BAAa,EAAE,CAAC;GACvD,SAAS,WAAW,WAAW;IAAE,WAAW,CAACA,6BAAa;IAAE,MAAM;IAAQ,CAAC;GAC5E;AAED,SACE,yDAACC;GACC,UAAU,QAAQ,KAAK;GACvB,MAAM,QAAQ,KAAK;GACnB,MAAM,QAAQ,KAAK;GACnB,8CAAkB;IAAE;IAAK;IAAQ,QAAQ,cAAc;IAAQ,CAAC;GAChE,8CAAkB;IAAE;IAAK;IAAQ,CAAC;cAElC,wDAACA,wBAAK;IACJ,MAAM;KACJ,KAAK,QAAQ,SAAS;KACtB,KAAK,QAAQ,SAAS;KACtB,KAAK,QAAQ,YAAY;KACzB,KAAK,QAAQ,aAAa;KAC1B,KAAK,QAAQ,cAAc;KAC3B,GAAI,KAAK,QAAQ,aAAa,KAAK,SAAS,KAAK,KAAK,IAAI,EAAE;KAC7D,CAAC,OAAO,QAAQ;IACjB,MAAM,QAAQ,KAAK;IACnB,MAAM,KAAK,KAAK;IAChB;KACA,EACF,wDAACC;IACC,MAAM,QAAQ;IACE;IAChB,aAAa,KAAK;IAClB,QAAQ,UAAU;IACT;IACT,KAAK,IAAIC,yBAAQ,UAAU,KAAK,CAAC,WAAW;KAC5C;IACG;;CAGZ,CAAC"}
|
package/dist/generators.cjs
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -25,17 +25,17 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
25
25
|
}) : target, mod));
|
|
26
26
|
|
|
27
27
|
//#endregion
|
|
28
|
-
const require_generators = require('./generators-
|
|
28
|
+
const require_generators = require('./generators-Nkjg7hcp.cjs');
|
|
29
29
|
let node_path = require("node:path");
|
|
30
30
|
node_path = __toESM(node_path);
|
|
31
|
-
let
|
|
32
|
-
let
|
|
33
|
-
let
|
|
34
|
-
let
|
|
31
|
+
let _kubb_core = require("@kubb/core");
|
|
32
|
+
let _kubb_core_transformers = require("@kubb/core/transformers");
|
|
33
|
+
let _kubb_plugin_oas = require("@kubb/plugin-oas");
|
|
34
|
+
let _kubb_plugin_ts = require("@kubb/plugin-ts");
|
|
35
35
|
|
|
36
36
|
//#region src/plugin.ts
|
|
37
37
|
const pluginCypressName = "plugin-cypress";
|
|
38
|
-
const pluginCypress = (0,
|
|
38
|
+
const pluginCypress = (0, _kubb_core.definePlugin)((options) => {
|
|
39
39
|
const { output = {
|
|
40
40
|
path: "cypress",
|
|
41
41
|
barrelType: "named"
|
|
@@ -48,10 +48,10 @@ const pluginCypress = (0, __kubb_core.definePlugin)((options) => {
|
|
|
48
48
|
group,
|
|
49
49
|
baseURL
|
|
50
50
|
},
|
|
51
|
-
pre: [
|
|
51
|
+
pre: [_kubb_plugin_oas.pluginOasName, _kubb_plugin_ts.pluginTsName].filter(Boolean),
|
|
52
52
|
resolvePath(baseName, pathMode, options$1) {
|
|
53
53
|
const root = node_path.default.resolve(this.config.root, this.config.output.path);
|
|
54
|
-
if ((pathMode ?? (0,
|
|
54
|
+
if ((pathMode ?? (0, _kubb_core.getMode)(node_path.default.resolve(root, output.path))) === "single")
|
|
55
55
|
/**
|
|
56
56
|
* when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend
|
|
57
57
|
* Other plugins then need to call addOrAppend instead of just add from the fileManager class
|
|
@@ -60,22 +60,22 @@ const pluginCypress = (0, __kubb_core.definePlugin)((options) => {
|
|
|
60
60
|
if (group && (options$1?.group?.path || options$1?.group?.tag)) {
|
|
61
61
|
const groupName = group?.name ? group.name : (ctx) => {
|
|
62
62
|
if (group?.type === "path") return `${ctx.group.split("/")[1]}`;
|
|
63
|
-
return `${(0,
|
|
63
|
+
return `${(0, _kubb_core_transformers.camelCase)(ctx.group)}Requests`;
|
|
64
64
|
};
|
|
65
65
|
return node_path.default.resolve(root, output.path, groupName({ group: group.type === "path" ? options$1.group.path : options$1.group.tag }), baseName);
|
|
66
66
|
}
|
|
67
67
|
return node_path.default.resolve(root, output.path, baseName);
|
|
68
68
|
},
|
|
69
69
|
resolveName(name, type) {
|
|
70
|
-
const resolvedName = (0,
|
|
70
|
+
const resolvedName = (0, _kubb_core_transformers.camelCase)(name, { isFile: type === "file" });
|
|
71
71
|
if (type) return transformers?.name?.(resolvedName, type) || resolvedName;
|
|
72
72
|
return resolvedName;
|
|
73
73
|
},
|
|
74
74
|
async install() {
|
|
75
75
|
const root = node_path.default.resolve(this.config.root, this.config.output.path);
|
|
76
|
-
const mode = (0,
|
|
76
|
+
const mode = (0, _kubb_core.getMode)(node_path.default.resolve(root, output.path));
|
|
77
77
|
const oas = await this.getOas();
|
|
78
|
-
const files = await new
|
|
78
|
+
const files = await new _kubb_plugin_oas.OperationGenerator(this.plugin.options, {
|
|
79
79
|
fabric: this.fabric,
|
|
80
80
|
oas,
|
|
81
81
|
pluginManager: this.pluginManager,
|
|
@@ -88,7 +88,7 @@ const pluginCypress = (0, __kubb_core.definePlugin)((options) => {
|
|
|
88
88
|
mode
|
|
89
89
|
}).build(...generators);
|
|
90
90
|
await this.upsertFile(...files);
|
|
91
|
-
const barrelFiles = await (0,
|
|
91
|
+
const barrelFiles = await (0, _kubb_core.getBarrelFiles)(this.fabric.files, {
|
|
92
92
|
type: output.barrelType ?? "named",
|
|
93
93
|
root,
|
|
94
94
|
output,
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["cypressGenerator","pluginOasName","pluginTsName","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'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { cypressGenerator } from './generators'\nimport type { PluginCypress } from './types.ts'\n\nexport const pluginCypressName = 'plugin-cypress' satisfies PluginCypress['name']\n\nexport const pluginCypress = definePlugin<PluginCypress>((options) => {\n const {\n output = { path: 'cypress', barrelType: 'named' },\n group,\n dataReturnType = 'data',\n exclude = [],\n include,\n override = [],\n transformers = {},\n generators = [cypressGenerator].filter(Boolean),\n contentType,\n baseURL,\n } = options\n\n return {\n name: pluginCypressName,\n options: {\n output,\n dataReturnType,\n group,\n baseURL,\n },\n pre: [pluginOasName, pluginTsName].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)}Requests`\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 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 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 pluginKey: this.plugin.key,\n },\n })\n\n await this.upsertFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,MAAa,oBAAoB;AAEjC,MAAa
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["cypressGenerator","pluginOasName","pluginTsName","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'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { cypressGenerator } from './generators'\nimport type { PluginCypress } from './types.ts'\n\nexport const pluginCypressName = 'plugin-cypress' satisfies PluginCypress['name']\n\nexport const pluginCypress = definePlugin<PluginCypress>((options) => {\n const {\n output = { path: 'cypress', barrelType: 'named' },\n group,\n dataReturnType = 'data',\n exclude = [],\n include,\n override = [],\n transformers = {},\n generators = [cypressGenerator].filter(Boolean),\n contentType,\n baseURL,\n } = options\n\n return {\n name: pluginCypressName,\n options: {\n output,\n dataReturnType,\n group,\n baseURL,\n },\n pre: [pluginOasName, pluginTsName].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)}Requests`\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 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 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 pluginKey: this.plugin.key,\n },\n })\n\n await this.upsertFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,MAAa,oBAAoB;AAEjC,MAAa,8CAA6C,YAAY;CACpE,MAAM,EACJ,SAAS;EAAE,MAAM;EAAW,YAAY;EAAS,EACjD,OACA,iBAAiB,QACjB,UAAU,EAAE,EACZ,SACA,WAAW,EAAE,EACb,eAAe,EAAE,EACjB,aAAa,CAACA,oCAAiB,CAAC,OAAO,QAAQ,EAC/C,aACA,YACE;AAEJ,QAAO;EACL,MAAM;EACN,SAAS;GACP;GACA;GACA;GACA;GACD;EACD,KAAK,CAACC,gCAAeC,6BAAa,CAAC,OAAO,QAAQ;EAClD,YAAY,UAAU,UAAU,WAAS;GACvC,MAAM,OAAOC,kBAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,KAAK;AAGpE,QAFa,oCAAoBA,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,0CAAa,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,sDAAyB,MAAM,EACnC,QAAQ,SAAS,QAClB,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,+BAAeA,kBAAK,QAAQ,MAAM,OAAO,KAAK,CAAC;GACrD,MAAM,MAAM,MAAM,KAAK,QAAQ;GAe/B,MAAM,QAAQ,MAba,IAAIG,oCAAmB,KAAK,OAAO,SAAS;IACrE,QAAQ,KAAK;IACb;IACA,eAAe,KAAK;IACpB,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,qCAAqB,KAAK,OAAO,OAAO;IAC1D,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,WAAW,KAAK,OAAO,KACxB;IACF,CAAC;AAEF,SAAM,KAAK,WAAW,GAAG,YAAY;;EAExC;EACD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-cypress",
|
|
3
|
-
"version": "4.12.
|
|
3
|
+
"version": "4.12.4",
|
|
4
4
|
"description": "Cypress test generator plugin for Kubb, creating end-to-end tests from OpenAPI specifications for automated API testing.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cypress",
|
|
@@ -74,11 +74,11 @@
|
|
|
74
74
|
}
|
|
75
75
|
],
|
|
76
76
|
"dependencies": {
|
|
77
|
-
"@kubb/react-fabric": "0.7.
|
|
78
|
-
"@kubb/core": "4.12.
|
|
79
|
-
"@kubb/oas": "4.12.
|
|
80
|
-
"@kubb/plugin-oas": "4.12.
|
|
81
|
-
"@kubb/plugin-ts": "4.12.
|
|
77
|
+
"@kubb/react-fabric": "0.7.1",
|
|
78
|
+
"@kubb/core": "4.12.4",
|
|
79
|
+
"@kubb/oas": "4.12.4",
|
|
80
|
+
"@kubb/plugin-oas": "4.12.4",
|
|
81
|
+
"@kubb/plugin-ts": "4.12.4"
|
|
82
82
|
},
|
|
83
83
|
"engines": {
|
|
84
84
|
"node": ">=20"
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
const require_components = require('./components-B0qj_LXl.cjs');
|
|
2
|
-
const require_index = require('./index.cjs');
|
|
3
|
-
let __kubb_plugin_ts = require("@kubb/plugin-ts");
|
|
4
|
-
let __kubb_core_hooks = require("@kubb/core/hooks");
|
|
5
|
-
let __kubb_core_utils = require("@kubb/core/utils");
|
|
6
|
-
let __kubb_plugin_oas_generators = require("@kubb/plugin-oas/generators");
|
|
7
|
-
let __kubb_plugin_oas_hooks = require("@kubb/plugin-oas/hooks");
|
|
8
|
-
let __kubb_plugin_oas_utils = require("@kubb/plugin-oas/utils");
|
|
9
|
-
let __kubb_react_fabric = require("@kubb/react-fabric");
|
|
10
|
-
let __kubb_react_fabric_jsx_runtime = require("@kubb/react-fabric/jsx-runtime");
|
|
11
|
-
|
|
12
|
-
//#region src/generators/cypressGenerator.tsx
|
|
13
|
-
const cypressGenerator = (0, __kubb_plugin_oas_generators.createReactGenerator)({
|
|
14
|
-
name: "cypress",
|
|
15
|
-
Operation({ operation, generator, plugin }) {
|
|
16
|
-
const { options: { output, baseURL, dataReturnType } } = plugin;
|
|
17
|
-
const pluginManager = (0, __kubb_core_hooks.usePluginManager)();
|
|
18
|
-
const oas = (0, __kubb_plugin_oas_hooks.useOas)();
|
|
19
|
-
const { getSchemas, getName, getFile } = (0, __kubb_plugin_oas_hooks.useOperationManager)(generator);
|
|
20
|
-
const request = {
|
|
21
|
-
name: getName(operation, { type: "function" }),
|
|
22
|
-
file: getFile(operation)
|
|
23
|
-
};
|
|
24
|
-
const type = {
|
|
25
|
-
file: getFile(operation, { pluginKey: [__kubb_plugin_ts.pluginTsName] }),
|
|
26
|
-
schemas: getSchemas(operation, {
|
|
27
|
-
pluginKey: [__kubb_plugin_ts.pluginTsName],
|
|
28
|
-
type: "type"
|
|
29
|
-
})
|
|
30
|
-
};
|
|
31
|
-
return /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsxs)(__kubb_react_fabric.File, {
|
|
32
|
-
baseName: request.file.baseName,
|
|
33
|
-
path: request.file.path,
|
|
34
|
-
meta: request.file.meta,
|
|
35
|
-
banner: (0, __kubb_plugin_oas_utils.getBanner)({
|
|
36
|
-
oas,
|
|
37
|
-
output,
|
|
38
|
-
config: pluginManager.config
|
|
39
|
-
}),
|
|
40
|
-
footer: (0, __kubb_plugin_oas_utils.getFooter)({
|
|
41
|
-
oas,
|
|
42
|
-
output
|
|
43
|
-
}),
|
|
44
|
-
children: [/* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
|
|
45
|
-
name: [
|
|
46
|
-
type.schemas.request?.name,
|
|
47
|
-
type.schemas.response.name,
|
|
48
|
-
type.schemas.pathParams?.name,
|
|
49
|
-
type.schemas.queryParams?.name,
|
|
50
|
-
type.schemas.headerParams?.name,
|
|
51
|
-
...type.schemas.statusCodes?.map((item) => item.name) || []
|
|
52
|
-
].filter(Boolean),
|
|
53
|
-
root: request.file.path,
|
|
54
|
-
path: type.file.path,
|
|
55
|
-
isTypeOnly: true
|
|
56
|
-
}), /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(require_components.Request, {
|
|
57
|
-
name: request.name,
|
|
58
|
-
dataReturnType,
|
|
59
|
-
typeSchemas: type.schemas,
|
|
60
|
-
method: operation.method,
|
|
61
|
-
baseURL,
|
|
62
|
-
url: new __kubb_core_utils.URLPath(operation.path).toURLPath()
|
|
63
|
-
})]
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
//#endregion
|
|
69
|
-
Object.defineProperty(exports, 'cypressGenerator', {
|
|
70
|
-
enumerable: true,
|
|
71
|
-
get: function () {
|
|
72
|
-
return cypressGenerator;
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
//# sourceMappingURL=generators-CvL7yszV.cjs.map
|