@kubb/plugin-cypress 4.3.1 → 4.4.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.
Files changed (34) hide show
  1. package/dist/chunk-DMmIE7y6.js +28 -0
  2. package/dist/{components-B-t6gvpJ.cjs → components-CDWcq6eX.cjs} +8 -8
  3. package/dist/components-CDWcq6eX.cjs.map +1 -0
  4. package/dist/{components-CkuOZl8o.js → components-Cs-85WSv.js} +3 -3
  5. package/dist/components-Cs-85WSv.js.map +1 -0
  6. package/dist/components.cjs +1 -1
  7. package/dist/components.d.cts +3 -2
  8. package/dist/components.d.ts +3 -2
  9. package/dist/components.js +1 -1
  10. package/dist/{generators-Dcm7kTBP.cjs → generators-CKKLK5ah.cjs} +9 -9
  11. package/dist/generators-CKKLK5ah.cjs.map +1 -0
  12. package/dist/{generators-v4Wf70NJ.js → generators-CfF-r6zR.js} +4 -4
  13. package/dist/generators-CfF-r6zR.js.map +1 -0
  14. package/dist/generators.cjs +2 -2
  15. package/dist/generators.d.cts +2 -2
  16. package/dist/generators.d.ts +2 -2
  17. package/dist/generators.js +2 -2
  18. package/dist/index.cjs +3 -2
  19. package/dist/index.cjs.map +1 -1
  20. package/dist/index.d.cts +1 -1
  21. package/dist/index.d.ts +1 -1
  22. package/dist/index.js +3 -2
  23. package/dist/index.js.map +1 -1
  24. package/dist/{types-DvtvRYFG.d.ts → types-bObu7JjR.d.cts} +230 -325
  25. package/dist/{types-BzpxVS9E.d.cts → types-dtu1Ew7p.d.ts} +230 -325
  26. package/package.json +16 -12
  27. package/src/components/Request.tsx +3 -3
  28. package/src/generators/cypressGenerator.tsx +1 -1
  29. package/src/plugin.ts +1 -0
  30. package/src/types.ts +2 -2
  31. package/dist/components-B-t6gvpJ.cjs.map +0 -1
  32. package/dist/components-CkuOZl8o.js.map +0 -1
  33. package/dist/generators-Dcm7kTBP.cjs.map +0 -1
  34. package/dist/generators-v4Wf70NJ.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-cypress",
3
- "version": "4.3.1",
3
+ "version": "4.4.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",
@@ -66,19 +66,23 @@
66
66
  "!/**/**.test.**",
67
67
  "!/**/__tests__/**"
68
68
  ],
69
+ "size-limit": [
70
+ {
71
+ "path": "./dist/*.js",
72
+ "limit": "510 KiB",
73
+ "gzip": true
74
+ }
75
+ ],
69
76
  "dependencies": {
70
- "@kubb/core": "4.3.1",
71
- "@kubb/oas": "4.3.1",
72
- "@kubb/plugin-oas": "4.3.1",
73
- "@kubb/plugin-ts": "4.3.1",
74
- "@kubb/react": "4.3.1"
75
- },
76
- "devDependencies": {
77
- "tsdown": "^0.15.9",
78
- "typescript": "^5.9.3"
77
+ "@kubb/react-fabric": "0.2.10",
78
+ "@kubb/core": "4.4.1",
79
+ "@kubb/oas": "4.4.1",
80
+ "@kubb/plugin-oas": "4.4.1",
81
+ "@kubb/plugin-ts": "4.4.1"
79
82
  },
83
+ "devDependencies": {},
80
84
  "peerDependencies": {
81
- "@kubb/react": "^4.3.0"
85
+ "@kubb/react-fabric": "0.2.10"
82
86
  },
83
87
  "engines": {
84
88
  "node": ">=20"
@@ -88,7 +92,7 @@
88
92
  "registry": "https://registry.npmjs.org/"
89
93
  },
90
94
  "scripts": {
91
- "build": "tsdown",
95
+ "build": "tsdown && size-limit",
92
96
  "clean": "npx rimraf ./dist",
93
97
  "lint": "bun biome lint .",
94
98
  "lint:fix": "bun biome lint --fix --unsafe .",
@@ -1,8 +1,8 @@
1
1
  import { URLPath } from '@kubb/core/utils'
2
-
3
2
  import { type HttpMethod, isOptional } from '@kubb/oas'
4
3
  import type { OperationSchemas } from '@kubb/plugin-oas'
5
- import { File, Function, FunctionParams } from '@kubb/react'
4
+ import { File, Function, FunctionParams } from '@kubb/react-fabric'
5
+ import type { KubbNode } from '@kubb/react-fabric/types'
6
6
  import type { PluginCypress } from '../types.ts'
7
7
 
8
8
  type Props = {
@@ -17,7 +17,7 @@ type Props = {
17
17
  method: HttpMethod
18
18
  }
19
19
 
20
- export function Request({ baseURL = '', name, dataReturnType, typeSchemas, url, method }: Props) {
20
+ export function Request({ baseURL = '', name, dataReturnType, typeSchemas, url, method }: Props): KubbNode {
21
21
  const params = FunctionParams.factory({
22
22
  data: typeSchemas.request?.name
23
23
  ? {
@@ -4,7 +4,7 @@ import { createReactGenerator } from '@kubb/plugin-oas'
4
4
  import { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'
5
5
  import { getBanner, getFooter } from '@kubb/plugin-oas/utils'
6
6
  import { pluginTsName } from '@kubb/plugin-ts'
7
- import { File } from '@kubb/react'
7
+ import { File } from '@kubb/react-fabric'
8
8
  import { Request } from '../components'
9
9
  import type { PluginCypress } from '../types'
10
10
 
package/src/plugin.ts CHANGED
@@ -85,6 +85,7 @@ export const pluginCypress = createPlugin<PluginCypress>((options) => {
85
85
  const mode = getMode(path.resolve(root, output.path))
86
86
 
87
87
  const operationGenerator = new OperationGenerator(this.plugin.options, {
88
+ fabric: this.fabric,
88
89
  oas,
89
90
  pluginManager: this.pluginManager,
90
91
  plugin: this.plugin,
package/src/types.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { Group, Output, PluginFactoryOptions, ResolveNameParams } from '@kubb/core'
2
2
 
3
- import type { Oas, contentType } from '@kubb/oas'
4
- import type { Exclude, Include, Override, ResolvePathOptions, Generator } from '@kubb/plugin-oas'
3
+ import type { contentType, Oas } from '@kubb/oas'
4
+ import type { Exclude, Generator, Include, Override, ResolvePathOptions } from '@kubb/plugin-oas'
5
5
 
6
6
  export type Options = {
7
7
  /**
@@ -1 +0,0 @@
1
- {"version":3,"file":"components-B-t6gvpJ.cjs","names":["FunctionParams","File","Function","URLPath"],"sources":["../src/components/Request.tsx"],"sourcesContent":["import { URLPath } from '@kubb/core/utils'\n\nimport { type HttpMethod, isOptional } from '@kubb/oas'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport { File, Function, FunctionParams } from '@kubb/react'\nimport type { PluginCypress } from '../types.ts'\n\ntype Props = {\n /**\n * Name of the function\n */\n name: string\n typeSchemas: OperationSchemas\n url: string\n baseURL: string | undefined\n dataReturnType: PluginCypress['resolvedOptions']['dataReturnType']\n method: HttpMethod\n}\n\nexport function Request({ baseURL = '', name, dataReturnType, typeSchemas, url, method }: Props) {\n const params = FunctionParams.factory({\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n })\n\n const returnType =\n dataReturnType === 'data' ? `Cypress.Chainable<${typeSchemas.response.name}>` : `Cypress.Chainable<Cypress.Response<${typeSchemas.response.name}>>`\n\n const body = typeSchemas.request?.name ? 'data' : undefined\n\n return (\n <File.Source name={name} isIndexable isExportable>\n <Function name={name} export params={params.toConstructor()} returnType={returnType}>\n {dataReturnType === 'data' &&\n `return cy.request('${method}', '${baseURL ?? ''}${new URLPath(url).toURLPath().replace(/([^/]):/g, '$1\\\\\\\\:')}', ${body}).then((res: Cypress.Response<${typeSchemas.response.name}>) => res.body)`}\n {dataReturnType === 'full' && `return cy.request('${method}', '${new URLPath(`${baseURL ?? ''}${url}`).toURLPath()}', ${body})`}\n </Function>\n </File.Source>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA,SAAgB,QAAQ,EAAE,UAAU,IAAI,MAAM,gBAAgB,aAAa,KAAK,UAAiB;CAC/F,MAAM,SAASA,4BAAe,QAAQ,EACpC,MAAM,YAAY,SAAS,OACvB;EACE,MAAM,YAAY,SAAS;EAC3B,qCAAqB,YAAY,SAAS,OAAO;EAClD,GACD,QACL,CAAC;CAEF,MAAM,aACJ,mBAAmB,SAAS,qBAAqB,YAAY,SAAS,KAAK,KAAK,sCAAsC,YAAY,SAAS,KAAK;CAElJ,MAAM,OAAO,YAAY,SAAS,OAAO,SAAS;AAElD,QACE,kDAACC,kBAAK;EAAa;EAAM;EAAY;YACnC,mDAACC;GAAe;GAAM;GAAO,QAAQ,OAAO,eAAe;GAAc;cACtE,mBAAmB,UAClB,sBAAsB,OAAO,MAAM,WAAW,KAAK,IAAIC,0BAAQ,IAAI,CAAC,WAAW,CAAC,QAAQ,YAAY,UAAU,CAAC,KAAK,KAAK,gCAAgC,YAAY,SAAS,KAAK,kBACpL,mBAAmB,UAAU,sBAAsB,OAAO,MAAM,IAAIA,0BAAQ,GAAG,WAAW,KAAK,MAAM,CAAC,WAAW,CAAC,KAAK,KAAK;IACpH;GACC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"components-CkuOZl8o.js","names":[],"sources":["../src/components/Request.tsx"],"sourcesContent":["import { URLPath } from '@kubb/core/utils'\n\nimport { type HttpMethod, isOptional } from '@kubb/oas'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport { File, Function, FunctionParams } from '@kubb/react'\nimport type { PluginCypress } from '../types.ts'\n\ntype Props = {\n /**\n * Name of the function\n */\n name: string\n typeSchemas: OperationSchemas\n url: string\n baseURL: string | undefined\n dataReturnType: PluginCypress['resolvedOptions']['dataReturnType']\n method: HttpMethod\n}\n\nexport function Request({ baseURL = '', name, dataReturnType, typeSchemas, url, method }: Props) {\n const params = FunctionParams.factory({\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n })\n\n const returnType =\n dataReturnType === 'data' ? `Cypress.Chainable<${typeSchemas.response.name}>` : `Cypress.Chainable<Cypress.Response<${typeSchemas.response.name}>>`\n\n const body = typeSchemas.request?.name ? 'data' : undefined\n\n return (\n <File.Source name={name} isIndexable isExportable>\n <Function name={name} export params={params.toConstructor()} returnType={returnType}>\n {dataReturnType === 'data' &&\n `return cy.request('${method}', '${baseURL ?? ''}${new URLPath(url).toURLPath().replace(/([^/]):/g, '$1\\\\\\\\:')}', ${body}).then((res: Cypress.Response<${typeSchemas.response.name}>) => res.body)`}\n {dataReturnType === 'full' && `return cy.request('${method}', '${new URLPath(`${baseURL ?? ''}${url}`).toURLPath()}', ${body})`}\n </Function>\n </File.Source>\n )\n}\n"],"mappings":";;;;;;AAmBA,SAAgB,QAAQ,EAAE,UAAU,IAAI,MAAM,gBAAgB,aAAa,KAAK,UAAiB;CAC/F,MAAM,SAAS,eAAe,QAAQ,EACpC,MAAM,YAAY,SAAS,OACvB;EACE,MAAM,YAAY,SAAS;EAC3B,UAAU,WAAW,YAAY,SAAS,OAAO;EAClD,GACD,QACL,CAAC;CAEF,MAAM,aACJ,mBAAmB,SAAS,qBAAqB,YAAY,SAAS,KAAK,KAAK,sCAAsC,YAAY,SAAS,KAAK;CAElJ,MAAM,OAAO,YAAY,SAAS,OAAO,SAAS;AAElD,QACE,oBAAC,KAAK;EAAa;EAAM;EAAY;YACnC,qBAAC;GAAe;GAAM;GAAO,QAAQ,OAAO,eAAe;GAAc;cACtE,mBAAmB,UAClB,sBAAsB,OAAO,MAAM,WAAW,KAAK,IAAI,QAAQ,IAAI,CAAC,WAAW,CAAC,QAAQ,YAAY,UAAU,CAAC,KAAK,KAAK,gCAAgC,YAAY,SAAS,KAAK,kBACpL,mBAAmB,UAAU,sBAAsB,OAAO,MAAM,IAAI,QAAQ,GAAG,WAAW,KAAK,MAAM,CAAC,WAAW,CAAC,KAAK,KAAK;IACpH;GACC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"generators-Dcm7kTBP.cjs","names":["pluginTsName","File","Request","URLPath"],"sources":["../src/generators/cypressGenerator.tsx"],"sourcesContent":["import { usePlugin, usePluginManager } from '@kubb/core/hooks'\nimport { URLPath } from '@kubb/core/utils'\nimport { createReactGenerator } from '@kubb/plugin-oas'\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'\nimport { Request } from '../components'\nimport type { PluginCypress } from '../types'\n\nexport const cypressGenerator = createReactGenerator<PluginCypress>({\n name: 'cypress',\n Operation({ operation }) {\n const {\n options: { output, baseURL, dataReturnType },\n } = usePlugin<PluginCypress>()\n const pluginManager = usePluginManager()\n\n const oas = useOas()\n const { getSchemas, getName, getFile } = useOperationManager()\n\n const request = {\n name: getName(operation, { type: 'function' }),\n file: getFile(operation),\n }\n\n const type = {\n file: getFile(operation, { pluginKey: [pluginTsName] }),\n schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' }),\n }\n\n return (\n <File\n baseName={request.file.baseName}\n path={request.file.path}\n meta={request.file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n <File.Import\n name={[\n type.schemas.request?.name,\n type.schemas.response.name,\n type.schemas.pathParams?.name,\n type.schemas.queryParams?.name,\n type.schemas.headerParams?.name,\n ...(type.schemas.statusCodes?.map((item) => item.name) || []),\n ].filter(Boolean)}\n root={request.file.path}\n path={type.file.path}\n isTypeOnly\n />\n <Request\n name={request.name}\n dataReturnType={dataReturnType}\n typeSchemas={type.schemas}\n method={operation.method}\n baseURL={baseURL}\n url={new URLPath(operation.path).toURLPath()}\n />\n </File>\n )\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAUA,MAAa,+DAAuD;CAClE,MAAM;CACN,UAAU,EAAE,aAAa;EACvB,MAAM,EACJ,SAAS,EAAE,QAAQ,SAAS,uDACA;EAC9B,MAAM,yDAAkC;EAExC,MAAM,2CAAc;EACpB,MAAM,EAAE,YAAY,SAAS,8DAAiC;EAE9D,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,8BAAa,EAAE,CAAC;GACvD,SAAS,WAAW,WAAW;IAAE,WAAW,CAACA,8BAAa;IAAE,MAAM;IAAQ,CAAC;GAC5E;AAED,SACE,mDAACC;GACC,UAAU,QAAQ,KAAK;GACvB,MAAM,QAAQ,KAAK;GACnB,MAAM,QAAQ,KAAK;GACnB,+CAAkB;IAAE;IAAK;IAAQ,QAAQ,cAAc;IAAQ,CAAC;GAChE,+CAAkB;IAAE;IAAK;IAAQ,CAAC;cAElC,kDAACA,kBAAK;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,kDAACC;IACC,MAAM,QAAQ;IACE;IAChB,aAAa,KAAK;IAClB,QAAQ,UAAU;IACT;IACT,KAAK,IAAIC,0BAAQ,UAAU,KAAK,CAAC,WAAW;KAC5C;IACG;;CAGZ,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"generators-v4Wf70NJ.js","names":[],"sources":["../src/generators/cypressGenerator.tsx"],"sourcesContent":["import { usePlugin, usePluginManager } from '@kubb/core/hooks'\nimport { URLPath } from '@kubb/core/utils'\nimport { createReactGenerator } from '@kubb/plugin-oas'\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'\nimport { Request } from '../components'\nimport type { PluginCypress } from '../types'\n\nexport const cypressGenerator = createReactGenerator<PluginCypress>({\n name: 'cypress',\n Operation({ operation }) {\n const {\n options: { output, baseURL, dataReturnType },\n } = usePlugin<PluginCypress>()\n const pluginManager = usePluginManager()\n\n const oas = useOas()\n const { getSchemas, getName, getFile } = useOperationManager()\n\n const request = {\n name: getName(operation, { type: 'function' }),\n file: getFile(operation),\n }\n\n const type = {\n file: getFile(operation, { pluginKey: [pluginTsName] }),\n schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' }),\n }\n\n return (\n <File\n baseName={request.file.baseName}\n path={request.file.path}\n meta={request.file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n <File.Import\n name={[\n type.schemas.request?.name,\n type.schemas.response.name,\n type.schemas.pathParams?.name,\n type.schemas.queryParams?.name,\n type.schemas.headerParams?.name,\n ...(type.schemas.statusCodes?.map((item) => item.name) || []),\n ].filter(Boolean)}\n root={request.file.path}\n path={type.file.path}\n isTypeOnly\n />\n <Request\n name={request.name}\n dataReturnType={dataReturnType}\n typeSchemas={type.schemas}\n method={operation.method}\n baseURL={baseURL}\n url={new URLPath(operation.path).toURLPath()}\n />\n </File>\n )\n },\n})\n"],"mappings":";;;;;;;;;;;AAUA,MAAa,mBAAmB,qBAAoC;CAClE,MAAM;CACN,UAAU,EAAE,aAAa;EACvB,MAAM,EACJ,SAAS,EAAE,QAAQ,SAAS,qBAC1B,WAA0B;EAC9B,MAAM,gBAAgB,kBAAkB;EAExC,MAAM,MAAM,QAAQ;EACpB,MAAM,EAAE,YAAY,SAAS,YAAY,qBAAqB;EAE9D,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;IAChB,aAAa,KAAK;IAClB,QAAQ,UAAU;IACT;IACT,KAAK,IAAI,QAAQ,UAAU,KAAK,CAAC,WAAW;KAC5C;IACG;;CAGZ,CAAC"}