@kubb/plugin-cypress 4.15.1 → 4.16.0
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-CKNcdnr_.js → components-ByyhXRwB.js} +32 -31
- package/dist/components-ByyhXRwB.js.map +1 -0
- package/dist/{components-UBGR5HIj.cjs → components-CEpexuad.cjs} +31 -30
- package/dist/components-CEpexuad.cjs.map +1 -0
- package/dist/components.cjs +1 -1
- package/dist/components.js +1 -1
- package/dist/{generators-D_AameR6.js → generators-3ldN506W.js} +2 -2
- package/dist/{generators-D_AameR6.js.map → generators-3ldN506W.js.map} +1 -1
- package/dist/{generators-Ct9I-qNg.cjs → generators-FDNmST6B.cjs} +2 -2
- package/dist/{generators-Ct9I-qNg.cjs.map → generators-FDNmST6B.cjs.map} +1 -1
- package/dist/generators.cjs +1 -1
- package/dist/generators.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/package.json +6 -6
- package/src/components/Request.tsx +5 -5
- package/src/generators/__snapshots__/createPet.ts +1 -1
- package/src/generators/__snapshots__/deletePet.ts +1 -1
- package/src/generators/__snapshots__/getPets.ts +1 -1
- package/src/generators/__snapshots__/getPetsWithTemplateString.ts +1 -1
- package/src/generators/__snapshots__/showPetById.ts +1 -1
- package/src/generators/__snapshots__/updatePet.ts +1 -1
- package/dist/components-CKNcdnr_.js.map +0 -1
- package/dist/components-UBGR5HIj.cjs.map +0 -1
|
@@ -1,39 +1,41 @@
|
|
|
1
1
|
import { getPathParams } from "@kubb/plugin-oas/utils";
|
|
2
2
|
import { File, Function, FunctionParams } from "@kubb/react-fabric";
|
|
3
3
|
import { URLPath } from "@kubb/core/utils";
|
|
4
|
-
import { isOptional } from "@kubb/oas";
|
|
4
|
+
import { isAllOptional, isOptional } from "@kubb/oas";
|
|
5
5
|
import { jsx } from "@kubb/react-fabric/jsx-runtime";
|
|
6
6
|
|
|
7
7
|
//#region src/components/Request.tsx
|
|
8
8
|
function getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas }) {
|
|
9
|
-
if (paramsType === "object")
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
9
|
+
if (paramsType === "object") {
|
|
10
|
+
const pathParams = getPathParams(typeSchemas.pathParams, {
|
|
11
|
+
typed: true,
|
|
12
|
+
casing: paramsCasing
|
|
13
|
+
});
|
|
14
|
+
return FunctionParams.factory({
|
|
15
|
+
data: {
|
|
16
|
+
mode: "object",
|
|
17
|
+
children: {
|
|
18
|
+
...pathParams,
|
|
19
|
+
data: typeSchemas.request?.name ? {
|
|
20
|
+
type: typeSchemas.request?.name,
|
|
21
|
+
optional: isOptional(typeSchemas.request?.schema)
|
|
22
|
+
} : void 0,
|
|
23
|
+
params: typeSchemas.queryParams?.name ? {
|
|
24
|
+
type: typeSchemas.queryParams?.name,
|
|
25
|
+
optional: isOptional(typeSchemas.queryParams?.schema)
|
|
26
|
+
} : void 0,
|
|
27
|
+
headers: typeSchemas.headerParams?.name ? {
|
|
28
|
+
type: typeSchemas.headerParams?.name,
|
|
29
|
+
optional: isOptional(typeSchemas.headerParams?.schema)
|
|
30
|
+
} : void 0
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
options: {
|
|
34
|
+
type: "Partial<Cypress.RequestOptions>",
|
|
35
|
+
default: "{}"
|
|
29
36
|
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
type: "Partial<Cypress.RequestOptions>",
|
|
33
|
-
optional: true,
|
|
34
|
-
default: "{}"
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
+
});
|
|
38
|
+
}
|
|
37
39
|
return FunctionParams.factory({
|
|
38
40
|
pathParams: typeSchemas.pathParams?.name ? {
|
|
39
41
|
mode: pathParamsType === "object" ? "object" : "inlineSpread",
|
|
@@ -41,7 +43,7 @@ function getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas }) {
|
|
|
41
43
|
typed: true,
|
|
42
44
|
casing: paramsCasing
|
|
43
45
|
}),
|
|
44
|
-
|
|
46
|
+
default: isAllOptional(typeSchemas.pathParams?.schema) ? "{}" : void 0
|
|
45
47
|
} : void 0,
|
|
46
48
|
data: typeSchemas.request?.name ? {
|
|
47
49
|
type: typeSchemas.request?.name,
|
|
@@ -57,7 +59,6 @@ function getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas }) {
|
|
|
57
59
|
} : void 0,
|
|
58
60
|
options: {
|
|
59
61
|
type: "Partial<Cypress.RequestOptions>",
|
|
60
|
-
optional: true,
|
|
61
62
|
default: "{}"
|
|
62
63
|
}
|
|
63
64
|
});
|
|
@@ -98,4 +99,4 @@ Request.getParams = getParams;
|
|
|
98
99
|
|
|
99
100
|
//#endregion
|
|
100
101
|
export { Request as t };
|
|
101
|
-
//# sourceMappingURL=components-
|
|
102
|
+
//# sourceMappingURL=components-ByyhXRwB.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components-ByyhXRwB.js","names":["requestOptions: string[]"],"sources":["../src/components/Request.tsx"],"sourcesContent":["import { URLPath } from '@kubb/core/utils'\nimport { type HttpMethod, isAllOptional, isOptional } from '@kubb/oas'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport { getPathParams } from '@kubb/plugin-oas/utils'\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 paramsCasing: PluginCypress['resolvedOptions']['paramsCasing']\n paramsType: PluginCypress['resolvedOptions']['paramsType']\n pathParamsType: PluginCypress['resolvedOptions']['pathParamsType']\n method: HttpMethod\n}\n\ntype GetParamsProps = {\n paramsCasing: PluginCypress['resolvedOptions']['paramsCasing']\n paramsType: PluginCypress['resolvedOptions']['paramsType']\n pathParamsType: PluginCypress['resolvedOptions']['pathParamsType']\n typeSchemas: OperationSchemas\n}\n\nfunction getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas }: GetParamsProps) {\n if (paramsType === 'object') {\n const pathParams = getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing })\n\n return FunctionParams.factory({\n data: {\n mode: 'object',\n children: {\n ...pathParams,\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n },\n },\n options: {\n type: 'Partial<Cypress.RequestOptions>',\n default: '{}',\n },\n })\n }\n\n return FunctionParams.factory({\n pathParams: typeSchemas.pathParams?.name\n ? {\n mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n default: isAllOptional(typeSchemas.pathParams?.schema) ? '{}' : undefined,\n }\n : undefined,\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n options: {\n type: 'Partial<Cypress.RequestOptions>',\n default: '{}',\n },\n })\n}\n\nexport function Request({ baseURL = '', name, dataReturnType, typeSchemas, url, method, paramsType, paramsCasing, pathParamsType }: Props): KubbNode {\n const path = new URLPath(url, { casing: paramsCasing })\n\n const params = getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas })\n\n const returnType =\n dataReturnType === 'data' ? `Cypress.Chainable<${typeSchemas.response.name}>` : `Cypress.Chainable<Cypress.Response<${typeSchemas.response.name}>>`\n\n // Build the URL template string - this will convert /pets/:petId to /pets/${petId}\n const urlTemplate = path.toTemplateString({ prefix: baseURL })\n\n // Build request options object\n const requestOptions: string[] = [`method: '${method}'`, `url: ${urlTemplate}`]\n\n // Add query params if they exist\n if (typeSchemas.queryParams?.name) {\n requestOptions.push('qs: params')\n }\n\n // Add headers if they exist\n if (typeSchemas.headerParams?.name) {\n requestOptions.push('headers')\n }\n\n // Add body if request schema exists\n if (typeSchemas.request?.name) {\n requestOptions.push('body: data')\n }\n\n // Spread additional Cypress options\n requestOptions.push('...options')\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<${typeSchemas.response.name}>({\n ${requestOptions.join(',\\n ')}\n}).then((res) => res.body)`\n : `return cy.request<${typeSchemas.response.name}>({\n ${requestOptions.join(',\\n ')}\n})`}\n </Function>\n </File.Source>\n )\n}\n\nRequest.getParams = getParams\n"],"mappings":";;;;;;;AA8BA,SAAS,UAAU,EAAE,YAAY,cAAc,gBAAgB,eAA+B;AAC5F,KAAI,eAAe,UAAU;EAC3B,MAAM,aAAa,cAAc,YAAY,YAAY;GAAE,OAAO;GAAM,QAAQ;GAAc,CAAC;AAE/F,SAAO,eAAe,QAAQ;GAC5B,MAAM;IACJ,MAAM;IACN,UAAU;KACR,GAAG;KACH,MAAM,YAAY,SAAS,OACvB;MACE,MAAM,YAAY,SAAS;MAC3B,UAAU,WAAW,YAAY,SAAS,OAAO;MAClD,GACD;KACJ,QA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AY,OAAO,IAAI,QAAQ,cAAc;AAG/E,KAAI,YAAY,aAAa,KAC3B,gBAAe,KAAK,aAAa;AAInC,KAAI,YAAY,cAAc,KAC5B,gBAAe,KAAK,UAAU;AAIhC,KAAI,YAAY,SAAS,KACvB,gBAAe,KAAK,aAAa;AAInC,gBAAe,KAAK,aAAa;AAEjC,QACE,oBAAC,KAAK;EAAa;EAAM;EAAY;YACnC,oBAAC;GAAe;GAAM;GAAO,QAAQ,OAAO,eAAe;GAAc;aACtE,mBAAmB,SAChB,qBAAqB,YAAY,SAAS,KAAK;IACvD,eAAe,KAAK,QAAQ,CAAC;8BAErB,qBAAqB,YAAY,SAAS,KAAK;IACvD,eAAe,KAAK,QAAQ,CAAC;;IAEhB;GACC;;AAIlB,QAAQ,YAAY"}
|
|
@@ -7,34 +7,36 @@ let _kubb_react_fabric_jsx_runtime = require("@kubb/react-fabric/jsx-runtime");
|
|
|
7
7
|
|
|
8
8
|
//#region src/components/Request.tsx
|
|
9
9
|
function getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas }) {
|
|
10
|
-
if (paramsType === "object")
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
10
|
+
if (paramsType === "object") {
|
|
11
|
+
const pathParams = (0, _kubb_plugin_oas_utils.getPathParams)(typeSchemas.pathParams, {
|
|
12
|
+
typed: true,
|
|
13
|
+
casing: paramsCasing
|
|
14
|
+
});
|
|
15
|
+
return _kubb_react_fabric.FunctionParams.factory({
|
|
16
|
+
data: {
|
|
17
|
+
mode: "object",
|
|
18
|
+
children: {
|
|
19
|
+
...pathParams,
|
|
20
|
+
data: typeSchemas.request?.name ? {
|
|
21
|
+
type: typeSchemas.request?.name,
|
|
22
|
+
optional: (0, _kubb_oas.isOptional)(typeSchemas.request?.schema)
|
|
23
|
+
} : void 0,
|
|
24
|
+
params: typeSchemas.queryParams?.name ? {
|
|
25
|
+
type: typeSchemas.queryParams?.name,
|
|
26
|
+
optional: (0, _kubb_oas.isOptional)(typeSchemas.queryParams?.schema)
|
|
27
|
+
} : void 0,
|
|
28
|
+
headers: typeSchemas.headerParams?.name ? {
|
|
29
|
+
type: typeSchemas.headerParams?.name,
|
|
30
|
+
optional: (0, _kubb_oas.isOptional)(typeSchemas.headerParams?.schema)
|
|
31
|
+
} : void 0
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
options: {
|
|
35
|
+
type: "Partial<Cypress.RequestOptions>",
|
|
36
|
+
default: "{}"
|
|
30
37
|
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
type: "Partial<Cypress.RequestOptions>",
|
|
34
|
-
optional: true,
|
|
35
|
-
default: "{}"
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
+
});
|
|
39
|
+
}
|
|
38
40
|
return _kubb_react_fabric.FunctionParams.factory({
|
|
39
41
|
pathParams: typeSchemas.pathParams?.name ? {
|
|
40
42
|
mode: pathParamsType === "object" ? "object" : "inlineSpread",
|
|
@@ -42,7 +44,7 @@ function getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas }) {
|
|
|
42
44
|
typed: true,
|
|
43
45
|
casing: paramsCasing
|
|
44
46
|
}),
|
|
45
|
-
|
|
47
|
+
default: (0, _kubb_oas.isAllOptional)(typeSchemas.pathParams?.schema) ? "{}" : void 0
|
|
46
48
|
} : void 0,
|
|
47
49
|
data: typeSchemas.request?.name ? {
|
|
48
50
|
type: typeSchemas.request?.name,
|
|
@@ -58,7 +60,6 @@ function getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas }) {
|
|
|
58
60
|
} : void 0,
|
|
59
61
|
options: {
|
|
60
62
|
type: "Partial<Cypress.RequestOptions>",
|
|
61
|
-
optional: true,
|
|
62
63
|
default: "{}"
|
|
63
64
|
}
|
|
64
65
|
});
|
|
@@ -104,4 +105,4 @@ Object.defineProperty(exports, 'Request', {
|
|
|
104
105
|
return Request;
|
|
105
106
|
}
|
|
106
107
|
});
|
|
107
|
-
//# sourceMappingURL=components-
|
|
108
|
+
//# sourceMappingURL=components-CEpexuad.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components-CEpexuad.cjs","names":["FunctionParams","URLPath","requestOptions: string[]","File","Function"],"sources":["../src/components/Request.tsx"],"sourcesContent":["import { URLPath } from '@kubb/core/utils'\nimport { type HttpMethod, isAllOptional, isOptional } from '@kubb/oas'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport { getPathParams } from '@kubb/plugin-oas/utils'\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 paramsCasing: PluginCypress['resolvedOptions']['paramsCasing']\n paramsType: PluginCypress['resolvedOptions']['paramsType']\n pathParamsType: PluginCypress['resolvedOptions']['pathParamsType']\n method: HttpMethod\n}\n\ntype GetParamsProps = {\n paramsCasing: PluginCypress['resolvedOptions']['paramsCasing']\n paramsType: PluginCypress['resolvedOptions']['paramsType']\n pathParamsType: PluginCypress['resolvedOptions']['pathParamsType']\n typeSchemas: OperationSchemas\n}\n\nfunction getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas }: GetParamsProps) {\n if (paramsType === 'object') {\n const pathParams = getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing })\n\n return FunctionParams.factory({\n data: {\n mode: 'object',\n children: {\n ...pathParams,\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n },\n },\n options: {\n type: 'Partial<Cypress.RequestOptions>',\n default: '{}',\n },\n })\n }\n\n return FunctionParams.factory({\n pathParams: typeSchemas.pathParams?.name\n ? {\n mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n default: isAllOptional(typeSchemas.pathParams?.schema) ? '{}' : undefined,\n }\n : undefined,\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n options: {\n type: 'Partial<Cypress.RequestOptions>',\n default: '{}',\n },\n })\n}\n\nexport function Request({ baseURL = '', name, dataReturnType, typeSchemas, url, method, paramsType, paramsCasing, pathParamsType }: Props): KubbNode {\n const path = new URLPath(url, { casing: paramsCasing })\n\n const params = getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas })\n\n const returnType =\n dataReturnType === 'data' ? `Cypress.Chainable<${typeSchemas.response.name}>` : `Cypress.Chainable<Cypress.Response<${typeSchemas.response.name}>>`\n\n // Build the URL template string - this will convert /pets/:petId to /pets/${petId}\n const urlTemplate = path.toTemplateString({ prefix: baseURL })\n\n // Build request options object\n const requestOptions: string[] = [`method: '${method}'`, `url: ${urlTemplate}`]\n\n // Add query params if they exist\n if (typeSchemas.queryParams?.name) {\n requestOptions.push('qs: params')\n }\n\n // Add headers if they exist\n if (typeSchemas.headerParams?.name) {\n requestOptions.push('headers')\n }\n\n // Add body if request schema exists\n if (typeSchemas.request?.name) {\n requestOptions.push('body: data')\n }\n\n // Spread additional Cypress options\n requestOptions.push('...options')\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<${typeSchemas.response.name}>({\n ${requestOptions.join(',\\n ')}\n}).then((res) => res.body)`\n : `return cy.request<${typeSchemas.response.name}>({\n ${requestOptions.join(',\\n ')}\n})`}\n </Function>\n </File.Source>\n )\n}\n\nRequest.getParams = getParams\n"],"mappings":";;;;;;;;AA8BA,SAAS,UAAU,EAAE,YAAY,cAAc,gBAAgB,eAA+B;AAC5F,KAAI,eAAe,UAAU;EAC3B,MAAM,uDAA2B,YAAY,YAAY;GAAE,OAAO;GAAM,QAAQ;GAAc,CAAC;AAE/F,SAAOA,kCAAe,QAAQ;GAC5B,MAAM;IACJ,MAAM;IACN,UAAU;KACR,GAAG;KACH,MAAM,YAAY,SAAS,OACvB;MACE,MAAM,YAAY,SAAS;MAC3B,oCAAqB,YAAY,SAAS,OAAO;MAClD,GACD;KACJ,QAAQ,YAAY,aAAa,OAC7B;MACE,MAAM,YAAY,aAAa;MAC/B,oCAAqB,YAAY,aAAa,OAAO;MACtD,GACD;KACJ,SAAS,YAAY,cAAc,OAC/B;MACE,MAAM,YAAY,cAAc;MAChC,oCAAqB,YAAY,cAAc,OAAO;MACvD,GACD;KACL;IACF;GACD,SAAS;IACP,MAAM;IACN,SAAS;IACV;GACF,CAAC;;AAGJ,QAAOA,kCAAe,QAAQ;EAC5B,YAAY,YAAY,YAAY,OAChC;GACE,MAAM,mBAAmB,WAAW,WAAW;GAC/C,oDAAwB,YAAY,YAAY;IAAE,OAAO;IAAM,QAAQ;IAAc,CAAC;GACtF,sCAAuB,YAAY,YAAY,OAAO,GAAG,OAAO;GACjE,GACD;EACJ,MAAM,YAAY,SAAS,OACvB;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
package/dist/components.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as Request } from "./components-
|
|
1
|
+
import { t as Request } from "./components-ByyhXRwB.js";
|
|
2
2
|
import { pluginTsName } from "@kubb/plugin-ts";
|
|
3
3
|
import { usePluginManager } from "@kubb/core/hooks";
|
|
4
4
|
import { createReactGenerator } from "@kubb/plugin-oas/generators";
|
|
@@ -68,4 +68,4 @@ const cypressGenerator = createReactGenerator({
|
|
|
68
68
|
|
|
69
69
|
//#endregion
|
|
70
70
|
export { cypressGenerator as t };
|
|
71
|
-
//# sourceMappingURL=generators-
|
|
71
|
+
//# sourceMappingURL=generators-3ldN506W.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generators-
|
|
1
|
+
{"version":3,"file":"generators-3ldN506W.js","names":[],"sources":["../src/generators/cypressGenerator.tsx"],"sourcesContent":["import { usePluginManager } from '@kubb/core/hooks'\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, paramsCasing, paramsType, pathParamsType },\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 paramsCasing={paramsCasing}\n paramsType={paramsType}\n pathParamsType={pathParamsType}\n typeSchemas={type.schemas}\n method={operation.method}\n baseURL={baseURL}\n url={operation.path}\n />\n </File>\n )\n },\n})\n"],"mappings":";;;;;;;;;;AASA,MAAa,mBAAmB,qBAAoC;CAClE,MAAM;CACN,UAAU,EAAE,WAAW,WAAW,UAAU;EAC1C,MAAM,EACJ,SAAS,EAAE,QAAQ,SAAS,gBAAgB,cAAc,YAAY,qBACpE;EACJ,MAAM,gBAAgB,kBAAkB;EAExC,MAAM,MAAM,QAAQ;EACpB,MAAM,EAAE,YAAY,SAAS,YAAY,oBAAoB,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,CAAC,aAAa,EAAE,CAAC;GACvD,SAAS,WAAW,WAAW;IAAE,WAAW,CAAC,aAAa;IAAE,MAAM;IAAQ,CAAC;GAC5E;AAED,SACE,qBAAC;GACC,UAAU,QAAQ,KAAK;GACvB,MAAM,QAAQ,KAAK;GACnB,MAAM,QAAQ,KAAK;GACnB,QAAQ,UAAU;IAAE;IAAK;IAAQ,QAAQ,cAAc;IAAQ,CAAC;GAChE,QAAQ,UAAU;IAAE;IAAK;IAAQ,CAAC;cAElC,oBAAC,KAAK;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,oBAAC;IACC,MAAM,QAAQ;IACE;IACF;IACF;IACI;IAChB,aAAa,KAAK;IAClB,QAAQ,UAAU;IACT;IACT,KAAK,UAAU;KACf;IACG;;CAGZ,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_components = require('./components-
|
|
1
|
+
const require_components = require('./components-CEpexuad.cjs');
|
|
2
2
|
const require_index = require('./index.cjs');
|
|
3
3
|
let _kubb_plugin_ts = require("@kubb/plugin-ts");
|
|
4
4
|
let _kubb_core_hooks = require("@kubb/core/hooks");
|
|
@@ -74,4 +74,4 @@ Object.defineProperty(exports, 'cypressGenerator', {
|
|
|
74
74
|
return cypressGenerator;
|
|
75
75
|
}
|
|
76
76
|
});
|
|
77
|
-
//# sourceMappingURL=generators-
|
|
77
|
+
//# sourceMappingURL=generators-FDNmST6B.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generators-
|
|
1
|
+
{"version":3,"file":"generators-FDNmST6B.cjs","names":["pluginTsName","File","Request"],"sources":["../src/generators/cypressGenerator.tsx"],"sourcesContent":["import { usePluginManager } from '@kubb/core/hooks'\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, paramsCasing, paramsType, pathParamsType },\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 paramsCasing={paramsCasing}\n paramsType={paramsType}\n pathParamsType={pathParamsType}\n typeSchemas={type.schemas}\n method={operation.method}\n baseURL={baseURL}\n url={operation.path}\n />\n </File>\n )\n },\n})\n"],"mappings":";;;;;;;;;;;AASA,MAAa,yEAAuD;CAClE,MAAM;CACN,UAAU,EAAE,WAAW,WAAW,UAAU;EAC1C,MAAM,EACJ,SAAS,EAAE,QAAQ,SAAS,gBAAgB,cAAc,YAAY,qBACpE;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;IACF;IACF;IACI;IAChB,aAAa,KAAK;IAClB,QAAQ,UAAU;IACT;IACT,KAAK,UAAU;KACf;IACG;;CAGZ,CAAC"}
|
package/dist/generators.cjs
CHANGED
package/dist/generators.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -25,7 +25,7 @@ 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-FDNmST6B.cjs');
|
|
29
29
|
let node_path = require("node:path");
|
|
30
30
|
node_path = __toESM(node_path);
|
|
31
31
|
let _kubb_core = require("@kubb/core");
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as cypressGenerator } from "./generators-
|
|
1
|
+
import { t as cypressGenerator } from "./generators-3ldN506W.js";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { definePlugin, getBarrelFiles, getMode } from "@kubb/core";
|
|
4
4
|
import { camelCase } from "@kubb/core/transformers";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-cypress",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.16.0",
|
|
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.9.
|
|
78
|
-
"@kubb/core": "4.
|
|
79
|
-
"@kubb/oas": "4.
|
|
80
|
-
"@kubb/plugin-oas": "4.
|
|
81
|
-
"@kubb/plugin-ts": "4.
|
|
77
|
+
"@kubb/react-fabric": "0.9.5",
|
|
78
|
+
"@kubb/core": "4.16.0",
|
|
79
|
+
"@kubb/oas": "4.16.0",
|
|
80
|
+
"@kubb/plugin-oas": "4.16.0",
|
|
81
|
+
"@kubb/plugin-ts": "4.16.0"
|
|
82
82
|
},
|
|
83
83
|
"engines": {
|
|
84
84
|
"node": ">=20"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { URLPath } from '@kubb/core/utils'
|
|
2
|
-
import { type HttpMethod, isOptional } from '@kubb/oas'
|
|
2
|
+
import { type HttpMethod, isAllOptional, isOptional } from '@kubb/oas'
|
|
3
3
|
import type { OperationSchemas } from '@kubb/plugin-oas'
|
|
4
4
|
import { getPathParams } from '@kubb/plugin-oas/utils'
|
|
5
5
|
import { File, Function, FunctionParams } from '@kubb/react-fabric'
|
|
@@ -30,11 +30,13 @@ type GetParamsProps = {
|
|
|
30
30
|
|
|
31
31
|
function getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas }: GetParamsProps) {
|
|
32
32
|
if (paramsType === 'object') {
|
|
33
|
+
const pathParams = getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing })
|
|
34
|
+
|
|
33
35
|
return FunctionParams.factory({
|
|
34
36
|
data: {
|
|
35
37
|
mode: 'object',
|
|
36
38
|
children: {
|
|
37
|
-
...
|
|
39
|
+
...pathParams,
|
|
38
40
|
data: typeSchemas.request?.name
|
|
39
41
|
? {
|
|
40
42
|
type: typeSchemas.request?.name,
|
|
@@ -57,7 +59,6 @@ function getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas }: Ge
|
|
|
57
59
|
},
|
|
58
60
|
options: {
|
|
59
61
|
type: 'Partial<Cypress.RequestOptions>',
|
|
60
|
-
optional: true,
|
|
61
62
|
default: '{}',
|
|
62
63
|
},
|
|
63
64
|
})
|
|
@@ -68,7 +69,7 @@ function getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas }: Ge
|
|
|
68
69
|
? {
|
|
69
70
|
mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',
|
|
70
71
|
children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
|
|
71
|
-
|
|
72
|
+
default: isAllOptional(typeSchemas.pathParams?.schema) ? '{}' : undefined,
|
|
72
73
|
}
|
|
73
74
|
: undefined,
|
|
74
75
|
data: typeSchemas.request?.name
|
|
@@ -91,7 +92,6 @@ function getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas }: Ge
|
|
|
91
92
|
: undefined,
|
|
92
93
|
options: {
|
|
93
94
|
type: 'Partial<Cypress.RequestOptions>',
|
|
94
|
-
optional: true,
|
|
95
95
|
default: '{}',
|
|
96
96
|
},
|
|
97
97
|
})
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Do not edit manually.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
export function createPets(data: CreatePetsMutationRequest, options
|
|
6
|
+
export function createPets(data: CreatePetsMutationRequest, options: Partial<Cypress.RequestOptions> = {}): Cypress.Chainable<CreatePetsMutationResponse> {
|
|
7
7
|
return cy
|
|
8
8
|
.request<CreatePetsMutationResponse>({
|
|
9
9
|
method: 'post',
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
export function deletePet(
|
|
7
7
|
petId: DeletePetPathParams['petId'],
|
|
8
8
|
headers?: DeletePetHeaderParams,
|
|
9
|
-
options
|
|
9
|
+
options: Partial<Cypress.RequestOptions> = {},
|
|
10
10
|
): Cypress.Chainable<DeletePetMutationResponse> {
|
|
11
11
|
return cy
|
|
12
12
|
.request<DeletePetMutationResponse>({
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Do not edit manually.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
export function listPets(params?: ListPetsQueryParams, options
|
|
6
|
+
export function listPets(params?: ListPetsQueryParams, options: Partial<Cypress.RequestOptions> = {}): Cypress.Chainable<ListPetsQueryResponse> {
|
|
7
7
|
return cy
|
|
8
8
|
.request<ListPetsQueryResponse>({
|
|
9
9
|
method: 'get',
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Do not edit manually.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
export function listPets(params?: ListPetsQueryParams, options
|
|
6
|
+
export function listPets(params?: ListPetsQueryParams, options: Partial<Cypress.RequestOptions> = {}): Cypress.Chainable<ListPetsQueryResponse> {
|
|
7
7
|
return cy
|
|
8
8
|
.request<ListPetsQueryResponse>({
|
|
9
9
|
method: 'get',
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Do not edit manually.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
export function showPetById(petId: ShowPetByIdPathParams['petId'], options
|
|
6
|
+
export function showPetById(petId: ShowPetByIdPathParams['petId'], options: Partial<Cypress.RequestOptions> = {}): Cypress.Chainable<ShowPetByIdQueryResponse> {
|
|
7
7
|
return cy
|
|
8
8
|
.request<ShowPetByIdQueryResponse>({
|
|
9
9
|
method: 'get',
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
export function updatePet(
|
|
7
7
|
petId: UpdatePetPathParams['petId'],
|
|
8
8
|
data: UpdatePetMutationRequest,
|
|
9
|
-
options
|
|
9
|
+
options: Partial<Cypress.RequestOptions> = {},
|
|
10
10
|
): Cypress.Chainable<UpdatePetMutationResponse> {
|
|
11
11
|
return cy
|
|
12
12
|
.request<UpdatePetMutationResponse>({
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"components-CKNcdnr_.js","names":["requestOptions: string[]"],"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 { getPathParams } from '@kubb/plugin-oas/utils'\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 paramsCasing: PluginCypress['resolvedOptions']['paramsCasing']\n paramsType: PluginCypress['resolvedOptions']['paramsType']\n pathParamsType: PluginCypress['resolvedOptions']['pathParamsType']\n method: HttpMethod\n}\n\ntype GetParamsProps = {\n paramsCasing: PluginCypress['resolvedOptions']['paramsCasing']\n paramsType: PluginCypress['resolvedOptions']['paramsType']\n pathParamsType: PluginCypress['resolvedOptions']['pathParamsType']\n typeSchemas: OperationSchemas\n}\n\nfunction getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas }: GetParamsProps) {\n if (paramsType === 'object') {\n return FunctionParams.factory({\n data: {\n mode: 'object',\n children: {\n ...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n },\n },\n options: {\n type: 'Partial<Cypress.RequestOptions>',\n optional: true,\n default: '{}',\n },\n })\n }\n\n return FunctionParams.factory({\n pathParams: typeSchemas.pathParams?.name\n ? {\n mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n optional: isOptional(typeSchemas.pathParams?.schema),\n }\n : undefined,\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n options: {\n type: 'Partial<Cypress.RequestOptions>',\n optional: true,\n default: '{}',\n },\n })\n}\n\nexport function Request({ baseURL = '', name, dataReturnType, typeSchemas, url, method, paramsType, paramsCasing, pathParamsType }: Props): KubbNode {\n const path = new URLPath(url, { casing: paramsCasing })\n\n const params = getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas })\n\n const returnType =\n dataReturnType === 'data' ? `Cypress.Chainable<${typeSchemas.response.name}>` : `Cypress.Chainable<Cypress.Response<${typeSchemas.response.name}>>`\n\n // Build the URL template string - this will convert /pets/:petId to /pets/${petId}\n const urlTemplate = path.toTemplateString({ prefix: baseURL })\n\n // Build request options object\n const requestOptions: string[] = [`method: '${method}'`, `url: ${urlTemplate}`]\n\n // Add query params if they exist\n if (typeSchemas.queryParams?.name) {\n requestOptions.push('qs: params')\n }\n\n // Add headers if they exist\n if (typeSchemas.headerParams?.name) {\n requestOptions.push('headers')\n }\n\n // Add body if request schema exists\n if (typeSchemas.request?.name) {\n requestOptions.push('body: data')\n }\n\n // Spread additional Cypress options\n requestOptions.push('...options')\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<${typeSchemas.response.name}>({\n ${requestOptions.join(',\\n ')}\n}).then((res) => res.body)`\n : `return cy.request<${typeSchemas.response.name}>({\n ${requestOptions.join(',\\n ')}\n})`}\n </Function>\n </File.Source>\n )\n}\n\nRequest.getParams = getParams\n"],"mappings":";;;;;;;AA8BA,SAAS,UAAU,EAAE,YAAY,cAAc,gBAAgB,eAA+B;AAC5F,KAAI,eAAe,SACjB,QAAO,eAAe,QAAQ;EAC5B,MAAM;GACJ,MAAM;GACN,UAAU;IACR,GAAG,cAAc,YAAY,YAAY;KAAE,OAAO;KAAM,QAAQ;KAAc,CAAC;IAC/E,MAAM,YAAY,SAAS,OACvB;KACE,MAAM,YAAY,SAAS;KAC3B,UAAU,WAAW,YAAY,SAAS,OAAO;KAClD,GACD;IACJ,QAAQ,YAAY,aAAa,OAC7B;KACE,MAAM,YAAY,aAAa;KAC/B,UAAU,WAAW,YAAY,aAAa,OAAO;KACtD,GACD;IACJ,SAAS,YAAY,cAAc,OAC/B;KACE,MAAM,YAAY,cAAc;KAChC,UAAU,WAAW,YAAY,cAAc,OAAO;KACvD,GACD;IACL;GACF;EACD,SAAS;GACP,MAAM;GACN,UAAU;GACV,SAAS;GACV;EACF,CAAC;AAGJ,QAAO,eAAe,QAAQ;EAC5B,YAAY,YAAY,YAAY,OAChC;GACE,MAAM,mBAAmB,WAAW,WAAW;GAC/C,UAAU,cAAc,YAAY,YAAY;IAAE,OAAO;IAAM,QAAQ;IAAc,CAAC;GACtF,UAAU,WAAW,YAAY,YAAY,OAAO;GACrD,GACD;EACJ,MAAM,YAAY,SAAS,OACvB;GACE,MAAM,YAAY,SAAS;GAC3B,UAAU,WAAW,YAAY,SAAS,OAAO;GAClD,GACD;EACJ,QAAQ,YAAY,aAAa,OAC7B;GACE,MAAM,YAAY,aAAa;GAC/B,UAAU,WAAW,YAAY,aAAa,OAAO;GACtD,GACD;EACJ,SAAS,YAAY,cAAc,OAC/B;GACE,MAAM,YAAY,cAAc;GAChC,UAAU,WAAW,YAAY,cAAc,OAAO;GACvD,GACD;EACJ,SAAS;GACP,MAAM;GACN,UAAU;GACV,SAAS;GACV;EACF,CAAC;;AAGJ,SAAgB,QAAQ,EAAE,UAAU,IAAI,MAAM,gBAAgB,aAAa,KAAK,QAAQ,YAAY,cAAc,kBAAmC;CACnJ,MAAM,OAAO,IAAI,QAAQ,KAAK,EAAE,QAAQ,cAAc,CAAC;CAEvD,MAAM,SAAS,UAAU;EAAE;EAAY;EAAc;EAAgB;EAAa,CAAC;CAEnF,MAAM,aACJ,mBAAmB,SAAS,qBAAqB,YAAY,SAAS,KAAK,KAAK,sCAAsC,YAAY,SAAS,KAAK;CAGlJ,MAAM,cAAc,KAAK,iBAAiB,EAAE,QAAQ,SAAS,CAAC;CAG9D,MAAMA,iBAA2B,CAAC,YAAY,OAAO,IAAI,QAAQ,cAAc;AAG/E,KAAI,YAAY,aAAa,KAC3B,gBAAe,KAAK,aAAa;AAInC,KAAI,YAAY,cAAc,KAC5B,gBAAe,KAAK,UAAU;AAIhC,KAAI,YAAY,SAAS,KACvB,gBAAe,KAAK,aAAa;AAInC,gBAAe,KAAK,aAAa;AAEjC,QACE,oBAAC,KAAK;EAAa;EAAM;EAAY;YACnC,oBAAC;GAAe;GAAM;GAAO,QAAQ,OAAO,eAAe;GAAc;aACtE,mBAAmB,SAChB,qBAAqB,YAAY,SAAS,KAAK;IACvD,eAAe,KAAK,QAAQ,CAAC;8BAErB,qBAAqB,YAAY,SAAS,KAAK;IACvD,eAAe,KAAK,QAAQ,CAAC;;IAEhB;GACC;;AAIlB,QAAQ,YAAY"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"components-UBGR5HIj.cjs","names":["FunctionParams","URLPath","requestOptions: string[]","File","Function"],"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 { getPathParams } from '@kubb/plugin-oas/utils'\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 paramsCasing: PluginCypress['resolvedOptions']['paramsCasing']\n paramsType: PluginCypress['resolvedOptions']['paramsType']\n pathParamsType: PluginCypress['resolvedOptions']['pathParamsType']\n method: HttpMethod\n}\n\ntype GetParamsProps = {\n paramsCasing: PluginCypress['resolvedOptions']['paramsCasing']\n paramsType: PluginCypress['resolvedOptions']['paramsType']\n pathParamsType: PluginCypress['resolvedOptions']['pathParamsType']\n typeSchemas: OperationSchemas\n}\n\nfunction getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas }: GetParamsProps) {\n if (paramsType === 'object') {\n return FunctionParams.factory({\n data: {\n mode: 'object',\n children: {\n ...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n },\n },\n options: {\n type: 'Partial<Cypress.RequestOptions>',\n optional: true,\n default: '{}',\n },\n })\n }\n\n return FunctionParams.factory({\n pathParams: typeSchemas.pathParams?.name\n ? {\n mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n optional: isOptional(typeSchemas.pathParams?.schema),\n }\n : undefined,\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n options: {\n type: 'Partial<Cypress.RequestOptions>',\n optional: true,\n default: '{}',\n },\n })\n}\n\nexport function Request({ baseURL = '', name, dataReturnType, typeSchemas, url, method, paramsType, paramsCasing, pathParamsType }: Props): KubbNode {\n const path = new URLPath(url, { casing: paramsCasing })\n\n const params = getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas })\n\n const returnType =\n dataReturnType === 'data' ? `Cypress.Chainable<${typeSchemas.response.name}>` : `Cypress.Chainable<Cypress.Response<${typeSchemas.response.name}>>`\n\n // Build the URL template string - this will convert /pets/:petId to /pets/${petId}\n const urlTemplate = path.toTemplateString({ prefix: baseURL })\n\n // Build request options object\n const requestOptions: string[] = [`method: '${method}'`, `url: ${urlTemplate}`]\n\n // Add query params if they exist\n if (typeSchemas.queryParams?.name) {\n requestOptions.push('qs: params')\n }\n\n // Add headers if they exist\n if (typeSchemas.headerParams?.name) {\n requestOptions.push('headers')\n }\n\n // Add body if request schema exists\n if (typeSchemas.request?.name) {\n requestOptions.push('body: data')\n }\n\n // Spread additional Cypress options\n requestOptions.push('...options')\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<${typeSchemas.response.name}>({\n ${requestOptions.join(',\\n ')}\n}).then((res) => res.body)`\n : `return cy.request<${typeSchemas.response.name}>({\n ${requestOptions.join(',\\n ')}\n})`}\n </Function>\n </File.Source>\n )\n}\n\nRequest.getParams = getParams\n"],"mappings":";;;;;;;;AA8BA,SAAS,UAAU,EAAE,YAAY,cAAc,gBAAgB,eAA+B;AAC5F,KA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