@kubb/plugin-oas 4.36.1 → 5.0.0-alpha.10

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 (47) hide show
  1. package/dist/{createGenerator-CBXpHeVY.d.ts → createGenerator-Cl7uTbJt.d.ts} +67 -61
  2. package/dist/{generators-CyWd3UXA.cjs → generators-BfTTScuN.cjs} +7 -7
  3. package/dist/generators-BfTTScuN.cjs.map +1 -0
  4. package/dist/{generators-D7C3CXsN.js → generators-BjsINk-u.js} +7 -7
  5. package/dist/generators-BjsINk-u.js.map +1 -0
  6. package/dist/generators.cjs +1 -1
  7. package/dist/generators.d.ts +2 -2
  8. package/dist/generators.js +1 -1
  9. package/dist/hooks.cjs +42 -62
  10. package/dist/hooks.cjs.map +1 -1
  11. package/dist/hooks.d.ts +15 -32
  12. package/dist/hooks.js +45 -64
  13. package/dist/hooks.js.map +1 -1
  14. package/dist/index.cjs +10 -10
  15. package/dist/index.cjs.map +1 -1
  16. package/dist/index.d.ts +26 -13
  17. package/dist/index.js +11 -11
  18. package/dist/index.js.map +1 -1
  19. package/dist/{requestBody-DIM-iDpM.cjs → requestBody-DyTNWJql.cjs} +45 -34
  20. package/dist/requestBody-DyTNWJql.cjs.map +1 -0
  21. package/dist/{requestBody-mUXoBwsu.js → requestBody-gV_d8sCu.js} +46 -35
  22. package/dist/requestBody-gV_d8sCu.js.map +1 -0
  23. package/dist/utils.cjs +1 -1
  24. package/dist/utils.cjs.map +1 -1
  25. package/dist/utils.d.ts +1 -1
  26. package/dist/utils.js +1 -1
  27. package/dist/utils.js.map +1 -1
  28. package/package.json +8 -8
  29. package/src/OperationGenerator.ts +12 -12
  30. package/src/SchemaGenerator.ts +19 -22
  31. package/src/generators/createGenerator.ts +12 -15
  32. package/src/generators/createReactGenerator.ts +12 -15
  33. package/src/generators/jsonGenerator.ts +4 -4
  34. package/src/generators/types.ts +5 -40
  35. package/src/hooks/index.ts +0 -1
  36. package/src/hooks/useOas.ts +5 -2
  37. package/src/hooks/useOperationManager.ts +34 -34
  38. package/src/hooks/useSchemaManager.ts +16 -15
  39. package/src/index.ts +1 -1
  40. package/src/plugin.ts +6 -6
  41. package/src/types.ts +7 -6
  42. package/src/utils.tsx +53 -35
  43. package/dist/generators-CyWd3UXA.cjs.map +0 -1
  44. package/dist/generators-D7C3CXsN.js.map +0 -1
  45. package/dist/requestBody-DIM-iDpM.cjs.map +0 -1
  46. package/dist/requestBody-mUXoBwsu.js.map +0 -1
  47. package/src/hooks/useRootNode.ts +0 -25
@@ -1,12 +1,12 @@
1
+ import type { AsyncEventEmitter } from '@internals/utils'
1
2
  import { pascalCase } from '@internals/utils'
2
- import type { AsyncEventEmitter, FileMetaBase, KubbEvents, Plugin, PluginFactoryOptions, PluginManager } from '@kubb/core'
3
- import type { KubbFile } from '@kubb/fabric-core/types'
3
+ import type { FileMetaBase, KubbEvents, Plugin, PluginDriver, PluginFactoryOptions } from '@kubb/core'
4
+ import type { Fabric as FabricType, KubbFile } from '@kubb/fabric-core/types'
4
5
  import type { contentType, HttpMethod, Oas, OasTypes, Operation, SchemaObject } from '@kubb/oas'
5
- import type { Fabric } from '@kubb/react-fabric'
6
6
  import pLimit from 'p-limit'
7
7
  import type { CoreGenerator } from './generators/createGenerator.ts'
8
8
  import type { ReactGenerator } from './generators/createReactGenerator.ts'
9
- import type { Generator, Version } from './generators/types.ts'
9
+ import type { Generator } from './generators/types.ts'
10
10
  import type { Exclude, Include, OperationSchemas, Override } from './types.ts'
11
11
  import { withRequiredRequestBodySchema } from './utils/requestBody.ts'
12
12
  import { buildOperation, buildOperations } from './utils.tsx'
@@ -14,13 +14,13 @@ import { buildOperation, buildOperations } from './utils.tsx'
14
14
  export type OperationMethodResult<TFileMeta extends FileMetaBase> = Promise<KubbFile.File<TFileMeta> | Array<KubbFile.File<TFileMeta>> | null>
15
15
 
16
16
  type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
17
- fabric: Fabric
17
+ fabric: FabricType
18
18
  oas: Oas
19
19
  exclude: Array<Exclude> | undefined
20
20
  include: Array<Include> | undefined
21
21
  override: Array<Override<TOptions>> | undefined
22
22
  contentType: contentType | undefined
23
- pluginManager: PluginManager
23
+ driver: PluginDriver
24
24
  events?: AsyncEventEmitter<KubbEvents>
25
25
  /**
26
26
  * Current plugin
@@ -206,7 +206,7 @@ export class OperationGenerator<TPluginOptions extends PluginFactoryOptions = Pl
206
206
  )
207
207
  }
208
208
 
209
- async build(...generators: Array<Generator<TPluginOptions, Version>>): Promise<Array<KubbFile.File<TFileMeta>>> {
209
+ async build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>> {
210
210
  const operations = await this.getOperations()
211
211
 
212
212
  // Increased parallelism for better performance
@@ -227,7 +227,7 @@ export class OperationGenerator<TPluginOptions extends PluginFactoryOptions = Pl
227
227
  }
228
228
 
229
229
  // After the v2 guard above, all generators here are v1
230
- const v1Generator = generator as ReactGenerator<TPluginOptions, '1'> | CoreGenerator<TPluginOptions, '1'>
230
+ const v1Generator = generator as ReactGenerator<TPluginOptions> | CoreGenerator<TPluginOptions>
231
231
 
232
232
  const operationTasks = operations.map(({ operation, method }) =>
233
233
  operationLimit(async () => {
@@ -235,7 +235,7 @@ export class OperationGenerator<TPluginOptions extends PluginFactoryOptions = Pl
235
235
 
236
236
  if (v1Generator.type === 'react') {
237
237
  await buildOperation(operation, {
238
- config: this.context.pluginManager.config,
238
+ config: this.context.driver.config,
239
239
  fabric: this.context.fabric,
240
240
  Component: v1Generator.Operation,
241
241
  generator: this,
@@ -253,7 +253,7 @@ export class OperationGenerator<TPluginOptions extends PluginFactoryOptions = Pl
253
253
 
254
254
  const result = await v1Generator.operation?.({
255
255
  generator: this,
256
- config: this.context.pluginManager.config,
256
+ config: this.context.driver.config,
257
257
  operation,
258
258
  plugin: {
259
259
  ...this.context.plugin,
@@ -276,7 +276,7 @@ export class OperationGenerator<TPluginOptions extends PluginFactoryOptions = Pl
276
276
  operations.map((op) => op.operation),
277
277
  {
278
278
  fabric: this.context.fabric,
279
- config: this.context.pluginManager.config,
279
+ config: this.context.driver.config,
280
280
  Component: v1Generator.Operations,
281
281
  generator: this,
282
282
  plugin: this.context.plugin,
@@ -288,7 +288,7 @@ export class OperationGenerator<TPluginOptions extends PluginFactoryOptions = Pl
288
288
 
289
289
  const operationsResult = await v1Generator.operations?.({
290
290
  generator: this,
291
- config: this.context.pluginManager.config,
291
+ config: this.context.driver.config,
292
292
  operations: operations.map((op) => op.operation),
293
293
  plugin: this.context.plugin,
294
294
  })
@@ -1,14 +1,14 @@
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 { Fabric as FabricType, KubbFile } 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
7
  import pLimit from 'p-limit'
8
8
  import { isDeepEqual, isNumber, uniqueWith } from 'remeda'
9
9
  import type { CoreGenerator } from './generators/createGenerator.ts'
10
10
  import type { ReactGenerator } from './generators/createReactGenerator.ts'
11
- import type { Generator, Version } from './generators/types.ts'
11
+ import type { Generator } from './generators/types.ts'
12
12
  import { isKeyword, type Schema, type SchemaKeywordMapper, schemaKeywords } from './SchemaMapper.ts'
13
13
  import type { OperationSchema, Override, Refs } from './types.ts'
14
14
  import { getSchemaFactory } from './utils/getSchemaFactory.ts'
@@ -24,9 +24,9 @@ const GENERATOR_CONCURRENCY = 3
24
24
  const SCHEMA_CONCURRENCY = 30
25
25
 
26
26
  type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
27
- fabric: Fabric
27
+ fabric: FabricType
28
28
  oas: Oas
29
- pluginManager: PluginManager
29
+ driver: PluginDriver
30
30
  events?: AsyncEventEmitter<KubbEvents>
31
31
  /**
32
32
  * Current plugin
@@ -524,20 +524,20 @@ export class SchemaGenerator<
524
524
  // Use the full $ref path to look up the collision-resolved name
525
525
  const resolvedName = this.#schemaNameMapping.get($ref) || originalName
526
526
 
527
- const propertyName = this.context.pluginManager.resolveName({
527
+ const propertyName = this.context.driver.resolveName({
528
528
  name: resolvedName,
529
- pluginKey: this.context.plugin.key,
529
+ pluginName: this.context.plugin.name,
530
530
  type: 'function',
531
531
  })
532
532
 
533
- const fileName = this.context.pluginManager.resolveName({
533
+ const fileName = this.context.driver.resolveName({
534
534
  name: resolvedName,
535
- pluginKey: this.context.plugin.key,
535
+ pluginName: this.context.plugin.name,
536
536
  type: 'file',
537
537
  })
538
- const file = this.context.pluginManager.getFile({
538
+ const file = this.context.driver.getFile({
539
539
  name: fileName,
540
- pluginKey: this.context.plugin.key,
540
+ pluginName: this.context.plugin.name,
541
541
  extname: '.ts',
542
542
  })
543
543
 
@@ -968,9 +968,9 @@ export class SchemaGenerator<
968
968
  const enumName = useCollisionDetection
969
969
  ? pascalCase(enumNameParts.join(' '))
970
970
  : getUniqueName(pascalCase(enumNameParts.join(' ')), this.options.usedEnumNames || {})
971
- const typeName = this.context.pluginManager.resolveName({
971
+ const typeName = this.context.driver.resolveName({
972
972
  name: enumName,
973
- pluginKey: this.context.plugin.key,
973
+ pluginName: this.context.plugin.name,
974
974
  type: 'type',
975
975
  })
976
976
 
@@ -1337,7 +1337,7 @@ export class SchemaGenerator<
1337
1337
  return [{ keyword: emptyType }, ...baseItems]
1338
1338
  }
1339
1339
 
1340
- async build(...generators: Array<Generator<TPluginOptions, Version>>): Promise<Array<KubbFile.File<TFileMeta>>> {
1340
+ async build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>> {
1341
1341
  const { oas, contentType, include } = this.context
1342
1342
 
1343
1343
  // Initialize the name mapping if not already done
@@ -1360,10 +1360,7 @@ export class SchemaGenerator<
1360
1360
  return this.#doBuild(schemas, generators)
1361
1361
  }
1362
1362
 
1363
- async #doBuild(
1364
- schemas: Record<string, OasTypes.SchemaObject>,
1365
- generators: Array<Generator<TPluginOptions, Version>>,
1366
- ): Promise<Array<KubbFile.File<TFileMeta>>> {
1363
+ async #doBuild(schemas: Record<string, OasTypes.SchemaObject>, generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>> {
1367
1364
  const schemaEntries = Object.entries(schemas)
1368
1365
 
1369
1366
  const generatorLimit = pLimit(GENERATOR_CONCURRENCY)
@@ -1376,7 +1373,7 @@ export class SchemaGenerator<
1376
1373
  }
1377
1374
 
1378
1375
  // After the v2 guard above, all generators here are v1
1379
- const v1Generator = generator as ReactGenerator<TPluginOptions, '1'> | CoreGenerator<TPluginOptions, '1'>
1376
+ const v1Generator = generator as ReactGenerator<TPluginOptions> | CoreGenerator<TPluginOptions>
1380
1377
 
1381
1378
  const schemaTasks = schemaEntries.map(([name, schemaObject]) =>
1382
1379
  schemaLimit(async () => {
@@ -1392,7 +1389,7 @@ export class SchemaGenerator<
1392
1389
  tree,
1393
1390
  },
1394
1391
  {
1395
- config: this.context.pluginManager.config,
1392
+ config: this.context.driver.config,
1396
1393
  fabric: this.context.fabric,
1397
1394
  Component: v1Generator.Schema,
1398
1395
  generator: this,
@@ -1410,7 +1407,7 @@ export class SchemaGenerator<
1410
1407
  }
1411
1408
 
1412
1409
  const result = await v1Generator.schema?.({
1413
- config: this.context.pluginManager.config,
1410
+ config: this.context.driver.config,
1414
1411
  generator: this,
1415
1412
  schema: {
1416
1413
  name,
@@ -1,30 +1,27 @@
1
1
  import type { PluginFactoryOptions } from '@kubb/core'
2
2
  import type { KubbFile } from '@kubb/fabric-core/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>) => 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<KubbFile.File[]>
8
+ operation?: (props: OperationProps<TOptions>) => Promise<KubbFile.File[]>
9
+ schema?: (props: SchemaProps<TOptions>) => Promise<KubbFile.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<KubbFile.File[]>
17
+ operation: (props: OperationProps<TOptions>) => Promise<KubbFile.File[]>
18
+ schema: (props: SchemaProps<TOptions>) => Promise<KubbFile.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
  },
@@ -7,12 +7,12 @@ 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',
15
- pluginKey: plugin.key,
15
+ pluginName: plugin.name,
16
16
  })
17
17
 
18
18
  return [
@@ -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 { 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,43 +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
- plugin: Plugin<TOptions>
22
- nodes: Array<OperationNode>
23
- }
24
-
25
- export type OperationV1Props<TOptions extends PluginFactoryOptions> = {
16
+ export type OperationProps<TOptions extends PluginFactoryOptions> = {
26
17
  config: Config
27
18
  generator: Omit<OperationGenerator<TOptions>, 'build'>
28
19
  plugin: Plugin<TOptions>
29
20
  operation: Operation
30
21
  }
31
22
 
32
- export type OperationV2Props<TOptions extends PluginFactoryOptions> = {
33
- config: Config
34
- plugin: Plugin<TOptions>
35
- node: OperationNode
36
- }
37
-
38
- export type OperationsProps<TOptions extends PluginFactoryOptions, TVersion extends Version = '1'> = TVersion extends '2'
39
- ? OperationsV2Props<TOptions>
40
- : OperationsV1Props<TOptions>
41
-
42
- export type OperationProps<TOptions extends PluginFactoryOptions, TVersion extends Version = '1'> = TVersion extends '2'
43
- ? OperationV2Props<TOptions>
44
- : OperationV1Props<TOptions>
45
-
46
- export type SchemaV1Props<TOptions extends PluginFactoryOptions> = {
23
+ export type SchemaProps<TOptions extends PluginFactoryOptions> = {
47
24
  config: Config
48
25
  generator: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>
49
26
  plugin: Plugin<TOptions>
@@ -54,16 +31,4 @@ export type SchemaV1Props<TOptions extends PluginFactoryOptions> = {
54
31
  }
55
32
  }
56
33
 
57
- export type SchemaV2Props<TOptions extends PluginFactoryOptions> = {
58
- config: Config
59
- plugin: Plugin<TOptions>
60
- node: SchemaNode
61
- }
62
-
63
- export type SchemaProps<TOptions extends PluginFactoryOptions, TVersion extends Version = '1'> = TVersion extends '2'
64
- ? SchemaV2Props<TOptions>
65
- : SchemaV1Props<TOptions>
66
-
67
- export type Generator<TOptions extends PluginFactoryOptions, TVersion extends Version = Version> =
68
- | CoreGenerator<TOptions, TVersion>
69
- | ReactGenerator<TOptions, TVersion>
34
+ export type Generator<TOptions extends PluginFactoryOptions> = CoreGenerator<TOptions> | ReactGenerator<TOptions> | CoreV2Generator<TOptions>
@@ -1,5 +1,4 @@
1
1
  export { useOas } from './useOas.ts'
2
2
  export type { SchemaNames } from './useOperationManager.ts'
3
3
  export { useOperationManager } from './useOperationManager.ts'
4
- export { useRootNode } from './useRootNode.ts'
5
4
  export { useSchemaManager } from './useSchemaManager.ts'
@@ -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,12 +1,12 @@
1
- import type { FileMetaBase, Plugin, PluginFactoryOptions, ResolveNameParams } from '@kubb/core'
2
- import { usePlugin, usePluginManager } from '@kubb/core/hooks'
1
+ import type { FileMetaBase, PluginFactoryOptions, ResolveNameParams } from '@kubb/core'
2
+ import { usePlugin, usePluginDriver } from '@kubb/core/hooks'
3
3
  import type { KubbFile } 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'
7
7
 
8
8
  type FileMeta = FileMetaBase & {
9
- pluginKey: Plugin['key']
9
+ pluginName: string
10
10
  name: string
11
11
  group?: {
12
12
  tag?: string
@@ -31,7 +31,7 @@ type UseOperationManagerResult = {
31
31
  params: {
32
32
  prefix?: string
33
33
  suffix?: string
34
- pluginKey?: Plugin['key']
34
+ pluginName?: string
35
35
  type: ResolveNameParams['type']
36
36
  },
37
37
  ) => string
@@ -40,7 +40,7 @@ type UseOperationManagerResult = {
40
40
  params?: {
41
41
  prefix?: string
42
42
  suffix?: string
43
- pluginKey?: Plugin['key']
43
+ pluginName?: string
44
44
  extname?: KubbFile.Extname
45
45
  group?: {
46
46
  tag?: string
@@ -51,11 +51,11 @@ type UseOperationManagerResult = {
51
51
  groupSchemasByName: (
52
52
  operation: OperationType,
53
53
  params: {
54
- pluginKey?: Plugin['key']
54
+ pluginName?: string
55
55
  type: ResolveNameParams['type']
56
56
  },
57
57
  ) => SchemaNames
58
- getSchemas: (operation: Operation, params?: { pluginKey?: Plugin['key']; type?: ResolveNameParams['type'] }) => OperationSchemas
58
+ getSchemas: (operation: Operation, params?: { pluginName?: string; type?: ResolveNameParams['type'] }) => OperationSchemas
59
59
  getGroup: (operation: Operation) => FileMeta['group'] | undefined
60
60
  }
61
61
 
@@ -66,12 +66,12 @@ 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 = usePluginDriver()
70
70
 
71
- const getName: UseOperationManagerResult['getName'] = (operation, { prefix = '', suffix = '', pluginKey = plugin.key, type }) => {
72
- return pluginManager.resolveName({
71
+ const getName: UseOperationManagerResult['getName'] = (operation, { prefix = '', suffix = '', pluginName = plugin.name, type }) => {
72
+ return driver.resolveName({
73
73
  name: `${prefix} ${operation.getOperationId()} ${suffix}`,
74
- pluginKey,
74
+ pluginName,
75
75
  type,
76
76
  })
77
77
  }
@@ -90,23 +90,23 @@ export function useOperationManager<TPluginOptions extends PluginFactoryOptions
90
90
 
91
91
  return generator.getSchemas(operation, {
92
92
  resolveName: (name) =>
93
- pluginManager.resolveName({
93
+ driver.resolveName({
94
94
  name,
95
- pluginKey: params?.pluginKey,
95
+ pluginName: params?.pluginName,
96
96
  type: params?.type,
97
97
  }),
98
98
  })
99
99
  }
100
100
 
101
- const getFile: UseOperationManagerResult['getFile'] = (operation, { prefix, suffix, pluginKey = plugin.key, extname = '.ts' } = {}) => {
102
- const name = getName(operation, { type: 'file', pluginKey, prefix, suffix })
101
+ const getFile: UseOperationManagerResult['getFile'] = (operation, { prefix, suffix, pluginName = plugin.name, extname = '.ts' } = {}) => {
102
+ const name = getName(operation, { type: 'file', pluginName, prefix, suffix })
103
103
  const group = getGroup(operation)
104
104
 
105
- const file = pluginManager.getFile({
105
+ const file = driver.getFile({
106
106
  name,
107
107
  extname,
108
- pluginKey,
109
- options: { type: 'file', pluginKey, group },
108
+ pluginName,
109
+ options: { type: 'file', pluginName, group },
110
110
  })
111
111
 
112
112
  return {
@@ -114,13 +114,13 @@ export function useOperationManager<TPluginOptions extends PluginFactoryOptions
114
114
  meta: {
115
115
  ...file.meta,
116
116
  name,
117
- pluginKey,
117
+ pluginName,
118
118
  group,
119
119
  },
120
120
  }
121
121
  }
122
122
 
123
- const groupSchemasByName: UseOperationManagerResult['groupSchemasByName'] = (operation, { pluginKey = plugin.key, type }) => {
123
+ const groupSchemasByName: UseOperationManagerResult['groupSchemasByName'] = (operation, { pluginName = plugin.name, type }) => {
124
124
  if (!generator) {
125
125
  throw new Error(`useOperationManager: 'generator' parameter is required but was not provided`)
126
126
  }
@@ -133,9 +133,9 @@ export function useOperationManager<TPluginOptions extends PluginFactoryOptions
133
133
  return prev
134
134
  }
135
135
 
136
- prev[acc.statusCode] = pluginManager.resolveName({
136
+ prev[acc.statusCode] = driver.resolveName({
137
137
  name: acc.name,
138
- pluginKey,
138
+ pluginName,
139
139
  type,
140
140
  })
141
141
 
@@ -150,9 +150,9 @@ export function useOperationManager<TPluginOptions extends PluginFactoryOptions
150
150
  return prev
151
151
  }
152
152
 
153
- prev[acc.statusCode] = pluginManager.resolveName({
153
+ prev[acc.statusCode] = driver.resolveName({
154
154
  name: acc.name,
155
- pluginKey,
155
+ pluginName,
156
156
  type,
157
157
  })
158
158
 
@@ -163,40 +163,40 @@ export function useOperationManager<TPluginOptions extends PluginFactoryOptions
163
163
 
164
164
  return {
165
165
  request: schemas.request?.name
166
- ? pluginManager.resolveName({
166
+ ? driver.resolveName({
167
167
  name: schemas.request.name,
168
- pluginKey,
168
+ pluginName,
169
169
  type,
170
170
  })
171
171
  : undefined,
172
172
  parameters: {
173
173
  path: schemas.pathParams?.name
174
- ? pluginManager.resolveName({
174
+ ? driver.resolveName({
175
175
  name: schemas.pathParams.name,
176
- pluginKey,
176
+ pluginName,
177
177
  type,
178
178
  })
179
179
  : undefined,
180
180
  query: schemas.queryParams?.name
181
- ? pluginManager.resolveName({
181
+ ? driver.resolveName({
182
182
  name: schemas.queryParams.name,
183
- pluginKey,
183
+ pluginName,
184
184
  type,
185
185
  })
186
186
  : undefined,
187
187
  header: schemas.headerParams?.name
188
- ? pluginManager.resolveName({
188
+ ? driver.resolveName({
189
189
  name: schemas.headerParams.name,
190
- pluginKey,
190
+ pluginName,
191
191
  type,
192
192
  })
193
193
  : undefined,
194
194
  },
195
195
  responses: {
196
196
  ...responses,
197
- ['default']: pluginManager.resolveName({
197
+ ['default']: driver.resolveName({
198
198
  name: schemas.response.name,
199
- pluginKey,
199
+ pluginName,
200
200
  type,
201
201
  }),
202
202
  ...errors,