@kubb/plugin-oas 3.0.0-alpha.2 → 3.0.0-alpha.21

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 (101) hide show
  1. package/README.md +13 -4
  2. package/dist/OperationGenerator-CHXolL0o.d.cts +553 -0
  3. package/dist/OperationGenerator-CHXolL0o.d.ts +553 -0
  4. package/dist/Schema-Ch0dHkM5.d.ts +22 -0
  5. package/dist/Schema-ClNodlyP.d.cts +22 -0
  6. package/dist/chunk-6UWOTOZJ.cjs +92 -0
  7. package/dist/chunk-6UWOTOZJ.cjs.map +1 -0
  8. package/dist/chunk-AZKUU24F.js +700 -0
  9. package/dist/chunk-AZKUU24F.js.map +1 -0
  10. package/dist/chunk-DFQJ57GH.js +45 -0
  11. package/dist/chunk-DFQJ57GH.js.map +1 -0
  12. package/dist/chunk-GF26SDHQ.js +28 -0
  13. package/dist/chunk-GF26SDHQ.js.map +1 -0
  14. package/dist/chunk-HP5WAFBU.cjs +48 -0
  15. package/dist/chunk-HP5WAFBU.cjs.map +1 -0
  16. package/dist/chunk-JNGUNN72.cjs +708 -0
  17. package/dist/chunk-JNGUNN72.cjs.map +1 -0
  18. package/dist/chunk-PADR76WZ.cjs +4 -0
  19. package/dist/chunk-PADR76WZ.cjs.map +1 -0
  20. package/dist/chunk-R47XMJ32.js +3 -0
  21. package/dist/chunk-R47XMJ32.js.map +1 -0
  22. package/dist/{chunk-Y4V7HHX7.js → chunk-THGCWF2O.js} +8 -13
  23. package/dist/{chunk-Y4V7HHX7.js.map → chunk-THGCWF2O.js.map} +1 -1
  24. package/dist/chunk-TRA5BTWI.js +88 -0
  25. package/dist/chunk-TRA5BTWI.js.map +1 -0
  26. package/dist/chunk-UO57DZPV.cjs +36 -0
  27. package/dist/chunk-UO57DZPV.cjs.map +1 -0
  28. package/dist/chunk-ZWHQ54JM.cjs +32 -0
  29. package/dist/chunk-ZWHQ54JM.cjs.map +1 -0
  30. package/dist/components.cjs +20 -17
  31. package/dist/components.cjs.map +1 -1
  32. package/dist/components.d.cts +12 -8
  33. package/dist/components.d.ts +12 -8
  34. package/dist/components.js +3 -17
  35. package/dist/components.js.map +1 -1
  36. package/dist/generators.cjs +14 -0
  37. package/dist/generators.cjs.map +1 -0
  38. package/dist/generators.d.cts +10 -0
  39. package/dist/generators.d.ts +10 -0
  40. package/dist/generators.js +5 -0
  41. package/dist/generators.js.map +1 -0
  42. package/dist/hooks.cjs +101 -57
  43. package/dist/hooks.cjs.map +1 -1
  44. package/dist/hooks.d.cts +40 -8
  45. package/dist/hooks.d.ts +40 -8
  46. package/dist/hooks.js +90 -53
  47. package/dist/hooks.js.map +1 -1
  48. package/dist/index.cjs +283 -261
  49. package/dist/index.cjs.map +1 -1
  50. package/dist/index.d.cts +6 -77
  51. package/dist/index.d.ts +6 -77
  52. package/dist/index.js +235 -240
  53. package/dist/index.js.map +1 -1
  54. package/dist/utils.cjs +32 -87
  55. package/dist/utils.cjs.map +1 -1
  56. package/dist/utils.d.cts +7 -41
  57. package/dist/utils.d.ts +7 -41
  58. package/dist/utils.js +8 -86
  59. package/dist/utils.js.map +1 -1
  60. package/package.json +20 -14
  61. package/src/OperationGenerator.ts +75 -43
  62. package/src/SchemaGenerator.ts +44 -18
  63. package/src/SchemaMapper.ts +1 -1
  64. package/src/components/Oas.tsx +9 -3
  65. package/src/components/Operation.tsx +1 -1
  66. package/src/components/Schema.tsx +2 -102
  67. package/src/generator.tsx +133 -0
  68. package/src/generators/index.ts +1 -0
  69. package/src/generators/jsonGenerator.ts +32 -0
  70. package/src/hooks/index.ts +2 -0
  71. package/src/hooks/useOperationManager.ts +76 -28
  72. package/src/hooks/useSchemaManager.ts +77 -0
  73. package/src/index.ts +3 -9
  74. package/src/plugin.ts +64 -47
  75. package/src/types.ts +23 -12
  76. package/src/utils/getParams.ts +2 -2
  77. package/src/utils/index.ts +2 -2
  78. package/dist/OperationGenerator-CeM_9pxW.d.cts +0 -60
  79. package/dist/OperationGenerator-DhUhvRJE.d.ts +0 -60
  80. package/dist/Schema-DefwBJMc.d.ts +0 -35
  81. package/dist/Schema-an5hOrjZ.d.cts +0 -35
  82. package/dist/SchemaMapper-CsBQ6eEx.d.cts +0 -248
  83. package/dist/SchemaMapper-CsBQ6eEx.d.ts +0 -248
  84. package/dist/chunk-CJXRFYEF.cjs +0 -698
  85. package/dist/chunk-CJXRFYEF.cjs.map +0 -1
  86. package/dist/chunk-DRLYORTT.cjs +0 -3265
  87. package/dist/chunk-DRLYORTT.cjs.map +0 -1
  88. package/dist/chunk-K6KUETAI.js +0 -698
  89. package/dist/chunk-K6KUETAI.js.map +0 -1
  90. package/dist/chunk-LEACSHKT.js +0 -3265
  91. package/dist/chunk-LEACSHKT.js.map +0 -1
  92. package/dist/chunk-P42X362U.cjs +0 -101
  93. package/dist/chunk-P42X362U.cjs.map +0 -1
  94. package/dist/chunk-QLJIL3U5.cjs +0 -35
  95. package/dist/chunk-QLJIL3U5.cjs.map +0 -1
  96. package/dist/chunk-UB552H4J.js +0 -101
  97. package/dist/chunk-UB552H4J.js.map +0 -1
  98. package/dist/types-Dte3MA6H.d.cts +0 -143
  99. package/dist/types-Dte3MA6H.d.ts +0 -143
  100. package/src/utils/getGroupedByTagFiles.ts +0 -82
  101. package/src/utils/refSorter.ts +0 -13
package/README.md CHANGED
@@ -13,10 +13,6 @@
13
13
  [![Coverage][coverage-src]][coverage-href]
14
14
  [![License][license-src]][license-href]
15
15
 
16
- <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
17
- <!-- ALL-CONTRIBUTORS-BADGE:END -->
18
- </p>
19
-
20
16
  <h4>
21
17
  <a href="https://codesandbox.io/s/github/kubb-labs/kubb/tree/alpha/examples/typescript" target="_blank">View Demo</a>
22
18
  <span> · </span>
@@ -28,6 +24,19 @@
28
24
  </h4>
29
25
  </div>
30
26
 
27
+ ## Supporting Kubb
28
+
29
+ Kubb uses an MIT-licensed open source project with its ongoing development made possible entirely by the support of Sponsors. If you would like to become a sponsor, please consider:
30
+
31
+ - [Become a Sponsor on GitHub](https://github.com/sponsors/stijnvanhulle)
32
+
33
+ <p align="center">
34
+ <a href="https://github.com/sponsors/stijnvanhulle">
35
+ <img src="https://raw.githubusercontent.com/stijnvanhulle/sponsors/main/sponsors.svg" alt="My sponsors" />
36
+ </a>
37
+ </p>
38
+
39
+
31
40
  <!-- Badges -->
32
41
 
33
42
  [npm-version-src]: https://img.shields.io/npm/v/@kubb/plugin-oas?flat&colorA=18181B&colorB=f58517
@@ -0,0 +1,553 @@
1
+ import { Plugin, ResolveNameParams, Output, PluginFactoryOptions, FileMetaBase, BaseGenerator, PluginManager } from '@kubb/core';
2
+ import * as KubbFile from '@kubb/fs/types';
3
+ import { Oas, contentType, OasTypes, SchemaObject, Operation, HttpMethod } from '@kubb/oas';
4
+ import { KubbNode } from '@kubb/react/types';
5
+ import { FormatOptions } from '@kubb/oas/parser';
6
+
7
+ type SchemaKeywordMapper = {
8
+ object: {
9
+ keyword: 'object';
10
+ args: {
11
+ properties: {
12
+ [x: string]: Schema[];
13
+ };
14
+ additionalProperties: Schema[];
15
+ strict?: boolean;
16
+ };
17
+ };
18
+ strict: {
19
+ keyword: 'strict';
20
+ };
21
+ url: {
22
+ keyword: 'url';
23
+ };
24
+ readOnly: {
25
+ keyword: 'readOnly';
26
+ };
27
+ uuid: {
28
+ keyword: 'uuid';
29
+ };
30
+ email: {
31
+ keyword: 'email';
32
+ };
33
+ firstName: {
34
+ keyword: 'firstName';
35
+ };
36
+ lastName: {
37
+ keyword: 'lastName';
38
+ };
39
+ phone: {
40
+ keyword: 'phone';
41
+ };
42
+ password: {
43
+ keyword: 'password';
44
+ };
45
+ date: {
46
+ keyword: 'date';
47
+ args: {
48
+ type?: 'date' | 'string';
49
+ };
50
+ };
51
+ time: {
52
+ keyword: 'time';
53
+ args: {
54
+ type?: 'date' | 'string';
55
+ };
56
+ };
57
+ datetime: {
58
+ keyword: 'datetime';
59
+ args: {
60
+ offset?: boolean;
61
+ local?: boolean;
62
+ };
63
+ };
64
+ tuple: {
65
+ keyword: 'tuple';
66
+ args: {
67
+ items: Schema[];
68
+ min?: number;
69
+ max?: number;
70
+ };
71
+ };
72
+ array: {
73
+ keyword: 'array';
74
+ args: {
75
+ items: Schema[];
76
+ min?: number;
77
+ max?: number;
78
+ };
79
+ };
80
+ enum: {
81
+ keyword: 'enum';
82
+ args: {
83
+ name: string;
84
+ typeName: string;
85
+ asConst: boolean;
86
+ items: Array<{
87
+ name: string | number;
88
+ format: 'string' | 'number';
89
+ value?: string | number;
90
+ }>;
91
+ };
92
+ };
93
+ and: {
94
+ keyword: 'and';
95
+ args: Schema[];
96
+ };
97
+ const: {
98
+ keyword: 'const';
99
+ args: {
100
+ name: string | number;
101
+ format: 'string' | 'number';
102
+ value?: string | number;
103
+ };
104
+ };
105
+ union: {
106
+ keyword: 'union';
107
+ args: Schema[];
108
+ };
109
+ ref: {
110
+ keyword: 'ref';
111
+ args: {
112
+ name: string;
113
+ path: KubbFile.OptionalPath;
114
+ };
115
+ };
116
+ matches: {
117
+ keyword: 'matches';
118
+ args?: string;
119
+ };
120
+ boolean: {
121
+ keyword: 'boolean';
122
+ };
123
+ default: {
124
+ keyword: 'default';
125
+ args: string | number | boolean;
126
+ };
127
+ string: {
128
+ keyword: 'string';
129
+ };
130
+ integer: {
131
+ keyword: 'integer';
132
+ };
133
+ number: {
134
+ keyword: 'number';
135
+ };
136
+ max: {
137
+ keyword: 'max';
138
+ args: number;
139
+ };
140
+ min: {
141
+ keyword: 'min';
142
+ args: number;
143
+ };
144
+ describe: {
145
+ keyword: 'describe';
146
+ args: string;
147
+ };
148
+ example: {
149
+ keyword: 'example';
150
+ args: string;
151
+ };
152
+ deprecated: {
153
+ keyword: 'deprecated';
154
+ };
155
+ optional: {
156
+ keyword: 'optional';
157
+ };
158
+ undefined: {
159
+ keyword: 'undefined';
160
+ };
161
+ nullish: {
162
+ keyword: 'nullish';
163
+ };
164
+ nullable: {
165
+ keyword: 'nullable';
166
+ };
167
+ null: {
168
+ keyword: 'null';
169
+ };
170
+ any: {
171
+ keyword: 'any';
172
+ };
173
+ unknown: {
174
+ keyword: 'unknown';
175
+ };
176
+ blob: {
177
+ keyword: 'blob';
178
+ };
179
+ schema: {
180
+ keyword: 'schema';
181
+ args: {
182
+ type: 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'object';
183
+ format?: string;
184
+ };
185
+ };
186
+ name: {
187
+ keyword: 'name';
188
+ args: string;
189
+ };
190
+ catchall: {
191
+ keyword: 'catchall';
192
+ };
193
+ };
194
+ declare const schemaKeywords: {
195
+ any: "any";
196
+ strict: "strict";
197
+ unknown: "unknown";
198
+ number: "number";
199
+ integer: "integer";
200
+ string: "string";
201
+ boolean: "boolean";
202
+ undefined: "undefined";
203
+ nullable: "nullable";
204
+ null: "null";
205
+ nullish: "nullish";
206
+ array: "array";
207
+ tuple: "tuple";
208
+ enum: "enum";
209
+ union: "union";
210
+ datetime: "datetime";
211
+ date: "date";
212
+ email: "email";
213
+ uuid: "uuid";
214
+ url: "url";
215
+ default: "default";
216
+ const: "const";
217
+ and: "and";
218
+ describe: "describe";
219
+ min: "min";
220
+ max: "max";
221
+ optional: "optional";
222
+ readOnly: "readOnly";
223
+ object: "object";
224
+ ref: "ref";
225
+ matches: "matches";
226
+ firstName: "firstName";
227
+ lastName: "lastName";
228
+ password: "password";
229
+ phone: "phone";
230
+ blob: "blob";
231
+ deprecated: "deprecated";
232
+ example: "example";
233
+ schema: "schema";
234
+ catchall: "catchall";
235
+ time: "time";
236
+ name: "name";
237
+ };
238
+ type SchemaKeyword = keyof SchemaKeywordMapper;
239
+ type SchemaMapper<T = string | null | undefined> = {
240
+ [K in keyof SchemaKeywordMapper]: (() => T | undefined) | undefined;
241
+ };
242
+ type SchemaKeywordBase<T> = {
243
+ keyword: SchemaKeyword;
244
+ args: T;
245
+ };
246
+ type Schema = {
247
+ keyword: string;
248
+ } | SchemaKeywordMapper[keyof SchemaKeywordMapper];
249
+ declare function isKeyword<T extends Schema, K extends keyof SchemaKeywordMapper>(meta: T, keyword: K): meta is Extract<T, SchemaKeywordMapper[K]>;
250
+
251
+ type Mode = 'schemas' | 'responses' | 'requestBodies';
252
+ type GetSchemasProps = {
253
+ oas: Oas;
254
+ contentType?: contentType;
255
+ includes?: Mode[];
256
+ };
257
+ declare function getSchemas({ oas, contentType, includes }: GetSchemasProps): Record<string, OasTypes.SchemaObject>;
258
+
259
+ type ResolvePathOptions = {
260
+ pluginKey?: Plugin['key'];
261
+ tag?: string;
262
+ type?: ResolveNameParams['type'];
263
+ };
264
+ type API = {
265
+ getOas: (formatOptions?: FormatOptions) => Promise<Oas>;
266
+ getSchemas: (options?: Pick<GetSchemasProps, 'includes'>) => Promise<Record<string, SchemaObject>>;
267
+ getBaseURL: () => Promise<string | undefined>;
268
+ contentType?: contentType;
269
+ };
270
+ type Options = {
271
+ /**
272
+ * Validate your input(see kubb.config) based on '@readme/openapi-parser'.
273
+ * @default true
274
+ */
275
+ validate?: boolean;
276
+ /**
277
+ * @default 'schemas'
278
+ */
279
+ output?: Output;
280
+ /**
281
+ * Which server to use from the array of `servers.url[serverIndex]`
282
+ * @example
283
+ * - `0` will return `http://petstore.swagger.io/api`
284
+ * - `1` will return `http://localhost:3000`
285
+ * @default 0
286
+ */
287
+ serverIndex?: number;
288
+ /**
289
+ * Define which contentType should be used.
290
+ * By default, this is set based on the first used contentType..
291
+ */
292
+ contentType?: contentType;
293
+ experimentalFilter?: FormatOptions['filterSet'];
294
+ experimentalSort?: FormatOptions['sortSet'];
295
+ /**
296
+ * Override some behaviour of the Oas class instance, see '@kubb/oas'
297
+ */
298
+ oasClass?: typeof Oas;
299
+ /**
300
+ * Define some generators next to the JSON generation
301
+ */
302
+ generators?: Array<Generator<PluginOas>>;
303
+ };
304
+ /**
305
+ * `propertyName` is the ref name + resolved with the nameResolver
306
+ * @example `import { Pet } from './Pet'`
307
+ *
308
+ * `originalName` is the original name used(in PascalCase), only used to remove duplicates
309
+ *
310
+ * `pluginKey` can be used to override the current plugin being used, handy when you want to import a type/schema out of another plugin
311
+ * @example import a type(plugin-ts) for a mock file(swagger-faker)
312
+ */
313
+ type Ref = {
314
+ propertyName: string;
315
+ originalName: string;
316
+ path: KubbFile.OptionalPath;
317
+ pluginKey?: Plugin['key'];
318
+ };
319
+ type Refs = Record<string, Ref>;
320
+ type Resolver = {
321
+ /**
322
+ * Original name or name resolved by `resolveName({ name: operation?.getOperationId() as string, pluginName })`
323
+ */
324
+ name: string;
325
+ baseName: KubbFile.BaseName;
326
+ path: KubbFile.Path;
327
+ };
328
+ type OperationSchema = {
329
+ /**
330
+ * Converted name, contains already `PathParams`, `QueryParams`, ...
331
+ */
332
+ name: string;
333
+ schema: SchemaObject;
334
+ operation?: Operation;
335
+ /**
336
+ * OperationName in PascalCase, only being used in OperationGenerator
337
+ */
338
+ operationName?: string;
339
+ description?: string;
340
+ statusCode?: number;
341
+ keys?: string[];
342
+ keysToOmit?: string[];
343
+ withData?: boolean;
344
+ };
345
+ type OperationSchemas = {
346
+ pathParams?: OperationSchema & {
347
+ keysToOmit?: never;
348
+ };
349
+ queryParams?: OperationSchema & {
350
+ keysToOmit?: never;
351
+ };
352
+ headerParams?: OperationSchema & {
353
+ keysToOmit?: never;
354
+ };
355
+ request?: OperationSchema;
356
+ response: OperationSchema;
357
+ statusCodes?: Array<OperationSchema>;
358
+ errors?: Array<OperationSchema>;
359
+ };
360
+ type OperationsByMethod = Record<string, Record<HttpMethod, {
361
+ operation: Operation;
362
+ schemas: OperationSchemas;
363
+ }>>;
364
+ type ByTag = {
365
+ type: 'tag';
366
+ pattern: string | RegExp;
367
+ };
368
+ type ByOperationId = {
369
+ type: 'operationId';
370
+ pattern: string | RegExp;
371
+ };
372
+ type ByPath = {
373
+ type: 'path';
374
+ pattern: string | RegExp;
375
+ };
376
+ type ByMethod = {
377
+ type: 'method';
378
+ pattern: HttpMethod | RegExp;
379
+ };
380
+ type BySchemaName = {
381
+ type: 'schemaName';
382
+ pattern: string | RegExp;
383
+ };
384
+ type Exclude = ByTag | ByOperationId | ByPath | ByMethod;
385
+ type Include = ByTag | ByOperationId | ByPath | ByMethod;
386
+ type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName) & {
387
+ options: Partial<TOptions>;
388
+ };
389
+ type ResolvedOptions = Options & {
390
+ output: Output;
391
+ };
392
+ type PluginOas = PluginFactoryOptions<'plugin-oas', Options, ResolvedOptions, API, never>;
393
+
394
+ type GetSchemaGeneratorOptions<T extends SchemaGenerator<any, any, any>> = T extends SchemaGenerator<infer Options, any, any> ? Options : never;
395
+ type SchemaMethodResult<TFileMeta extends FileMetaBase> = Promise<KubbFile.File<TFileMeta> | Array<KubbFile.File<TFileMeta>> | null>;
396
+ type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
397
+ oas: Oas;
398
+ pluginManager: PluginManager;
399
+ /**
400
+ * Current plugin
401
+ */
402
+ plugin: Plugin<TPluginOptions>;
403
+ mode: KubbFile.Mode;
404
+ include?: Array<'schemas' | 'responses' | 'requestBodies'>;
405
+ override: Array<Override<TOptions>> | undefined;
406
+ contentType?: contentType;
407
+ output?: string;
408
+ };
409
+ type SchemaGeneratorOptions = {
410
+ dateType: false | 'string' | 'stringOffset' | 'stringLocal' | 'date';
411
+ unknownType: 'any' | 'unknown';
412
+ enumType?: 'enum' | 'asConst' | 'asPascalConst' | 'constEnum' | 'literal';
413
+ enumSuffix?: string;
414
+ usedEnumNames?: Record<string, number>;
415
+ mapper?: Record<string, string>;
416
+ typed?: boolean;
417
+ transformers: {
418
+ /**
419
+ * Customize the names based on the type that is provided by the plugin.
420
+ */
421
+ name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
422
+ /**
423
+ * Receive schema and name(propertName) and return FakerMeta array
424
+ * TODO TODO add docs
425
+ * @beta
426
+ */
427
+ schema?: (schemaProps: SchemaProps$1, defaultSchemas: Schema[]) => Schema[] | undefined;
428
+ };
429
+ };
430
+ type SchemaGeneratorBuildOptions = Omit<OperationSchema, 'name' | 'schema'>;
431
+ type SchemaProps$1 = {
432
+ schema?: SchemaObject;
433
+ name?: string;
434
+ parentName?: string;
435
+ };
436
+ declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions, Context$1<TOptions, TPluginOptions>> {
437
+ #private;
438
+ refs: Refs;
439
+ /**
440
+ * Creates a type node from a given schema.
441
+ * Delegates to getBaseTypeFromSchema internally and
442
+ * optionally adds a union with null.
443
+ */
444
+ parse(props: SchemaProps$1): Schema[];
445
+ deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T][];
446
+ find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
447
+ static deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T][];
448
+ static findInObject<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
449
+ static find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
450
+ build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
451
+ /**
452
+ * Schema
453
+ */
454
+ schema(name: string, object: SchemaObject, options: TOptions): SchemaMethodResult<TFileMeta>;
455
+ }
456
+
457
+ type OperationsProps<TOptions extends PluginFactoryOptions> = {
458
+ instance: Omit<OperationGenerator<TOptions>, 'build'>;
459
+ options: TOptions['resolvedOptions'];
460
+ operations: Array<Operation>;
461
+ operationsByMethod: OperationsByMethod;
462
+ };
463
+ type OperationProps<TOptions extends PluginFactoryOptions> = {
464
+ instance: Omit<OperationGenerator<TOptions>, 'build'>;
465
+ options: TOptions['resolvedOptions'];
466
+ operation: Operation;
467
+ };
468
+ type SchemaProps<TOptions extends PluginFactoryOptions> = {
469
+ instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>;
470
+ schema: {
471
+ name: string;
472
+ tree: Array<Schema>;
473
+ value: SchemaObject;
474
+ };
475
+ options: TOptions['resolvedOptions'];
476
+ };
477
+ type GeneratorOptions<TOptions extends PluginFactoryOptions> = {
478
+ name: string;
479
+ operations?: (this: GeneratorOptions<TOptions>, props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>;
480
+ operation?: (this: GeneratorOptions<TOptions>, props: OperationProps<TOptions>) => Promise<KubbFile.File[]>;
481
+ schema?: (this: GeneratorOptions<TOptions>, props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>;
482
+ };
483
+ type Generator<TOptions extends PluginFactoryOptions> = GeneratorOptions<TOptions>;
484
+ declare function createGenerator<TOptions extends PluginFactoryOptions>(parseOptions: GeneratorOptions<TOptions>): Generator<TOptions>;
485
+ type ReactGeneratorOptions<TOptions extends PluginFactoryOptions> = {
486
+ name: string;
487
+ Operations?: (this: ReactGeneratorOptions<TOptions>, props: OperationsProps<TOptions>) => KubbNode;
488
+ Operation?: (this: ReactGeneratorOptions<TOptions>, props: OperationProps<TOptions>) => KubbNode;
489
+ Schema?: (this: ReactGeneratorOptions<TOptions>, props: SchemaProps<TOptions>) => KubbNode;
490
+ /**
491
+ * Combine all react nodes and only render ones(to string or render)
492
+ */
493
+ render?: () => any;
494
+ };
495
+ declare function createReactGenerator<TOptions extends PluginFactoryOptions>(parseOptions: ReactGeneratorOptions<TOptions>): Generator<TOptions>;
496
+
497
+ /**
498
+ * @deprecated
499
+ */
500
+ type GetOperationGeneratorOptions<T = any> = any;
501
+ type OperationMethodResult<TFileMeta extends FileMetaBase> = Promise<KubbFile.File<TFileMeta> | Array<KubbFile.File<TFileMeta>> | null>;
502
+ type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
503
+ oas: Oas;
504
+ exclude: Array<Exclude> | undefined;
505
+ include: Array<Include> | undefined;
506
+ override: Array<Override<TOptions>> | undefined;
507
+ contentType: contentType | undefined;
508
+ pluginManager: PluginManager;
509
+ /**
510
+ * Current plugin
511
+ */
512
+ plugin: Plugin<TPluginOptions>;
513
+ mode: KubbFile.Mode;
514
+ };
515
+ declare class OperationGenerator<TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TPluginOptions['resolvedOptions'], Context<TPluginOptions['resolvedOptions'], TPluginOptions>> {
516
+ #private;
517
+ get operationsByMethod(): OperationsByMethod;
518
+ set operationsByMethod(paths: OperationsByMethod);
519
+ getSchemas(operation: Operation, { resolveName, }?: {
520
+ resolveName?: (name: string) => string;
521
+ }): OperationSchemas;
522
+ build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
523
+ /**
524
+ * Operation
525
+ */
526
+ operation(operation: Operation, options: TPluginOptions['resolvedOptions']): OperationMethodResult<TFileMeta>;
527
+ /**
528
+ * GET
529
+ */
530
+ get(operation: Operation, options: TPluginOptions['resolvedOptions']): OperationMethodResult<TFileMeta>;
531
+ /**
532
+ * POST
533
+ */
534
+ post(operation: Operation, options: TPluginOptions['resolvedOptions']): OperationMethodResult<TFileMeta>;
535
+ /**
536
+ * PATCH
537
+ */
538
+ patch(operation: Operation, options: TPluginOptions['resolvedOptions']): OperationMethodResult<TFileMeta>;
539
+ /**
540
+ * PUT
541
+ */
542
+ put(operation: Operation, options: TPluginOptions['resolvedOptions']): OperationMethodResult<TFileMeta>;
543
+ /**
544
+ * DELETE
545
+ */
546
+ delete(operation: Operation, options: TPluginOptions['resolvedOptions']): OperationMethodResult<TFileMeta>;
547
+ /**
548
+ * Combination of GET, POST, PATCH, PUT, DELETE
549
+ */
550
+ all(operations: Operation[], paths: OperationsByMethod): OperationMethodResult<TFileMeta>;
551
+ }
552
+
553
+ export { type API as A, getSchemas as B, type Exclude as E, type GetOperationGeneratorOptions as G, type Include as I, type Options as O, type PluginOas as P, type ReactGeneratorOptions as R, type SchemaGeneratorBuildOptions as S, type OperationMethodResult as a, OperationGenerator as b, type GetSchemaGeneratorOptions as c, type SchemaGeneratorOptions as d, type SchemaMethodResult as e, SchemaGenerator as f, type Schema as g, type SchemaKeyword as h, type SchemaKeywordBase as i, type SchemaKeywordMapper as j, type SchemaMapper as k, isKeyword as l, createGenerator as m, createReactGenerator as n, type Generator as o, type GeneratorOptions as p, type ResolvePathOptions as q, type Ref as r, schemaKeywords as s, type Refs as t, type Resolver as u, type OperationSchema as v, type OperationSchemas as w, type OperationsByMethod as x, type Override as y, type GetSchemasProps as z };