@kubb/plugin-faker 5.0.0-beta.81 → 5.0.0-beta.85
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 +530 -405
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +74 -114
- package/dist/index.js +493 -346
- package/dist/index.js.map +1 -1
- package/package.json +4 -6
package/dist/index.d.ts
CHANGED
|
@@ -1,121 +1,81 @@
|
|
|
1
1
|
import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
|
|
2
|
-
import { Exclude, Group, Include, Output, OutputOptions, Override, PluginFactoryOptions, Resolver, ast } from "
|
|
3
|
-
import { KubbReactNode } from "
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Resolver interface for building operation parameters.
|
|
7
|
-
*
|
|
8
|
-
* `ResolverTs` from `@kubb/plugin-ts` satisfies this interface and can be passed directly.
|
|
9
|
-
*/
|
|
10
|
-
type OperationParamsResolver = {
|
|
11
|
-
/**
|
|
12
|
-
* Resolves the type name for an individual parameter.
|
|
13
|
-
*
|
|
14
|
-
* @example Individual path parameter name
|
|
15
|
-
* `resolver.resolveParamName(node, param) // → 'DeletePetPathPetId'`
|
|
16
|
-
*/
|
|
17
|
-
resolveParamName(node: ast.OperationNode, param: ast.ParameterNode): string;
|
|
18
|
-
/**
|
|
19
|
-
* Resolves the request body type name.
|
|
20
|
-
*
|
|
21
|
-
* @example Request body type name
|
|
22
|
-
* `resolver.resolveDataName(node) // → 'CreatePetData'`
|
|
23
|
-
*/
|
|
24
|
-
resolveDataName(node: ast.OperationNode): string;
|
|
25
|
-
/**
|
|
26
|
-
* Resolves the grouped path parameters type name.
|
|
27
|
-
* When the return value equals `resolveParamName`, no indexed access is emitted.
|
|
28
|
-
*
|
|
29
|
-
* @example Grouped path params type name
|
|
30
|
-
* `resolver.resolvePathParamsName(node, param) // → 'DeletePetPathParams'`
|
|
31
|
-
*/
|
|
32
|
-
resolvePathParamsName(node: ast.OperationNode, param: ast.ParameterNode): string;
|
|
33
|
-
/**
|
|
34
|
-
* Resolves the grouped query parameters type name.
|
|
35
|
-
* When the return value equals `resolveParamName`, an inline struct type is emitted instead.
|
|
36
|
-
*
|
|
37
|
-
* @example Grouped query params type name
|
|
38
|
-
* `resolver.resolveQueryParamsName(node, param) // → 'FindPetsByStatusQueryParams'`
|
|
39
|
-
*/
|
|
40
|
-
resolveQueryParamsName(node: ast.OperationNode, param: ast.ParameterNode): string;
|
|
41
|
-
/**
|
|
42
|
-
* Resolves the grouped header parameters type name.
|
|
43
|
-
* When the return value equals `resolveParamName`, an inline struct type is emitted instead.
|
|
44
|
-
*
|
|
45
|
-
* @example Grouped header params type name
|
|
46
|
-
* `resolver.resolveHeaderParamsName(node, param) // → 'DeletePetHeaderParams'`
|
|
47
|
-
*/
|
|
48
|
-
resolveHeaderParamsName(node: ast.OperationNode, param: ast.ParameterNode): string;
|
|
49
|
-
};
|
|
50
|
-
//#endregion
|
|
2
|
+
import { Exclude, Group, Include, Output, OutputOptions, Override, PluginFactoryOptions, Resolver, ResolverPatch, ast } from "kubb/kit";
|
|
3
|
+
import { KubbReactNode } from "kubb/jsx";
|
|
4
|
+
|
|
51
5
|
//#region src/types.d.ts
|
|
52
6
|
/**
|
|
53
7
|
* Resolver for Faker that provides naming methods for mock functions.
|
|
8
|
+
*
|
|
9
|
+
* The top-level `name` and `file` apply the plugin's `create` prefix. Composite
|
|
10
|
+
* operation naming is grouped into the `param` and `response` namespaces.
|
|
54
11
|
*/
|
|
55
|
-
type ResolverFaker = Resolver &
|
|
56
|
-
/**
|
|
57
|
-
* Resolves the faker function name for a schema.
|
|
58
|
-
*
|
|
59
|
-
* @example Resolving faker function names
|
|
60
|
-
* `resolver.resolveName('show pet by id') // -> 'showPetById'`
|
|
61
|
-
*/
|
|
62
|
-
resolveName(this: ResolverFaker, name: string, type?: 'file' | 'function' | 'type' | 'const'): string;
|
|
63
|
-
/**
|
|
64
|
-
* Resolves the output file name for a faker module.
|
|
65
|
-
*
|
|
66
|
-
* @example Resolving faker file names
|
|
67
|
-
* `resolver.resolvePathName('show pet by id', 'file') // -> 'showPetById'`
|
|
68
|
-
*/
|
|
69
|
-
resolvePathName(this: ResolverFaker, name: string, type?: 'file' | 'function' | 'type' | 'const'): string;
|
|
70
|
-
/**
|
|
71
|
-
* Resolves the faker function name for a request body.
|
|
72
|
-
*
|
|
73
|
-
* @example Resolving data function names
|
|
74
|
-
* `resolver.resolveDataName(node) // -> 'createPetsData'`
|
|
75
|
-
*/
|
|
76
|
-
resolveDataName(this: ResolverFaker, node: ast.OperationNode): string;
|
|
77
|
-
/**
|
|
78
|
-
* Resolves the faker function name for a response by status code.
|
|
79
|
-
*
|
|
80
|
-
* @example Response status names
|
|
81
|
-
* `resolver.resolveResponseStatusName(node, 200) // -> 'listPetsStatus200'`
|
|
82
|
-
*/
|
|
83
|
-
resolveResponseStatusName(this: ResolverFaker, node: ast.OperationNode, statusCode: ast.StatusCode): string;
|
|
12
|
+
type ResolverFaker = Resolver & {
|
|
84
13
|
/**
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
* @example Response union names
|
|
88
|
-
* `resolver.resolveResponseName(node) // -> 'listPetsResponse'`
|
|
14
|
+
* Naming for operation parameters, keyed by their location.
|
|
89
15
|
*/
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
16
|
+
param: {
|
|
17
|
+
/**
|
|
18
|
+
* Resolves the faker function name for an individual parameter.
|
|
19
|
+
*
|
|
20
|
+
* @example Individual parameter name
|
|
21
|
+
* `resolver.param.name(node, param) // -> 'showPetByIdPathPetId'`
|
|
22
|
+
*/
|
|
23
|
+
name(node: ast.OperationNode, param: ast.ParameterNode): string;
|
|
24
|
+
/**
|
|
25
|
+
* Resolves the faker function name for an operation's grouped path parameters.
|
|
26
|
+
*
|
|
27
|
+
* @example Grouped path parameters name
|
|
28
|
+
* `resolver.param.path(node, param) // -> 'createShowPetByIdPath'`
|
|
29
|
+
*/
|
|
30
|
+
path(node: ast.OperationNode, param: ast.ParameterNode): string;
|
|
31
|
+
/**
|
|
32
|
+
* Resolves the faker function name for an operation's grouped query parameters.
|
|
33
|
+
*
|
|
34
|
+
* @example Grouped query parameters name
|
|
35
|
+
* `resolver.param.query(node, param) // -> 'createListPetsQuery'`
|
|
36
|
+
*/
|
|
37
|
+
query(node: ast.OperationNode, param: ast.ParameterNode): string;
|
|
38
|
+
/**
|
|
39
|
+
* Resolves the faker function name for an operation's grouped header parameters.
|
|
40
|
+
*
|
|
41
|
+
* @example Grouped header parameters name
|
|
42
|
+
* `resolver.param.headers(node, param) // -> 'createDeletePetHeaders'`
|
|
43
|
+
*/
|
|
44
|
+
headers(node: ast.OperationNode, param: ast.ParameterNode): string;
|
|
45
|
+
};
|
|
112
46
|
/**
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
* @example Header parameters names
|
|
116
|
-
* `resolver.resolveHeaderParamsName(node, param) // -> 'deletePetHeaderApiKey'`
|
|
47
|
+
* Naming for operation request bodies and responses.
|
|
117
48
|
*/
|
|
118
|
-
|
|
49
|
+
response: {
|
|
50
|
+
/**
|
|
51
|
+
* Resolves the faker function name for a response by status code.
|
|
52
|
+
*
|
|
53
|
+
* @example Response status name
|
|
54
|
+
* `resolver.response.status(node, 200) // -> 'listPetsStatus200'`
|
|
55
|
+
*/
|
|
56
|
+
status(node: ast.OperationNode, statusCode: ast.StatusCode): string;
|
|
57
|
+
/**
|
|
58
|
+
* Resolves the faker function name for a request body.
|
|
59
|
+
*
|
|
60
|
+
* @example Request body name
|
|
61
|
+
* `resolver.response.body(node) // -> 'createPetsBody'`
|
|
62
|
+
*/
|
|
63
|
+
body(node: ast.OperationNode): string;
|
|
64
|
+
/**
|
|
65
|
+
* Resolves the faker function name for the response union.
|
|
66
|
+
*
|
|
67
|
+
* @example Response union name
|
|
68
|
+
* `resolver.response.response(node) // -> 'listPetsResponse'`
|
|
69
|
+
*/
|
|
70
|
+
response(node: ast.OperationNode): string;
|
|
71
|
+
/**
|
|
72
|
+
* Resolves the faker function name for the response collection.
|
|
73
|
+
*
|
|
74
|
+
* @example Responses collection name
|
|
75
|
+
* `resolver.response.responses(node) // -> 'listPetsResponses'`
|
|
76
|
+
*/
|
|
77
|
+
responses(node: ast.OperationNode): string;
|
|
78
|
+
};
|
|
119
79
|
};
|
|
120
80
|
/**
|
|
121
81
|
* Where the generated mock factories are written and how they are exported, plus the optional
|
|
@@ -172,7 +132,7 @@ type Options = OutputOptions & {
|
|
|
172
132
|
* Override the naming of generated factory helpers. Common use: append `Mock` or
|
|
173
133
|
* `Factory` so helpers do not clash with imported types.
|
|
174
134
|
*/
|
|
175
|
-
resolver?:
|
|
135
|
+
resolver?: ResolverPatch<ResolverFaker>;
|
|
176
136
|
/**
|
|
177
137
|
* Macros applied to schema and operation nodes before printing.
|
|
178
138
|
*/
|
|
@@ -297,7 +257,7 @@ declare function Faker({
|
|
|
297
257
|
* factory returns a value matching the corresponding TypeScript type from
|
|
298
258
|
* `@kubb/plugin-ts`.
|
|
299
259
|
*/
|
|
300
|
-
declare const fakerGenerator: import("
|
|
260
|
+
declare const fakerGenerator: import("kubb/kit").Generator<PluginFaker, unknown>;
|
|
301
261
|
//#endregion
|
|
302
262
|
//#region src/plugin.d.ts
|
|
303
263
|
/**
|
|
@@ -312,7 +272,7 @@ declare const pluginFakerName = "plugin-faker";
|
|
|
312
272
|
*
|
|
313
273
|
* @example
|
|
314
274
|
* ```ts
|
|
315
|
-
* import { defineConfig } from 'kubb'
|
|
275
|
+
* import { defineConfig } from 'kubb/config'
|
|
316
276
|
* import { pluginTs } from '@kubb/plugin-ts'
|
|
317
277
|
* import { pluginFaker } from '@kubb/plugin-faker'
|
|
318
278
|
*
|
|
@@ -329,7 +289,7 @@ declare const pluginFakerName = "plugin-faker";
|
|
|
329
289
|
* })
|
|
330
290
|
* ```
|
|
331
291
|
*/
|
|
332
|
-
declare const pluginFaker: (options?: Options | undefined) => import("
|
|
292
|
+
declare const pluginFaker: (options?: Options | undefined) => import("kubb/kit").Plugin<PluginFaker>;
|
|
333
293
|
//#endregion
|
|
334
294
|
//#region src/resolvers/resolverFaker.d.ts
|
|
335
295
|
/**
|
|
@@ -341,7 +301,7 @@ declare const pluginFaker: (options?: Options | undefined) => import("@kubb/core
|
|
|
341
301
|
* ```ts
|
|
342
302
|
* import { resolverFaker } from '@kubb/plugin-faker'
|
|
343
303
|
*
|
|
344
|
-
* resolverFaker.
|
|
304
|
+
* resolverFaker.name('list pets') // 'createListPets'
|
|
345
305
|
* ```
|
|
346
306
|
*/
|
|
347
307
|
declare const resolverFaker: ResolverFaker;
|