@kubb/plugin-oas 5.0.0-alpha.2 → 5.0.0-alpha.4

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 (41) hide show
  1. package/dist/{createGenerator-B8BypXNu.d.ts → createGenerator-B4JjYBuF.d.ts} +32 -54
  2. package/dist/{generators-vAAte6w6.cjs → generators-D_7I5QrN.cjs} +3 -3
  3. package/dist/generators-D_7I5QrN.cjs.map +1 -0
  4. package/dist/{generators-B8HiBWvT.js → generators-DxN9Dqyi.js} +3 -3
  5. package/dist/generators-DxN9Dqyi.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 +1 -24
  10. package/dist/hooks.cjs.map +1 -1
  11. package/dist/hooks.d.ts +3 -23
  12. package/dist/hooks.js +2 -24
  13. package/dist/hooks.js.map +1 -1
  14. package/dist/index.cjs +2 -2
  15. package/dist/index.cjs.map +1 -1
  16. package/dist/index.d.ts +22 -9
  17. package/dist/index.js +2 -2
  18. package/dist/index.js.map +1 -1
  19. package/dist/{requestBody-DQMKhTin.js → requestBody-BehWL7WM.js} +23 -12
  20. package/dist/requestBody-BehWL7WM.js.map +1 -0
  21. package/dist/{requestBody-FpiwLR1p.cjs → requestBody-Di4JV1zs.cjs} +23 -12
  22. package/dist/requestBody-Di4JV1zs.cjs.map +1 -0
  23. package/dist/utils.cjs +1 -1
  24. package/dist/utils.d.ts +1 -1
  25. package/dist/utils.js +1 -1
  26. package/package.json +3 -3
  27. package/src/OperationGenerator.ts +3 -3
  28. package/src/SchemaGenerator.ts +4 -7
  29. package/src/generators/createGenerator.ts +12 -15
  30. package/src/generators/createReactGenerator.ts +12 -15
  31. package/src/generators/types.ts +5 -40
  32. package/src/hooks/index.ts +0 -1
  33. package/src/hooks/useSchemaManager.ts +1 -0
  34. package/src/index.ts +1 -1
  35. package/src/types.ts +2 -2
  36. package/src/utils.tsx +35 -18
  37. package/dist/generators-B8HiBWvT.js.map +0 -1
  38. package/dist/generators-vAAte6w6.cjs.map +0 -1
  39. package/dist/requestBody-DQMKhTin.js.map +0 -1
  40. package/dist/requestBody-FpiwLR1p.cjs.map +0 -1
  41. package/src/hooks/useRootNode.ts +0 -25
package/dist/utils.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import "./chunk--u3MIqq1.js";
2
2
  import { n as getBanner, r as camelCase, t as getFooter } from "./getFooter-Pw3tLCiV.js";
3
- import { n as withRequiredRequestBodySchema, r as SchemaGenerator, s as getSchemaFactory, t as isRequestBodyRequired } from "./requestBody-DQMKhTin.js";
3
+ import { n as withRequiredRequestBodySchema, r as SchemaGenerator, s as getSchemaFactory, t as isRequestBodyRequired } from "./requestBody-BehWL7WM.js";
4
4
  import { n as schemaKeywords } from "./SchemaMapper-CqMkO2T1.js";
5
5
  import { isOptional } from "@kubb/oas";
6
6
  //#region ../../internals/utils/src/reserved.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-oas",
3
- "version": "5.0.0-alpha.2",
3
+ "version": "5.0.0-alpha.4",
4
4
  "description": "OpenAPI Specification (OAS) plugin for Kubb, providing core functionality for parsing and processing OpenAPI/Swagger schemas for code generation.",
5
5
  "keywords": [
6
6
  "openapi",
@@ -84,8 +84,8 @@
84
84
  "@kubb/fabric-core": "0.13.3",
85
85
  "@kubb/react-fabric": "0.13.3",
86
86
  "remeda": "^2.33.6",
87
- "@kubb/core": "5.0.0-alpha.2",
88
- "@kubb/oas": "5.0.0-alpha.2"
87
+ "@kubb/core": "5.0.0-alpha.4",
88
+ "@kubb/oas": "5.0.0-alpha.4"
89
89
  },
90
90
  "peerDependencies": {
91
91
  "@kubb/fabric-core": "0.13.3",
@@ -6,7 +6,7 @@ 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'
@@ -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 () => {
@@ -8,7 +8,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'
@@ -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 () => {
@@ -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
  },
@@ -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'
@@ -29,6 +29,7 @@ type UseSchemaManagerResult = {
29
29
 
30
30
  /**
31
31
  * `useSchemaManager` returns helper functions to get the schema file and schema name.
32
+ * @deprecated
32
33
  */
33
34
  export function useSchemaManager(): UseSchemaManagerResult {
34
35
  const plugin = usePlugin()
package/src/index.ts CHANGED
@@ -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>
package/src/types.ts CHANGED
@@ -220,8 +220,8 @@ type ByContentType = {
220
220
  pattern: string | RegExp
221
221
  }
222
222
 
223
- export type Exclude = ByTag | ByOperationId | ByPath | ByMethod | ByContentType
224
- export type Include = ByTag | ByOperationId | ByPath | ByMethod | ByContentType
223
+ export type Exclude = ByTag | ByOperationId | ByPath | ByMethod | ByContentType | BySchemaName
224
+ export type Include = ByTag | ByOperationId | ByPath | ByMethod | ByContentType | BySchemaName
225
225
 
226
226
  export type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName | ByContentType) & {
227
227
  options: Partial<TOptions>
package/src/utils.tsx CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { OperationNode, SchemaNode } from '@kubb/ast/types'
2
- import type { Config, Plugin, PluginFactoryOptions } from '@kubb/core'
2
+ import type { Adapter, Config, Plugin, PluginFactoryOptions, PluginManager, ReactGeneratorV2 } from '@kubb/core'
3
+ import type { KubbFile } from '@kubb/fabric-core/types'
3
4
  import type { Operation, SchemaObject } from '@kubb/oas'
4
5
  import { App, createReactFabric, type Fabric } from '@kubb/react-fabric'
5
6
  import type { ReactGenerator } from './generators/createReactGenerator.ts'
@@ -15,13 +16,17 @@ type BuildOperationsBaseOptions<TOptions extends PluginFactoryOptions> = {
15
16
 
16
17
  type BuildOperationsV1Options<TOptions extends PluginFactoryOptions> = BuildOperationsBaseOptions<TOptions> & {
17
18
  version?: '1'
18
- Component: ReactGenerator<any, '1'>['Operations']
19
+ Component: ReactGenerator<TOptions>['Operations']
19
20
  generator: Omit<OperationGenerator<TOptions>, 'build'>
20
21
  }
21
22
 
22
23
  type BuildOperationsV2Options<TOptions extends PluginFactoryOptions> = BuildOperationsBaseOptions<TOptions> & {
23
24
  version: '2'
24
- Component: ReactGenerator<any, '2'>['Operations']
25
+ Component: ReactGeneratorV2<TOptions>['Operations'] | undefined
26
+ adapter: Adapter
27
+ pluginManager: PluginManager
28
+ mode: KubbFile.Mode
29
+ options: TOptions['resolvedOptions'] | null
25
30
  }
26
31
 
27
32
  function isBuildOperationsV1Options<TOptions extends PluginFactoryOptions>(
@@ -60,15 +65,16 @@ export async function buildOperations<TOptions extends PluginFactoryOptions>(
60
65
  </App>,
61
66
  )
62
67
  } else {
63
- const { Component } = options
68
+ const { Component, adapter } = options
69
+
64
70
  await fabricChild.render(
65
71
  <App meta={{ plugin }}>
66
- <Component config={config} nodes={operationsOrNodes as Array<OperationNode>} plugin={plugin} />
72
+ <Component config={config} adapter={adapter} nodes={operationsOrNodes as Array<OperationNode>} options={options.options} />
67
73
  </App>,
68
74
  )
69
75
  }
70
76
 
71
- await fabric.context.fileManager.upsert(...fabricChild.files)
77
+ fabric.context.fileManager.upsert(...fabricChild.files)
72
78
  fabricChild.unmount()
73
79
  }
74
80
 
@@ -80,13 +86,17 @@ type BuildOperationBaseOptions<TOptions extends PluginFactoryOptions> = {
80
86
 
81
87
  type BuildOperationV1Options<TOptions extends PluginFactoryOptions> = BuildOperationBaseOptions<TOptions> & {
82
88
  version?: '1'
83
- Component: ReactGenerator<any, '1'>['Operation']
89
+ Component: ReactGenerator<TOptions>['Operation']
84
90
  generator: Omit<OperationGenerator<TOptions>, 'build'>
85
91
  }
86
92
 
87
93
  type BuildOperationV2Options<TOptions extends PluginFactoryOptions> = BuildOperationBaseOptions<TOptions> & {
88
94
  version: '2'
89
- Component: ReactGenerator<any, '2'>['Operation']
95
+ Component: ReactGeneratorV2<TOptions>['Operation'] | undefined
96
+ adapter: Adapter
97
+ pluginManager: PluginManager
98
+ mode: KubbFile.Mode
99
+ options: TOptions['resolvedOptions'] | null
90
100
  }
91
101
 
92
102
  function isBuildOperationV1Options<TOptions extends PluginFactoryOptions>(
@@ -119,15 +129,16 @@ export async function buildOperation<TOptions extends PluginFactoryOptions>(
119
129
  </App>,
120
130
  )
121
131
  } else {
122
- const { Component } = options
132
+ const { Component, adapter, pluginManager, mode } = options
133
+
123
134
  await fabricChild.render(
124
- <App meta={{ plugin }}>
125
- <Component config={config} node={operationOrNode as OperationNode} plugin={plugin} />
135
+ <App meta={{ plugin, pluginManager, mode }}>
136
+ <Component config={config} adapter={adapter} node={operationOrNode as OperationNode} options={options.options} />
126
137
  </App>,
127
138
  )
128
139
  }
129
140
 
130
- await fabric.context.fileManager.upsert(...fabricChild.files)
141
+ fabric.context.fileManager.upsert(...fabricChild.files)
131
142
  fabricChild.unmount()
132
143
  }
133
144
 
@@ -139,13 +150,17 @@ type BuildSchemaBaseOptions<TOptions extends PluginFactoryOptions> = {
139
150
 
140
151
  type BuildSchemaV1Options<TOptions extends PluginFactoryOptions> = BuildSchemaBaseOptions<TOptions> & {
141
152
  version?: '1'
142
- Component: ReactGenerator<any, '1'>['Schema']
153
+ Component: ReactGenerator<TOptions>['Schema']
143
154
  generator: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>
144
155
  }
145
156
 
146
157
  type BuildSchemaV2Options<TOptions extends PluginFactoryOptions> = BuildSchemaBaseOptions<TOptions> & {
147
158
  version: '2'
148
- Component: ReactGenerator<any, '2'>['Schema']
159
+ Component: ReactGeneratorV2<TOptions>['Schema'] | undefined
160
+ adapter: Adapter
161
+ pluginManager: PluginManager
162
+ mode: KubbFile.Mode
163
+ options: TOptions['resolvedOptions'] | null
149
164
  }
150
165
 
151
166
  function isBuildSchemaV1Options<TOptions extends PluginFactoryOptions>(
@@ -181,14 +196,16 @@ export async function buildSchema<TOptions extends PluginFactoryOptions>(
181
196
  </App>,
182
197
  )
183
198
  } else {
184
- const { Component } = options
199
+ const { Component, adapter, pluginManager, mode } = options
200
+
185
201
  await fabricChild.render(
186
- <App meta={{ plugin }}>
187
- <Component config={config} node={schema as SchemaNode} plugin={plugin} />
202
+ <App meta={{ plugin, pluginManager, mode }}>
203
+ <Component config={config} adapter={adapter} node={schema as SchemaNode} options={options.options} />
188
204
  </App>,
189
205
  )
190
206
  }
191
207
 
192
- await fabric.context.fileManager.upsert(...fabricChild.files)
208
+ fabric.context.fileManager.upsert(...fabricChild.files)
209
+
193
210
  fabricChild.unmount()
194
211
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"generators-B8HiBWvT.js","names":[],"sources":["../src/generators/createGenerator.ts","../src/generators/createReactGenerator.ts","../src/generators/jsonGenerator.ts"],"sourcesContent":["import type { PluginFactoryOptions } from '@kubb/core'\nimport type { KubbFile } from '@kubb/fabric-core/types'\nimport type { OperationProps, OperationsProps, SchemaProps, Version } from './types.ts'\n\ntype UserGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version> = {\n name: string\n version?: TVersion\n operations?: (props: OperationsProps<TOptions, TVersion>) => Promise<KubbFile.File[]>\n operation?: (props: OperationProps<TOptions, TVersion>) => Promise<KubbFile.File[]>\n schema?: (props: SchemaProps<TOptions, TVersion>) => Promise<KubbFile.File[]>\n}\n\nexport type CoreGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version> = {\n name: string\n type: 'core'\n version: TVersion\n operations: (props: OperationsProps<TOptions, TVersion>) => Promise<KubbFile.File[]>\n operation: (props: OperationProps<TOptions, TVersion>) => Promise<KubbFile.File[]>\n schema: (props: SchemaProps<TOptions, TVersion>) => Promise<KubbFile.File[]>\n}\n\nexport function createGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version = '1'>(\n generator: UserGenerator<TOptions, TVersion>,\n): CoreGenerator<TOptions, TVersion> {\n return {\n type: 'core',\n version: (generator.version ?? '1') as TVersion,\n async operations() {\n return []\n },\n async operation() {\n return []\n },\n async schema() {\n return []\n },\n ...generator,\n }\n}\n","import type { PluginFactoryOptions } from '@kubb/core'\nimport type { FabricReactNode } from '@kubb/react-fabric/types'\nimport type { OperationProps, OperationsProps, SchemaProps, Version } from './types.ts'\n\ntype UserGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version> = {\n name: string\n version?: TVersion\n Operations?: (props: OperationsProps<TOptions, TVersion>) => FabricReactNode\n Operation?: (props: OperationProps<TOptions, TVersion>) => FabricReactNode\n Schema?: (props: SchemaProps<TOptions, TVersion>) => FabricReactNode\n}\n\nexport type ReactGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version> = {\n name: string\n type: 'react'\n version: TVersion\n Operations: (props: OperationsProps<TOptions, TVersion>) => FabricReactNode\n Operation: (props: OperationProps<TOptions, TVersion>) => FabricReactNode\n Schema: (props: SchemaProps<TOptions, TVersion>) => FabricReactNode\n}\n\n/****\n * Creates a generator that uses React component functions to generate files for OpenAPI operations and schemas.\n *\n * The returned generator exposes async methods for generating files from operations, a single operation, or a schema, using the corresponding React components if provided. If a component is not defined, the method returns an empty array.\n *\n * @returns A generator object with async methods for operations, operation, and schema file generation.\n */\nexport function createReactGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version = '1'>(\n generator: UserGenerator<TOptions, TVersion>,\n): ReactGenerator<TOptions, TVersion> {\n return {\n type: 'react',\n version: (generator.version ?? '1') as TVersion,\n Operations() {\n return null\n },\n Operation() {\n return null\n },\n Schema() {\n return null\n },\n ...generator,\n }\n}\n","import { camelCase } from '@internals/utils'\nimport type { PluginOas } from '../types.ts'\nimport { getBanner } from '../utils/getBanner.ts'\nimport { getFooter } from '../utils/getFooter.ts'\nimport { createGenerator } from './createGenerator.ts'\n\nexport const jsonGenerator = createGenerator<PluginOas>({\n name: 'plugin-oas',\n async schema({ schema, generator }) {\n const { pluginManager, plugin } = generator.context\n const file = pluginManager.getFile({\n name: camelCase(schema.name),\n extname: '.json',\n mode: 'split',\n pluginName: plugin.name,\n })\n\n return [\n {\n ...file,\n sources: [\n {\n name: camelCase(schema.name),\n isExportable: false,\n isIndexable: false,\n value: JSON.stringify(schema.value),\n },\n ],\n banner: getBanner({\n oas: generator.context.oas,\n output: plugin.options.output,\n config: pluginManager.config,\n }),\n format: getFooter({ oas: generator.context.oas, output: plugin.options.output }),\n },\n ]\n },\n})\n"],"mappings":";;;AAqBA,SAAgB,gBACd,WACmC;AACnC,QAAO;EACL,MAAM;EACN,SAAU,UAAU,WAAW;EAC/B,MAAM,aAAa;AACjB,UAAO,EAAE;;EAEX,MAAM,YAAY;AAChB,UAAO,EAAE;;EAEX,MAAM,SAAS;AACb,UAAO,EAAE;;EAEX,GAAG;EACJ;;;;;;;;;;;ACTH,SAAgB,qBACd,WACoC;AACpC,QAAO;EACL,MAAM;EACN,SAAU,UAAU,WAAW;EAC/B,aAAa;AACX,UAAO;;EAET,YAAY;AACV,UAAO;;EAET,SAAS;AACP,UAAO;;EAET,GAAG;EACJ;;;;ACtCH,MAAa,gBAAgB,gBAA2B;CACtD,MAAM;CACN,MAAM,OAAO,EAAE,QAAQ,aAAa;EAClC,MAAM,EAAE,eAAe,WAAW,UAAU;AAQ5C,SAAO,CACL;GACE,GATS,cAAc,QAAQ;IACjC,MAAM,UAAU,OAAO,KAAK;IAC5B,SAAS;IACT,MAAM;IACN,YAAY,OAAO;IACpB,CAAC;GAKE,SAAS,CACP;IACE,MAAM,UAAU,OAAO,KAAK;IAC5B,cAAc;IACd,aAAa;IACb,OAAO,KAAK,UAAU,OAAO,MAAM;IACpC,CACF;GACD,QAAQ,UAAU;IAChB,KAAK,UAAU,QAAQ;IACvB,QAAQ,OAAO,QAAQ;IACvB,QAAQ,cAAc;IACvB,CAAC;GACF,QAAQ,UAAU;IAAE,KAAK,UAAU,QAAQ;IAAK,QAAQ,OAAO,QAAQ;IAAQ,CAAC;GACjF,CACF;;CAEJ,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"generators-vAAte6w6.cjs","names":["camelCase","getBanner","getFooter"],"sources":["../src/generators/createGenerator.ts","../src/generators/createReactGenerator.ts","../src/generators/jsonGenerator.ts"],"sourcesContent":["import type { PluginFactoryOptions } from '@kubb/core'\nimport type { KubbFile } from '@kubb/fabric-core/types'\nimport type { OperationProps, OperationsProps, SchemaProps, Version } from './types.ts'\n\ntype UserGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version> = {\n name: string\n version?: TVersion\n operations?: (props: OperationsProps<TOptions, TVersion>) => Promise<KubbFile.File[]>\n operation?: (props: OperationProps<TOptions, TVersion>) => Promise<KubbFile.File[]>\n schema?: (props: SchemaProps<TOptions, TVersion>) => Promise<KubbFile.File[]>\n}\n\nexport type CoreGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version> = {\n name: string\n type: 'core'\n version: TVersion\n operations: (props: OperationsProps<TOptions, TVersion>) => Promise<KubbFile.File[]>\n operation: (props: OperationProps<TOptions, TVersion>) => Promise<KubbFile.File[]>\n schema: (props: SchemaProps<TOptions, TVersion>) => Promise<KubbFile.File[]>\n}\n\nexport function createGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version = '1'>(\n generator: UserGenerator<TOptions, TVersion>,\n): CoreGenerator<TOptions, TVersion> {\n return {\n type: 'core',\n version: (generator.version ?? '1') as TVersion,\n async operations() {\n return []\n },\n async operation() {\n return []\n },\n async schema() {\n return []\n },\n ...generator,\n }\n}\n","import type { PluginFactoryOptions } from '@kubb/core'\nimport type { FabricReactNode } from '@kubb/react-fabric/types'\nimport type { OperationProps, OperationsProps, SchemaProps, Version } from './types.ts'\n\ntype UserGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version> = {\n name: string\n version?: TVersion\n Operations?: (props: OperationsProps<TOptions, TVersion>) => FabricReactNode\n Operation?: (props: OperationProps<TOptions, TVersion>) => FabricReactNode\n Schema?: (props: SchemaProps<TOptions, TVersion>) => FabricReactNode\n}\n\nexport type ReactGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version> = {\n name: string\n type: 'react'\n version: TVersion\n Operations: (props: OperationsProps<TOptions, TVersion>) => FabricReactNode\n Operation: (props: OperationProps<TOptions, TVersion>) => FabricReactNode\n Schema: (props: SchemaProps<TOptions, TVersion>) => FabricReactNode\n}\n\n/****\n * Creates a generator that uses React component functions to generate files for OpenAPI operations and schemas.\n *\n * The returned generator exposes async methods for generating files from operations, a single operation, or a schema, using the corresponding React components if provided. If a component is not defined, the method returns an empty array.\n *\n * @returns A generator object with async methods for operations, operation, and schema file generation.\n */\nexport function createReactGenerator<TOptions extends PluginFactoryOptions, TVersion extends Version = '1'>(\n generator: UserGenerator<TOptions, TVersion>,\n): ReactGenerator<TOptions, TVersion> {\n return {\n type: 'react',\n version: (generator.version ?? '1') as TVersion,\n Operations() {\n return null\n },\n Operation() {\n return null\n },\n Schema() {\n return null\n },\n ...generator,\n }\n}\n","import { camelCase } from '@internals/utils'\nimport type { PluginOas } from '../types.ts'\nimport { getBanner } from '../utils/getBanner.ts'\nimport { getFooter } from '../utils/getFooter.ts'\nimport { createGenerator } from './createGenerator.ts'\n\nexport const jsonGenerator = createGenerator<PluginOas>({\n name: 'plugin-oas',\n async schema({ schema, generator }) {\n const { pluginManager, plugin } = generator.context\n const file = pluginManager.getFile({\n name: camelCase(schema.name),\n extname: '.json',\n mode: 'split',\n pluginName: plugin.name,\n })\n\n return [\n {\n ...file,\n sources: [\n {\n name: camelCase(schema.name),\n isExportable: false,\n isIndexable: false,\n value: JSON.stringify(schema.value),\n },\n ],\n banner: getBanner({\n oas: generator.context.oas,\n output: plugin.options.output,\n config: pluginManager.config,\n }),\n format: getFooter({ oas: generator.context.oas, output: plugin.options.output }),\n },\n ]\n },\n})\n"],"mappings":";;;AAqBA,SAAgB,gBACd,WACmC;AACnC,QAAO;EACL,MAAM;EACN,SAAU,UAAU,WAAW;EAC/B,MAAM,aAAa;AACjB,UAAO,EAAE;;EAEX,MAAM,YAAY;AAChB,UAAO,EAAE;;EAEX,MAAM,SAAS;AACb,UAAO,EAAE;;EAEX,GAAG;EACJ;;;;;;;;;;;ACTH,SAAgB,qBACd,WACoC;AACpC,QAAO;EACL,MAAM;EACN,SAAU,UAAU,WAAW;EAC/B,aAAa;AACX,UAAO;;EAET,YAAY;AACV,UAAO;;EAET,SAAS;AACP,UAAO;;EAET,GAAG;EACJ;;;;ACtCH,MAAa,gBAAgB,gBAA2B;CACtD,MAAM;CACN,MAAM,OAAO,EAAE,QAAQ,aAAa;EAClC,MAAM,EAAE,eAAe,WAAW,UAAU;AAQ5C,SAAO,CACL;GACE,GATS,cAAc,QAAQ;IACjC,MAAMA,kBAAAA,UAAU,OAAO,KAAK;IAC5B,SAAS;IACT,MAAM;IACN,YAAY,OAAO;IACpB,CAAC;GAKE,SAAS,CACP;IACE,MAAMA,kBAAAA,UAAU,OAAO,KAAK;IAC5B,cAAc;IACd,aAAa;IACb,OAAO,KAAK,UAAU,OAAO,MAAM;IACpC,CACF;GACD,QAAQC,kBAAAA,UAAU;IAChB,KAAK,UAAU,QAAQ;IACvB,QAAQ,OAAO,QAAQ;IACvB,QAAQ,cAAc;IACvB,CAAC;GACF,QAAQC,kBAAAA,UAAU;IAAE,KAAK,UAAU,QAAQ;IAAK,QAAQ,OAAO,QAAQ;IAAQ,CAAC;GACjF,CACF;;CAEJ,CAAC"}