@kubb/plugin-oas 0.0.0-canary-20251028131922 → 0.0.0-canary-20251103125929

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 (107) hide show
  1. package/dist/{SchemaGenerator-DzVHk6OP.cjs → SchemaGenerator-B8Reay1m.cjs} +114 -16
  2. package/dist/SchemaGenerator-B8Reay1m.cjs.map +1 -0
  3. package/dist/{SchemaGenerator-7wBwdv8G.js → SchemaGenerator-ChoBQWm5.js} +93 -15
  4. package/dist/SchemaGenerator-ChoBQWm5.js.map +1 -0
  5. package/dist/{SchemaMapper-DoL-a6qq.cjs → SchemaMapper-BUV8vhg0.cjs} +1 -1
  6. package/dist/SchemaMapper-BUV8vhg0.cjs.map +1 -0
  7. package/dist/{SchemaMapper-CqBW0VOy.d.ts → SchemaMapper-CX7sIIuZ.d.cts} +5 -118
  8. package/dist/{SchemaMapper-Cx4X1al6.js → SchemaMapper-D30tqRoX.js} +1 -1
  9. package/dist/SchemaMapper-D30tqRoX.js.map +1 -0
  10. package/dist/{SchemaMapper-MiRB5_Zp.d.cts → SchemaMapper-m5TKynWt.d.ts} +5 -118
  11. package/dist/{OperationGenerator-BZPWkxw4.d.ts → createGenerator-DlSlv4sR.d.ts} +130 -182
  12. package/dist/{OperationGenerator-CJTAer7l.d.cts → createGenerator-PIseu7v9.d.cts} +131 -183
  13. package/dist/{generators-C61FxVIj.js → generators-CJDEf8Kn.js} +6 -6
  14. package/dist/generators-CJDEf8Kn.js.map +1 -0
  15. package/dist/{generators-B27La9Vd.cjs → generators-udGOxdUV.cjs} +6 -6
  16. package/dist/generators-udGOxdUV.cjs.map +1 -0
  17. package/dist/generators.cjs +2 -7
  18. package/dist/generators.d.cts +8 -3
  19. package/dist/generators.d.ts +8 -3
  20. package/dist/generators.js +3 -5
  21. package/dist/{getFooter-D5MdeUVv.js → getFooter-CV73pVXj.js} +2 -2
  22. package/dist/{getFooter-D5MdeUVv.js.map → getFooter-CV73pVXj.js.map} +1 -1
  23. package/dist/{getFooter-CwjCW4h5.cjs → getFooter-DPh4lxBH.cjs} +3 -3
  24. package/dist/{getFooter-CwjCW4h5.cjs.map → getFooter-DPh4lxBH.cjs.map} +1 -1
  25. package/dist/{getSchemas-DY8s2CSl.cjs → getSchemas-CP_YS4_2.cjs} +1 -1
  26. package/dist/getSchemas-CP_YS4_2.cjs.map +1 -0
  27. package/dist/{getSchemas-Bdg6n9Qk.js → getSchemas-CTi8zYew.js} +1 -1
  28. package/dist/getSchemas-CTi8zYew.js.map +1 -0
  29. package/dist/hooks.cjs +6 -47
  30. package/dist/hooks.cjs.map +1 -1
  31. package/dist/hooks.d.cts +11 -45
  32. package/dist/hooks.d.ts +11 -45
  33. package/dist/hooks.js +8 -46
  34. package/dist/hooks.js.map +1 -1
  35. package/dist/index.cjs +37 -32
  36. package/dist/index.cjs.map +1 -1
  37. package/dist/index.d.cts +58 -3
  38. package/dist/index.d.ts +58 -3
  39. package/dist/index.js +32 -24
  40. package/dist/index.js.map +1 -1
  41. package/dist/mocks.cjs +1 -1
  42. package/dist/mocks.d.cts +1 -1
  43. package/dist/mocks.d.ts +1 -1
  44. package/dist/mocks.js +1 -1
  45. package/dist/{parseFromConfig-CqiiLCPe.js → parseFromConfig-BkUoWC2U.js} +1 -1
  46. package/dist/parseFromConfig-BkUoWC2U.js.map +1 -0
  47. package/dist/{parseFromConfig-RR31a98-.cjs → parseFromConfig-EjsCZ0-8.cjs} +1 -1
  48. package/dist/parseFromConfig-EjsCZ0-8.cjs.map +1 -0
  49. package/dist/utils.cjs +3 -3
  50. package/dist/utils.cjs.map +1 -1
  51. package/dist/utils.d.cts +24 -24
  52. package/dist/utils.d.ts +24 -24
  53. package/dist/utils.js +3 -3
  54. package/dist/utils.js.map +1 -1
  55. package/package.json +14 -17
  56. package/src/OperationGenerator.ts +27 -14
  57. package/src/SchemaGenerator.ts +19 -11
  58. package/src/SchemaMapper.ts +1 -1
  59. package/src/generators/createGenerator.ts +1 -1
  60. package/src/generators/index.ts +0 -1
  61. package/src/generators/jsonGenerator.ts +4 -4
  62. package/src/generators/types.ts +13 -14
  63. package/src/hooks/index.ts +1 -4
  64. package/src/hooks/useOas.ts +5 -11
  65. package/src/hooks/useOperationManager.ts +3 -5
  66. package/src/hooks/useSchemaManager.ts +1 -1
  67. package/src/index.ts +1 -1
  68. package/src/types.ts +1 -1
  69. package/src/utils/getBanner.ts +1 -1
  70. package/src/utils/getParams.ts +1 -2
  71. package/src/utils/getSchemaFactory.ts +1 -2
  72. package/src/utils/getSchemas.ts +1 -1
  73. package/src/utils/index.ts +3 -4
  74. package/src/utils/parseFromConfig.ts +2 -6
  75. package/src/utils.tsx +101 -0
  76. package/dist/Oas-BzrQ6RGC.cjs +0 -80
  77. package/dist/Oas-BzrQ6RGC.cjs.map +0 -1
  78. package/dist/Oas-CIeHKOo0.js +0 -60
  79. package/dist/Oas-CIeHKOo0.js.map +0 -1
  80. package/dist/Schema-CjraJhJi.d.ts +0 -38
  81. package/dist/Schema-zcZF0UIp.d.cts +0 -38
  82. package/dist/SchemaGenerator-7wBwdv8G.js.map +0 -1
  83. package/dist/SchemaGenerator-DzVHk6OP.cjs.map +0 -1
  84. package/dist/SchemaMapper-Cx4X1al6.js.map +0 -1
  85. package/dist/SchemaMapper-DoL-a6qq.cjs.map +0 -1
  86. package/dist/components.cjs +0 -5
  87. package/dist/components.d.cts +0 -42
  88. package/dist/components.d.ts +0 -42
  89. package/dist/components.js +0 -3
  90. package/dist/generators-B27La9Vd.cjs.map +0 -1
  91. package/dist/generators-C61FxVIj.js.map +0 -1
  92. package/dist/getSchemas-Bdg6n9Qk.js.map +0 -1
  93. package/dist/getSchemas-DY8s2CSl.cjs.map +0 -1
  94. package/dist/parseFromConfig-CqiiLCPe.js.map +0 -1
  95. package/dist/parseFromConfig-RR31a98-.cjs.map +0 -1
  96. package/dist/utils-BnkB1ikY.js +0 -99
  97. package/dist/utils-BnkB1ikY.js.map +0 -1
  98. package/dist/utils-nzdccPlU.cjs +0 -119
  99. package/dist/utils-nzdccPlU.cjs.map +0 -1
  100. package/src/components/Oas.tsx +0 -35
  101. package/src/components/Operation.tsx +0 -20
  102. package/src/components/Schema.tsx +0 -38
  103. package/src/components/index.ts +0 -3
  104. package/src/generators/utils.tsx +0 -114
  105. package/src/hooks/useOperation.ts +0 -18
  106. package/src/hooks/useOperations.ts +0 -40
  107. package/src/hooks/useSchema.ts +0 -16
@@ -1,35 +0,0 @@
1
- import type { Oas as OasType, Operation as OperationType } from '@kubb/oas'
2
- import { createContext } from '@kubb/react-fabric'
3
- import type { KubbNode } from '@kubb/react-fabric/types'
4
- import type { OperationGenerator } from '../OperationGenerator.ts'
5
- import { Operation } from './Operation.tsx'
6
- import { Schema } from './Schema.tsx'
7
-
8
- type Props = {
9
- oas: OasType
10
- operations?: OperationType[]
11
- /**
12
- * @deprecated
13
- */
14
- generator?: Omit<OperationGenerator, 'build'>
15
- children?: KubbNode
16
- }
17
-
18
- type OasContextProps = {
19
- oas?: OasType
20
- operations?: OperationType[]
21
- /**
22
- * @deprecated
23
- */
24
- generator?: Omit<OperationGenerator, 'build'>
25
- }
26
-
27
- const OasContext = createContext<OasContextProps>({})
28
-
29
- export function Oas({ oas, children, operations, generator }: Props): KubbNode {
30
- return <OasContext.Provider value={{ oas, generator, operations }}>{children}</OasContext.Provider>
31
- }
32
-
33
- Oas.Context = OasContext
34
- Oas.Operation = Operation
35
- Oas.Schema = Schema
@@ -1,20 +0,0 @@
1
- import type { Operation as OperationType } from '@kubb/oas'
2
- import { createContext } from '@kubb/react-fabric'
3
- import type { KubbNode } from '@kubb/react-fabric/types'
4
-
5
- type Props = {
6
- operation: OperationType
7
- children?: KubbNode
8
- }
9
-
10
- type OperationContextProps = {
11
- operation?: OperationType
12
- }
13
-
14
- const OperationContext = createContext<OperationContextProps>({})
15
-
16
- export function Operation({ operation, children }: Props): KubbNode {
17
- return <OperationContext.Provider value={{ operation }}>{children}</OperationContext.Provider>
18
- }
19
-
20
- Operation.Context = OperationContext
@@ -1,38 +0,0 @@
1
- import type { SchemaObject } from '@kubb/oas'
2
- import { createContext } from '@kubb/react-fabric'
3
- import type { Key, KubbNode } from '@kubb/react-fabric/types'
4
- import type { Schema as SchemaType } from '../SchemaMapper.ts'
5
-
6
- export type SchemaContextProps = {
7
- name: string
8
- schemaObject?: SchemaObject
9
- tree: Array<SchemaType>
10
- }
11
-
12
- type Props = {
13
- key?: Key
14
- name: string
15
- schemaObject?: SchemaObject
16
- tree?: Array<SchemaType>
17
- children?: KubbNode
18
- }
19
-
20
- const SchemaContext = createContext<SchemaContextProps>({
21
- name: 'unknown',
22
- tree: [],
23
- })
24
-
25
- /**
26
- * Provides schema-related context to descendant components.
27
- *
28
- * Wraps its children with a context containing the schema name, optional schema object, and an optional schema type tree.
29
- *
30
- * @param name - The name of the schema.
31
- * @param schemaObject - The schema object to provide in context, if available.
32
- * @param tree - An array representing the schema type hierarchy.
33
- */
34
- export function Schema({ name, schemaObject, tree = [], children }: Props): KubbNode {
35
- return <SchemaContext.Provider value={{ name, schemaObject, tree }}>{children}</SchemaContext.Provider>
36
- }
37
-
38
- Schema.Context = SchemaContext
@@ -1,3 +0,0 @@
1
- export { Oas } from './Oas.tsx'
2
- export { Operation } from './Operation.tsx'
3
- export { Schema } from './Schema.tsx'
@@ -1,114 +0,0 @@
1
- import type { PluginFactoryOptions } from '@kubb/core'
2
- import type { Operation, SchemaObject } from '@kubb/oas'
3
- import { App, createReactFabric, type Fabric } from '@kubb/react-fabric'
4
- import { Oas } from '../components/Oas.tsx'
5
- import type { OperationGenerator } from '../OperationGenerator.ts'
6
- import type { SchemaGenerator, SchemaGeneratorOptions } from '../SchemaGenerator.ts'
7
- import type { Schema } from '../SchemaMapper.ts'
8
- import type { ReactGenerator } from './/createReactGenerator.ts'
9
-
10
- type BuildOperationsOptions<TOptions extends PluginFactoryOptions> = {
11
- fabric: Fabric
12
- generator: ReactGenerator<any>
13
- /**
14
- * @deprecated
15
- */
16
- instance: Omit<OperationGenerator<TOptions>, 'build'>
17
- options: TOptions['resolvedOptions']
18
- }
19
-
20
- export async function buildOperations<TOptions extends PluginFactoryOptions>(
21
- operations: Array<Operation>,
22
- { fabric, options, instance, generator }: BuildOperationsOptions<TOptions>,
23
- ): Promise<void> {
24
- if (!generator.Operations) {
25
- return undefined
26
- }
27
-
28
- const { pluginManager, oas, plugin, mode } = instance.context
29
-
30
- function Component() {
31
- return (
32
- <App meta={{ pluginManager, plugin, mode }}>
33
- <Oas oas={oas} operations={operations} generator={instance}>
34
- <generator.Operations operations={operations} instance={instance} options={options} />
35
- </Oas>
36
- </App>
37
- )
38
- }
39
-
40
- const fabricChild = createReactFabric()
41
- fabricChild.render(Component)
42
-
43
- await fabric.context.fileManager.add(...fabricChild.files)
44
- }
45
-
46
- type BuildOperationOptions<TOptions extends PluginFactoryOptions> = BuildOperationsOptions<TOptions>
47
-
48
- export async function buildOperation<TOptions extends PluginFactoryOptions>(
49
- operation: Operation,
50
- { fabric, options, instance, generator }: BuildOperationOptions<TOptions>,
51
- ): Promise<void> {
52
- if (!generator.Operation) {
53
- return undefined
54
- }
55
-
56
- const { pluginManager, oas, plugin, mode } = instance.context
57
-
58
- function Component() {
59
- return (
60
- <App meta={{ pluginManager, plugin: { ...plugin, options }, mode }}>
61
- <Oas oas={oas} operations={[operation]} generator={instance}>
62
- <Oas.Operation operation={operation}>
63
- <generator.Operation operation={operation} options={options} instance={instance} />
64
- </Oas.Operation>
65
- </Oas>
66
- </App>
67
- )
68
- }
69
- const fabricChild = createReactFabric()
70
- fabricChild.render(Component)
71
-
72
- await fabric.context.fileManager.add(...fabricChild.files)
73
- }
74
-
75
- type BuildSchemaOptions<TOptions extends PluginFactoryOptions> = {
76
- fabric: Fabric
77
- generator: ReactGenerator<any>
78
- /**
79
- * @deprecated
80
- */
81
- instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>
82
- options: TOptions['resolvedOptions']
83
- }
84
-
85
- export async function buildSchema<TOptions extends PluginFactoryOptions>(
86
- schema: {
87
- name: string
88
- tree: Array<Schema>
89
- value: SchemaObject
90
- },
91
- { fabric, options, instance, generator }: BuildSchemaOptions<TOptions>,
92
- ): Promise<void> {
93
- if (!generator.Schema) {
94
- return undefined
95
- }
96
-
97
- const { pluginManager, oas, plugin, mode } = instance.context
98
-
99
- function Component() {
100
- return (
101
- <App meta={{ pluginManager, plugin: { ...plugin, options }, mode }}>
102
- <Oas oas={oas}>
103
- <Oas.Schema name={schema.name} schemaObject={schema.value} tree={schema.tree}>
104
- <generator.Schema schema={schema} options={options} instance={instance} />
105
- </Oas.Schema>
106
- </Oas>
107
- </App>
108
- )
109
- }
110
- const fabricChild = createReactFabric()
111
- fabricChild.render(Component)
112
-
113
- await fabric.context.fileManager.add(...fabricChild.files)
114
- }
@@ -1,18 +0,0 @@
1
- import { useContext } from '@kubb/react-fabric'
2
-
3
- import { Operation } from '../components/Operation.tsx'
4
-
5
- import type { Operation as OperationType } from '@kubb/oas'
6
-
7
- /**
8
- * `useOperation` will return the current `Operation`
9
- */
10
- export function useOperation(): OperationType {
11
- const { operation } = useContext(Operation.Context)
12
-
13
- if (!operation) {
14
- throw new Error('Operation is not defined')
15
- }
16
-
17
- return operation
18
- }
@@ -1,40 +0,0 @@
1
- import { useContext } from '@kubb/react-fabric'
2
-
3
- import { Oas } from '../components/Oas.tsx'
4
-
5
- import type { HttpMethod, Operation } from '@kubb/oas'
6
-
7
- type UseOperationsProps = {
8
- /**
9
- * Filter based on path
10
- * Weight: 2
11
- */
12
- path?: string
13
- /**
14
- * Filter based on method
15
- * Weight: 1
16
- */
17
- method?: HttpMethod
18
- }
19
-
20
- /**
21
- * `useOperations` will return all the Operations
22
- */
23
- export function useOperations({ method, path }: UseOperationsProps = {}): Operation[] {
24
- const { operations } = useContext(Oas.Context)
25
-
26
- if (!operations) {
27
- throw new Error('Operations is not defined')
28
- }
29
- let items = operations
30
-
31
- if (path) {
32
- items = items.filter((item) => item.path === path)
33
- }
34
-
35
- if (method) {
36
- items = items.filter((item) => item.method === method)
37
- }
38
-
39
- return items
40
- }
@@ -1,16 +0,0 @@
1
- import { useContext } from '@kubb/react-fabric'
2
-
3
- import { Schema } from '../components/Schema.tsx'
4
-
5
- import type { SchemaContextProps } from '../components/Schema.tsx'
6
-
7
- type UseSchemaResult = SchemaContextProps
8
-
9
- /**
10
- * `useSchema` will return the current `schema properties`
11
- */
12
- export function useSchema(): UseSchemaResult {
13
- const props = useContext(Schema.Context)
14
-
15
- return props as UseSchemaResult
16
- }