@kubb/plugin-zod 3.0.0-alpha.2 → 3.0.0-alpha.20

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 (83) hide show
  1. package/README.md +13 -4
  2. package/dist/chunk-GILKYHDS.cjs +250 -0
  3. package/dist/chunk-GILKYHDS.cjs.map +1 -0
  4. package/dist/chunk-KGKZCQKF.js +322 -0
  5. package/dist/chunk-KGKZCQKF.js.map +1 -0
  6. package/dist/chunk-RPZWETTK.cjs +329 -0
  7. package/dist/chunk-RPZWETTK.cjs.map +1 -0
  8. package/dist/chunk-WIOP5MTW.js +241 -0
  9. package/dist/chunk-WIOP5MTW.js.map +1 -0
  10. package/dist/components.cjs +11 -6
  11. package/dist/components.cjs.map +1 -1
  12. package/dist/components.d.cts +20 -19
  13. package/dist/components.d.ts +20 -19
  14. package/dist/components.js +2 -10
  15. package/dist/components.js.map +1 -1
  16. package/dist/generators.cjs +17 -0
  17. package/dist/generators.cjs.map +1 -0
  18. package/dist/generators.d.cts +10 -0
  19. package/dist/generators.d.ts +10 -0
  20. package/dist/generators.js +4 -0
  21. package/dist/generators.js.map +1 -0
  22. package/dist/index.cjs +12 -4
  23. package/dist/index.cjs.map +1 -1
  24. package/dist/index.d.cts +4 -137
  25. package/dist/index.d.ts +4 -137
  26. package/dist/index.js +3 -8
  27. package/dist/index.js.map +1 -1
  28. package/dist/types-BRWHhUnI.d.cts +109 -0
  29. package/dist/types-BRWHhUnI.d.ts +109 -0
  30. package/package.json +18 -20
  31. package/src/components/Operations.tsx +19 -103
  32. package/src/components/Zod.tsx +66 -0
  33. package/src/components/index.ts +1 -2
  34. package/src/generators/__snapshots__/anyof.ts +3 -0
  35. package/src/generators/__snapshots__/createPet.ts +15 -0
  36. package/src/generators/__snapshots__/createPetWithUnknownTypeAny.ts +13 -0
  37. package/src/generators/__snapshots__/createPetWithUnknownTypeUnknown.ts +15 -0
  38. package/src/generators/__snapshots__/deletePet.ts +3 -0
  39. package/src/generators/__snapshots__/enumNamesType.ts +3 -0
  40. package/src/generators/__snapshots__/enumNullable.ts +3 -0
  41. package/src/generators/__snapshots__/enumVarNamesType.ts +3 -0
  42. package/src/generators/__snapshots__/example.ts +3 -0
  43. package/src/generators/__snapshots__/getPets.ts +18 -0
  44. package/src/generators/__snapshots__/mixedValueTypeConst.ts +6 -0
  45. package/src/generators/__snapshots__/nullableString.ts +3 -0
  46. package/src/generators/__snapshots__/nullableStringUuid.ts +3 -0
  47. package/src/generators/__snapshots__/nullableStringWithAnyOf.ts +3 -0
  48. package/src/generators/__snapshots__/numberValueConst.ts +6 -0
  49. package/src/generators/__snapshots__/oneof.ts +3 -0
  50. package/src/generators/__snapshots__/operations.ts +46 -0
  51. package/src/generators/__snapshots__/optionalPetInfer.ts +5 -0
  52. package/src/generators/__snapshots__/optionalPetTyped.ts +3 -0
  53. package/src/generators/__snapshots__/order.ts +3 -0
  54. package/src/generators/__snapshots__/orderDateTyeString.ts +10 -0
  55. package/src/generators/__snapshots__/orderDateTypeFalse.ts +3 -0
  56. package/src/generators/__snapshots__/orderDateTypeString.ts +3 -0
  57. package/src/generators/__snapshots__/pet.ts +3 -0
  58. package/src/generators/__snapshots__/petArray.ts +6 -0
  59. package/src/generators/__snapshots__/petCoercion.ts +3 -0
  60. package/src/generators/__snapshots__/petTupleObject.ts +6 -0
  61. package/src/generators/__snapshots__/petWithMapper.ts +3 -0
  62. package/src/generators/__snapshots__/pets.ts +3 -0
  63. package/src/generators/__snapshots__/recursive.ts +3 -0
  64. package/src/generators/__snapshots__/showPetById.ts +18 -0
  65. package/src/generators/__snapshots__/stringValueConst.ts +6 -0
  66. package/src/generators/__snapshots__/uuidSchema.ts +3 -0
  67. package/src/generators/index.ts +2 -0
  68. package/src/generators/operationsGenerator.tsx +39 -0
  69. package/src/generators/zodGenerator.tsx +121 -0
  70. package/src/parser/index.ts +11 -3
  71. package/src/plugin.ts +22 -37
  72. package/src/types.ts +38 -70
  73. package/dist/Operations-BlQtRP31.d.cts +0 -47
  74. package/dist/Operations-BlQtRP31.d.ts +0 -47
  75. package/dist/chunk-KP7GRUCO.cjs +0 -1279
  76. package/dist/chunk-KP7GRUCO.cjs.map +0 -1
  77. package/dist/chunk-ORHAR2XI.js +0 -1279
  78. package/dist/chunk-ORHAR2XI.js.map +0 -1
  79. package/src/OperationGenerator.tsx +0 -54
  80. package/src/SchemaGenerator.tsx +0 -31
  81. package/src/components/OperationSchema.tsx +0 -66
  82. package/src/components/Schema.tsx +0 -171
  83. package/src/components/__snapshots__/operations.ts +0 -50
@@ -0,0 +1,121 @@
1
+ import { type OperationSchema as OperationSchemaType, SchemaGenerator, createReactGenerator, schemaKeywords } from '@kubb/plugin-oas'
2
+ import { Oas } from '@kubb/plugin-oas/components'
3
+ import { useOas, useOperationManager, useSchemaManager } from '@kubb/plugin-oas/hooks'
4
+ import { pluginTsName } from '@kubb/plugin-ts'
5
+ import { File, useApp } from '@kubb/react'
6
+ import { Zod } from '../components'
7
+ import type { PluginZod } from '../types'
8
+
9
+ export const zodGenerator = createReactGenerator<PluginZod>({
10
+ name: 'zod',
11
+ Operation({ operation, options }) {
12
+ const { coercion, inferred, typed, mapper } = options
13
+
14
+ const { plugin, pluginManager, mode } = useApp<PluginZod>()
15
+ const oas = useOas()
16
+ const { getSchemas, getFile } = useOperationManager()
17
+ const schemaManager = useSchemaManager()
18
+
19
+ const file = getFile(operation)
20
+ const schemas = getSchemas(operation)
21
+ const schemaGenerator = new SchemaGenerator(options, {
22
+ oas,
23
+ plugin,
24
+ pluginManager,
25
+ mode,
26
+ override: options.override,
27
+ })
28
+
29
+ const operationSchemas = [schemas.pathParams, schemas.queryParams, schemas.headerParams, schemas.statusCodes, schemas.request, schemas.response]
30
+ .flat()
31
+ .filter(Boolean)
32
+
33
+ const mapOperationSchema = ({ name, schema, description, keysToOmit, ...options }: OperationSchemaType, i: number) => {
34
+ // hack so Params can be optional when needed
35
+ const required = Array.isArray(schema?.required) ? !!schema.required.length : !!schema?.required
36
+ const optional = !required && !!name.includes('Params')
37
+ const tree = [...schemaGenerator.parse({ schema, name }), optional ? { keyword: schemaKeywords.optional } : undefined].filter(Boolean)
38
+ const imports = schemaManager.getImports(tree)
39
+
40
+ const zod = {
41
+ name: schemaManager.getName(name, { type: 'function' }),
42
+ inferTypeName: schemaManager.getName(name, { type: 'type' }),
43
+ file: schemaManager.getFile(name),
44
+ }
45
+
46
+ const type = {
47
+ name: schemaManager.getName(name, { type: 'type', pluginKey: [pluginTsName] }),
48
+ file: schemaManager.getFile(options.operationName || name, { pluginKey: [pluginTsName], tag: options.operation?.getTags()[0]?.name }),
49
+ }
50
+
51
+ return (
52
+ <Oas.Schema key={i} name={name} value={schema} tree={tree}>
53
+ {typed && <File.Import isTypeOnly root={file.path} path={type.file.path} name={[type.name]} />}
54
+ {imports.map((imp, index) => (
55
+ <File.Import key={index} root={file.path} path={imp.path} name={imp.name} />
56
+ ))}
57
+ <Zod
58
+ name={zod.name}
59
+ typeName={typed ? type.name : undefined}
60
+ inferTypeName={inferred ? zod.inferTypeName : undefined}
61
+ description={description}
62
+ tree={tree}
63
+ mapper={mapper}
64
+ coercion={coercion}
65
+ keysToOmit={keysToOmit}
66
+ />
67
+ </Oas.Schema>
68
+ )
69
+ }
70
+
71
+ return (
72
+ <File baseName={file.baseName} path={file.path} meta={file.meta} banner={plugin.options.output?.banner} footer={plugin.options.output?.footer}>
73
+ <File.Import name={['z']} path={plugin.options.importPath} />
74
+ {operationSchemas.map(mapOperationSchema)}
75
+ </File>
76
+ )
77
+ },
78
+ Schema({ schema, options }) {
79
+ const { coercion, inferred, typed, mapper, importPath } = options
80
+
81
+ const { getName, getFile, getImports } = useSchemaManager()
82
+ const {
83
+ plugin: {
84
+ options: { output },
85
+ },
86
+ } = useApp<PluginZod>()
87
+
88
+ const imports = getImports(schema.tree)
89
+
90
+ const zod = {
91
+ name: getName(schema.name, { type: 'function' }),
92
+ inferTypeName: getName(schema.name, { type: 'type' }),
93
+ file: getFile(schema.name),
94
+ }
95
+
96
+ const type = {
97
+ name: getName(schema.name, { type: 'type', pluginKey: [pluginTsName] }),
98
+ file: getFile(schema.name, { pluginKey: [pluginTsName] }),
99
+ }
100
+
101
+ return (
102
+ <File baseName={zod.file.baseName} path={zod.file.path} meta={zod.file.meta} banner={output?.banner} footer={output?.footer}>
103
+ <File.Import name={['z']} path={importPath} />
104
+ {typed && <File.Import isTypeOnly root={zod.file.path} path={type.file.path} name={[type.name]} />}
105
+ {imports.map((imp, index) => (
106
+ <File.Import key={index} root={zod.file.path} path={imp.path} name={imp.name} />
107
+ ))}
108
+
109
+ <Zod
110
+ name={zod.name}
111
+ typeName={typed ? type.name : undefined}
112
+ inferTypeName={inferred ? zod.inferTypeName : undefined}
113
+ description={schema.value.description}
114
+ tree={schema.tree}
115
+ mapper={mapper}
116
+ coercion={coercion}
117
+ />
118
+ </File>
119
+ )
120
+ },
121
+ })
@@ -3,7 +3,7 @@ import { type SchemaKeywordMapper, isKeyword, schemaKeywords } from '@kubb/plugi
3
3
 
4
4
  import type { Schema, SchemaKeywordBase, SchemaMapper } from '@kubb/plugin-oas'
5
5
 
6
- export const zodKeywordMapper = {
6
+ const zodKeywordMapper = {
7
7
  any: () => 'z.any()',
8
8
  unknown: () => 'z.unknown()',
9
9
  number: (coercion?: boolean, min?: number, max?: number) => {
@@ -12,7 +12,11 @@ export const zodKeywordMapper = {
12
12
  .join('')
13
13
  },
14
14
  integer: (coercion?: boolean, min?: number, max?: number) => {
15
- return [coercion ? 'z.coerce.number()' : 'z.number()', min !== undefined ? `.min(${min})` : undefined, max !== undefined ? `.max(${max})` : undefined]
15
+ return [
16
+ coercion ? 'z.coerce.number().int()' : 'z.number().int()',
17
+ min !== undefined ? `.min(${min})` : undefined,
18
+ max !== undefined ? `.max(${max})` : undefined,
19
+ ]
16
20
  .filter(Boolean)
17
21
  .join('')
18
22
  },
@@ -308,10 +312,14 @@ export function parse(parent: Schema | undefined, current: Schema, options: Pars
308
312
  return zodKeywordMapper.string(options.coercion)
309
313
  }
310
314
 
311
- if (isKeyword(current, schemaKeywords.number) || isKeyword(current, schemaKeywords.integer)) {
315
+ if (isKeyword(current, schemaKeywords.number)) {
312
316
  return zodKeywordMapper.number(options.coercion)
313
317
  }
314
318
 
319
+ if (isKeyword(current, schemaKeywords.integer)) {
320
+ return zodKeywordMapper.integer(options.coercion)
321
+ }
322
+
315
323
  if (isKeyword(current, schemaKeywords.min)) {
316
324
  return zodKeywordMapper.min(current.args)
317
325
  }
package/src/plugin.ts CHANGED
@@ -3,16 +3,14 @@ import path from 'node:path'
3
3
  import { FileManager, PluginManager, createPlugin } from '@kubb/core'
4
4
  import { camelCase, pascalCase } from '@kubb/core/transformers'
5
5
  import { renderTemplate } from '@kubb/core/utils'
6
- import { pluginOasName } from '@kubb/plugin-oas'
7
- import { getGroupedByTagFiles } from '@kubb/plugin-oas/utils'
8
- import { pluginTsName } from '@kubb/plugin-ts'
6
+ import { OperationGenerator, SchemaGenerator, pluginOasName } from '@kubb/plugin-oas'
9
7
 
10
- import { OperationGenerator } from './OperationGenerator.tsx'
11
- import { SchemaGenerator } from './SchemaGenerator.tsx'
8
+ import { pluginTsName } from '@kubb/plugin-ts'
12
9
 
13
10
  import type { Plugin } from '@kubb/core'
14
11
  import type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'
15
- import { Operations } from './components/Operations.tsx'
12
+ import { operationsGenerator } from './generators'
13
+ import { zodGenerator } from './generators/zodGenerator.tsx'
16
14
  import type { PluginZod } from './types.ts'
17
15
 
18
16
  export const pluginZodName = 'plugin-zod' satisfies PluginZod['name']
@@ -28,33 +26,34 @@ export const pluginZod = createPlugin<PluginZod>((options) => {
28
26
  dateType = 'string',
29
27
  unknownType = 'any',
30
28
  typed = false,
31
- typedSchema = false,
32
29
  mapper = {},
33
- templates,
30
+ operations = false,
34
31
  importPath = 'zod',
35
32
  coercion = false,
33
+ inferred = false,
36
34
  } = options
37
35
  const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`
38
36
 
39
37
  return {
40
38
  name: pluginZodName,
41
39
  options: {
40
+ output: {
41
+ exportType: 'barrelNamed',
42
+ ...output,
43
+ },
42
44
  extName: output.extName,
43
45
  transformers,
44
46
  include,
45
47
  exclude,
46
48
  override,
47
49
  typed,
48
- typedSchema,
49
50
  dateType,
50
51
  unknownType,
51
52
  mapper,
52
53
  importPath,
53
54
  coercion,
54
- templates: {
55
- operations: Operations.templates,
56
- ...templates,
57
- },
55
+ operations,
56
+ inferred,
58
57
  },
59
58
  pre: [pluginOasName, typed ? pluginTsName : undefined].filter(Boolean),
60
59
  resolvePath(baseName, pathMode, options) {
@@ -111,7 +110,7 @@ export const pluginZod = createPlugin<PluginZod>((options) => {
111
110
  output: output.path,
112
111
  })
113
112
 
114
- const schemaFiles = await schemaGenerator.build()
113
+ const schemaFiles = await schemaGenerator.build(...[zodGenerator, operations ? operationsGenerator : undefined].filter(Boolean))
115
114
  await this.addFile(...schemaFiles)
116
115
 
117
116
  const operationGenerator = new OperationGenerator(this.plugin.options, {
@@ -125,36 +124,22 @@ export const pluginZod = createPlugin<PluginZod>((options) => {
125
124
  mode,
126
125
  })
127
126
 
128
- const operationFiles = await operationGenerator.build()
127
+ const operationFiles = await operationGenerator.build(...[zodGenerator, operations ? operationsGenerator : undefined].filter(Boolean))
129
128
  await this.addFile(...operationFiles)
130
- },
131
- async buildEnd() {
132
- if (this.config.output.write === false) {
133
- return
134
- }
135
-
136
- const root = path.resolve(this.config.root, this.config.output.path)
137
129
 
138
- if (group?.type === 'tag') {
139
- const rootFiles = await getGroupedByTagFiles({
140
- logger: this.logger,
141
- files: this.fileManager.files,
142
- plugin: this.plugin,
143
- template,
144
- exportAs: group.exportAs || '{{tag}}Schemas',
130
+ if (this.config.output.exportType) {
131
+ const barrelFiles = await this.fileManager.getBarrelFiles({
145
132
  root,
146
133
  output,
134
+ files: this.fileManager.files,
135
+ meta: {
136
+ pluginKey: this.plugin.key,
137
+ },
138
+ logger: this.logger,
147
139
  })
148
140
 
149
- await this.addFile(...rootFiles)
141
+ await this.addFile(...barrelFiles)
150
142
  }
151
-
152
- await this.fileManager.addIndexes({
153
- root,
154
- output,
155
- meta: { pluginKey: this.plugin.key },
156
- logger: this.logger,
157
- })
158
143
  },
159
144
  }
160
145
  })
package/src/types.ts CHANGED
@@ -1,35 +1,12 @@
1
- import type { Plugin, PluginFactoryOptions, ResolveNameParams } from '@kubb/core'
2
- import type * as KubbFile from '@kubb/fs/types'
1
+ import type { Output, PluginFactoryOptions, ResolveNameParams } from '@kubb/core'
3
2
  import type { SchemaObject } from '@kubb/oas'
4
3
  import type { Exclude, Include, Override, ResolvePathOptions, Schema } from '@kubb/plugin-oas'
5
- import type { Operations } from './components/Operations'
6
-
7
- type Templates = {
8
- operations?: typeof Operations.templates | false
9
- }
10
4
 
11
5
  export type Options = {
12
- output?: {
13
- /**
14
- * Relative path to save the Zod schemas.
15
- * When output is a file it will save all models inside that file else it will create a file per schema item.
16
- * @default 'zod'
17
- */
18
- path: string
19
- /**
20
- * Name to be used for the `export * as {{exportAs}} from './'`
21
- */
22
- exportAs?: string
23
- /**
24
- * Add an extension to the generated imports and exports, default it will not use an extension
25
- */
26
- extName?: KubbFile.Extname
27
- /**
28
- * Define what needs to exported, here you can also disable the export of barrel files
29
- * @default `'barrel'`
30
- */
31
- exportType?: 'barrel' | 'barrelNamed' | false
32
- }
6
+ /**
7
+ * @default 'zod'
8
+ */
9
+ output?: Output
33
10
  /**
34
11
  * Group the Zod schemas based on the provided name.
35
12
  */
@@ -64,30 +41,15 @@ export type Options = {
64
41
  * Array containing override parameters to override `options` based on tags/operations/methods/paths.
65
42
  */
66
43
  override?: Array<Override<ResolvedOptions>>
67
- transformers?: {
68
- /**
69
- * Customize the names based on the type that is provided by the plugin.
70
- */
71
- name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string
72
- /**
73
- * Receive schema and baseName(propertName) and return FakerMeta array
74
- * TODO TODO add docs
75
- * @beta
76
- */
77
- schema?: (
78
- props: {
79
- schema?: SchemaObject
80
- name?: string
81
- parentName?: string
82
- },
83
- defaultSchemas: Schema[],
84
- ) => Schema[] | undefined
85
- }
86
- mapper?: Record<string, string>
87
44
  /**
88
- * Make it possible to override one of the templates
45
+ * Path to Zod
46
+ * It will be used as `import { z } from '${importPath}'`.
47
+ * It allows both relative and absolute path.
48
+ * the path will be applied as is, so relative path should be based on the file being generated.
49
+ * @default 'zod'
89
50
  */
90
- templates?: Partial<Templates>
51
+ importPath?: string
52
+
91
53
  /**
92
54
  * Choose to use `date` or `datetime` as JavaScript `Date` instead of `string`.
93
55
  * False will fallback on a simple z.string() format
@@ -106,40 +68,46 @@ export type Options = {
106
68
  /**
107
69
  * Return Zod generated schema as type with z.infer<TYPE>
108
70
  */
109
- typedSchema?: boolean
71
+ inferred?: boolean
110
72
  /**
111
73
  * Use of z.coerce.string() instead of z.string()
112
74
  */
113
75
  coercion?: boolean
114
- /**
115
- * Path to Zod
116
- * It will be used as `import { z } from '${importPath}'`.
117
- * It allows both relative and absolute path.
118
- * the path will be applied as is, so relative path should be based on the file being generated.
119
- * @default 'zod'
120
- */
121
- importPath?: string
76
+ operations?: boolean
77
+ mapper?: Record<string, string>
78
+ transformers?: {
79
+ /**
80
+ * Customize the names based on the type that is provided by the plugin.
81
+ */
82
+ name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string
83
+ /**
84
+ * Receive schema and baseName(propertName) and return FakerMeta array
85
+ * TODO TODO add docs
86
+ * @beta
87
+ */
88
+ schema?: (
89
+ props: {
90
+ schema?: SchemaObject
91
+ name?: string
92
+ parentName?: string
93
+ },
94
+ defaultSchemas: Schema[],
95
+ ) => Schema[] | undefined
96
+ }
122
97
  }
123
98
 
124
99
  type ResolvedOptions = {
125
- extName: KubbFile.Extname | undefined
100
+ output: Output
101
+ override: NonNullable<Options['override']>
126
102
  transformers: NonNullable<Options['transformers']>
127
- exclude: Options['exclude']
128
- include: Options['include']
129
- override: Options['override']
130
103
  dateType: NonNullable<Options['dateType']>
131
104
  unknownType: NonNullable<Options['unknownType']>
132
105
  typed: NonNullable<Options['typed']>
133
- typedSchema: NonNullable<Options['typedSchema']>
134
- templates: NonNullable<Templates>
106
+ inferred: NonNullable<Options['inferred']>
135
107
  mapper: NonNullable<Options['mapper']>
136
108
  importPath: NonNullable<Options['importPath']>
137
109
  coercion: NonNullable<Options['coercion']>
138
- }
139
-
140
- export type FileMeta = {
141
- pluginKey?: Plugin['key']
142
- tag?: string
110
+ operations: NonNullable<Options['coercion']>
143
111
  }
144
112
 
145
113
  export type PluginZod = PluginFactoryOptions<'plugin-zod', Options, ResolvedOptions, never, ResolvePathOptions>
@@ -1,47 +0,0 @@
1
- import { Operation } from '@kubb/oas';
2
- import { KubbNode } from '@kubb/react';
3
- import { ComponentType, ComponentProps } from 'react';
4
-
5
- type TemplateProps = {
6
- /**
7
- * Name of the function
8
- */
9
- operationsName: string;
10
- /**
11
- * Name of the function
12
- */
13
- pathsName: string;
14
- operations: Operation[];
15
- };
16
- declare function Template({ operationsName, pathsName, operations }: TemplateProps): KubbNode;
17
- type RootTemplateProps = {
18
- children?: React.ReactNode;
19
- };
20
- declare function RootTemplate({ children }: RootTemplateProps): JSX.Element;
21
- declare const defaultTemplates: {
22
- readonly default: typeof Template;
23
- readonly root: typeof RootTemplate;
24
- };
25
- type Templates = Partial<typeof defaultTemplates>;
26
- type Props = {
27
- /**
28
- * This will make it possible to override the default behaviour.
29
- */
30
- Template?: ComponentType<ComponentProps<typeof Template>>;
31
- };
32
- declare function Operations({ Template }: Props): KubbNode;
33
- declare namespace Operations {
34
- var File: (props: FileProps) => KubbNode;
35
- var templates: {
36
- readonly default: typeof Template;
37
- readonly root: typeof RootTemplate;
38
- };
39
- }
40
- type FileProps = {
41
- /**
42
- * This will make it possible to override the default behaviour.
43
- */
44
- templates?: Templates;
45
- };
46
-
47
- export { Operations as O };
@@ -1,47 +0,0 @@
1
- import { Operation } from '@kubb/oas';
2
- import { KubbNode } from '@kubb/react';
3
- import { ComponentType, ComponentProps } from 'react';
4
-
5
- type TemplateProps = {
6
- /**
7
- * Name of the function
8
- */
9
- operationsName: string;
10
- /**
11
- * Name of the function
12
- */
13
- pathsName: string;
14
- operations: Operation[];
15
- };
16
- declare function Template({ operationsName, pathsName, operations }: TemplateProps): KubbNode;
17
- type RootTemplateProps = {
18
- children?: React.ReactNode;
19
- };
20
- declare function RootTemplate({ children }: RootTemplateProps): JSX.Element;
21
- declare const defaultTemplates: {
22
- readonly default: typeof Template;
23
- readonly root: typeof RootTemplate;
24
- };
25
- type Templates = Partial<typeof defaultTemplates>;
26
- type Props = {
27
- /**
28
- * This will make it possible to override the default behaviour.
29
- */
30
- Template?: ComponentType<ComponentProps<typeof Template>>;
31
- };
32
- declare function Operations({ Template }: Props): KubbNode;
33
- declare namespace Operations {
34
- var File: (props: FileProps) => KubbNode;
35
- var templates: {
36
- readonly default: typeof Template;
37
- readonly root: typeof RootTemplate;
38
- };
39
- }
40
- type FileProps = {
41
- /**
42
- * This will make it possible to override the default behaviour.
43
- */
44
- templates?: Templates;
45
- };
46
-
47
- export { Operations as O };