@kubb/plugin-oas 5.0.0-alpha.3 → 5.0.0-alpha.30

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 (61) hide show
  1. package/dist/{SchemaMapper-SneuY1wg.d.ts → SchemaMapper-CLIXrzqv.d.ts} +3 -3
  2. package/dist/SchemaMapper-CeavHZlp.cjs.map +1 -1
  3. package/dist/SchemaMapper-CqMkO2T1.js.map +1 -1
  4. package/dist/{createGenerator-jtR_okrd.d.ts → createGenerator-DL3CAvaU.d.ts} +121 -70
  5. package/dist/{generators-vAAte6w6.cjs → generators-85sP4GIS.cjs} +7 -7
  6. package/dist/generators-85sP4GIS.cjs.map +1 -0
  7. package/dist/{generators-B8HiBWvT.js → generators-hPE06pZB.js} +7 -7
  8. package/dist/generators-hPE06pZB.js.map +1 -0
  9. package/dist/generators.cjs +1 -1
  10. package/dist/generators.d.ts +4 -3
  11. package/dist/generators.js +1 -1
  12. package/dist/{getFooter-Pw3tLCiV.js → getFooter-Dz4u5Mg4.js} +5 -2
  13. package/dist/getFooter-Dz4u5Mg4.js.map +1 -0
  14. package/dist/{getFooter-BBzsC616.cjs → getFooter-gshcRE1-.cjs} +5 -2
  15. package/dist/getFooter-gshcRE1-.cjs.map +1 -0
  16. package/dist/hooks.cjs +25 -21
  17. package/dist/hooks.cjs.map +1 -1
  18. package/dist/hooks.d.ts +10 -7
  19. package/dist/hooks.js +27 -23
  20. package/dist/hooks.js.map +1 -1
  21. package/dist/index.cjs +50 -45
  22. package/dist/index.cjs.map +1 -1
  23. package/dist/index.d.ts +26 -52
  24. package/dist/index.js +49 -44
  25. package/dist/index.js.map +1 -1
  26. package/dist/mocks.d.ts +1 -1
  27. package/dist/{requestBody-BJJL0mpy.cjs → requestBody-94hwM4b-.cjs} +115 -304
  28. package/dist/requestBody-94hwM4b-.cjs.map +1 -0
  29. package/dist/{requestBody-CSL-jLGQ.js → requestBody-BO3N7fWH.js} +107 -290
  30. package/dist/requestBody-BO3N7fWH.js.map +1 -0
  31. package/dist/utils.cjs +61 -11
  32. package/dist/utils.cjs.map +1 -1
  33. package/dist/utils.d.ts +4 -4
  34. package/dist/utils.js +61 -11
  35. package/dist/utils.js.map +1 -1
  36. package/package.json +8 -12
  37. package/src/OperationGenerator.ts +72 -86
  38. package/src/SchemaGenerator.ts +61 -82
  39. package/src/SchemaMapper.ts +2 -2
  40. package/src/generators/createGenerator.ts +13 -16
  41. package/src/generators/createReactGenerator.ts +12 -15
  42. package/src/generators/index.ts +2 -2
  43. package/src/generators/jsonGenerator.ts +3 -3
  44. package/src/generators/types.ts +5 -43
  45. package/src/hooks/useOas.ts +5 -2
  46. package/src/hooks/useOperationManager.ts +22 -21
  47. package/src/hooks/useSchemaManager.ts +8 -8
  48. package/src/index.ts +2 -2
  49. package/src/plugin.ts +13 -9
  50. package/src/types.ts +15 -8
  51. package/src/utils/getBanner.ts +1 -1
  52. package/src/utils/getFooter.ts +1 -1
  53. package/src/utils/getImports.ts +3 -3
  54. package/src/utils/getParams.ts +2 -2
  55. package/src/utils.tsx +51 -151
  56. package/dist/generators-B8HiBWvT.js.map +0 -1
  57. package/dist/generators-vAAte6w6.cjs.map +0 -1
  58. package/dist/getFooter-BBzsC616.cjs.map +0 -1
  59. package/dist/getFooter-Pw3tLCiV.js.map +0 -1
  60. package/dist/requestBody-BJJL0mpy.cjs.map +0 -1
  61. package/dist/requestBody-CSL-jLGQ.js.map +0 -1
@@ -1,38 +1,32 @@
1
+ import type { AsyncEventEmitter } from '@internals/utils'
1
2
  import { getUniqueName, pascalCase, stringify } from '@internals/utils'
2
- import type { AsyncEventEmitter, FileMetaBase, KubbEvents, Plugin, PluginFactoryOptions, PluginManager, ResolveNameParams } from '@kubb/core'
3
- import type { KubbFile } from '@kubb/fabric-core/types'
3
+ import type { FileMetaBase, KubbEvents, Plugin, PluginDriver, PluginFactoryOptions, ResolveNameParams } from '@kubb/core'
4
+ import type { FabricFile, Fabric as FabricType } from '@kubb/fabric-core/types'
4
5
  import type { contentType, Oas, OasTypes, OpenAPIV3, SchemaObject } from '@kubb/oas'
5
6
  import { isDiscriminator, isNullable, isReference, KUBB_INLINE_REF_PREFIX } from '@kubb/oas'
6
- import type { Fabric } from '@kubb/react-fabric'
7
- import pLimit from 'p-limit'
8
7
  import { isDeepEqual, isNumber, uniqueWith } from 'remeda'
9
8
  import type { CoreGenerator } from './generators/createGenerator.ts'
10
9
  import type { ReactGenerator } from './generators/createReactGenerator.ts'
11
- import type { Generator, Version } from './generators/types.ts'
10
+ import type { Generator } from './generators/types.ts'
12
11
  import { isKeyword, type Schema, type SchemaKeywordMapper, schemaKeywords } from './SchemaMapper.ts'
13
12
  import type { OperationSchema, Override, Refs } from './types.ts'
14
13
  import { getSchemaFactory } from './utils/getSchemaFactory.ts'
15
- import { buildSchema } from './utils.tsx'
14
+ import { renderSchema } from './utils.tsx'
16
15
 
17
16
  export type GetSchemaGeneratorOptions<T extends SchemaGenerator<any, any, any>> = T extends SchemaGenerator<infer Options, any, any> ? Options : never
18
17
 
19
- export type SchemaMethodResult<TFileMeta extends FileMetaBase> = Promise<KubbFile.File<TFileMeta> | Array<KubbFile.File<TFileMeta>> | null>
20
-
21
- /** Max concurrent generator tasks (across generators). */
22
- const GENERATOR_CONCURRENCY = 3
23
- /** Max concurrent schema parsing tasks (per generator). */
24
- const SCHEMA_CONCURRENCY = 30
18
+ export type SchemaMethodResult<TFileMeta extends FileMetaBase> = Promise<FabricFile.File<TFileMeta> | Array<FabricFile.File<TFileMeta>> | null>
25
19
 
26
20
  type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
27
- fabric: Fabric
21
+ fabric: FabricType
28
22
  oas: Oas
29
- pluginManager: PluginManager
23
+ driver: PluginDriver
30
24
  events?: AsyncEventEmitter<KubbEvents>
31
25
  /**
32
26
  * Current plugin
33
27
  */
34
28
  plugin: Plugin<TPluginOptions>
35
- mode: KubbFile.Mode
29
+ mode: FabricFile.Mode
36
30
  include?: Array<'schemas' | 'responses' | 'requestBodies'>
37
31
  override: Array<Override<TOptions>> | undefined
38
32
  contentType?: contentType
@@ -524,18 +518,18 @@ export class SchemaGenerator<
524
518
  // Use the full $ref path to look up the collision-resolved name
525
519
  const resolvedName = this.#schemaNameMapping.get($ref) || originalName
526
520
 
527
- const propertyName = this.context.pluginManager.resolveName({
521
+ const propertyName = this.context.driver.resolveName({
528
522
  name: resolvedName,
529
523
  pluginName: this.context.plugin.name,
530
524
  type: 'function',
531
525
  })
532
526
 
533
- const fileName = this.context.pluginManager.resolveName({
527
+ const fileName = this.context.driver.resolveName({
534
528
  name: resolvedName,
535
529
  pluginName: this.context.plugin.name,
536
530
  type: 'file',
537
531
  })
538
- const file = this.context.pluginManager.getFile({
532
+ const file = this.context.driver.getFile({
539
533
  name: fileName,
540
534
  pluginName: this.context.plugin.name,
541
535
  extname: '.ts',
@@ -968,7 +962,7 @@ export class SchemaGenerator<
968
962
  const enumName = useCollisionDetection
969
963
  ? pascalCase(enumNameParts.join(' '))
970
964
  : getUniqueName(pascalCase(enumNameParts.join(' ')), this.options.usedEnumNames || {})
971
- const typeName = this.context.pluginManager.resolveName({
965
+ const typeName = this.context.driver.resolveName({
972
966
  name: enumName,
973
967
  pluginName: this.context.plugin.name,
974
968
  type: 'type',
@@ -1337,7 +1331,7 @@ export class SchemaGenerator<
1337
1331
  return [{ keyword: emptyType }, ...baseItems]
1338
1332
  }
1339
1333
 
1340
- async build(...generators: Array<Generator<TPluginOptions, Version>>): Promise<Array<KubbFile.File<TFileMeta>>> {
1334
+ async build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<FabricFile.File<TFileMeta>>> {
1341
1335
  const { oas, contentType, include } = this.context
1342
1336
 
1343
1337
  // Initialize the name mapping if not already done
@@ -1360,83 +1354,68 @@ export class SchemaGenerator<
1360
1354
  return this.#doBuild(schemas, generators)
1361
1355
  }
1362
1356
 
1363
- async #doBuild(
1364
- schemas: Record<string, OasTypes.SchemaObject>,
1365
- generators: Array<Generator<TPluginOptions, Version>>,
1366
- ): Promise<Array<KubbFile.File<TFileMeta>>> {
1357
+ async #doBuild(schemas: Record<string, OasTypes.SchemaObject>, generators: Array<Generator<TPluginOptions>>): Promise<Array<FabricFile.File<TFileMeta>>> {
1367
1358
  const schemaEntries = Object.entries(schemas)
1368
1359
 
1369
- const generatorLimit = pLimit(GENERATOR_CONCURRENCY)
1370
- const schemaLimit = pLimit(SCHEMA_CONCURRENCY)
1360
+ const results: Array<FabricFile.File<TFileMeta>> = []
1371
1361
 
1372
- const writeTasks = generators.map((generator) =>
1373
- generatorLimit(async () => {
1374
- if (generator.version === '2') {
1375
- return []
1376
- }
1362
+ for (const generator of generators) {
1363
+ if (!('type' in generator)) {
1364
+ continue
1365
+ }
1377
1366
 
1378
- // After the v2 guard above, all generators here are v1
1379
- const v1Generator = generator as ReactGenerator<TPluginOptions, '1'> | CoreGenerator<TPluginOptions, '1'>
1367
+ // After the v2 guard above, all generators here are v1
1368
+ const v1Generator = generator as ReactGenerator<TPluginOptions> | CoreGenerator<TPluginOptions>
1380
1369
 
1381
- const schemaTasks = schemaEntries.map(([name, schemaObject]) =>
1382
- schemaLimit(async () => {
1383
- const options = this.#getOptions(name)
1370
+ for (const [name, schemaObject] of schemaEntries) {
1371
+ const options = this.#getOptions(name)
1384
1372
 
1385
- const tree = this.parse({ schema: schemaObject as SchemaObject, name, parentName: null, rootName: name })
1373
+ const tree = this.parse({ schema: schemaObject as SchemaObject, name, parentName: null, rootName: name })
1386
1374
 
1387
- if (v1Generator.type === 'react') {
1388
- await buildSchema(
1389
- {
1390
- name,
1391
- value: schemaObject as SchemaObject,
1392
- tree,
1393
- },
1394
- {
1395
- config: this.context.pluginManager.config,
1396
- fabric: this.context.fabric,
1397
- Component: v1Generator.Schema,
1398
- generator: this,
1399
- plugin: {
1400
- ...this.context.plugin,
1401
- options: {
1402
- ...this.options,
1403
- ...options,
1404
- },
1405
- },
1406
- },
1407
- )
1408
-
1409
- return []
1410
- }
1411
-
1412
- const result = await v1Generator.schema?.({
1413
- config: this.context.pluginManager.config,
1375
+ if (v1Generator.type === 'react') {
1376
+ await renderSchema(
1377
+ {
1378
+ name,
1379
+ value: schemaObject as SchemaObject,
1380
+ tree,
1381
+ },
1382
+ {
1383
+ config: this.context.driver.config,
1384
+ fabric: this.context.fabric,
1385
+ Component: v1Generator.Schema,
1414
1386
  generator: this,
1415
- schema: {
1416
- name,
1417
- value: schemaObject as SchemaObject,
1418
- tree,
1419
- },
1420
1387
  plugin: {
1421
1388
  ...this.context.plugin,
1422
1389
  options: {
1423
1390
  ...this.options,
1424
1391
  ...options,
1425
- },
1392
+ } as unknown as Plugin<TPluginOptions>['options'],
1426
1393
  },
1427
- })
1428
-
1429
- return result ?? []
1430
- }),
1431
- )
1432
-
1433
- const schemaResults = await Promise.all(schemaTasks)
1434
- return schemaResults.flat() as unknown as KubbFile.File<TFileMeta>
1435
- }),
1436
- )
1394
+ },
1395
+ )
1396
+ } else {
1397
+ const result = await v1Generator.schema?.({
1398
+ config: this.context.driver.config,
1399
+ generator: this,
1400
+ schema: {
1401
+ name,
1402
+ value: schemaObject as SchemaObject,
1403
+ tree,
1404
+ },
1405
+ plugin: {
1406
+ ...this.context.plugin,
1407
+ options: {
1408
+ ...this.options,
1409
+ ...options,
1410
+ } as unknown as Plugin<TPluginOptions>['options'],
1411
+ },
1412
+ })
1437
1413
 
1438
- const nestedResults = await Promise.all(writeTasks)
1414
+ results.push(...([result ?? []].flat() as Array<FabricFile.File<TFileMeta>>))
1415
+ }
1416
+ }
1417
+ }
1439
1418
 
1440
- return nestedResults.flat()
1419
+ return results
1441
1420
  }
1442
1421
  }
@@ -1,4 +1,4 @@
1
- import type { KubbFile } from '@kubb/fabric-core/types'
1
+ import type { FabricFile } from '@kubb/fabric-core/types'
2
2
  import type { SchemaObject } from '@kubb/oas'
3
3
 
4
4
  export type SchemaKeywordMapper = {
@@ -59,7 +59,7 @@ export type SchemaKeywordMapper = {
59
59
  /**
60
60
  * Full qualified path.
61
61
  */
62
- path: KubbFile.Path
62
+ path: FabricFile.Path
63
63
  /**
64
64
  * When true `File.Import` is used.
65
65
  * When false a reference is used inside the current file.
@@ -1,30 +1,27 @@
1
1
  import type { PluginFactoryOptions } from '@kubb/core'
2
- import type { KubbFile } from '@kubb/fabric-core/types'
3
- import type { OperationProps, OperationsProps, SchemaProps, Version } from './types.ts'
2
+ import type { FabricFile } from '@kubb/fabric-core/types'
3
+ import type { OperationProps, OperationsProps, SchemaProps } from './types.ts'
4
4
 
5
- type UserGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version> = {
5
+ type UserGenerator<TOptions extends PluginFactoryOptions> = {
6
6
  name: string
7
- version?: TVersion
8
- operations?: (props: OperationsProps<TOptions, TVersion>) => Promise<KubbFile.File[]>
9
- operation?: (props: OperationProps<TOptions, TVersion>) => Promise<KubbFile.File[]>
10
- schema?: (props: SchemaProps<TOptions, TVersion>) => Promise<KubbFile.File[]>
7
+ operations?: (props: OperationsProps<TOptions>) => Promise<FabricFile.File[]>
8
+ operation?: (props: OperationProps<TOptions>) => Promise<FabricFile.File[]>
9
+ schema?: (props: SchemaProps<TOptions>) => Promise<FabricFile.File[]>
11
10
  }
12
11
 
13
- export type CoreGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version> = {
12
+ export type CoreGenerator<TOptions extends PluginFactoryOptions> = {
14
13
  name: string
15
14
  type: 'core'
16
- version: TVersion
17
- operations: (props: OperationsProps<TOptions, TVersion>) => Promise<KubbFile.File[]>
18
- operation: (props: OperationProps<TOptions, TVersion>) => Promise<KubbFile.File[]>
19
- schema: (props: SchemaProps<TOptions, TVersion>) => Promise<KubbFile.File[]>
15
+ version: '1'
16
+ operations: (props: OperationsProps<TOptions>) => Promise<FabricFile.File[]>
17
+ operation: (props: OperationProps<TOptions>) => Promise<FabricFile.File[]>
18
+ schema: (props: SchemaProps<TOptions>) => Promise<FabricFile.File[]>
20
19
  }
21
20
 
22
- export function createGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version = '1'>(
23
- generator: UserGenerator<TOptions, TVersion>,
24
- ): CoreGenerator<TOptions, TVersion> {
21
+ export function createGenerator<TOptions extends PluginFactoryOptions>(generator: UserGenerator<TOptions>): CoreGenerator<TOptions> {
25
22
  return {
26
23
  type: 'core',
27
- version: (generator.version ?? '1') as TVersion,
24
+ version: '1',
28
25
  async operations() {
29
26
  return []
30
27
  },
@@ -1,22 +1,21 @@
1
1
  import type { PluginFactoryOptions } from '@kubb/core'
2
2
  import type { FabricReactNode } from '@kubb/react-fabric/types'
3
- import type { OperationProps, OperationsProps, SchemaProps, Version } from './types.ts'
3
+ import type { OperationProps, OperationsProps, SchemaProps } from './types.ts'
4
4
 
5
- type UserGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version> = {
5
+ type UserGenerator<TOptions extends PluginFactoryOptions> = {
6
6
  name: string
7
- version?: TVersion
8
- Operations?: (props: OperationsProps<TOptions, TVersion>) => FabricReactNode
9
- Operation?: (props: OperationProps<TOptions, TVersion>) => FabricReactNode
10
- Schema?: (props: SchemaProps<TOptions, TVersion>) => FabricReactNode
7
+ Operations?: (props: OperationsProps<TOptions>) => FabricReactNode
8
+ Operation?: (props: OperationProps<TOptions>) => FabricReactNode
9
+ Schema?: (props: SchemaProps<TOptions>) => FabricReactNode
11
10
  }
12
11
 
13
- export type ReactGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version> = {
12
+ export type ReactGenerator<TOptions extends PluginFactoryOptions> = {
14
13
  name: string
15
14
  type: 'react'
16
- version: TVersion
17
- Operations: (props: OperationsProps<TOptions, TVersion>) => FabricReactNode
18
- Operation: (props: OperationProps<TOptions, TVersion>) => FabricReactNode
19
- Schema: (props: SchemaProps<TOptions, TVersion>) => FabricReactNode
15
+ version: '1'
16
+ Operations: (props: OperationsProps<TOptions>) => FabricReactNode
17
+ Operation: (props: OperationProps<TOptions>) => FabricReactNode
18
+ Schema: (props: SchemaProps<TOptions>) => FabricReactNode
20
19
  }
21
20
 
22
21
  /****
@@ -26,12 +25,10 @@ export type ReactGenerator<TOptions extends PluginFactoryOptions, TVersion exten
26
25
  *
27
26
  * @returns A generator object with async methods for operations, operation, and schema file generation.
28
27
  */
29
- export function createReactGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version = '1'>(
30
- generator: UserGenerator<TOptions, TVersion>,
31
- ): ReactGenerator<TOptions, TVersion> {
28
+ export function createReactGenerator<TOptions extends PluginFactoryOptions>(generator: UserGenerator<TOptions>): ReactGenerator<TOptions> {
32
29
  return {
33
30
  type: 'react',
34
- version: (generator.version ?? '1') as TVersion,
31
+ version: '1',
35
32
  Operations() {
36
33
  return null
37
34
  },
@@ -1,4 +1,4 @@
1
- export { createGenerator } from './createGenerator.ts'
2
- export { createReactGenerator } from './createReactGenerator.ts'
1
+ export { type CoreGenerator, createGenerator } from './createGenerator.ts'
2
+ export { createReactGenerator, type ReactGenerator } from './createReactGenerator.ts'
3
3
  export { jsonGenerator } from './jsonGenerator.ts'
4
4
  export type { Generator } from './types.ts'
@@ -7,8 +7,8 @@ import { createGenerator } from './createGenerator.ts'
7
7
  export const jsonGenerator = createGenerator<PluginOas>({
8
8
  name: 'plugin-oas',
9
9
  async schema({ schema, generator }) {
10
- const { pluginManager, plugin } = generator.context
11
- const file = pluginManager.getFile({
10
+ const { driver, plugin } = generator.context
11
+ const file = driver.getFile({
12
12
  name: camelCase(schema.name),
13
13
  extname: '.json',
14
14
  mode: 'split',
@@ -29,7 +29,7 @@ export const jsonGenerator = createGenerator<PluginOas>({
29
29
  banner: getBanner({
30
30
  oas: generator.context.oas,
31
31
  output: plugin.options.output,
32
- config: pluginManager.config,
32
+ config: driver.config,
33
33
  }),
34
34
  format: getFooter({ oas: generator.context.oas, output: plugin.options.output }),
35
35
  },
@@ -1,5 +1,4 @@
1
- import type { OperationNode, SchemaNode } from '@kubb/ast/types'
2
- import type { Adapter, Config, Plugin, PluginFactoryOptions } from '@kubb/core'
1
+ import type { Config, Generator as CoreV2Generator, Plugin, PluginFactoryOptions } from '@kubb/core'
3
2
  import type { Operation, SchemaObject } from '@kubb/oas'
4
3
  import type { OperationGenerator } from '../OperationGenerator.ts'
5
4
  import type { SchemaGenerator, SchemaGeneratorOptions } from '../SchemaGenerator.ts'
@@ -7,45 +6,21 @@ import type { Schema } from '../SchemaMapper.ts'
7
6
  import type { CoreGenerator } from './createGenerator.ts'
8
7
  import type { ReactGenerator } from './createReactGenerator.ts'
9
8
 
10
- export type Version = '1' | '2'
11
-
12
- export type OperationsV1Props<TOptions extends PluginFactoryOptions> = {
9
+ export type OperationsProps<TOptions extends PluginFactoryOptions> = {
13
10
  config: Config
14
11
  generator: Omit<OperationGenerator<TOptions>, 'build'>
15
12
  plugin: Plugin<TOptions>
16
13
  operations: Array<Operation>
17
14
  }
18
15
 
19
- export type OperationsV2Props<TOptions extends PluginFactoryOptions> = {
20
- config: Config
21
- adapter: Adapter
22
- options: Plugin<TOptions>['options']
23
- nodes: Array<OperationNode>
24
- }
25
-
26
- export type OperationV1Props<TOptions extends PluginFactoryOptions> = {
16
+ export type OperationProps<TOptions extends PluginFactoryOptions> = {
27
17
  config: Config
28
18
  generator: Omit<OperationGenerator<TOptions>, 'build'>
29
19
  plugin: Plugin<TOptions>
30
20
  operation: Operation
31
21
  }
32
22
 
33
- export type OperationV2Props<TOptions extends PluginFactoryOptions> = {
34
- config: Config
35
- adapter: Adapter
36
- options: Plugin<TOptions>['options']
37
- node: OperationNode
38
- }
39
-
40
- export type OperationsProps<TOptions extends PluginFactoryOptions, TVersion extends Version = '1'> = TVersion extends '2'
41
- ? OperationsV2Props<TOptions>
42
- : OperationsV1Props<TOptions>
43
-
44
- export type OperationProps<TOptions extends PluginFactoryOptions, TVersion extends Version = '1'> = TVersion extends '2'
45
- ? OperationV2Props<TOptions>
46
- : OperationV1Props<TOptions>
47
-
48
- export type SchemaV1Props<TOptions extends PluginFactoryOptions> = {
23
+ export type SchemaProps<TOptions extends PluginFactoryOptions> = {
49
24
  config: Config
50
25
  generator: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>
51
26
  plugin: Plugin<TOptions>
@@ -56,17 +31,4 @@ export type SchemaV1Props<TOptions extends PluginFactoryOptions> = {
56
31
  }
57
32
  }
58
33
 
59
- export type SchemaV2Props<TOptions extends PluginFactoryOptions> = {
60
- config: Config
61
- options: Plugin<TOptions>['options']
62
- node: SchemaNode
63
- adapter: Adapter
64
- }
65
-
66
- export type SchemaProps<TOptions extends PluginFactoryOptions, TVersion extends Version = '1'> = TVersion extends '2'
67
- ? SchemaV2Props<TOptions>
68
- : SchemaV1Props<TOptions>
69
-
70
- export type Generator<TOptions extends PluginFactoryOptions, TVersion extends Version = Version> =
71
- | CoreGenerator<TOptions, TVersion>
72
- | ReactGenerator<TOptions, TVersion>
34
+ export type Generator<TOptions extends PluginFactoryOptions> = CoreGenerator<TOptions> | ReactGenerator<TOptions> | CoreV2Generator<TOptions>
@@ -1,9 +1,12 @@
1
1
  import type { Oas } from '@kubb/oas'
2
2
 
3
- import { useApp } from '@kubb/react-fabric'
3
+ import { useFabric } from '@kubb/react-fabric'
4
4
 
5
+ /**
6
+ * @deprecated use schemaNode or operationNode instead
7
+ */
5
8
  export function useOas(): Oas {
6
- const { meta } = useApp<{ oas: Oas }>()
9
+ const { meta } = useFabric<{ oas: Oas }>()
7
10
 
8
11
  return meta.oas
9
12
  }
@@ -1,6 +1,6 @@
1
1
  import type { FileMetaBase, PluginFactoryOptions, ResolveNameParams } from '@kubb/core'
2
- import { usePlugin, usePluginManager } from '@kubb/core/hooks'
3
- import type { KubbFile } from '@kubb/fabric-core/types'
2
+ import { useDriver, usePlugin } from '@kubb/core/hooks'
3
+ import type { FabricFile } from '@kubb/fabric-core/types'
4
4
  import type { Operation, Operation as OperationType } from '@kubb/oas'
5
5
  import type { OperationGenerator } from '../OperationGenerator.ts'
6
6
  import type { OperationSchemas } from '../types.ts'
@@ -41,13 +41,13 @@ type UseOperationManagerResult = {
41
41
  prefix?: string
42
42
  suffix?: string
43
43
  pluginName?: string
44
- extname?: KubbFile.Extname
44
+ extname?: FabricFile.Extname
45
45
  group?: {
46
46
  tag?: string
47
47
  path?: string
48
48
  }
49
49
  },
50
- ) => KubbFile.File<FileMeta>
50
+ ) => FabricFile.File<FileMeta>
51
51
  groupSchemasByName: (
52
52
  operation: OperationType,
53
53
  params: {
@@ -66,10 +66,11 @@ export function useOperationManager<TPluginOptions extends PluginFactoryOptions
66
66
  generator: Omit<OperationGenerator<TPluginOptions>, 'build'>,
67
67
  ): UseOperationManagerResult {
68
68
  const plugin = usePlugin()
69
- const pluginManager = usePluginManager()
69
+ const driver = useDriver()
70
+ const defaultPluginName = plugin.name
70
71
 
71
- const getName: UseOperationManagerResult['getName'] = (operation, { prefix = '', suffix = '', pluginName = plugin.name, type }) => {
72
- return pluginManager.resolveName({
72
+ const getName: UseOperationManagerResult['getName'] = (operation, { prefix = '', suffix = '', pluginName = defaultPluginName, type }) => {
73
+ return driver.resolveName({
73
74
  name: `${prefix} ${operation.getOperationId()} ${suffix}`,
74
75
  pluginName,
75
76
  type,
@@ -78,7 +79,7 @@ export function useOperationManager<TPluginOptions extends PluginFactoryOptions
78
79
 
79
80
  const getGroup: UseOperationManagerResult['getGroup'] = (operation) => {
80
81
  return {
81
- tag: operation.getTags().at(0)?.name,
82
+ tag: operation.getTags().at(0)?.name ?? 'default',
82
83
  path: operation.path,
83
84
  }
84
85
  }
@@ -90,19 +91,19 @@ export function useOperationManager<TPluginOptions extends PluginFactoryOptions
90
91
 
91
92
  return generator.getSchemas(operation, {
92
93
  resolveName: (name) =>
93
- pluginManager.resolveName({
94
+ driver.resolveName({
94
95
  name,
95
- pluginName: params?.pluginName,
96
+ pluginName: params?.pluginName ?? defaultPluginName,
96
97
  type: params?.type,
97
98
  }),
98
99
  })
99
100
  }
100
101
 
101
- const getFile: UseOperationManagerResult['getFile'] = (operation, { prefix, suffix, pluginName = plugin.name, extname = '.ts' } = {}) => {
102
+ const getFile: UseOperationManagerResult['getFile'] = (operation, { prefix, suffix, pluginName = defaultPluginName, extname = '.ts' } = {}) => {
102
103
  const name = getName(operation, { type: 'file', pluginName, prefix, suffix })
103
104
  const group = getGroup(operation)
104
105
 
105
- const file = pluginManager.getFile({
106
+ const file = driver.getFile({
106
107
  name,
107
108
  extname,
108
109
  pluginName,
@@ -120,12 +121,12 @@ export function useOperationManager<TPluginOptions extends PluginFactoryOptions
120
121
  }
121
122
  }
122
123
 
123
- const groupSchemasByName: UseOperationManagerResult['groupSchemasByName'] = (operation, { pluginName = plugin.name, type }) => {
124
+ const groupSchemasByName: UseOperationManagerResult['groupSchemasByName'] = (operation, { pluginName = defaultPluginName, type }) => {
124
125
  if (!generator) {
125
126
  throw new Error(`useOperationManager: 'generator' parameter is required but was not provided`)
126
127
  }
127
128
 
128
- const schemas = generator.getSchemas(operation)
129
+ const schemas = getSchemas(operation)
129
130
 
130
131
  const errors = (schemas.errors || []).reduce(
131
132
  (prev, acc) => {
@@ -133,7 +134,7 @@ export function useOperationManager<TPluginOptions extends PluginFactoryOptions
133
134
  return prev
134
135
  }
135
136
 
136
- prev[acc.statusCode] = pluginManager.resolveName({
137
+ prev[acc.statusCode] = driver.resolveName({
137
138
  name: acc.name,
138
139
  pluginName,
139
140
  type,
@@ -150,7 +151,7 @@ export function useOperationManager<TPluginOptions extends PluginFactoryOptions
150
151
  return prev
151
152
  }
152
153
 
153
- prev[acc.statusCode] = pluginManager.resolveName({
154
+ prev[acc.statusCode] = driver.resolveName({
154
155
  name: acc.name,
155
156
  pluginName,
156
157
  type,
@@ -163,7 +164,7 @@ export function useOperationManager<TPluginOptions extends PluginFactoryOptions
163
164
 
164
165
  return {
165
166
  request: schemas.request?.name
166
- ? pluginManager.resolveName({
167
+ ? driver.resolveName({
167
168
  name: schemas.request.name,
168
169
  pluginName,
169
170
  type,
@@ -171,21 +172,21 @@ export function useOperationManager<TPluginOptions extends PluginFactoryOptions
171
172
  : undefined,
172
173
  parameters: {
173
174
  path: schemas.pathParams?.name
174
- ? pluginManager.resolveName({
175
+ ? driver.resolveName({
175
176
  name: schemas.pathParams.name,
176
177
  pluginName,
177
178
  type,
178
179
  })
179
180
  : undefined,
180
181
  query: schemas.queryParams?.name
181
- ? pluginManager.resolveName({
182
+ ? driver.resolveName({
182
183
  name: schemas.queryParams.name,
183
184
  pluginName,
184
185
  type,
185
186
  })
186
187
  : undefined,
187
188
  header: schemas.headerParams?.name
188
- ? pluginManager.resolveName({
189
+ ? driver.resolveName({
189
190
  name: schemas.headerParams.name,
190
191
  pluginName,
191
192
  type,
@@ -194,7 +195,7 @@ export function useOperationManager<TPluginOptions extends PluginFactoryOptions
194
195
  },
195
196
  responses: {
196
197
  ...responses,
197
- ['default']: pluginManager.resolveName({
198
+ ['default']: driver.resolveName({
198
199
  name: schemas.response.name,
199
200
  pluginName,
200
201
  type,
@@ -1,6 +1,6 @@
1
1
  import type { FileMetaBase, ResolveNameParams } from '@kubb/core'
2
- import { usePlugin, usePluginManager } from '@kubb/core/hooks'
3
- import type { KubbFile } from '@kubb/fabric-core/types'
2
+ import { useDriver, usePlugin } from '@kubb/core/hooks'
3
+ import type { FabricFile } from '@kubb/fabric-core/types'
4
4
 
5
5
  type FileMeta = FileMetaBase & {
6
6
  pluginName: string
@@ -17,14 +17,14 @@ type UseSchemaManagerResult = {
17
17
  name: string,
18
18
  params?: {
19
19
  pluginName?: string
20
- mode?: KubbFile.Mode
21
- extname?: KubbFile.Extname
20
+ mode?: FabricFile.Mode
21
+ extname?: FabricFile.Extname
22
22
  group?: {
23
23
  tag?: string
24
24
  path?: string
25
25
  }
26
26
  },
27
- ) => KubbFile.File<FileMeta>
27
+ ) => FabricFile.File<FileMeta>
28
28
  }
29
29
 
30
30
  /**
@@ -33,10 +33,10 @@ type UseSchemaManagerResult = {
33
33
  */
34
34
  export function useSchemaManager(): UseSchemaManagerResult {
35
35
  const plugin = usePlugin()
36
- const pluginManager = usePluginManager()
36
+ const driver = useDriver()
37
37
 
38
38
  const getName: UseSchemaManagerResult['getName'] = (name, { pluginName = plugin.name, type }) => {
39
- return pluginManager.resolveName({
39
+ return driver.resolveName({
40
40
  name,
41
41
  pluginName,
42
42
  type,
@@ -46,7 +46,7 @@ export function useSchemaManager(): UseSchemaManagerResult {
46
46
  const getFile: UseSchemaManagerResult['getFile'] = (name, { mode = 'split', pluginName = plugin.name, extname = '.ts', group } = {}) => {
47
47
  const resolvedName = mode === 'single' ? '' : getName(name, { type: 'file', pluginName })
48
48
 
49
- const file = pluginManager.getFile({
49
+ const file = driver.getFile({
50
50
  name: resolvedName,
51
51
  extname,
52
52
  pluginName,
package/src/index.ts CHANGED
@@ -25,7 +25,7 @@ export type {
25
25
  } from './SchemaMapper.ts'
26
26
  export { isKeyword, schemaKeywords } from './SchemaMapper.ts'
27
27
  export type * from './types.ts'
28
- export { buildOperation, buildOperations, buildSchema } from './utils.tsx'
28
+ export { renderOperation, renderOperations, renderSchema } from './utils.tsx'
29
29
 
30
30
  /**
31
31
  * @deprecated use `import { createGenerator } from '@kubb/plugin-oas/generators'`
@@ -40,4 +40,4 @@ export const createReactGenerator = _createReactGenerator
40
40
  /**
41
41
  * @deprecated use `import { Generator } from '@kubb/plugin-oas/generators'`
42
42
  */
43
- export type Generator<TOptions extends PluginFactoryOptions, TVersion extends import('./generators/types.ts').Version = '1'> = _Generator<TOptions, TVersion>
43
+ export type Generator<TOptions extends PluginFactoryOptions> = _Generator<TOptions>