@kubb/plugin-cypress 5.0.0-alpha.3 → 5.0.0-alpha.31
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/index.cjs +465 -59
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +206 -4
- package/dist/index.js +463 -60
- package/dist/index.js.map +1 -1
- package/package.json +6 -30
- package/src/components/Request.tsx +72 -108
- package/src/generators/cypressGenerator.tsx +48 -43
- package/src/index.ts +8 -1
- package/src/plugin.ts +81 -91
- package/src/presets.ts +23 -0
- package/src/resolvers/resolverCypress.ts +26 -0
- package/src/types.ts +105 -38
- package/dist/components-BK_6GU4v.js +0 -257
- package/dist/components-BK_6GU4v.js.map +0 -1
- package/dist/components-Drg_gLu2.cjs +0 -305
- package/dist/components-Drg_gLu2.cjs.map +0 -1
- package/dist/components.cjs +0 -3
- package/dist/components.d.ts +0 -50
- package/dist/components.js +0 -2
- package/dist/generators-BImGfp9Q.js +0 -71
- package/dist/generators-BImGfp9Q.js.map +0 -1
- package/dist/generators-DdeGa-zp.cjs +0 -75
- package/dist/generators-DdeGa-zp.cjs.map +0 -1
- package/dist/generators.cjs +0 -3
- package/dist/generators.d.ts +0 -500
- package/dist/generators.js +0 -2
- package/dist/types-BzXXi6dv.d.ts +0 -85
- package/src/components/index.ts +0 -1
- package/src/generators/index.ts +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,212 @@
|
|
|
1
1
|
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
|
-
import {
|
|
3
|
-
import * as _kubb_core0 from "@kubb/core";
|
|
2
|
+
import { ResolverTs } from "@kubb/plugin-ts";
|
|
3
|
+
import * as _$_kubb_core0 from "@kubb/core";
|
|
4
|
+
import { CompatibilityPreset, Exclude, Generator, Group, Include, Output, Override, PluginFactoryOptions, ResolvePathOptions, Resolver, UserGroup } from "@kubb/core";
|
|
5
|
+
import { OperationNode, Visitor } from "@kubb/ast/types";
|
|
6
|
+
import { FabricReactNode } from "@kubb/react-fabric/types";
|
|
4
7
|
|
|
8
|
+
//#region src/types.d.ts
|
|
9
|
+
/**
|
|
10
|
+
* The concrete resolver type for `@kubb/plugin-cypress`.
|
|
11
|
+
* Extends the base `Resolver` with a `resolveName` helper for operation function names.
|
|
12
|
+
*/
|
|
13
|
+
type ResolverCypress = Resolver & {
|
|
14
|
+
/**
|
|
15
|
+
* Resolves the function name for a given raw operation name.
|
|
16
|
+
* @example
|
|
17
|
+
* resolver.resolveName('show pet by id') // -> 'showPetById'
|
|
18
|
+
*/
|
|
19
|
+
resolveName(this: ResolverCypress, name: string): string;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Discriminated union that ties `pathParamsType` to the `paramsType` values where it is meaningful.
|
|
23
|
+
*
|
|
24
|
+
* - `paramsType: 'object'` — all parameters (including path params) are merged into a single
|
|
25
|
+
* destructured object. `pathParamsType` is never reached in this code path and has no effect.
|
|
26
|
+
* - `paramsType?: 'inline'` (or omitted) — each parameter group is a separate function argument.
|
|
27
|
+
* `pathParamsType` controls whether the path-param group itself is destructured (`'object'`)
|
|
28
|
+
* or spread as individual arguments (`'inline'`).
|
|
29
|
+
*/
|
|
30
|
+
type ParamsTypeOptions = {
|
|
31
|
+
/**
|
|
32
|
+
* All parameters — path, query, headers, and body — are merged into a single
|
|
33
|
+
* destructured object argument.
|
|
34
|
+
* - 'object' returns the params and pathParams as an object.
|
|
35
|
+
* @default 'inline'
|
|
36
|
+
*/
|
|
37
|
+
paramsType: 'object';
|
|
38
|
+
/**
|
|
39
|
+
* `pathParamsType` has no effect when `paramsType` is `'object'`.
|
|
40
|
+
* Path params are already inside the single destructured object.
|
|
41
|
+
*/
|
|
42
|
+
pathParamsType?: never;
|
|
43
|
+
} | {
|
|
44
|
+
/**
|
|
45
|
+
* Each parameter group is emitted as a separate function argument.
|
|
46
|
+
* - 'inline' returns the params as comma separated params.
|
|
47
|
+
* @default 'inline'
|
|
48
|
+
*/
|
|
49
|
+
paramsType?: 'inline';
|
|
50
|
+
/**
|
|
51
|
+
* Controls how path parameters are arranged within the inline argument list.
|
|
52
|
+
* - 'object' groups path params into a destructured object: `{ petId }: PathParams`.
|
|
53
|
+
* - 'inline' emits each path param as its own argument: `petId: string`.
|
|
54
|
+
* @default 'inline'
|
|
55
|
+
*/
|
|
56
|
+
pathParamsType?: 'object' | 'inline';
|
|
57
|
+
};
|
|
58
|
+
type Options = {
|
|
59
|
+
/**
|
|
60
|
+
* Specify the export location for the files and define the behavior of the output.
|
|
61
|
+
* @default { path: 'cypress', barrelType: 'named' }
|
|
62
|
+
*/
|
|
63
|
+
output?: Output;
|
|
64
|
+
/**
|
|
65
|
+
* Return type when calling cy.request.
|
|
66
|
+
* - 'data' returns ResponseConfig[data].
|
|
67
|
+
* - 'full' returns ResponseConfig.
|
|
68
|
+
* @default 'data'
|
|
69
|
+
*/
|
|
70
|
+
dataReturnType?: 'data' | 'full';
|
|
71
|
+
/**
|
|
72
|
+
* How to style your params, by default no casing is applied.
|
|
73
|
+
* - 'camelcase' uses camelCase for the params names.
|
|
74
|
+
*/
|
|
75
|
+
paramsCasing?: 'camelcase';
|
|
76
|
+
/**
|
|
77
|
+
* Base URL prepended to every generated request URL.
|
|
78
|
+
*/
|
|
79
|
+
baseURL?: string;
|
|
80
|
+
/**
|
|
81
|
+
* Group the Cypress requests based on the provided name.
|
|
82
|
+
*/
|
|
83
|
+
group?: UserGroup;
|
|
84
|
+
/**
|
|
85
|
+
* Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
|
|
86
|
+
*/
|
|
87
|
+
exclude?: Array<Exclude>;
|
|
88
|
+
/**
|
|
89
|
+
* Array containing include parameters to include tags/operations/methods/paths.
|
|
90
|
+
*/
|
|
91
|
+
include?: Array<Include>;
|
|
92
|
+
/**
|
|
93
|
+
* Array containing override parameters to override `options` based on tags/operations/methods/paths.
|
|
94
|
+
*/
|
|
95
|
+
override?: Array<Override<ResolvedOptions>>;
|
|
96
|
+
/**
|
|
97
|
+
* Apply a compatibility naming preset.
|
|
98
|
+
* @default 'default'
|
|
99
|
+
*/
|
|
100
|
+
compatibilityPreset?: CompatibilityPreset;
|
|
101
|
+
/**
|
|
102
|
+
* A single resolver whose methods override the default resolver's naming conventions.
|
|
103
|
+
* When a method returns `null` or `undefined`, the default resolver's result is used instead.
|
|
104
|
+
*/
|
|
105
|
+
resolver?: Partial<ResolverCypress> & ThisType<ResolverCypress>;
|
|
106
|
+
/**
|
|
107
|
+
* A single AST visitor applied before printing.
|
|
108
|
+
* When a visitor method returns `null` or `undefined`, the preset transformer's result is used instead.
|
|
109
|
+
*/
|
|
110
|
+
transformer?: Visitor;
|
|
111
|
+
/**
|
|
112
|
+
* Define some generators next to the default generators.
|
|
113
|
+
*/
|
|
114
|
+
generators?: Array<Generator<PluginCypress>>;
|
|
115
|
+
} & ParamsTypeOptions;
|
|
116
|
+
type ResolvedOptions = {
|
|
117
|
+
output: Output;
|
|
118
|
+
exclude: Array<Exclude>;
|
|
119
|
+
include: Array<Include> | undefined;
|
|
120
|
+
override: Array<Override<ResolvedOptions>>;
|
|
121
|
+
group: Group | undefined;
|
|
122
|
+
baseURL: Options['baseURL'] | undefined;
|
|
123
|
+
dataReturnType: NonNullable<Options['dataReturnType']>;
|
|
124
|
+
pathParamsType: NonNullable<NonNullable<Options['pathParamsType']>>;
|
|
125
|
+
paramsType: NonNullable<Options['paramsType']>;
|
|
126
|
+
paramsCasing: Options['paramsCasing'];
|
|
127
|
+
resolver: ResolverCypress;
|
|
128
|
+
};
|
|
129
|
+
type PluginCypress = PluginFactoryOptions<'plugin-cypress', Options, ResolvedOptions, never, ResolvePathOptions, ResolverCypress>;
|
|
130
|
+
declare global {
|
|
131
|
+
namespace Kubb {
|
|
132
|
+
interface PluginRegistry {
|
|
133
|
+
'plugin-cypress': PluginCypress;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
//#endregion
|
|
138
|
+
//#region src/components/Request.d.ts
|
|
139
|
+
type Props = {
|
|
140
|
+
/**
|
|
141
|
+
* Name of the function
|
|
142
|
+
*/
|
|
143
|
+
name: string;
|
|
144
|
+
/**
|
|
145
|
+
* AST operation node
|
|
146
|
+
*/
|
|
147
|
+
node: OperationNode;
|
|
148
|
+
/**
|
|
149
|
+
* TypeScript resolver for resolving param/data/response type names
|
|
150
|
+
*/
|
|
151
|
+
resolver: ResolverTs;
|
|
152
|
+
baseURL: string | undefined;
|
|
153
|
+
dataReturnType: PluginCypress['resolvedOptions']['dataReturnType'];
|
|
154
|
+
paramsCasing: PluginCypress['resolvedOptions']['paramsCasing'];
|
|
155
|
+
paramsType: PluginCypress['resolvedOptions']['paramsType'];
|
|
156
|
+
pathParamsType: PluginCypress['resolvedOptions']['pathParamsType'];
|
|
157
|
+
};
|
|
158
|
+
declare function Request({
|
|
159
|
+
baseURL,
|
|
160
|
+
name,
|
|
161
|
+
dataReturnType,
|
|
162
|
+
resolver,
|
|
163
|
+
node,
|
|
164
|
+
paramsType,
|
|
165
|
+
pathParamsType,
|
|
166
|
+
paramsCasing
|
|
167
|
+
}: Props): FabricReactNode;
|
|
168
|
+
//#endregion
|
|
169
|
+
//#region src/generators/cypressGenerator.d.ts
|
|
170
|
+
declare const cypressGenerator: _$_kubb_core0.Generator<PluginCypress>;
|
|
171
|
+
//#endregion
|
|
5
172
|
//#region src/plugin.d.ts
|
|
173
|
+
/**
|
|
174
|
+
* Canonical plugin name for `@kubb/plugin-cypress`, used to identify the plugin
|
|
175
|
+
* in driver lookups and warnings.
|
|
176
|
+
*/
|
|
6
177
|
declare const pluginCypressName = "plugin-cypress";
|
|
7
|
-
|
|
178
|
+
/**
|
|
179
|
+
* The `@kubb/plugin-cypress` plugin factory.
|
|
180
|
+
*
|
|
181
|
+
* Generates Cypress `cy.request()` test functions from an OpenAPI/AST `RootNode`.
|
|
182
|
+
* Walks operations, delegates rendering to the active generators,
|
|
183
|
+
* and writes barrel files based on `output.barrelType`.
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* ```ts
|
|
187
|
+
* import { pluginCypress } from '@kubb/plugin-cypress'
|
|
188
|
+
*
|
|
189
|
+
* export default defineConfig({
|
|
190
|
+
* plugins: [pluginCypress({ output: { path: 'cypress' } })],
|
|
191
|
+
* })
|
|
192
|
+
* ```
|
|
193
|
+
*/
|
|
194
|
+
declare const pluginCypress: (options?: Options | undefined) => _$_kubb_core0.UserPluginWithLifeCycle<PluginCypress>;
|
|
195
|
+
//#endregion
|
|
196
|
+
//#region src/resolvers/resolverCypress.d.ts
|
|
197
|
+
/**
|
|
198
|
+
* Resolver for `@kubb/plugin-cypress` that provides the default naming
|
|
199
|
+
* and path-resolution helpers used by the plugin.
|
|
200
|
+
*
|
|
201
|
+
* @example
|
|
202
|
+
* ```ts
|
|
203
|
+
* import { resolverCypress } from '@kubb/plugin-cypress'
|
|
204
|
+
*
|
|
205
|
+
* resolverCypress.default('list pets', 'function') // -> 'listPets'
|
|
206
|
+
* resolverCypress.resolveName('show pet by id') // -> 'showPetById'
|
|
207
|
+
* ```
|
|
208
|
+
*/
|
|
209
|
+
declare const resolverCypress: ResolverCypress;
|
|
8
210
|
//#endregion
|
|
9
|
-
export { type PluginCypress, pluginCypress, pluginCypressName };
|
|
211
|
+
export { type PluginCypress, Request, type ResolverCypress, cypressGenerator, pluginCypress, pluginCypressName, resolverCypress };
|
|
10
212
|
//# sourceMappingURL=index.d.ts.map
|