@kubb/plugin-oas 4.5.1 → 4.5.3

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 (56) hide show
  1. package/dist/{SchemaGenerator-BwYbrh7a.js → SchemaGenerator-BAE9VJgN.js} +6 -6
  2. package/dist/SchemaGenerator-BAE9VJgN.js.map +1 -0
  3. package/dist/{SchemaGenerator-C81yEgKY.cjs → SchemaGenerator-JB63cfsY.cjs} +7 -7
  4. package/dist/SchemaGenerator-JB63cfsY.cjs.map +1 -0
  5. package/dist/SchemaMapper-BUV8vhg0.cjs.map +1 -1
  6. package/dist/{createGenerator-BvCDyuKS.d.ts → SchemaMapper-BtvCVaPJ.d.ts} +327 -345
  7. package/dist/SchemaMapper-D30tqRoX.js.map +1 -1
  8. package/dist/{createGenerator-CPNglV1d.d.cts → SchemaMapper-DhH_z_t3.d.cts} +327 -345
  9. package/dist/createGenerator-CZv5P-nq.d.ts +319 -0
  10. package/dist/createGenerator-Dd3Q2BgZ.d.cts +319 -0
  11. package/dist/{generators-udGOxdUV.cjs → generators-DTxTiYOL.cjs} +1 -1
  12. package/dist/{generators-udGOxdUV.cjs.map → generators-DTxTiYOL.cjs.map} +1 -1
  13. package/dist/{generators-CJDEf8Kn.js → generators-v153n8vw.js} +1 -1
  14. package/dist/{generators-CJDEf8Kn.js.map → generators-v153n8vw.js.map} +1 -1
  15. package/dist/generators.cjs +1 -1
  16. package/dist/generators.d.cts +2 -2
  17. package/dist/generators.d.ts +2 -2
  18. package/dist/generators.js +1 -1
  19. package/dist/hooks.cjs +1 -1
  20. package/dist/hooks.cjs.map +1 -1
  21. package/dist/hooks.d.cts +3 -3
  22. package/dist/hooks.d.ts +3 -3
  23. package/dist/hooks.js +1 -1
  24. package/dist/hooks.js.map +1 -1
  25. package/dist/index.cjs +34 -25
  26. package/dist/index.cjs.map +1 -1
  27. package/dist/index.d.cts +17 -3
  28. package/dist/index.d.ts +17 -3
  29. package/dist/index.js +33 -27
  30. package/dist/index.js.map +1 -1
  31. package/dist/mocks.d.cts +1 -1
  32. package/dist/mocks.d.ts +1 -1
  33. package/dist/utils.cjs +2 -4
  34. package/dist/utils.cjs.map +1 -1
  35. package/dist/utils.d.cts +5 -14
  36. package/dist/utils.d.ts +5 -14
  37. package/dist/utils.js +2 -3
  38. package/dist/utils.js.map +1 -1
  39. package/package.json +5 -5
  40. package/src/SchemaGenerator.ts +1 -1
  41. package/src/SchemaMapper.ts +1 -1
  42. package/src/hooks/useOperationManager.ts +4 -2
  43. package/src/index.ts +20 -0
  44. package/src/plugin.ts +19 -19
  45. package/src/types.ts +13 -7
  46. package/src/utils/index.ts +0 -1
  47. package/src/utils.tsx +3 -3
  48. package/dist/SchemaGenerator-BwYbrh7a.js.map +0 -1
  49. package/dist/SchemaGenerator-C81yEgKY.cjs.map +0 -1
  50. package/dist/SchemaMapper-CgGWx6jF.d.cts +0 -297
  51. package/dist/SchemaMapper-Cj3vjPGs.d.ts +0 -297
  52. package/dist/parseFromConfig-BkUoWC2U.js +0 -22
  53. package/dist/parseFromConfig-BkUoWC2U.js.map +0 -1
  54. package/dist/parseFromConfig-EjsCZ0-8.cjs +0 -32
  55. package/dist/parseFromConfig-EjsCZ0-8.cjs.map +0 -1
  56. package/src/utils/parseFromConfig.ts +0 -39
@@ -0,0 +1,319 @@
1
+ import { C as Plugin, D as BaseGenerator, S as Output, T as ResolveNameParams, _ as contentType, b as Config, d as HttpMethod, g as SchemaObject, h as Operation, i as SchemaKeywordMapper, t as Schema, u as Oas, v as FileMetaBase, w as PluginFactoryOptions, x as Group, y as PluginManager } from "./SchemaMapper-BtvCVaPJ.js";
2
+ import { Fabric } from "@kubb/react-fabric";
3
+ import { KubbFile } from "@kubb/fabric-core/types";
4
+ import { KubbNode } from "@kubb/react-fabric/types";
5
+
6
+ //#region src/types.d.ts
7
+ type Context$2 = {
8
+ getOas(): Promise<Oas>;
9
+ getBaseURL(): Promise<string | undefined>;
10
+ };
11
+ declare global {
12
+ namespace Kubb {
13
+ interface PluginContext extends Context$2 {}
14
+ }
15
+ }
16
+ type ResolvePathOptions = {
17
+ pluginKey?: Plugin['key'];
18
+ group?: {
19
+ tag?: string;
20
+ path?: string;
21
+ };
22
+ type?: ResolveNameParams['type'];
23
+ };
24
+ type Options$1 = {
25
+ /**
26
+ * Validate your input(see kubb.config) based on '@readme/openapi-parser'.
27
+ * @default true
28
+ */
29
+ validate?: boolean;
30
+ /**
31
+ * Specify the export location for the files and define the behavior of the output
32
+ * @default { path: 'schemas', barrelType: 'named' }
33
+ */
34
+ output?: Output<Oas>;
35
+ /**
36
+ * Group the JSON files based on the provided name.
37
+ */
38
+ group?: Group;
39
+ /**
40
+ * Which server to use from the array of `servers.url[serverIndex]`
41
+ * @example
42
+ * - `0` will return `http://petstore.swagger.io/api`
43
+ * - `1` will return `http://localhost:3000`
44
+ */
45
+ serverIndex?: number;
46
+ /**
47
+ * Define which contentType should be used.
48
+ * By default, the first JSON valid mediaType will be used
49
+ */
50
+ contentType?: contentType;
51
+ /**
52
+ * Defines how the discriminator value should be interpreted during processing.
53
+ *
54
+ * @default 'strict'
55
+ *
56
+ * @example
57
+ * - `inherit`: Replaces the `oneOf` schema with the schema referenced by `discriminator.mapping[key]`.
58
+ * - `strict`: Uses the `oneOf` schemas as defined, without modification.
59
+ *
60
+ * @see https://github.com/kubb-labs/kubb/issues/1736
61
+ */
62
+ discriminator?: 'strict' | 'inherit';
63
+ /**
64
+ * Override some behaviour of the Oas class instance, see '@kubb/oas'
65
+ */
66
+ oasClass?: typeof Oas;
67
+ /**
68
+ * Define some generators next to the JSON generation
69
+ */
70
+ generators?: Array<Generator<PluginOas>>;
71
+ };
72
+ /**
73
+ * `propertyName` is the ref name + resolved with the nameResolver
74
+ * @example import { Pet } from './Pet'
75
+ *
76
+ * `originalName` is the original name used(in PascalCase), only used to remove duplicates
77
+ *
78
+ * `pluginKey` can be used to override the current plugin being used, handy when you want to import a type/schema out of another plugin
79
+ * @example import a type(plugin-ts) for a mock file(swagger-faker)
80
+ */
81
+ type Ref = {
82
+ propertyName: string;
83
+ originalName: string;
84
+ path: KubbFile.Path;
85
+ pluginKey?: Plugin['key'];
86
+ };
87
+ type Refs = Record<string, Ref>;
88
+ type Resolver = {
89
+ /**
90
+ * Original name or name resolved by `resolveName({ name: operation?.getOperationId() as string, pluginName })`
91
+ */
92
+ name: string;
93
+ baseName: KubbFile.BaseName;
94
+ path: KubbFile.Path;
95
+ };
96
+ type OperationSchema = {
97
+ /**
98
+ * Converted name, contains already `PathParams`, `QueryParams`, ...
99
+ */
100
+ name: string;
101
+ schema: SchemaObject;
102
+ operation?: Operation;
103
+ /**
104
+ * OperationName in PascalCase, only being used in OperationGenerator
105
+ */
106
+ operationName: string;
107
+ description?: string;
108
+ statusCode?: number;
109
+ keys?: string[];
110
+ keysToOmit?: string[];
111
+ withData?: boolean;
112
+ };
113
+ type OperationSchemas = {
114
+ pathParams?: OperationSchema & {
115
+ keysToOmit?: never;
116
+ };
117
+ queryParams?: OperationSchema & {
118
+ keysToOmit?: never;
119
+ };
120
+ headerParams?: OperationSchema & {
121
+ keysToOmit?: never;
122
+ };
123
+ request?: OperationSchema;
124
+ response: OperationSchema;
125
+ responses: Array<OperationSchema>;
126
+ statusCodes?: Array<OperationSchema>;
127
+ errors?: Array<OperationSchema>;
128
+ };
129
+ type ByTag = {
130
+ type: 'tag';
131
+ pattern: string | RegExp;
132
+ };
133
+ type ByOperationId = {
134
+ type: 'operationId';
135
+ pattern: string | RegExp;
136
+ };
137
+ type ByPath = {
138
+ type: 'path';
139
+ pattern: string | RegExp;
140
+ };
141
+ type ByMethod = {
142
+ type: 'method';
143
+ pattern: HttpMethod | RegExp;
144
+ };
145
+ type BySchemaName = {
146
+ type: 'schemaName';
147
+ pattern: string | RegExp;
148
+ };
149
+ type ByContentType = {
150
+ type: 'contentType';
151
+ pattern: string | RegExp;
152
+ };
153
+ type Exclude = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
154
+ type Include = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
155
+ type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName | ByContentType) & {
156
+ options: Partial<TOptions>;
157
+ };
158
+ type ResolvedOptions = Options$1 & {
159
+ output: Output<Oas>;
160
+ };
161
+ type PluginOas = PluginFactoryOptions<'plugin-oas', Options$1, ResolvedOptions, Context$2, ResolvePathOptions>;
162
+ //#endregion
163
+ //#region src/OperationGenerator.d.ts
164
+ type OperationMethodResult<TFileMeta extends FileMetaBase> = Promise<KubbFile.File<TFileMeta> | Array<KubbFile.File<TFileMeta>> | null>;
165
+ type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
166
+ fabric: Fabric;
167
+ oas: Oas;
168
+ exclude: Array<Exclude> | undefined;
169
+ include: Array<Include> | undefined;
170
+ override: Array<Override<TOptions>> | undefined;
171
+ contentType: contentType | undefined;
172
+ pluginManager: PluginManager;
173
+ /**
174
+ * Current plugin
175
+ */
176
+ plugin: Plugin<TPluginOptions>;
177
+ mode: KubbFile.Mode;
178
+ };
179
+ declare class OperationGenerator<TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TPluginOptions['resolvedOptions'], Context$1<TPluginOptions['resolvedOptions'], TPluginOptions>> {
180
+ #private;
181
+ getSchemas(operation: Operation, {
182
+ resolveName
183
+ }?: {
184
+ resolveName?: (name: string) => string;
185
+ }): OperationSchemas;
186
+ getOperations(): Promise<Array<{
187
+ path: string;
188
+ method: HttpMethod;
189
+ operation: Operation;
190
+ }>>;
191
+ build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
192
+ }
193
+ //#endregion
194
+ //#region src/SchemaGenerator.d.ts
195
+ type GetSchemaGeneratorOptions<T extends SchemaGenerator<any, any, any>> = T extends SchemaGenerator<infer Options, any, any> ? Options : never;
196
+ type SchemaMethodResult<TFileMeta extends FileMetaBase> = Promise<KubbFile.File<TFileMeta> | Array<KubbFile.File<TFileMeta>> | null>;
197
+ type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
198
+ fabric: Fabric;
199
+ oas: Oas;
200
+ pluginManager: PluginManager;
201
+ /**
202
+ * Current plugin
203
+ */
204
+ plugin: Plugin<TPluginOptions>;
205
+ mode: KubbFile.Mode;
206
+ include?: Array<'schemas' | 'responses' | 'requestBodies'>;
207
+ override: Array<Override<TOptions>> | undefined;
208
+ contentType?: contentType;
209
+ output?: string;
210
+ };
211
+ type SchemaGeneratorOptions = {
212
+ dateType: false | 'string' | 'stringOffset' | 'stringLocal' | 'date';
213
+ unknownType: 'any' | 'unknown' | 'void';
214
+ emptySchemaType: 'any' | 'unknown' | 'void';
215
+ enumType?: 'enum' | 'asConst' | 'asPascalConst' | 'constEnum' | 'literal';
216
+ enumSuffix?: string;
217
+ usedEnumNames?: Record<string, number>;
218
+ mapper?: Record<string, string>;
219
+ typed?: boolean;
220
+ transformers: {
221
+ /**
222
+ * Customize the names based on the type that is provided by the plugin.
223
+ */
224
+ name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
225
+ /**
226
+ * Receive schema and name(propertName) and return FakerMeta array
227
+ * TODO TODO add docs
228
+ * @beta
229
+ */
230
+ schema?: (schemaProps: SchemaProps$1, defaultSchemas: Schema[]) => Schema[] | undefined;
231
+ };
232
+ };
233
+ type SchemaGeneratorBuildOptions = Omit<OperationSchema, 'name' | 'schema'>;
234
+ type SchemaProps$1 = {
235
+ schemaObject?: SchemaObject;
236
+ name?: string;
237
+ parentName?: string;
238
+ };
239
+ declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions, Context<TOptions, TPluginOptions>> {
240
+ #private;
241
+ refs: Refs;
242
+ /**
243
+ * Creates a type node from a given schema.
244
+ * Delegates to getBaseTypeFromSchema internally and
245
+ * optionally adds a union with null.
246
+ */
247
+ parse(props: SchemaProps$1): Schema[];
248
+ static deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
249
+ static find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
250
+ static combineObjects(tree: Schema[] | undefined): Schema[];
251
+ build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
252
+ }
253
+ //#endregion
254
+ //#region src/generators/createReactGenerator.d.ts
255
+ type UserGenerator$1<TOptions extends PluginFactoryOptions> = {
256
+ name: string;
257
+ Operations?: (props: OperationsProps<TOptions>) => KubbNode;
258
+ Operation?: (props: OperationProps<TOptions>) => KubbNode;
259
+ Schema?: (props: SchemaProps<TOptions>) => KubbNode;
260
+ };
261
+ type ReactGenerator<TOptions extends PluginFactoryOptions> = {
262
+ name: string;
263
+ type: 'react';
264
+ Operations: (props: OperationsProps<TOptions>) => KubbNode;
265
+ Operation: (props: OperationProps<TOptions>) => KubbNode;
266
+ Schema: (props: SchemaProps<TOptions>) => KubbNode;
267
+ };
268
+ /****
269
+ * Creates a generator that uses React component functions to generate files for OpenAPI operations and schemas.
270
+ *
271
+ * The returned generator exposes async methods for generating files from operations, a single operation, or a schema, using the corresponding React components if provided. If a component is not defined, the method returns an empty array.
272
+ *
273
+ * @returns A generator object with async methods for operations, operation, and schema file generation.
274
+ */
275
+ declare function createReactGenerator<TOptions extends PluginFactoryOptions>(generator: UserGenerator$1<TOptions>): ReactGenerator<TOptions>;
276
+ //#endregion
277
+ //#region src/generators/types.d.ts
278
+ type OperationsProps<TOptions extends PluginFactoryOptions> = {
279
+ config: Config;
280
+ generator: Omit<OperationGenerator<TOptions>, 'build'>;
281
+ plugin: Plugin<TOptions>;
282
+ operations: Array<Operation>;
283
+ };
284
+ type OperationProps<TOptions extends PluginFactoryOptions> = {
285
+ config: Config;
286
+ generator: Omit<OperationGenerator<TOptions>, 'build'>;
287
+ plugin: Plugin<TOptions>;
288
+ operation: Operation;
289
+ };
290
+ type SchemaProps<TOptions extends PluginFactoryOptions> = {
291
+ config: Config;
292
+ generator: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>;
293
+ plugin: Plugin<TOptions>;
294
+ schema: {
295
+ name: string;
296
+ tree: Array<Schema>;
297
+ value: SchemaObject;
298
+ };
299
+ };
300
+ type Generator<TOptions extends PluginFactoryOptions> = CoreGenerator<TOptions> | ReactGenerator<TOptions>;
301
+ //#endregion
302
+ //#region src/generators/createGenerator.d.ts
303
+ type UserGenerator<TOptions extends PluginFactoryOptions> = {
304
+ name: string;
305
+ operations?: (props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>;
306
+ operation?: (props: OperationProps<TOptions>) => Promise<KubbFile.File[]>;
307
+ schema?: (props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>;
308
+ };
309
+ type CoreGenerator<TOptions extends PluginFactoryOptions> = {
310
+ name: string;
311
+ type: 'core';
312
+ operations: (props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>;
313
+ operation: (props: OperationProps<TOptions>) => Promise<KubbFile.File[]>;
314
+ schema: (props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>;
315
+ };
316
+ declare function createGenerator<TOptions extends PluginFactoryOptions>(generator: UserGenerator<TOptions>): CoreGenerator<TOptions>;
317
+ //#endregion
318
+ export { Resolver as C, ResolvePathOptions as S, Options$1 as _, createReactGenerator as a, Ref as b, SchemaGeneratorBuildOptions as c, OperationGenerator as d, OperationMethodResult as f, OperationSchemas as g, OperationSchema as h, ReactGenerator as i, SchemaGeneratorOptions as l, Include as m, createGenerator as n, GetSchemaGeneratorOptions as o, Exclude as p, Generator as r, SchemaGenerator as s, CoreGenerator as t, SchemaMethodResult as u, Override as v, Refs as x, PluginOas as y };
319
+ //# sourceMappingURL=createGenerator-CZv5P-nq.d.ts.map
@@ -0,0 +1,319 @@
1
+ import { C as Plugin, D as BaseGenerator, S as Output, T as ResolveNameParams, _ as contentType, b as Config, d as HttpMethod, g as SchemaObject, h as Operation, i as SchemaKeywordMapper, t as Schema, u as Oas, v as FileMetaBase, w as PluginFactoryOptions, x as Group, y as PluginManager } from "./SchemaMapper-DhH_z_t3.cjs";
2
+ import { KubbFile } from "@kubb/fabric-core/types";
3
+ import { Fabric } from "@kubb/react-fabric";
4
+ import { KubbNode } from "@kubb/react-fabric/types";
5
+
6
+ //#region src/types.d.ts
7
+ type Context$2 = {
8
+ getOas(): Promise<Oas>;
9
+ getBaseURL(): Promise<string | undefined>;
10
+ };
11
+ declare global {
12
+ namespace Kubb {
13
+ interface PluginContext extends Context$2 {}
14
+ }
15
+ }
16
+ type ResolvePathOptions = {
17
+ pluginKey?: Plugin['key'];
18
+ group?: {
19
+ tag?: string;
20
+ path?: string;
21
+ };
22
+ type?: ResolveNameParams['type'];
23
+ };
24
+ type Options$1 = {
25
+ /**
26
+ * Validate your input(see kubb.config) based on '@readme/openapi-parser'.
27
+ * @default true
28
+ */
29
+ validate?: boolean;
30
+ /**
31
+ * Specify the export location for the files and define the behavior of the output
32
+ * @default { path: 'schemas', barrelType: 'named' }
33
+ */
34
+ output?: Output<Oas>;
35
+ /**
36
+ * Group the JSON files based on the provided name.
37
+ */
38
+ group?: Group;
39
+ /**
40
+ * Which server to use from the array of `servers.url[serverIndex]`
41
+ * @example
42
+ * - `0` will return `http://petstore.swagger.io/api`
43
+ * - `1` will return `http://localhost:3000`
44
+ */
45
+ serverIndex?: number;
46
+ /**
47
+ * Define which contentType should be used.
48
+ * By default, the first JSON valid mediaType will be used
49
+ */
50
+ contentType?: contentType;
51
+ /**
52
+ * Defines how the discriminator value should be interpreted during processing.
53
+ *
54
+ * @default 'strict'
55
+ *
56
+ * @example
57
+ * - `inherit`: Replaces the `oneOf` schema with the schema referenced by `discriminator.mapping[key]`.
58
+ * - `strict`: Uses the `oneOf` schemas as defined, without modification.
59
+ *
60
+ * @see https://github.com/kubb-labs/kubb/issues/1736
61
+ */
62
+ discriminator?: 'strict' | 'inherit';
63
+ /**
64
+ * Override some behaviour of the Oas class instance, see '@kubb/oas'
65
+ */
66
+ oasClass?: typeof Oas;
67
+ /**
68
+ * Define some generators next to the JSON generation
69
+ */
70
+ generators?: Array<Generator<PluginOas>>;
71
+ };
72
+ /**
73
+ * `propertyName` is the ref name + resolved with the nameResolver
74
+ * @example import { Pet } from './Pet'
75
+ *
76
+ * `originalName` is the original name used(in PascalCase), only used to remove duplicates
77
+ *
78
+ * `pluginKey` can be used to override the current plugin being used, handy when you want to import a type/schema out of another plugin
79
+ * @example import a type(plugin-ts) for a mock file(swagger-faker)
80
+ */
81
+ type Ref = {
82
+ propertyName: string;
83
+ originalName: string;
84
+ path: KubbFile.Path;
85
+ pluginKey?: Plugin['key'];
86
+ };
87
+ type Refs = Record<string, Ref>;
88
+ type Resolver = {
89
+ /**
90
+ * Original name or name resolved by `resolveName({ name: operation?.getOperationId() as string, pluginName })`
91
+ */
92
+ name: string;
93
+ baseName: KubbFile.BaseName;
94
+ path: KubbFile.Path;
95
+ };
96
+ type OperationSchema = {
97
+ /**
98
+ * Converted name, contains already `PathParams`, `QueryParams`, ...
99
+ */
100
+ name: string;
101
+ schema: SchemaObject;
102
+ operation?: Operation;
103
+ /**
104
+ * OperationName in PascalCase, only being used in OperationGenerator
105
+ */
106
+ operationName: string;
107
+ description?: string;
108
+ statusCode?: number;
109
+ keys?: string[];
110
+ keysToOmit?: string[];
111
+ withData?: boolean;
112
+ };
113
+ type OperationSchemas = {
114
+ pathParams?: OperationSchema & {
115
+ keysToOmit?: never;
116
+ };
117
+ queryParams?: OperationSchema & {
118
+ keysToOmit?: never;
119
+ };
120
+ headerParams?: OperationSchema & {
121
+ keysToOmit?: never;
122
+ };
123
+ request?: OperationSchema;
124
+ response: OperationSchema;
125
+ responses: Array<OperationSchema>;
126
+ statusCodes?: Array<OperationSchema>;
127
+ errors?: Array<OperationSchema>;
128
+ };
129
+ type ByTag = {
130
+ type: 'tag';
131
+ pattern: string | RegExp;
132
+ };
133
+ type ByOperationId = {
134
+ type: 'operationId';
135
+ pattern: string | RegExp;
136
+ };
137
+ type ByPath = {
138
+ type: 'path';
139
+ pattern: string | RegExp;
140
+ };
141
+ type ByMethod = {
142
+ type: 'method';
143
+ pattern: HttpMethod | RegExp;
144
+ };
145
+ type BySchemaName = {
146
+ type: 'schemaName';
147
+ pattern: string | RegExp;
148
+ };
149
+ type ByContentType = {
150
+ type: 'contentType';
151
+ pattern: string | RegExp;
152
+ };
153
+ type Exclude = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
154
+ type Include = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
155
+ type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName | ByContentType) & {
156
+ options: Partial<TOptions>;
157
+ };
158
+ type ResolvedOptions = Options$1 & {
159
+ output: Output<Oas>;
160
+ };
161
+ type PluginOas = PluginFactoryOptions<'plugin-oas', Options$1, ResolvedOptions, Context$2, ResolvePathOptions>;
162
+ //#endregion
163
+ //#region src/OperationGenerator.d.ts
164
+ type OperationMethodResult<TFileMeta extends FileMetaBase> = Promise<KubbFile.File<TFileMeta> | Array<KubbFile.File<TFileMeta>> | null>;
165
+ type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
166
+ fabric: Fabric;
167
+ oas: Oas;
168
+ exclude: Array<Exclude> | undefined;
169
+ include: Array<Include> | undefined;
170
+ override: Array<Override<TOptions>> | undefined;
171
+ contentType: contentType | undefined;
172
+ pluginManager: PluginManager;
173
+ /**
174
+ * Current plugin
175
+ */
176
+ plugin: Plugin<TPluginOptions>;
177
+ mode: KubbFile.Mode;
178
+ };
179
+ declare class OperationGenerator<TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TPluginOptions['resolvedOptions'], Context$1<TPluginOptions['resolvedOptions'], TPluginOptions>> {
180
+ #private;
181
+ getSchemas(operation: Operation, {
182
+ resolveName
183
+ }?: {
184
+ resolveName?: (name: string) => string;
185
+ }): OperationSchemas;
186
+ getOperations(): Promise<Array<{
187
+ path: string;
188
+ method: HttpMethod;
189
+ operation: Operation;
190
+ }>>;
191
+ build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
192
+ }
193
+ //#endregion
194
+ //#region src/SchemaGenerator.d.ts
195
+ type GetSchemaGeneratorOptions<T extends SchemaGenerator<any, any, any>> = T extends SchemaGenerator<infer Options, any, any> ? Options : never;
196
+ type SchemaMethodResult<TFileMeta extends FileMetaBase> = Promise<KubbFile.File<TFileMeta> | Array<KubbFile.File<TFileMeta>> | null>;
197
+ type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
198
+ fabric: Fabric;
199
+ oas: Oas;
200
+ pluginManager: PluginManager;
201
+ /**
202
+ * Current plugin
203
+ */
204
+ plugin: Plugin<TPluginOptions>;
205
+ mode: KubbFile.Mode;
206
+ include?: Array<'schemas' | 'responses' | 'requestBodies'>;
207
+ override: Array<Override<TOptions>> | undefined;
208
+ contentType?: contentType;
209
+ output?: string;
210
+ };
211
+ type SchemaGeneratorOptions = {
212
+ dateType: false | 'string' | 'stringOffset' | 'stringLocal' | 'date';
213
+ unknownType: 'any' | 'unknown' | 'void';
214
+ emptySchemaType: 'any' | 'unknown' | 'void';
215
+ enumType?: 'enum' | 'asConst' | 'asPascalConst' | 'constEnum' | 'literal';
216
+ enumSuffix?: string;
217
+ usedEnumNames?: Record<string, number>;
218
+ mapper?: Record<string, string>;
219
+ typed?: boolean;
220
+ transformers: {
221
+ /**
222
+ * Customize the names based on the type that is provided by the plugin.
223
+ */
224
+ name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
225
+ /**
226
+ * Receive schema and name(propertName) and return FakerMeta array
227
+ * TODO TODO add docs
228
+ * @beta
229
+ */
230
+ schema?: (schemaProps: SchemaProps$1, defaultSchemas: Schema[]) => Schema[] | undefined;
231
+ };
232
+ };
233
+ type SchemaGeneratorBuildOptions = Omit<OperationSchema, 'name' | 'schema'>;
234
+ type SchemaProps$1 = {
235
+ schemaObject?: SchemaObject;
236
+ name?: string;
237
+ parentName?: string;
238
+ };
239
+ declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions, Context<TOptions, TPluginOptions>> {
240
+ #private;
241
+ refs: Refs;
242
+ /**
243
+ * Creates a type node from a given schema.
244
+ * Delegates to getBaseTypeFromSchema internally and
245
+ * optionally adds a union with null.
246
+ */
247
+ parse(props: SchemaProps$1): Schema[];
248
+ static deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
249
+ static find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
250
+ static combineObjects(tree: Schema[] | undefined): Schema[];
251
+ build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
252
+ }
253
+ //#endregion
254
+ //#region src/generators/createReactGenerator.d.ts
255
+ type UserGenerator$1<TOptions extends PluginFactoryOptions> = {
256
+ name: string;
257
+ Operations?: (props: OperationsProps<TOptions>) => KubbNode;
258
+ Operation?: (props: OperationProps<TOptions>) => KubbNode;
259
+ Schema?: (props: SchemaProps<TOptions>) => KubbNode;
260
+ };
261
+ type ReactGenerator<TOptions extends PluginFactoryOptions> = {
262
+ name: string;
263
+ type: 'react';
264
+ Operations: (props: OperationsProps<TOptions>) => KubbNode;
265
+ Operation: (props: OperationProps<TOptions>) => KubbNode;
266
+ Schema: (props: SchemaProps<TOptions>) => KubbNode;
267
+ };
268
+ /****
269
+ * Creates a generator that uses React component functions to generate files for OpenAPI operations and schemas.
270
+ *
271
+ * The returned generator exposes async methods for generating files from operations, a single operation, or a schema, using the corresponding React components if provided. If a component is not defined, the method returns an empty array.
272
+ *
273
+ * @returns A generator object with async methods for operations, operation, and schema file generation.
274
+ */
275
+ declare function createReactGenerator<TOptions extends PluginFactoryOptions>(generator: UserGenerator$1<TOptions>): ReactGenerator<TOptions>;
276
+ //#endregion
277
+ //#region src/generators/types.d.ts
278
+ type OperationsProps<TOptions extends PluginFactoryOptions> = {
279
+ config: Config;
280
+ generator: Omit<OperationGenerator<TOptions>, 'build'>;
281
+ plugin: Plugin<TOptions>;
282
+ operations: Array<Operation>;
283
+ };
284
+ type OperationProps<TOptions extends PluginFactoryOptions> = {
285
+ config: Config;
286
+ generator: Omit<OperationGenerator<TOptions>, 'build'>;
287
+ plugin: Plugin<TOptions>;
288
+ operation: Operation;
289
+ };
290
+ type SchemaProps<TOptions extends PluginFactoryOptions> = {
291
+ config: Config;
292
+ generator: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>;
293
+ plugin: Plugin<TOptions>;
294
+ schema: {
295
+ name: string;
296
+ tree: Array<Schema>;
297
+ value: SchemaObject;
298
+ };
299
+ };
300
+ type Generator<TOptions extends PluginFactoryOptions> = CoreGenerator<TOptions> | ReactGenerator<TOptions>;
301
+ //#endregion
302
+ //#region src/generators/createGenerator.d.ts
303
+ type UserGenerator<TOptions extends PluginFactoryOptions> = {
304
+ name: string;
305
+ operations?: (props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>;
306
+ operation?: (props: OperationProps<TOptions>) => Promise<KubbFile.File[]>;
307
+ schema?: (props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>;
308
+ };
309
+ type CoreGenerator<TOptions extends PluginFactoryOptions> = {
310
+ name: string;
311
+ type: 'core';
312
+ operations: (props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>;
313
+ operation: (props: OperationProps<TOptions>) => Promise<KubbFile.File[]>;
314
+ schema: (props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>;
315
+ };
316
+ declare function createGenerator<TOptions extends PluginFactoryOptions>(generator: UserGenerator<TOptions>): CoreGenerator<TOptions>;
317
+ //#endregion
318
+ export { Resolver as C, ResolvePathOptions as S, Options$1 as _, createReactGenerator as a, Ref as b, SchemaGeneratorBuildOptions as c, OperationGenerator as d, OperationMethodResult as f, OperationSchemas as g, OperationSchema as h, ReactGenerator as i, SchemaGeneratorOptions as l, Include as m, createGenerator as n, GetSchemaGeneratorOptions as o, Exclude as p, Generator as r, SchemaGenerator as s, CoreGenerator as t, SchemaMethodResult as u, Override as v, Refs as x, PluginOas as y };
319
+ //# sourceMappingURL=createGenerator-Dd3Q2BgZ.d.cts.map
@@ -96,4 +96,4 @@ Object.defineProperty(exports, 'jsonGenerator', {
96
96
  return jsonGenerator;
97
97
  }
98
98
  });
99
- //# sourceMappingURL=generators-udGOxdUV.cjs.map
99
+ //# sourceMappingURL=generators-DTxTiYOL.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"generators-udGOxdUV.cjs","names":["getBanner","getFooter"],"sources":["../src/generators/createGenerator.ts","../src/generators/createReactGenerator.ts","../src/generators/jsonGenerator.ts"],"sourcesContent":["import type { PluginFactoryOptions } from '@kubb/core'\nimport type { KubbFile } from '@kubb/fabric-core/types'\nimport type { OperationProps, OperationsProps, SchemaProps } from './types.ts'\n\ntype UserGenerator<TOptions extends PluginFactoryOptions> = {\n name: string\n operations?: (props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>\n operation?: (props: OperationProps<TOptions>) => Promise<KubbFile.File[]>\n schema?: (props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>\n}\n\nexport type CoreGenerator<TOptions extends PluginFactoryOptions> = {\n name: string\n type: 'core'\n operations: (props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>\n operation: (props: OperationProps<TOptions>) => Promise<KubbFile.File[]>\n schema: (props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>\n}\n\nexport function createGenerator<TOptions extends PluginFactoryOptions>(generator: UserGenerator<TOptions>): CoreGenerator<TOptions> {\n return {\n type: 'core',\n async operations() {\n return []\n },\n async operation() {\n return []\n },\n async schema() {\n return []\n },\n ...generator,\n }\n}\n","import type { PluginFactoryOptions } from '@kubb/core'\nimport type { KubbNode } from '@kubb/react-fabric/types'\nimport type { OperationProps, OperationsProps, SchemaProps } from './types.ts'\n\ntype UserGenerator<TOptions extends PluginFactoryOptions> = {\n name: string\n Operations?: (props: OperationsProps<TOptions>) => KubbNode\n Operation?: (props: OperationProps<TOptions>) => KubbNode\n Schema?: (props: SchemaProps<TOptions>) => KubbNode\n}\n\nexport type ReactGenerator<TOptions extends PluginFactoryOptions> = {\n name: string\n type: 'react'\n Operations: (props: OperationsProps<TOptions>) => KubbNode\n Operation: (props: OperationProps<TOptions>) => KubbNode\n Schema: (props: SchemaProps<TOptions>) => KubbNode\n}\n\n/****\n * Creates a generator that uses React component functions to generate files for OpenAPI operations and schemas.\n *\n * The returned generator exposes async methods for generating files from operations, a single operation, or a schema, using the corresponding React components if provided. If a component is not defined, the method returns an empty array.\n *\n * @returns A generator object with async methods for operations, operation, and schema file generation.\n */\nexport function createReactGenerator<TOptions extends PluginFactoryOptions>(generator: UserGenerator<TOptions>): ReactGenerator<TOptions> {\n return {\n type: 'react',\n Operations() {\n return null\n },\n Operation() {\n return null\n },\n Schema() {\n return null\n },\n ...generator,\n }\n}\n","import { camelCase } from '@kubb/core/transformers'\nimport type { PluginOas } from '../types.ts'\nimport { getBanner } from '../utils/getBanner.ts'\nimport { getFooter } from '../utils/getFooter.ts'\nimport { createGenerator } from './createGenerator.ts'\n\nexport const jsonGenerator = createGenerator<PluginOas>({\n name: 'plugin-oas',\n async schema({ schema, generator }) {\n const { pluginManager, plugin } = generator.context\n const file = pluginManager.getFile({\n name: camelCase(schema.name),\n extname: '.json',\n mode: 'split',\n pluginKey: plugin.key,\n })\n\n return [\n {\n ...file,\n sources: [\n {\n name: camelCase(schema.name),\n isExportable: false,\n isIndexable: false,\n value: JSON.stringify(schema.value),\n },\n ],\n banner: getBanner({\n oas: generator.context.oas,\n output: plugin.options.output,\n config: pluginManager.config,\n }),\n format: getFooter({ oas: generator.context.oas, output: plugin.options.output }),\n },\n ]\n },\n})\n"],"mappings":";;;;;;AAmBA,SAAgB,gBAAuD,WAA6D;AAClI,QAAO;EACL,MAAM;EACN,MAAM,aAAa;AACjB,UAAO,EAAE;;EAEX,MAAM,YAAY;AAChB,UAAO,EAAE;;EAEX,MAAM,SAAS;AACb,UAAO,EAAE;;EAEX,GAAG;EACJ;;;;;;;;;;;;ACNH,SAAgB,qBAA4D,WAA8D;AACxI,QAAO;EACL,MAAM;EACN,aAAa;AACX,UAAO;;EAET,YAAY;AACV,UAAO;;EAET,SAAS;AACP,UAAO;;EAET,GAAG;EACJ;;;;;ACjCH,MAAa,gBAAgB,gBAA2B;CACtD,MAAM;CACN,MAAM,OAAO,EAAE,QAAQ,aAAa;EAClC,MAAM,EAAE,eAAe,WAAW,UAAU;AAQ5C,SAAO,CACL;GACE,GATS,cAAc,QAAQ;IACjC,8CAAgB,OAAO,KAAK;IAC5B,SAAS;IACT,MAAM;IACN,WAAW,OAAO;IACnB,CAAC;GAKE,SAAS,CACP;IACE,8CAAgB,OAAO,KAAK;IAC5B,cAAc;IACd,aAAa;IACb,OAAO,KAAK,UAAU,OAAO,MAAM;IACpC,CACF;GACD,QAAQA,4BAAU;IAChB,KAAK,UAAU,QAAQ;IACvB,QAAQ,OAAO,QAAQ;IACvB,QAAQ,cAAc;IACvB,CAAC;GACF,QAAQC,4BAAU;IAAE,KAAK,UAAU,QAAQ;IAAK,QAAQ,OAAO,QAAQ;IAAQ,CAAC;GACjF,CACF;;CAEJ,CAAC"}
1
+ {"version":3,"file":"generators-DTxTiYOL.cjs","names":["getBanner","getFooter"],"sources":["../src/generators/createGenerator.ts","../src/generators/createReactGenerator.ts","../src/generators/jsonGenerator.ts"],"sourcesContent":["import type { PluginFactoryOptions } from '@kubb/core'\nimport type { KubbFile } from '@kubb/fabric-core/types'\nimport type { OperationProps, OperationsProps, SchemaProps } from './types.ts'\n\ntype UserGenerator<TOptions extends PluginFactoryOptions> = {\n name: string\n operations?: (props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>\n operation?: (props: OperationProps<TOptions>) => Promise<KubbFile.File[]>\n schema?: (props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>\n}\n\nexport type CoreGenerator<TOptions extends PluginFactoryOptions> = {\n name: string\n type: 'core'\n operations: (props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>\n operation: (props: OperationProps<TOptions>) => Promise<KubbFile.File[]>\n schema: (props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>\n}\n\nexport function createGenerator<TOptions extends PluginFactoryOptions>(generator: UserGenerator<TOptions>): CoreGenerator<TOptions> {\n return {\n type: 'core',\n async operations() {\n return []\n },\n async operation() {\n return []\n },\n async schema() {\n return []\n },\n ...generator,\n }\n}\n","import type { PluginFactoryOptions } from '@kubb/core'\nimport type { KubbNode } from '@kubb/react-fabric/types'\nimport type { OperationProps, OperationsProps, SchemaProps } from './types.ts'\n\ntype UserGenerator<TOptions extends PluginFactoryOptions> = {\n name: string\n Operations?: (props: OperationsProps<TOptions>) => KubbNode\n Operation?: (props: OperationProps<TOptions>) => KubbNode\n Schema?: (props: SchemaProps<TOptions>) => KubbNode\n}\n\nexport type ReactGenerator<TOptions extends PluginFactoryOptions> = {\n name: string\n type: 'react'\n Operations: (props: OperationsProps<TOptions>) => KubbNode\n Operation: (props: OperationProps<TOptions>) => KubbNode\n Schema: (props: SchemaProps<TOptions>) => KubbNode\n}\n\n/****\n * Creates a generator that uses React component functions to generate files for OpenAPI operations and schemas.\n *\n * The returned generator exposes async methods for generating files from operations, a single operation, or a schema, using the corresponding React components if provided. If a component is not defined, the method returns an empty array.\n *\n * @returns A generator object with async methods for operations, operation, and schema file generation.\n */\nexport function createReactGenerator<TOptions extends PluginFactoryOptions>(generator: UserGenerator<TOptions>): ReactGenerator<TOptions> {\n return {\n type: 'react',\n Operations() {\n return null\n },\n Operation() {\n return null\n },\n Schema() {\n return null\n },\n ...generator,\n }\n}\n","import { camelCase } from '@kubb/core/transformers'\nimport type { PluginOas } from '../types.ts'\nimport { getBanner } from '../utils/getBanner.ts'\nimport { getFooter } from '../utils/getFooter.ts'\nimport { createGenerator } from './createGenerator.ts'\n\nexport const jsonGenerator = createGenerator<PluginOas>({\n name: 'plugin-oas',\n async schema({ schema, generator }) {\n const { pluginManager, plugin } = generator.context\n const file = pluginManager.getFile({\n name: camelCase(schema.name),\n extname: '.json',\n mode: 'split',\n pluginKey: plugin.key,\n })\n\n return [\n {\n ...file,\n sources: [\n {\n name: camelCase(schema.name),\n isExportable: false,\n isIndexable: false,\n value: JSON.stringify(schema.value),\n },\n ],\n banner: getBanner({\n oas: generator.context.oas,\n output: plugin.options.output,\n config: pluginManager.config,\n }),\n format: getFooter({ oas: generator.context.oas, output: plugin.options.output }),\n },\n ]\n },\n})\n"],"mappings":";;;;;;AAmBA,SAAgB,gBAAuD,WAA6D;AAClI,QAAO;EACL,MAAM;EACN,MAAM,aAAa;AACjB,UAAO,EAAE;;EAEX,MAAM,YAAY;AAChB,UAAO,EAAE;;EAEX,MAAM,SAAS;AACb,UAAO,EAAE;;EAEX,GAAG;EACJ;;;;;;;;;;;;ACNH,SAAgB,qBAA4D,WAA8D;AACxI,QAAO;EACL,MAAM;EACN,aAAa;AACX,UAAO;;EAET,YAAY;AACV,UAAO;;EAET,SAAS;AACP,UAAO;;EAET,GAAG;EACJ;;;;;ACjCH,MAAa,gBAAgB,gBAA2B;CACtD,MAAM;CACN,MAAM,OAAO,EAAE,QAAQ,aAAa;EAClC,MAAM,EAAE,eAAe,WAAW,UAAU;AAQ5C,SAAO,CACL;GACE,GATS,cAAc,QAAQ;IACjC,8CAAgB,OAAO,KAAK;IAC5B,SAAS;IACT,MAAM;IACN,WAAW,OAAO;IACnB,CAAC;GAKE,SAAS,CACP;IACE,8CAAgB,OAAO,KAAK;IAC5B,cAAc;IACd,aAAa;IACb,OAAO,KAAK,UAAU,OAAO,MAAM;IACpC,CACF;GACD,QAAQA,4BAAU;IAChB,KAAK,UAAU,QAAQ;IACvB,QAAQ,OAAO,QAAQ;IACvB,QAAQ,cAAc;IACvB,CAAC;GACF,QAAQC,4BAAU;IAAE,KAAK,UAAU,QAAQ;IAAK,QAAQ,OAAO,QAAQ;IAAQ,CAAC;GACjF,CACF;;CAEJ,CAAC"}
@@ -77,4 +77,4 @@ const jsonGenerator = createGenerator({
77
77
 
78
78
  //#endregion
79
79
  export { createReactGenerator as n, createGenerator as r, jsonGenerator as t };
80
- //# sourceMappingURL=generators-CJDEf8Kn.js.map
80
+ //# sourceMappingURL=generators-v153n8vw.js.map