@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-oas",
3
- "version": "3.0.0-alpha.2",
3
+ "version": "3.0.0-alpha.21",
4
4
  "description": "Generator swagger",
5
5
  "keywords": [
6
6
  "typescript",
@@ -25,6 +25,11 @@
25
25
  "require": "./dist/index.cjs",
26
26
  "default": "./dist/index.cjs"
27
27
  },
28
+ "./generators": {
29
+ "import": "./dist/generators.js",
30
+ "require": "./dist/generators.cjs",
31
+ "default": "./dist/generators.cjs"
32
+ },
28
33
  "./utils": {
29
34
  "import": "./dist/utils.js",
30
35
  "require": "./dist/utils.cjs",
@@ -56,6 +61,9 @@
56
61
  ],
57
62
  "components": [
58
63
  "./dist/components.d.ts"
64
+ ],
65
+ "generators": [
66
+ "./dist/generators.d.ts"
59
67
  ]
60
68
  }
61
69
  },
@@ -67,24 +75,22 @@
67
75
  ],
68
76
  "dependencies": {
69
77
  "@stoplight/yaml": "^4.3.0",
70
- "remeda": "^2.11.0",
71
- "@kubb/core": "3.0.0-alpha.2",
72
- "@kubb/fs": "3.0.0-alpha.2",
73
- "@kubb/oas": "3.0.0-alpha.2",
74
- "@kubb/react": "3.0.0-alpha.2"
78
+ "remeda": "^2.14.0",
79
+ "@kubb/core": "3.0.0-alpha.21",
80
+ "@kubb/fs": "3.0.0-alpha.21",
81
+ "@kubb/oas": "3.0.0-alpha.21",
82
+ "@kubb/react": "3.0.0-alpha.21"
75
83
  },
76
84
  "devDependencies": {
77
- "@types/react": "^18.3.4",
78
- "@types/react-dom": "^18.3.0",
85
+ "@types/react": "^18.3.8",
79
86
  "react": "^18.3.1",
80
- "tsup": "^8.2.4",
81
- "typescript": "^5.5.4",
82
- "@kubb/config-biome": "3.0.0-alpha.2",
83
- "@kubb/config-ts": "3.0.0-alpha.2",
84
- "@kubb/config-tsup": "3.0.0-alpha.2"
87
+ "tsup": "^8.3.0",
88
+ "typescript": "^5.6.2",
89
+ "@kubb/config-ts": "3.0.0-alpha.21",
90
+ "@kubb/config-tsup": "3.0.0-alpha.21"
85
91
  },
86
92
  "peerDependencies": {
87
- "@kubb/react": "3.0.0-alpha.2"
93
+ "@kubb/react": "3.0.0-alpha.21"
88
94
  },
89
95
  "engines": {
90
96
  "node": ">=20"
@@ -1,4 +1,4 @@
1
- import { type FileMetaBase, Generator } from '@kubb/core'
1
+ import { BaseGenerator, type FileMetaBase } from '@kubb/core'
2
2
  import transformers from '@kubb/core/transformers'
3
3
 
4
4
  import type { PluginFactoryOptions, PluginManager } from '@kubb/core'
@@ -6,9 +6,13 @@ import type * as KubbFile from '@kubb/fs/types'
6
6
 
7
7
  import type { Plugin } from '@kubb/core'
8
8
  import type { HttpMethod, Oas, OasTypes, Operation, contentType } from '@kubb/oas'
9
+ import type { Generator } from './generator.tsx'
9
10
  import type { Exclude, Include, OperationSchemas, OperationsByMethod, Override } from './types.ts'
10
11
 
11
- export type GetOperationGeneratorOptions<T extends OperationGenerator<any, any, any>> = T extends OperationGenerator<infer Options, any, any> ? Options : never
12
+ /**
13
+ * @deprecated
14
+ */
15
+ export type GetOperationGeneratorOptions<T = any> = any
12
16
 
13
17
  export type OperationMethodResult<TFileMeta extends FileMetaBase> = Promise<KubbFile.File<TFileMeta> | Array<KubbFile.File<TFileMeta>> | null>
14
18
 
@@ -26,11 +30,10 @@ type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
26
30
  mode: KubbFile.Mode
27
31
  }
28
32
 
29
- export abstract class OperationGenerator<
30
- TOptions = unknown,
33
+ export class OperationGenerator<
31
34
  TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions,
32
35
  TFileMeta extends FileMetaBase = FileMetaBase,
33
- > extends Generator<TOptions, Context<TOptions, TPluginOptions>> {
36
+ > extends BaseGenerator<TPluginOptions['resolvedOptions'], Context<TPluginOptions['resolvedOptions'], TPluginOptions>> {
34
37
  #operationsByMethod: OperationsByMethod = {}
35
38
  get operationsByMethod(): OperationsByMethod {
36
39
  return this.#operationsByMethod
@@ -40,7 +43,7 @@ export abstract class OperationGenerator<
40
43
  this.#operationsByMethod = paths
41
44
  }
42
45
 
43
- #getOptions(operation: Operation, method: HttpMethod): Partial<TOptions> {
46
+ #getOptions(operation: Operation, method: HttpMethod): Partial<TPluginOptions['resolvedOptions']> {
44
47
  const { override = [] } = this.context
45
48
 
46
49
  return (
@@ -65,6 +68,7 @@ export abstract class OperationGenerator<
65
68
  })?.options || {}
66
69
  )
67
70
  }
71
+
68
72
  /**
69
73
  *
70
74
  * @deprecated
@@ -93,6 +97,7 @@ export abstract class OperationGenerator<
93
97
 
94
98
  return matched
95
99
  }
100
+
96
101
  /**
97
102
  *
98
103
  * @deprecated
@@ -124,14 +129,17 @@ export abstract class OperationGenerator<
124
129
 
125
130
  getSchemas(
126
131
  operation: Operation,
127
- { forStatusCode, resolveName = (name) => name }: { forStatusCode?: string | number; resolveName?: (name: string) => string } = {},
132
+ {
133
+ resolveName = (name) => name,
134
+ }: {
135
+ resolveName?: (name: string) => string
136
+ } = {},
128
137
  ): OperationSchemas {
129
138
  const pathParamsSchema = this.context.oas.getParametersSchema(operation, 'path')
130
139
  const queryParamsSchema = this.context.oas.getParametersSchema(operation, 'query')
131
140
  const headerParamsSchema = this.context.oas.getParametersSchema(operation, 'header')
132
141
  const requestSchema = this.context.oas.getRequestSchema(operation)
133
- const responseStatusCode =
134
- forStatusCode || (operation.schema.responses && Object.keys(operation.schema.responses).find((key) => key.startsWith('2'))) || 200
142
+ const responseStatusCode = (operation.schema.responses && Object.keys(operation.schema.responses).find((key) => key.startsWith('2'))) || 200
135
143
  const responseSchema = this.context.oas.getResponseSchema(operation, responseStatusCode)
136
144
  const statusCodes = operation.getResponseStatusCodes().map((statusCode) => {
137
145
  let name = statusCode
@@ -217,20 +225,9 @@ export abstract class OperationGenerator<
217
225
  }
218
226
  }
219
227
 
220
- get #methods() {
221
- return {
222
- get: this.get,
223
- post: this.post,
224
- patch: this.patch,
225
- put: this.put,
226
- delete: this.delete,
227
- head: undefined,
228
- options: undefined,
229
- trace: undefined,
230
- } as const
231
- }
228
+ #methods = ['get', 'post', 'patch', 'put', 'delete']
232
229
 
233
- async build(): Promise<Array<KubbFile.File<TFileMeta>>> {
230
+ async build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>> {
234
231
  const { oas } = this.context
235
232
 
236
233
  const paths = oas.getPaths()
@@ -239,7 +236,7 @@ export abstract class OperationGenerator<
239
236
 
240
237
  methods.forEach((method) => {
241
238
  const operation = oas.operation(path, method)
242
- if (operation && this.#methods[method]) {
239
+ if (operation && [this.#methods].some((methods) => method === operation.method)) {
243
240
  const isExcluded = this.#isExcluded(operation, method)
244
241
  const isIncluded = this.context.include ? this.#isIncluded(operation, method) : true
245
242
 
@@ -267,21 +264,43 @@ export abstract class OperationGenerator<
267
264
  methods.forEach((method) => {
268
265
  const { operation } = this.operationsByMethod[path]?.[method]!
269
266
  const options = this.#getOptions(operation, method)
270
- const promiseMethod = this.#methods[method]?.call(this, operation, {
271
- ...this.options,
272
- ...options,
273
- })
267
+
268
+ const methodToCall = this[method as keyof typeof this] as any
269
+
270
+ if (typeof methodToCall === 'function') {
271
+ const promiseMethod = methodToCall?.call(this, operation, {
272
+ ...this.options,
273
+ ...options,
274
+ })
275
+
276
+ if (promiseMethod) {
277
+ acc.push(promiseMethod)
278
+ }
279
+ }
280
+
274
281
  const promiseOperation = this.operation.call(this, operation, {
275
282
  ...this.options,
276
283
  ...options,
277
284
  })
278
285
 
279
- if (promiseMethod) {
280
- acc.push(promiseMethod)
281
- }
282
286
  if (promiseOperation) {
283
287
  acc.push(promiseOperation)
284
288
  }
289
+
290
+ generators?.forEach((generator) => {
291
+ const promise = generator.operation?.({
292
+ instance: this,
293
+ operation,
294
+ options: {
295
+ ...this.options,
296
+ ...options,
297
+ },
298
+ } as any) as Promise<Array<KubbFile.File<TFileMeta>>>
299
+
300
+ if (promise) {
301
+ acc.push(promise)
302
+ }
303
+ })
285
304
  })
286
305
 
287
306
  return acc
@@ -291,6 +310,19 @@ export abstract class OperationGenerator<
291
310
 
292
311
  promises.push(this.all(operations.flat().filter(Boolean), this.operationsByMethod))
293
312
 
313
+ generators?.forEach((generator) => {
314
+ const promise = generator.operations?.({
315
+ instance: this,
316
+ operations: operations.flat().filter(Boolean),
317
+ operationsByMethod: this.operationsByMethod,
318
+ options: this.options,
319
+ } as any) as Promise<Array<KubbFile.File<TFileMeta>>>
320
+
321
+ if (promise) {
322
+ promises.push(promise)
323
+ }
324
+ })
325
+
294
326
  const files = await Promise.all(promises)
295
327
 
296
328
  // using .flat because operationGenerator[method] can return a array of files or just one file
@@ -300,48 +332,48 @@ export abstract class OperationGenerator<
300
332
  /**
301
333
  * Operation
302
334
  */
303
- async operation(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta> {
304
- return null
335
+ async operation(operation: Operation, options: TPluginOptions['resolvedOptions']): OperationMethodResult<TFileMeta> {
336
+ return []
305
337
  }
306
338
 
307
339
  /**
308
340
  * GET
309
341
  */
310
- async get(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta> {
311
- return null
342
+ async get(operation: Operation, options: TPluginOptions['resolvedOptions']): OperationMethodResult<TFileMeta> {
343
+ return []
312
344
  }
313
345
 
314
346
  /**
315
347
  * POST
316
348
  */
317
- async post(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta> {
318
- return null
349
+ async post(operation: Operation, options: TPluginOptions['resolvedOptions']): OperationMethodResult<TFileMeta> {
350
+ return []
319
351
  }
320
352
  /**
321
353
  * PATCH
322
354
  */
323
- async patch(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta> {
324
- return null
355
+ async patch(operation: Operation, options: TPluginOptions['resolvedOptions']): OperationMethodResult<TFileMeta> {
356
+ return []
325
357
  }
326
358
 
327
359
  /**
328
360
  * PUT
329
361
  */
330
- async put(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta> {
331
- return null
362
+ async put(operation: Operation, options: TPluginOptions['resolvedOptions']): OperationMethodResult<TFileMeta> {
363
+ return []
332
364
  }
333
365
 
334
366
  /**
335
367
  * DELETE
336
368
  */
337
- async delete(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta> {
338
- return null
369
+ async delete(operation: Operation, options: TPluginOptions['resolvedOptions']): OperationMethodResult<TFileMeta> {
370
+ return []
339
371
  }
340
372
 
341
373
  /**
342
374
  * Combination of GET, POST, PATCH, PUT, DELETE
343
375
  */
344
376
  async all(operations: Operation[], paths: OperationsByMethod): OperationMethodResult<TFileMeta> {
345
- return null
377
+ return []
346
378
  }
347
379
  }
@@ -1,4 +1,4 @@
1
- import { type FileMetaBase, Generator } from '@kubb/core'
1
+ import { BaseGenerator, type FileMetaBase } from '@kubb/core'
2
2
  import transformers, { pascalCase } from '@kubb/core/transformers'
3
3
  import { getUniqueName } from '@kubb/core/utils'
4
4
 
@@ -13,6 +13,7 @@ import type * as KubbFile from '@kubb/fs/types'
13
13
 
14
14
  import type { Oas, OpenAPIV3, SchemaObject, contentType } from '@kubb/oas'
15
15
  import type { Schema, SchemaKeywordMapper } from './SchemaMapper.ts'
16
+ import type { Generator } from './generator.tsx'
16
17
  import type { OperationSchema, Override, Refs } from './types.ts'
17
18
 
18
19
  export type GetSchemaGeneratorOptions<T extends SchemaGenerator<any, any, any>> = T extends SchemaGenerator<infer Options, any, any> ? Options : never
@@ -63,11 +64,11 @@ type SchemaProps = {
63
64
  parentName?: string
64
65
  }
65
66
 
66
- export abstract class SchemaGenerator<
67
+ export class SchemaGenerator<
67
68
  TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions,
68
69
  TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions,
69
70
  TFileMeta extends FileMetaBase = FileMetaBase,
70
- > extends Generator<TOptions, Context<TOptions, TPluginOptions>> {
71
+ > extends BaseGenerator<TOptions, Context<TOptions, TPluginOptions>> {
71
72
  // Collect the types of all referenced schemas, so we can export them later
72
73
  refs: Refs = {}
73
74
 
@@ -360,7 +361,7 @@ export abstract class SchemaGenerator<
360
361
  return [
361
362
  {
362
363
  keyword: schemaKeywords.ref,
363
- args: { name: ref.propertyName, path: ref?.path, isTypeOnly: false },
364
+ args: { name: ref.propertyName, path: ref?.path },
364
365
  },
365
366
  ]
366
367
  }
@@ -378,12 +379,6 @@ export abstract class SchemaGenerator<
378
379
  const options = this.#getOptions({ schema: _schema, name })
379
380
  const unknownReturn = this.#getUnknownReturn({ schema: _schema, name })
380
381
  const { schema, version } = this.#getParsedSchemaObject(_schema)
381
- const resolvedName = this.context.pluginManager.resolveName({
382
- name: `${parentName || ''} ${name}`,
383
- pluginKey: this.context.plugin.key,
384
- type: 'type',
385
- })
386
-
387
382
  if (!schema) {
388
383
  return [{ keyword: unknownReturn }]
389
384
  }
@@ -407,12 +402,16 @@ export abstract class SchemaGenerator<
407
402
  keyword: schemaKeywords.default,
408
403
  args: transformers.stringify(schema.default),
409
404
  })
410
- }
411
- if (typeof schema.default === 'boolean') {
405
+ } else if (typeof schema.default === 'boolean') {
412
406
  baseItems.push({
413
407
  keyword: schemaKeywords.default,
414
408
  args: schema.default ?? false,
415
409
  })
410
+ } else {
411
+ baseItems.push({
412
+ keyword: schemaKeywords.default,
413
+ args: schema.default,
414
+ })
416
415
  }
417
416
  }
418
417
 
@@ -809,7 +808,7 @@ export abstract class SchemaGenerator<
809
808
  ].filter(Boolean)
810
809
  }
811
810
 
812
- if (!['boolean', 'object', 'number', 'string', 'integer'].includes(schema.type)) {
811
+ if (!['boolean', 'object', 'number', 'string', 'integer', 'null'].includes(schema.type)) {
813
812
  this.context.pluginManager.logger.emit('warning', `Schema type '${schema.type}' is not valid for schema ${parentName}.${name}`)
814
813
  }
815
814
 
@@ -820,14 +819,18 @@ export abstract class SchemaGenerator<
820
819
  return [{ keyword: unknownReturn }]
821
820
  }
822
821
 
823
- async build(): Promise<Array<KubbFile.File<TFileMeta>>> {
822
+ async build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>> {
824
823
  const { oas, contentType, include } = this.context
825
824
 
826
825
  const schemas = getSchemas({ oas, contentType, includes: include })
827
826
 
828
- const promises = Object.entries(schemas).reduce((acc, [name, schema]) => {
827
+ const promises = Object.entries(schemas).reduce((acc, [name, value]) => {
828
+ if (!value) {
829
+ return acc
830
+ }
831
+
829
832
  const options = this.#getOptions({ name })
830
- const promiseOperation = this.schema.call(this, name, schema, {
833
+ const promiseOperation = this.schema.call(this, name, value, {
831
834
  ...this.options,
832
835
  ...options,
833
836
  })
@@ -836,17 +839,40 @@ export abstract class SchemaGenerator<
836
839
  acc.push(promiseOperation)
837
840
  }
838
841
 
842
+ generators?.forEach((generator) => {
843
+ const tree = this.parse({ schema: value, name: name })
844
+
845
+ const promise = generator.schema?.({
846
+ instance: this,
847
+ schema: {
848
+ name,
849
+ value,
850
+ tree,
851
+ },
852
+ options: {
853
+ ...this.options,
854
+ ...options,
855
+ },
856
+ } as any) as Promise<Array<KubbFile.File<TFileMeta>>>
857
+
858
+ if (promise) {
859
+ acc.push(promise)
860
+ }
861
+ })
862
+
839
863
  return acc
840
864
  }, [] as SchemaMethodResult<TFileMeta>[])
841
865
 
842
866
  const files = await Promise.all(promises)
843
867
 
844
- // using .flat because schemaGenerator[method] can return a array of files or just one file
868
+ // using .flat because schemaGenerator[method] can return an array of files or just one file
845
869
  return files.flat().filter(Boolean)
846
870
  }
847
871
 
848
872
  /**
849
873
  * Schema
850
874
  */
851
- abstract schema(name: string, object: SchemaObject, options: TOptions): SchemaMethodResult<TFileMeta>
875
+ async schema(name: string, object: SchemaObject, options: TOptions): SchemaMethodResult<TFileMeta> {
876
+ return []
877
+ }
852
878
  }
@@ -51,7 +51,7 @@ export type SchemaKeywordMapper = {
51
51
  union: { keyword: 'union'; args: Schema[] }
52
52
  ref: {
53
53
  keyword: 'ref'
54
- args: { name: string; path: KubbFile.OptionalPath; isTypeOnly?: boolean }
54
+ args: { name: string; path: KubbFile.OptionalPath }
55
55
  }
56
56
  matches: { keyword: 'matches'; args?: string }
57
57
  boolean: { keyword: 'boolean' }
@@ -4,20 +4,26 @@ import { Operation } from './Operation.tsx'
4
4
  import { Schema } from './Schema.tsx'
5
5
 
6
6
  import type { Oas as OasType, Operation as OperationType } from '@kubb/oas'
7
- import type { KubbNode } from '@kubb/react'
7
+ import type { KubbNode } from '@kubb/react/types'
8
8
  import type { OperationGenerator } from '../OperationGenerator.ts'
9
9
 
10
10
  type Props = {
11
11
  oas: OasType
12
12
  operations?: OperationType[]
13
- generator?: OperationGenerator
13
+ /**
14
+ * @deprecated
15
+ */
16
+ generator?: Omit<OperationGenerator, 'build'>
14
17
  children?: KubbNode
15
18
  }
16
19
 
17
20
  type OasContextProps = {
18
21
  oas?: OasType
19
22
  operations?: OperationType[]
20
- generator?: OperationGenerator
23
+ /**
24
+ * @deprecated
25
+ */
26
+ generator?: Omit<OperationGenerator, 'build'>
21
27
  }
22
28
 
23
29
  const OasContext = createContext<OasContextProps>({})
@@ -1,7 +1,7 @@
1
1
  import { createContext } from '@kubb/react'
2
2
 
3
3
  import type { Operation as OperationType } from '@kubb/oas'
4
- import type { KubbNode } from '@kubb/react'
4
+ import type { KubbNode } from '@kubb/react/types'
5
5
 
6
6
  type Props = {
7
7
  operation: OperationType
@@ -1,15 +1,8 @@
1
- import { File, Parser, createContext, useApp, useFile } from '@kubb/react'
1
+ import { createContext } from '@kubb/react'
2
2
 
3
- import { schemaKeywords } from '../SchemaMapper.ts'
4
- import { useSchema } from '../hooks/useSchema.ts'
5
-
6
- import type * as KubbFile from '@kubb/fs/types'
7
3
  import type { SchemaObject } from '@kubb/oas'
8
- import type { KubbNode } from '@kubb/react'
9
- import type { ReactNode } from 'react'
10
- import { SchemaGenerator } from '../SchemaGenerator.ts'
4
+ import type { KubbNode } from '@kubb/react/types'
11
5
  import type { Schema as SchemaType } from '../SchemaMapper.ts'
12
- import type { PluginOas } from '../types.ts'
13
6
 
14
7
  export type SchemaContextProps = {
15
8
  name: string
@@ -33,97 +26,4 @@ export function Schema({ name, value, tree = [], children }: Props): KubbNode {
33
26
  return <SchemaContext.Provider value={{ name, schema: value, tree }}>{children}</SchemaContext.Provider>
34
27
  }
35
28
 
36
- type FileProps = {
37
- isTypeOnly?: boolean
38
- output: string | undefined
39
- children?: KubbNode
40
- }
41
-
42
- Schema.File = function ({ output, isTypeOnly, children }: FileProps): ReactNode {
43
- const { plugin, pluginManager, mode } = useApp<PluginOas>()
44
- const { name } = useSchema()
45
-
46
- if (mode === 'single') {
47
- const baseName = output as KubbFile.BaseName
48
- const resolvedPath = pluginManager.resolvePath({
49
- baseName: '',
50
- pluginKey: plugin.key,
51
- })
52
-
53
- if (!resolvedPath) {
54
- return null
55
- }
56
-
57
- return (
58
- <Parser language="typescript">
59
- <File
60
- baseName={baseName}
61
- path={resolvedPath}
62
- meta={{
63
- pluginKey: plugin.key,
64
- }}
65
- >
66
- {children}
67
- </File>
68
- </Parser>
69
- )
70
- }
71
-
72
- const baseName = `${pluginManager.resolveName({
73
- name,
74
- pluginKey: plugin.key,
75
- type: 'file',
76
- })}.ts` as const
77
- const resolvedPath = pluginManager.resolvePath({
78
- baseName,
79
- pluginKey: plugin.key,
80
- })
81
-
82
- if (!resolvedPath) {
83
- return null
84
- }
85
-
86
- return (
87
- <Parser language="typescript">
88
- <File
89
- baseName={baseName}
90
- path={resolvedPath}
91
- meta={{
92
- pluginKey: plugin.key,
93
- }}
94
- >
95
- <Schema.Imports isTypeOnly={isTypeOnly} />
96
- {children}
97
- </File>
98
- </Parser>
99
- )
100
- }
101
-
102
- type SchemaImportsProps = {
103
- isTypeOnly?: boolean
104
- extName?: KubbFile.Extname
105
- }
106
-
107
- Schema.Imports = ({ isTypeOnly, extName }: SchemaImportsProps): ReactNode => {
108
- const { tree } = useSchema()
109
- const { path: root } = useFile()
110
-
111
- const refs = SchemaGenerator.deepSearch(tree, schemaKeywords.ref)
112
-
113
- return (
114
- <>
115
- {refs
116
- ?.map((item, i) => {
117
- if (!item.args.path) {
118
- return undefined
119
- }
120
-
121
- return (
122
- <File.Import key={i} extName={extName} root={root} name={[item.args.name]} path={item.args.path} isTypeOnly={item.args.isTypeOnly ?? isTypeOnly} />
123
- )
124
- })
125
- .filter(Boolean)}
126
- </>
127
- )
128
- }
129
29
  Schema.Context = SchemaContext