@kubb/plugin-cypress 4.28.1 → 4.29.1
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-CI2gDAda.cjs → Request-BLWRRosC.cjs} +2 -2
- package/dist/Request-BLWRRosC.cjs.map +1 -0
- package/dist/{components-BlvQKb3f.js → Request-DOzOQGgb.js} +2 -2
- package/dist/Request-DOzOQGgb.js.map +1 -0
- package/dist/{chunk-eQyhnF5A.js → chunk-DKWOrOAv.js} +1 -1
- package/dist/components.cjs +3 -2
- package/dist/components.d.ts +2 -2
- package/dist/components.js +1 -1
- package/dist/{generators-BMwRo8o2.js → cypressGenerator-D7trA-II.js} +3 -3
- package/dist/cypressGenerator-D7trA-II.js.map +1 -0
- package/dist/{generators-Dfxz9bL7.cjs → cypressGenerator-DQvbGuBm.cjs} +3 -3
- package/dist/cypressGenerator-DQvbGuBm.cjs.map +1 -0
- package/dist/generators.cjs +3 -2
- package/dist/generators.d.ts +2 -2
- package/dist/generators.js +1 -1
- package/dist/index.cjs +8 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/{types-eAm46aNL.d.cts → types-B9vKVNbE.d.ts} +2 -2
- package/dist/{types-C8Wk6XaU.d.ts → types-Bqm12ZUC.d.ts} +2 -2
- package/package.json +16 -16
- package/dist/components-BlvQKb3f.js.map +0 -1
- package/dist/components-CI2gDAda.cjs.map +0 -1
- package/dist/components.d.cts +0 -49
- package/dist/generators-BMwRo8o2.js.map +0 -1
- package/dist/generators-Dfxz9bL7.cjs.map +0 -1
- package/dist/generators.d.cts +0 -467
- package/dist/index.d.cts +0 -9
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
2
|
var __create = Object.create;
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __name = (target, value) => __defProp(target, "name", {
|
|
@@ -147,4 +147,4 @@ Object.defineProperty(exports, '__toESM', {
|
|
|
147
147
|
return __toESM;
|
|
148
148
|
}
|
|
149
149
|
});
|
|
150
|
-
//# sourceMappingURL=
|
|
150
|
+
//# sourceMappingURL=Request-BLWRRosC.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Request-BLWRRosC.cjs","names":["FunctionParams","URLPath","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 { FabricReactNode } 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): FabricReactNode {\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;GACE,MAAM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
|
-
import { t as __name } from "./chunk-
|
|
1
|
+
import { t as __name } from "./chunk-DKWOrOAv.js";
|
|
2
2
|
import { getPathParams } from "@kubb/plugin-oas/utils";
|
|
3
3
|
import { File, Function, FunctionParams } from "@kubb/react-fabric";
|
|
4
4
|
import { URLPath } from "@kubb/core/utils";
|
|
@@ -100,4 +100,4 @@ Request.getParams = getParams;
|
|
|
100
100
|
|
|
101
101
|
//#endregion
|
|
102
102
|
export { Request as t };
|
|
103
|
-
//# sourceMappingURL=
|
|
103
|
+
//# sourceMappingURL=Request-DOzOQGgb.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Request-DOzOQGgb.js","names":[],"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 { FabricReactNode } 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): FabricReactNode {\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,QAAQ,YAAY,aAAa,OAC7B;MACE,MAAM,YAAY,aAAa;MAC/B,UAAU,WAAW,YAAY,aAAa,OAAO;MACtD,GACD;KACJ,SAAS,YAAY,cAAc,OAC/B;MACE,MAAM,YAAY,cAAc;MAChC,UAAU,WAAW,YAAY,cAAc,OAAO;MACvD,GACD;KACL;IACF;GACD,SAAS;IACP,MAAM;IACN,SAAS;IACV;GACF,CAAC;;AAGJ,QAAO,eAAe,QAAQ;EAC5B,YAAY,YAAY,YAAY,OAChC;GACE,MAAM,mBAAmB,WAAW,WAAW;GAC/C,UAAU,cAAc,YAAY,YAAY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Q,CAAC;8BAErB,qBAAqB,YAAY,SAAS,KAAK;IACvD,eAAe,KAAK,QAAQ,CAAC;;IAEhB;GACC;;AAIlB,QAAQ,YAAY"}
|
package/dist/components.cjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_Request = require('./Request-BLWRRosC.cjs');
|
|
2
3
|
|
|
3
|
-
exports.Request =
|
|
4
|
+
exports.Request = require_Request.Request;
|
package/dist/components.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as __name } from "./chunk-
|
|
2
|
-
import { n as PluginCypress } from "./types-
|
|
1
|
+
import { t as __name } from "./chunk-DKWOrOAv.js";
|
|
2
|
+
import { n as PluginCypress } from "./types-Bqm12ZUC.js";
|
|
3
3
|
import { OperationSchemas } from "@kubb/plugin-oas";
|
|
4
4
|
import { FunctionParams } from "@kubb/react-fabric";
|
|
5
5
|
import { HttpMethod } from "@kubb/oas";
|
package/dist/components.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as __name } from "./chunk-
|
|
2
|
-
import { t as Request } from "./
|
|
1
|
+
import { t as __name } from "./chunk-DKWOrOAv.js";
|
|
2
|
+
import { t as Request } from "./Request-DOzOQGgb.js";
|
|
3
3
|
import { pluginTsName } from "@kubb/plugin-ts";
|
|
4
4
|
import { usePluginManager } from "@kubb/core/hooks";
|
|
5
5
|
import { createReactGenerator } from "@kubb/plugin-oas/generators";
|
|
@@ -69,4 +69,4 @@ const cypressGenerator = createReactGenerator({
|
|
|
69
69
|
|
|
70
70
|
//#endregion
|
|
71
71
|
export { cypressGenerator as t };
|
|
72
|
-
//# sourceMappingURL=
|
|
72
|
+
//# sourceMappingURL=cypressGenerator-D7trA-II.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cypressGenerator-D7trA-II.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
|
|
1
|
+
const require_Request = require('./Request-BLWRRosC.cjs');
|
|
2
2
|
let _kubb_plugin_ts = require("@kubb/plugin-ts");
|
|
3
3
|
let _kubb_core_hooks = require("@kubb/core/hooks");
|
|
4
4
|
let _kubb_plugin_oas_generators = require("@kubb/plugin-oas/generators");
|
|
@@ -51,7 +51,7 @@ const cypressGenerator = (0, _kubb_plugin_oas_generators.createReactGenerator)({
|
|
|
51
51
|
root: request.file.path,
|
|
52
52
|
path: type.file.path,
|
|
53
53
|
isTypeOnly: true
|
|
54
|
-
}), /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(
|
|
54
|
+
}), /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(require_Request.Request, {
|
|
55
55
|
name: request.name,
|
|
56
56
|
dataReturnType,
|
|
57
57
|
paramsCasing,
|
|
@@ -73,4 +73,4 @@ Object.defineProperty(exports, 'cypressGenerator', {
|
|
|
73
73
|
return cypressGenerator;
|
|
74
74
|
}
|
|
75
75
|
});
|
|
76
|
-
//# sourceMappingURL=
|
|
76
|
+
//# sourceMappingURL=cypressGenerator-DQvbGuBm.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cypressGenerator-DQvbGuBm.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
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_cypressGenerator = require('./cypressGenerator-DQvbGuBm.cjs');
|
|
2
3
|
|
|
3
|
-
exports.cypressGenerator =
|
|
4
|
+
exports.cypressGenerator = require_cypressGenerator.cypressGenerator;
|
package/dist/generators.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as __name } from "./chunk-
|
|
2
|
-
import { n as PluginCypress } from "./types-
|
|
1
|
+
import { t as __name } from "./chunk-DKWOrOAv.js";
|
|
2
|
+
import { n as PluginCypress } from "./types-Bqm12ZUC.js";
|
|
3
3
|
import { BaseGenerator, Config, FileMetaBase, Group, KubbEvents, Output, Plugin, PluginFactoryOptions, PluginManager, ResolveNameParams } from "@kubb/core";
|
|
4
4
|
import { Fabric } from "@kubb/react-fabric";
|
|
5
5
|
import { AsyncEventEmitter } from "@kubb/core/utils";
|
package/dist/generators.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
const
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_Request = require('./Request-BLWRRosC.cjs');
|
|
3
|
+
const require_cypressGenerator = require('./cypressGenerator-DQvbGuBm.cjs');
|
|
3
4
|
let node_path = require("node:path");
|
|
4
|
-
node_path =
|
|
5
|
+
node_path = require_Request.__toESM(node_path);
|
|
5
6
|
let _kubb_core = require("@kubb/core");
|
|
6
7
|
let _kubb_core_transformers = require("@kubb/core/transformers");
|
|
7
8
|
let _kubb_plugin_oas = require("@kubb/plugin-oas");
|
|
@@ -13,7 +14,7 @@ const pluginCypress = (0, _kubb_core.definePlugin)((options) => {
|
|
|
13
14
|
const { output = {
|
|
14
15
|
path: "cypress",
|
|
15
16
|
barrelType: "named"
|
|
16
|
-
}, group, dataReturnType = "data", exclude = [], include, override = [], transformers = {}, generators = [
|
|
17
|
+
}, group, dataReturnType = "data", exclude = [], include, override = [], transformers = {}, generators = [require_cypressGenerator.cypressGenerator].filter(Boolean), contentType, baseURL, paramsCasing, paramsType = "inline", pathParamsType = paramsType === "object" ? "object" : options.pathParamsType || "inline" } = options;
|
|
17
18
|
return {
|
|
18
19
|
name: pluginCypressName,
|
|
19
20
|
options: {
|
|
@@ -26,7 +27,7 @@ const pluginCypress = (0, _kubb_core.definePlugin)((options) => {
|
|
|
26
27
|
pathParamsType
|
|
27
28
|
},
|
|
28
29
|
pre: [_kubb_plugin_oas.pluginOasName, _kubb_plugin_ts.pluginTsName].filter(Boolean),
|
|
29
|
-
resolvePath(baseName, pathMode, options
|
|
30
|
+
resolvePath(baseName, pathMode, options) {
|
|
30
31
|
const root = node_path.default.resolve(this.config.root, this.config.output.path);
|
|
31
32
|
if ((pathMode ?? (0, _kubb_core.getMode)(node_path.default.resolve(root, output.path))) === "single")
|
|
32
33
|
/**
|
|
@@ -34,12 +35,12 @@ const pluginCypress = (0, _kubb_core.definePlugin)((options) => {
|
|
|
34
35
|
* Other plugins then need to call addOrAppend instead of just add from the fileManager class
|
|
35
36
|
*/
|
|
36
37
|
return node_path.default.resolve(root, output.path);
|
|
37
|
-
if (group && (options
|
|
38
|
+
if (group && (options?.group?.path || options?.group?.tag)) {
|
|
38
39
|
const groupName = group?.name ? group.name : (ctx) => {
|
|
39
40
|
if (group?.type === "path") return `${ctx.group.split("/")[1]}`;
|
|
40
41
|
return `${(0, _kubb_core_transformers.camelCase)(ctx.group)}Requests`;
|
|
41
42
|
};
|
|
42
|
-
return node_path.default.resolve(root, output.path, groupName({ group: group.type === "path" ? options
|
|
43
|
+
return node_path.default.resolve(root, output.path, groupName({ group: group.type === "path" ? options.group.path : options.group.tag }), baseName);
|
|
43
44
|
}
|
|
44
45
|
return node_path.default.resolve(root, output.path, baseName);
|
|
45
46
|
},
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["cypressGenerator","pluginOasName","pluginTsName","path","
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["cypressGenerator","pluginOasName","pluginTsName","path","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 paramsCasing,\n paramsType = 'inline',\n pathParamsType = paramsType === 'object' ? 'object' : options.pathParamsType || 'inline',\n } = options\n\n return {\n name: pluginCypressName,\n options: {\n output,\n dataReturnType,\n group,\n baseURL,\n\n paramsCasing,\n paramsType,\n pathParamsType,\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,0CAAiB,CAAC,OAAO,QAAQ,EAC/C,aACA,SACA,cACA,aAAa,UACb,iBAAiB,eAA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pB,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/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as __name } from "./chunk-
|
|
2
|
-
import { n as PluginCypress, t as Options } from "./types-
|
|
1
|
+
import { t as __name } from "./chunk-DKWOrOAv.js";
|
|
2
|
+
import { n as PluginCypress, t as Options } from "./types-Bqm12ZUC.js";
|
|
3
3
|
import * as _kubb_core0 from "@kubb/core";
|
|
4
4
|
|
|
5
5
|
//#region src/plugin.d.ts
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as __name } from "./chunk-
|
|
2
|
-
import { t as cypressGenerator } from "./
|
|
1
|
+
import { t as __name } from "./chunk-DKWOrOAv.js";
|
|
2
|
+
import { t as cypressGenerator } from "./cypressGenerator-D7trA-II.js";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { definePlugin, getBarrelFiles, getMode } from "@kubb/core";
|
|
5
5
|
import { camelCase } from "@kubb/core/transformers";
|
|
@@ -25,7 +25,7 @@ const pluginCypress = definePlugin((options) => {
|
|
|
25
25
|
pathParamsType
|
|
26
26
|
},
|
|
27
27
|
pre: [pluginOasName, pluginTsName].filter(Boolean),
|
|
28
|
-
resolvePath(baseName, pathMode, options
|
|
28
|
+
resolvePath(baseName, pathMode, options) {
|
|
29
29
|
const root = path.resolve(this.config.root, this.config.output.path);
|
|
30
30
|
if ((pathMode ?? getMode(path.resolve(root, output.path))) === "single")
|
|
31
31
|
/**
|
|
@@ -33,12 +33,12 @@ const pluginCypress = definePlugin((options) => {
|
|
|
33
33
|
* Other plugins then need to call addOrAppend instead of just add from the fileManager class
|
|
34
34
|
*/
|
|
35
35
|
return path.resolve(root, output.path);
|
|
36
|
-
if (group && (options
|
|
36
|
+
if (group && (options?.group?.path || options?.group?.tag)) {
|
|
37
37
|
const groupName = group?.name ? group.name : (ctx) => {
|
|
38
38
|
if (group?.type === "path") return `${ctx.group.split("/")[1]}`;
|
|
39
39
|
return `${camelCase(ctx.group)}Requests`;
|
|
40
40
|
};
|
|
41
|
-
return path.resolve(root, output.path, groupName({ group: group.type === "path" ? options
|
|
41
|
+
return path.resolve(root, output.path, groupName({ group: group.type === "path" ? options.group.path : options.group.tag }), baseName);
|
|
42
42
|
}
|
|
43
43
|
return path.resolve(root, output.path, baseName);
|
|
44
44
|
},
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"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 paramsCasing,\n paramsType = 'inline',\n pathParamsType = paramsType === 'object' ? 'object' : options.pathParamsType || 'inline',\n } = options\n\n return {\n name: pluginCypressName,\n options: {\n output,\n dataReturnType,\n group,\n baseURL,\n\n paramsCasing,\n paramsType,\n pathParamsType,\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,gBAAgB,cAA6B,YAAY;CACpE,MAAM,EACJ,SAAS;EAAE,MAAM;EAAW,YAAY;EAAS,EACjD,OACA,iBAAiB,QACjB,UAAU,EAAE,EACZ,SACA,WAAW,EAAE,EACb,eAAe,EAAE,EAC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AQ,MAba,IAAI,mBAAmB,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,MAAM,eAAe,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"}
|
|
@@ -3,7 +3,7 @@ import { Exclude, Include, Override, ResolvePathOptions } from "@kubb/plugin-oas
|
|
|
3
3
|
import { Group, Output, PluginFactoryOptions, ResolveNameParams } from "@kubb/core";
|
|
4
4
|
import { Generator } from "@kubb/plugin-oas/generators";
|
|
5
5
|
|
|
6
|
-
//#region
|
|
6
|
+
//#region \0rolldown/runtime.js
|
|
7
7
|
//#endregion
|
|
8
8
|
//#region src/types.d.ts
|
|
9
9
|
type Options = {
|
|
@@ -83,4 +83,4 @@ type ResolvedOptions = {
|
|
|
83
83
|
type PluginCypress = PluginFactoryOptions<'plugin-cypress', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
84
84
|
//#endregion
|
|
85
85
|
export { PluginCypress as n, __name as r, Options as t };
|
|
86
|
-
//# sourceMappingURL=types-
|
|
86
|
+
//# sourceMappingURL=types-B9vKVNbE.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as __name } from "./chunk-
|
|
1
|
+
import { t as __name } from "./chunk-DKWOrOAv.js";
|
|
2
2
|
import { Group, Output, PluginFactoryOptions, ResolveNameParams } from "@kubb/core";
|
|
3
3
|
import { Exclude, Include, Override, ResolvePathOptions } from "@kubb/plugin-oas";
|
|
4
4
|
import { Generator } from "@kubb/plugin-oas/generators";
|
|
@@ -82,4 +82,4 @@ type ResolvedOptions = {
|
|
|
82
82
|
type PluginCypress = PluginFactoryOptions<'plugin-cypress', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
83
83
|
//#endregion
|
|
84
84
|
export { PluginCypress as n, Options as t };
|
|
85
|
-
//# sourceMappingURL=types-
|
|
85
|
+
//# sourceMappingURL=types-Bqm12ZUC.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-cypress",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.29.1",
|
|
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",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
],
|
|
23
23
|
"repository": {
|
|
24
24
|
"type": "git",
|
|
25
|
-
"url": "https://github.com/kubb-labs/kubb.git",
|
|
25
|
+
"url": "git+https://github.com/kubb-labs/kubb.git",
|
|
26
26
|
"directory": "packages/plugin-cypress"
|
|
27
27
|
},
|
|
28
28
|
"license": "MIT",
|
|
@@ -31,22 +31,20 @@
|
|
|
31
31
|
"type": "module",
|
|
32
32
|
"exports": {
|
|
33
33
|
".": {
|
|
34
|
-
"
|
|
35
|
-
"
|
|
34
|
+
"import": "./dist/index.js",
|
|
35
|
+
"require": "./dist/index.cjs"
|
|
36
36
|
},
|
|
37
37
|
"./components": {
|
|
38
|
-
"
|
|
39
|
-
"
|
|
38
|
+
"import": "./dist/components.js",
|
|
39
|
+
"require": "./dist/components.cjs"
|
|
40
40
|
},
|
|
41
41
|
"./generators": {
|
|
42
|
-
"
|
|
43
|
-
"
|
|
42
|
+
"import": "./dist/generators.js",
|
|
43
|
+
"require": "./dist/generators.cjs"
|
|
44
44
|
},
|
|
45
45
|
"./package.json": "./package.json"
|
|
46
46
|
},
|
|
47
|
-
"
|
|
48
|
-
"module": "./dist/index.js",
|
|
49
|
-
"types": "./dist/index.d.cts",
|
|
47
|
+
"types": "./dist/index.d.ts",
|
|
50
48
|
"typesVersions": {
|
|
51
49
|
"*": {
|
|
52
50
|
"utils": [
|
|
@@ -77,11 +75,11 @@
|
|
|
77
75
|
}
|
|
78
76
|
],
|
|
79
77
|
"dependencies": {
|
|
80
|
-
"@kubb/react-fabric": "0.
|
|
81
|
-
"@kubb/core": "4.
|
|
82
|
-
"@kubb/oas": "4.
|
|
83
|
-
"@kubb/plugin-oas": "4.
|
|
84
|
-
"@kubb/plugin-ts": "4.
|
|
78
|
+
"@kubb/react-fabric": "0.13.1",
|
|
79
|
+
"@kubb/core": "4.29.1",
|
|
80
|
+
"@kubb/oas": "4.29.1",
|
|
81
|
+
"@kubb/plugin-oas": "4.29.1",
|
|
82
|
+
"@kubb/plugin-ts": "4.29.1"
|
|
85
83
|
},
|
|
86
84
|
"engines": {
|
|
87
85
|
"node": ">=20"
|
|
@@ -90,6 +88,8 @@
|
|
|
90
88
|
"access": "public",
|
|
91
89
|
"registry": "https://registry.npmjs.org/"
|
|
92
90
|
},
|
|
91
|
+
"main": "./dist/index.cjs",
|
|
92
|
+
"module": "./dist/index.js",
|
|
93
93
|
"scripts": {
|
|
94
94
|
"build": "tsdown && size-limit",
|
|
95
95
|
"clean": "npx rimraf ./dist",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"components-BlvQKb3f.js","names":[],"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 { FabricReactNode } 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): FabricReactNode {\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,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AK,iBAAiB,EAAE,QAAQ,SAAS,CAAC;CAG9D,MAAM,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-CI2gDAda.cjs","names":["FunctionParams","URLPath","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 { FabricReactNode } 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): FabricReactNode {\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;MAC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AY,SAAS,KACvB,gBAAe,KAAK,aAAa;AAInC,gBAAe,KAAK,aAAa;AAEjC,QACE,wDAACC,wBAAK;EAAa;EAAM;EAAY;YACnC,wDAACC;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"}
|
package/dist/components.d.cts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { n as PluginCypress, r as __name } from "./types-eAm46aNL.cjs";
|
|
2
|
-
import { HttpMethod } from "@kubb/oas";
|
|
3
|
-
import { OperationSchemas } from "@kubb/plugin-oas";
|
|
4
|
-
import { FunctionParams } from "@kubb/react-fabric";
|
|
5
|
-
import { FabricReactNode } from "@kubb/react-fabric/types";
|
|
6
|
-
|
|
7
|
-
//#region src/components/Request.d.ts
|
|
8
|
-
type Props = {
|
|
9
|
-
/**
|
|
10
|
-
* Name of the function
|
|
11
|
-
*/
|
|
12
|
-
name: string;
|
|
13
|
-
typeSchemas: OperationSchemas;
|
|
14
|
-
url: string;
|
|
15
|
-
baseURL: string | undefined;
|
|
16
|
-
dataReturnType: PluginCypress['resolvedOptions']['dataReturnType'];
|
|
17
|
-
paramsCasing: PluginCypress['resolvedOptions']['paramsCasing'];
|
|
18
|
-
paramsType: PluginCypress['resolvedOptions']['paramsType'];
|
|
19
|
-
pathParamsType: PluginCypress['resolvedOptions']['pathParamsType'];
|
|
20
|
-
method: HttpMethod;
|
|
21
|
-
};
|
|
22
|
-
type GetParamsProps = {
|
|
23
|
-
paramsCasing: PluginCypress['resolvedOptions']['paramsCasing'];
|
|
24
|
-
paramsType: PluginCypress['resolvedOptions']['paramsType'];
|
|
25
|
-
pathParamsType: PluginCypress['resolvedOptions']['pathParamsType'];
|
|
26
|
-
typeSchemas: OperationSchemas;
|
|
27
|
-
};
|
|
28
|
-
declare function Request({
|
|
29
|
-
baseURL,
|
|
30
|
-
name,
|
|
31
|
-
dataReturnType,
|
|
32
|
-
typeSchemas,
|
|
33
|
-
url,
|
|
34
|
-
method,
|
|
35
|
-
paramsType,
|
|
36
|
-
paramsCasing,
|
|
37
|
-
pathParamsType
|
|
38
|
-
}: Props): FabricReactNode;
|
|
39
|
-
declare namespace Request {
|
|
40
|
-
var getParams: ({
|
|
41
|
-
paramsType,
|
|
42
|
-
paramsCasing,
|
|
43
|
-
pathParamsType,
|
|
44
|
-
typeSchemas
|
|
45
|
-
}: GetParamsProps) => FunctionParams;
|
|
46
|
-
}
|
|
47
|
-
//#endregion
|
|
48
|
-
export { Request };
|
|
49
|
-
//# sourceMappingURL=components.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generators-BMwRo8o2.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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generators-Dfxz9bL7.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.d.cts
DELETED
|
@@ -1,467 +0,0 @@
|
|
|
1
|
-
import { n as PluginCypress, r as __name } from "./types-eAm46aNL.cjs";
|
|
2
|
-
import { HttpMethod, Oas, Operation, SchemaObject, contentType } from "@kubb/oas";
|
|
3
|
-
import { Fabric } from "@kubb/react-fabric";
|
|
4
|
-
import { FabricReactNode } from "@kubb/react-fabric/types";
|
|
5
|
-
import { BaseGenerator, Config, FileMetaBase, Group, KubbEvents, Output, Plugin, PluginFactoryOptions, PluginManager, ResolveNameParams } from "@kubb/core";
|
|
6
|
-
import { AsyncEventEmitter } from "@kubb/core/utils";
|
|
7
|
-
import { KubbFile } from "@kubb/fabric-core/types";
|
|
8
|
-
|
|
9
|
-
//#region ../plugin-oas/src/types.d.ts
|
|
10
|
-
type GetOasOptions = {
|
|
11
|
-
validate?: boolean;
|
|
12
|
-
};
|
|
13
|
-
type Context$2 = {
|
|
14
|
-
getOas(options?: GetOasOptions): Promise<Oas>;
|
|
15
|
-
getBaseURL(): Promise<string | undefined>;
|
|
16
|
-
};
|
|
17
|
-
declare global {
|
|
18
|
-
namespace Kubb {
|
|
19
|
-
interface PluginContext extends Context$2 {}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* `propertyName` is the ref name + resolved with the nameResolver
|
|
24
|
-
* @example import { Pet } from './Pet'
|
|
25
|
-
*
|
|
26
|
-
* `originalName` is the original name used(in PascalCase), only used to remove duplicates
|
|
27
|
-
*
|
|
28
|
-
* `pluginKey` can be used to override the current plugin being used, handy when you want to import a type/schema out of another plugin
|
|
29
|
-
* @example import a type(plugin-ts) for a mock file(swagger-faker)
|
|
30
|
-
*/
|
|
31
|
-
type Ref = {
|
|
32
|
-
propertyName: string;
|
|
33
|
-
originalName: string;
|
|
34
|
-
path: KubbFile.Path;
|
|
35
|
-
pluginKey?: Plugin['key'];
|
|
36
|
-
};
|
|
37
|
-
type Refs = Record<string, Ref>;
|
|
38
|
-
type OperationSchema = {
|
|
39
|
-
/**
|
|
40
|
-
* Converted name, contains already `PathParams`, `QueryParams`, ...
|
|
41
|
-
*/
|
|
42
|
-
name: string;
|
|
43
|
-
schema: SchemaObject;
|
|
44
|
-
operation?: Operation;
|
|
45
|
-
/**
|
|
46
|
-
* OperationName in PascalCase, only being used in OperationGenerator
|
|
47
|
-
*/
|
|
48
|
-
operationName: string;
|
|
49
|
-
description?: string;
|
|
50
|
-
statusCode?: number;
|
|
51
|
-
keys?: string[];
|
|
52
|
-
keysToOmit?: string[];
|
|
53
|
-
withData?: boolean;
|
|
54
|
-
};
|
|
55
|
-
type OperationSchemas = {
|
|
56
|
-
pathParams?: OperationSchema & {
|
|
57
|
-
keysToOmit?: never;
|
|
58
|
-
};
|
|
59
|
-
queryParams?: OperationSchema & {
|
|
60
|
-
keysToOmit?: never;
|
|
61
|
-
};
|
|
62
|
-
headerParams?: OperationSchema & {
|
|
63
|
-
keysToOmit?: never;
|
|
64
|
-
};
|
|
65
|
-
request?: OperationSchema;
|
|
66
|
-
response: OperationSchema;
|
|
67
|
-
responses: Array<OperationSchema>;
|
|
68
|
-
statusCodes?: Array<OperationSchema>;
|
|
69
|
-
errors?: Array<OperationSchema>;
|
|
70
|
-
};
|
|
71
|
-
type ByTag = {
|
|
72
|
-
type: 'tag';
|
|
73
|
-
pattern: string | RegExp;
|
|
74
|
-
};
|
|
75
|
-
type ByOperationId = {
|
|
76
|
-
type: 'operationId';
|
|
77
|
-
pattern: string | RegExp;
|
|
78
|
-
};
|
|
79
|
-
type ByPath = {
|
|
80
|
-
type: 'path';
|
|
81
|
-
pattern: string | RegExp;
|
|
82
|
-
};
|
|
83
|
-
type ByMethod = {
|
|
84
|
-
type: 'method';
|
|
85
|
-
pattern: HttpMethod | RegExp;
|
|
86
|
-
};
|
|
87
|
-
type BySchemaName = {
|
|
88
|
-
type: 'schemaName';
|
|
89
|
-
pattern: string | RegExp;
|
|
90
|
-
};
|
|
91
|
-
type ByContentType = {
|
|
92
|
-
type: 'contentType';
|
|
93
|
-
pattern: string | RegExp;
|
|
94
|
-
};
|
|
95
|
-
type Exclude = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
|
|
96
|
-
type Include = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
|
|
97
|
-
type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName | ByContentType) & {
|
|
98
|
-
options: Partial<TOptions>;
|
|
99
|
-
};
|
|
100
|
-
//#endregion
|
|
101
|
-
//#region ../plugin-oas/src/OperationGenerator.d.ts
|
|
102
|
-
type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
103
|
-
fabric: Fabric;
|
|
104
|
-
oas: Oas;
|
|
105
|
-
exclude: Array<Exclude> | undefined;
|
|
106
|
-
include: Array<Include> | undefined;
|
|
107
|
-
override: Array<Override<TOptions>> | undefined;
|
|
108
|
-
contentType: contentType | undefined;
|
|
109
|
-
pluginManager: PluginManager;
|
|
110
|
-
events?: AsyncEventEmitter<KubbEvents>;
|
|
111
|
-
/**
|
|
112
|
-
* Current plugin
|
|
113
|
-
*/
|
|
114
|
-
plugin: Plugin<TPluginOptions>;
|
|
115
|
-
mode: KubbFile.Mode;
|
|
116
|
-
UNSTABLE_NAMING?: true;
|
|
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
|
-
getOptions(operation: Operation, method: HttpMethod): Partial<TPluginOptions['resolvedOptions']>;
|
|
121
|
-
getSchemas(operation: Operation, {
|
|
122
|
-
resolveName
|
|
123
|
-
}?: {
|
|
124
|
-
resolveName?: (name: string) => string;
|
|
125
|
-
}): OperationSchemas;
|
|
126
|
-
getOperations(): Promise<Array<{
|
|
127
|
-
path: string;
|
|
128
|
-
method: HttpMethod;
|
|
129
|
-
operation: Operation;
|
|
130
|
-
}>>;
|
|
131
|
-
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
132
|
-
}
|
|
133
|
-
//#endregion
|
|
134
|
-
//#region ../plugin-oas/src/SchemaMapper.d.ts
|
|
135
|
-
type SchemaKeywordMapper = {
|
|
136
|
-
object: {
|
|
137
|
-
keyword: 'object';
|
|
138
|
-
args: {
|
|
139
|
-
properties: {
|
|
140
|
-
[x: string]: Schema[];
|
|
141
|
-
};
|
|
142
|
-
additionalProperties: Schema[];
|
|
143
|
-
patternProperties?: Record<string, Schema[]>;
|
|
144
|
-
strict?: boolean;
|
|
145
|
-
};
|
|
146
|
-
};
|
|
147
|
-
url: {
|
|
148
|
-
keyword: 'url';
|
|
149
|
-
};
|
|
150
|
-
readOnly: {
|
|
151
|
-
keyword: 'readOnly';
|
|
152
|
-
};
|
|
153
|
-
writeOnly: {
|
|
154
|
-
keyword: 'writeOnly';
|
|
155
|
-
};
|
|
156
|
-
uuid: {
|
|
157
|
-
keyword: 'uuid';
|
|
158
|
-
};
|
|
159
|
-
email: {
|
|
160
|
-
keyword: 'email';
|
|
161
|
-
};
|
|
162
|
-
firstName: {
|
|
163
|
-
keyword: 'firstName';
|
|
164
|
-
};
|
|
165
|
-
lastName: {
|
|
166
|
-
keyword: 'lastName';
|
|
167
|
-
};
|
|
168
|
-
phone: {
|
|
169
|
-
keyword: 'phone';
|
|
170
|
-
};
|
|
171
|
-
password: {
|
|
172
|
-
keyword: 'password';
|
|
173
|
-
};
|
|
174
|
-
date: {
|
|
175
|
-
keyword: 'date';
|
|
176
|
-
args: {
|
|
177
|
-
type?: 'date' | 'string';
|
|
178
|
-
};
|
|
179
|
-
};
|
|
180
|
-
time: {
|
|
181
|
-
keyword: 'time';
|
|
182
|
-
args: {
|
|
183
|
-
type?: 'date' | 'string';
|
|
184
|
-
};
|
|
185
|
-
};
|
|
186
|
-
datetime: {
|
|
187
|
-
keyword: 'datetime';
|
|
188
|
-
args: {
|
|
189
|
-
offset?: boolean;
|
|
190
|
-
local?: boolean;
|
|
191
|
-
};
|
|
192
|
-
};
|
|
193
|
-
tuple: {
|
|
194
|
-
keyword: 'tuple';
|
|
195
|
-
args: {
|
|
196
|
-
items: Schema[];
|
|
197
|
-
min?: number;
|
|
198
|
-
max?: number;
|
|
199
|
-
rest?: Schema;
|
|
200
|
-
};
|
|
201
|
-
};
|
|
202
|
-
array: {
|
|
203
|
-
keyword: 'array';
|
|
204
|
-
args: {
|
|
205
|
-
items: Schema[];
|
|
206
|
-
min?: number;
|
|
207
|
-
max?: number;
|
|
208
|
-
unique?: boolean;
|
|
209
|
-
};
|
|
210
|
-
};
|
|
211
|
-
enum: {
|
|
212
|
-
keyword: 'enum';
|
|
213
|
-
args: {
|
|
214
|
-
name: string;
|
|
215
|
-
typeName: string;
|
|
216
|
-
asConst: boolean;
|
|
217
|
-
items: Array<{
|
|
218
|
-
name: string | number;
|
|
219
|
-
format: 'string' | 'number' | 'boolean';
|
|
220
|
-
value?: string | number | boolean;
|
|
221
|
-
}>;
|
|
222
|
-
};
|
|
223
|
-
};
|
|
224
|
-
and: {
|
|
225
|
-
keyword: 'and';
|
|
226
|
-
args: Schema[];
|
|
227
|
-
};
|
|
228
|
-
const: {
|
|
229
|
-
keyword: 'const';
|
|
230
|
-
args: {
|
|
231
|
-
name: string | number;
|
|
232
|
-
format: 'string' | 'number' | 'boolean';
|
|
233
|
-
value?: string | number | boolean;
|
|
234
|
-
};
|
|
235
|
-
};
|
|
236
|
-
union: {
|
|
237
|
-
keyword: 'union';
|
|
238
|
-
args: Schema[];
|
|
239
|
-
};
|
|
240
|
-
ref: {
|
|
241
|
-
keyword: 'ref';
|
|
242
|
-
args: {
|
|
243
|
-
name: string;
|
|
244
|
-
$ref: string;
|
|
245
|
-
/**
|
|
246
|
-
* Full qualified path.
|
|
247
|
-
*/
|
|
248
|
-
path: KubbFile.Path;
|
|
249
|
-
/**
|
|
250
|
-
* When true `File.Import` is used.
|
|
251
|
-
* When false a reference is used inside the current file.
|
|
252
|
-
*/
|
|
253
|
-
isImportable: boolean;
|
|
254
|
-
};
|
|
255
|
-
};
|
|
256
|
-
matches: {
|
|
257
|
-
keyword: 'matches';
|
|
258
|
-
args?: string;
|
|
259
|
-
};
|
|
260
|
-
boolean: {
|
|
261
|
-
keyword: 'boolean';
|
|
262
|
-
};
|
|
263
|
-
default: {
|
|
264
|
-
keyword: 'default';
|
|
265
|
-
args: string | number | boolean;
|
|
266
|
-
};
|
|
267
|
-
string: {
|
|
268
|
-
keyword: 'string';
|
|
269
|
-
};
|
|
270
|
-
integer: {
|
|
271
|
-
keyword: 'integer';
|
|
272
|
-
};
|
|
273
|
-
bigint: {
|
|
274
|
-
keyword: 'bigint';
|
|
275
|
-
};
|
|
276
|
-
number: {
|
|
277
|
-
keyword: 'number';
|
|
278
|
-
};
|
|
279
|
-
max: {
|
|
280
|
-
keyword: 'max';
|
|
281
|
-
args: number;
|
|
282
|
-
};
|
|
283
|
-
min: {
|
|
284
|
-
keyword: 'min';
|
|
285
|
-
args: number;
|
|
286
|
-
};
|
|
287
|
-
exclusiveMaximum: {
|
|
288
|
-
keyword: 'exclusiveMaximum';
|
|
289
|
-
args: number;
|
|
290
|
-
};
|
|
291
|
-
exclusiveMinimum: {
|
|
292
|
-
keyword: 'exclusiveMinimum';
|
|
293
|
-
args: number;
|
|
294
|
-
};
|
|
295
|
-
describe: {
|
|
296
|
-
keyword: 'describe';
|
|
297
|
-
args: string;
|
|
298
|
-
};
|
|
299
|
-
example: {
|
|
300
|
-
keyword: 'example';
|
|
301
|
-
args: string;
|
|
302
|
-
};
|
|
303
|
-
deprecated: {
|
|
304
|
-
keyword: 'deprecated';
|
|
305
|
-
};
|
|
306
|
-
optional: {
|
|
307
|
-
keyword: 'optional';
|
|
308
|
-
};
|
|
309
|
-
undefined: {
|
|
310
|
-
keyword: 'undefined';
|
|
311
|
-
};
|
|
312
|
-
nullish: {
|
|
313
|
-
keyword: 'nullish';
|
|
314
|
-
};
|
|
315
|
-
nullable: {
|
|
316
|
-
keyword: 'nullable';
|
|
317
|
-
};
|
|
318
|
-
null: {
|
|
319
|
-
keyword: 'null';
|
|
320
|
-
};
|
|
321
|
-
any: {
|
|
322
|
-
keyword: 'any';
|
|
323
|
-
};
|
|
324
|
-
unknown: {
|
|
325
|
-
keyword: 'unknown';
|
|
326
|
-
};
|
|
327
|
-
void: {
|
|
328
|
-
keyword: 'void';
|
|
329
|
-
};
|
|
330
|
-
blob: {
|
|
331
|
-
keyword: 'blob';
|
|
332
|
-
};
|
|
333
|
-
schema: {
|
|
334
|
-
keyword: 'schema';
|
|
335
|
-
args: {
|
|
336
|
-
type: 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'object';
|
|
337
|
-
format?: string;
|
|
338
|
-
};
|
|
339
|
-
};
|
|
340
|
-
name: {
|
|
341
|
-
keyword: 'name';
|
|
342
|
-
args: string;
|
|
343
|
-
};
|
|
344
|
-
catchall: {
|
|
345
|
-
keyword: 'catchall';
|
|
346
|
-
};
|
|
347
|
-
interface: {
|
|
348
|
-
keyword: 'interface';
|
|
349
|
-
};
|
|
350
|
-
};
|
|
351
|
-
type Schema = {
|
|
352
|
-
keyword: string;
|
|
353
|
-
} | SchemaKeywordMapper[keyof SchemaKeywordMapper];
|
|
354
|
-
//#endregion
|
|
355
|
-
//#region ../plugin-oas/src/SchemaGenerator.d.ts
|
|
356
|
-
type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
357
|
-
fabric: Fabric;
|
|
358
|
-
oas: Oas;
|
|
359
|
-
pluginManager: PluginManager;
|
|
360
|
-
events?: AsyncEventEmitter<KubbEvents>;
|
|
361
|
-
/**
|
|
362
|
-
* Current plugin
|
|
363
|
-
*/
|
|
364
|
-
plugin: Plugin<TPluginOptions>;
|
|
365
|
-
mode: KubbFile.Mode;
|
|
366
|
-
include?: Array<'schemas' | 'responses' | 'requestBodies'>;
|
|
367
|
-
override: Array<Override<TOptions>> | undefined;
|
|
368
|
-
contentType?: contentType;
|
|
369
|
-
output?: string;
|
|
370
|
-
};
|
|
371
|
-
type SchemaGeneratorOptions = {
|
|
372
|
-
dateType: false | 'string' | 'stringOffset' | 'stringLocal' | 'date';
|
|
373
|
-
integerType?: 'number' | 'bigint';
|
|
374
|
-
unknownType: 'any' | 'unknown' | 'void';
|
|
375
|
-
emptySchemaType: 'any' | 'unknown' | 'void';
|
|
376
|
-
enumType?: 'enum' | 'asConst' | 'asPascalConst' | 'constEnum' | 'literal' | 'inlineLiteral';
|
|
377
|
-
enumSuffix?: string;
|
|
378
|
-
/**
|
|
379
|
-
* @deprecated Will be removed in v5. Use `collisionDetection: true` instead to prevent enum name collisions.
|
|
380
|
-
* When `collisionDetection` is enabled, the rootName-based approach eliminates the need for numeric suffixes.
|
|
381
|
-
* @internal
|
|
382
|
-
*/
|
|
383
|
-
usedEnumNames?: Record<string, number>;
|
|
384
|
-
mapper?: Record<string, string>;
|
|
385
|
-
typed?: boolean;
|
|
386
|
-
transformers: {
|
|
387
|
-
/**
|
|
388
|
-
* Customize the names based on the type that is provided by the plugin.
|
|
389
|
-
*/
|
|
390
|
-
name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
391
|
-
/**
|
|
392
|
-
* Receive schema and name(propertyName) and return FakerMeta array
|
|
393
|
-
* TODO TODO add docs
|
|
394
|
-
* @beta
|
|
395
|
-
*/
|
|
396
|
-
schema?: (schemaProps: SchemaProps$1, defaultSchemas: Schema[]) => Array<Schema> | undefined;
|
|
397
|
-
};
|
|
398
|
-
};
|
|
399
|
-
type SchemaProps$1 = {
|
|
400
|
-
schema: SchemaObject | null;
|
|
401
|
-
name: string | null;
|
|
402
|
-
parentName: string | null;
|
|
403
|
-
rootName?: string | null;
|
|
404
|
-
};
|
|
405
|
-
declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions, Context<TOptions, TPluginOptions>> {
|
|
406
|
-
#private;
|
|
407
|
-
refs: Refs;
|
|
408
|
-
/**
|
|
409
|
-
* Creates a type node from a given schema.
|
|
410
|
-
* Delegates to getBaseTypeFromSchema internally and
|
|
411
|
-
* optionally adds a union with null.
|
|
412
|
-
*/
|
|
413
|
-
parse(props: SchemaProps$1): Schema[];
|
|
414
|
-
static deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
|
|
415
|
-
static find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
416
|
-
static combineObjects(tree: Schema[] | undefined): Schema[];
|
|
417
|
-
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
418
|
-
}
|
|
419
|
-
//#endregion
|
|
420
|
-
//#region ../plugin-oas/src/generators/createGenerator.d.ts
|
|
421
|
-
type CoreGenerator<TOptions extends PluginFactoryOptions> = {
|
|
422
|
-
name: string;
|
|
423
|
-
type: 'core';
|
|
424
|
-
operations: (props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
425
|
-
operation: (props: OperationProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
426
|
-
schema: (props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
427
|
-
};
|
|
428
|
-
//#endregion
|
|
429
|
-
//#region ../plugin-oas/src/generators/types.d.ts
|
|
430
|
-
type OperationsProps<TOptions extends PluginFactoryOptions> = {
|
|
431
|
-
config: Config;
|
|
432
|
-
generator: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
433
|
-
plugin: Plugin<TOptions>;
|
|
434
|
-
operations: Array<Operation>;
|
|
435
|
-
};
|
|
436
|
-
type OperationProps<TOptions extends PluginFactoryOptions> = {
|
|
437
|
-
config: Config;
|
|
438
|
-
generator: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
439
|
-
plugin: Plugin<TOptions>;
|
|
440
|
-
operation: Operation;
|
|
441
|
-
};
|
|
442
|
-
type SchemaProps<TOptions extends PluginFactoryOptions> = {
|
|
443
|
-
config: Config;
|
|
444
|
-
generator: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>;
|
|
445
|
-
plugin: Plugin<TOptions>;
|
|
446
|
-
schema: {
|
|
447
|
-
name: string;
|
|
448
|
-
tree: Array<Schema>;
|
|
449
|
-
value: SchemaObject;
|
|
450
|
-
};
|
|
451
|
-
};
|
|
452
|
-
type Generator<TOptions extends PluginFactoryOptions> = CoreGenerator<TOptions> | ReactGenerator<TOptions>;
|
|
453
|
-
//#endregion
|
|
454
|
-
//#region ../plugin-oas/src/generators/createReactGenerator.d.ts
|
|
455
|
-
type ReactGenerator<TOptions extends PluginFactoryOptions> = {
|
|
456
|
-
name: string;
|
|
457
|
-
type: 'react';
|
|
458
|
-
Operations: (props: OperationsProps<TOptions>) => FabricReactNode;
|
|
459
|
-
Operation: (props: OperationProps<TOptions>) => FabricReactNode;
|
|
460
|
-
Schema: (props: SchemaProps<TOptions>) => FabricReactNode;
|
|
461
|
-
};
|
|
462
|
-
//#endregion
|
|
463
|
-
//#region src/generators/cypressGenerator.d.ts
|
|
464
|
-
declare const cypressGenerator: ReactGenerator<PluginCypress>;
|
|
465
|
-
//#endregion
|
|
466
|
-
export { cypressGenerator };
|
|
467
|
-
//# sourceMappingURL=generators.d.cts.map
|
package/dist/index.d.cts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { n as PluginCypress, r as __name, t as Options } from "./types-eAm46aNL.cjs";
|
|
2
|
-
import * as _kubb_core0 from "@kubb/core";
|
|
3
|
-
|
|
4
|
-
//#region src/plugin.d.ts
|
|
5
|
-
declare const pluginCypressName = "plugin-cypress";
|
|
6
|
-
declare const pluginCypress: (options?: Options | undefined) => _kubb_core0.UserPluginWithLifeCycle<PluginCypress>;
|
|
7
|
-
//#endregion
|
|
8
|
-
export { type PluginCypress, pluginCypress, pluginCypressName };
|
|
9
|
-
//# sourceMappingURL=index.d.cts.map
|