@kubb/plugin-oas 0.0.0-canary-20240806053140 → 0.0.0-canary-20241106205013

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 (105) hide show
  1. package/README.md +14 -5
  2. package/dist/OperationGenerator-Bw6sj3Eb.d.cts +560 -0
  3. package/dist/OperationGenerator-Bw6sj3Eb.d.ts +560 -0
  4. package/dist/Schema-4FwWfdim.d.cts +22 -0
  5. package/dist/Schema-BlGtSgNB.d.ts +22 -0
  6. package/dist/chunk-2TGWPVZN.cjs +92 -0
  7. package/dist/chunk-2TGWPVZN.cjs.map +1 -0
  8. package/dist/chunk-A3ROGKLW.cjs +752 -0
  9. package/dist/chunk-A3ROGKLW.cjs.map +1 -0
  10. package/dist/chunk-ABOQ73FL.cjs +36 -0
  11. package/dist/chunk-ABOQ73FL.cjs.map +1 -0
  12. package/dist/chunk-BG77DP54.js +30 -0
  13. package/dist/chunk-BG77DP54.js.map +1 -0
  14. package/dist/chunk-GF26SDHQ.js +28 -0
  15. package/dist/chunk-GF26SDHQ.js.map +1 -0
  16. package/dist/chunk-JA75IPYU.js +744 -0
  17. package/dist/chunk-JA75IPYU.js.map +1 -0
  18. package/dist/chunk-PADR76WZ.cjs +4 -0
  19. package/dist/chunk-PADR76WZ.cjs.map +1 -0
  20. package/dist/chunk-QAFBZLJA.cjs +48 -0
  21. package/dist/chunk-QAFBZLJA.cjs.map +1 -0
  22. package/dist/chunk-R47XMJ32.js +3 -0
  23. package/dist/chunk-R47XMJ32.js.map +1 -0
  24. package/dist/chunk-TNWNNVQW.js +88 -0
  25. package/dist/chunk-TNWNNVQW.js.map +1 -0
  26. package/dist/chunk-XNCEFOE6.js +45 -0
  27. package/dist/chunk-XNCEFOE6.js.map +1 -0
  28. package/dist/chunk-ZWHQ54JM.cjs +32 -0
  29. package/dist/chunk-ZWHQ54JM.cjs.map +1 -0
  30. package/dist/components.cjs +20 -17
  31. package/dist/components.cjs.map +1 -1
  32. package/dist/components.d.cts +12 -9
  33. package/dist/components.d.ts +12 -9
  34. package/dist/components.js +3 -17
  35. package/dist/components.js.map +1 -1
  36. package/dist/generators.cjs +14 -0
  37. package/dist/generators.cjs.map +1 -0
  38. package/dist/generators.d.cts +9 -0
  39. package/dist/generators.d.ts +9 -0
  40. package/dist/generators.js +5 -0
  41. package/dist/generators.js.map +1 -0
  42. package/dist/hooks.cjs +90 -58
  43. package/dist/hooks.cjs.map +1 -1
  44. package/dist/hooks.d.cts +37 -10
  45. package/dist/hooks.d.ts +37 -10
  46. package/dist/hooks.js +79 -54
  47. package/dist/hooks.js.map +1 -1
  48. package/dist/index.cjs +277 -270
  49. package/dist/index.cjs.map +1 -1
  50. package/dist/index.d.cts +6 -78
  51. package/dist/index.d.ts +6 -78
  52. package/dist/index.js +235 -255
  53. package/dist/index.js.map +1 -1
  54. package/dist/utils.cjs +32 -87
  55. package/dist/utils.cjs.map +1 -1
  56. package/dist/utils.d.cts +8 -43
  57. package/dist/utils.d.ts +8 -43
  58. package/dist/utils.js +8 -86
  59. package/dist/utils.js.map +1 -1
  60. package/package.json +21 -15
  61. package/src/OperationGenerator.ts +91 -64
  62. package/src/SchemaGenerator.ts +102 -22
  63. package/src/SchemaMapper.ts +24 -5
  64. package/src/components/Oas.tsx +9 -3
  65. package/src/components/Operation.tsx +1 -1
  66. package/src/components/Schema.tsx +2 -102
  67. package/src/generator.tsx +129 -0
  68. package/src/generators/index.ts +1 -0
  69. package/src/generators/jsonGenerator.ts +32 -0
  70. package/src/hooks/index.ts +2 -0
  71. package/src/hooks/useOperationManager.ts +56 -30
  72. package/src/hooks/useSchemaManager.ts +77 -0
  73. package/src/index.ts +5 -13
  74. package/src/plugin.ts +73 -69
  75. package/src/types.ts +29 -27
  76. package/src/utils/getParams.ts +2 -2
  77. package/src/utils/getSchemaFactory.ts +1 -1
  78. package/src/utils/index.ts +2 -2
  79. package/src/utils/parseFromConfig.ts +7 -7
  80. package/dist/OperationGenerator-BV6QRtkW.d.cts +0 -60
  81. package/dist/OperationGenerator-DO5tNGuT.d.ts +0 -60
  82. package/dist/Schema-DefwBJMc.d.ts +0 -35
  83. package/dist/Schema-an5hOrjZ.d.cts +0 -35
  84. package/dist/SchemaMapper-CsBQ6eEx.d.cts +0 -248
  85. package/dist/SchemaMapper-CsBQ6eEx.d.ts +0 -248
  86. package/dist/chunk-6QFVU3BI.js +0 -3265
  87. package/dist/chunk-6QFVU3BI.js.map +0 -1
  88. package/dist/chunk-7BYOJGO3.js +0 -35
  89. package/dist/chunk-7BYOJGO3.js.map +0 -1
  90. package/dist/chunk-DHPXS6V7.cjs +0 -35
  91. package/dist/chunk-DHPXS6V7.cjs.map +0 -1
  92. package/dist/chunk-E4NYDEAU.js +0 -101
  93. package/dist/chunk-E4NYDEAU.js.map +0 -1
  94. package/dist/chunk-KGR7UP2W.js +0 -695
  95. package/dist/chunk-KGR7UP2W.js.map +0 -1
  96. package/dist/chunk-M62LERKB.cjs +0 -695
  97. package/dist/chunk-M62LERKB.cjs.map +0 -1
  98. package/dist/chunk-NLQIW5KR.cjs +0 -3265
  99. package/dist/chunk-NLQIW5KR.cjs.map +0 -1
  100. package/dist/chunk-PHNRHM3I.cjs +0 -101
  101. package/dist/chunk-PHNRHM3I.cjs.map +0 -1
  102. package/dist/types-Db0qp8u-.d.cts +0 -148
  103. package/dist/types-Db0qp8u-.d.ts +0 -148
  104. package/src/utils/getGroupedByTagFiles.ts +0 -82
  105. package/src/utils/refSorter.ts +0 -13
package/src/plugin.ts CHANGED
@@ -1,34 +1,35 @@
1
- import path from 'node:path'
2
-
3
- import { createPlugin } from '@kubb/core'
4
- import { camelCase } from '@kubb/core/transformers'
1
+ import { FileManager, createPlugin } from '@kubb/core'
5
2
 
6
3
  import { getSchemas } from './utils/getSchemas.ts'
4
+ import { parseFromConfig } from './utils/parseFromConfig.ts'
7
5
 
6
+ import path from 'node:path'
8
7
  import type { Config } from '@kubb/core'
9
8
  import type { Logger } from '@kubb/core/logger'
10
- import type { Oas, OasTypes } from '@kubb/oas'
11
- import type { FormatOptions } from '@kubb/oas/parser'
9
+ import type { Oas } from '@kubb/oas'
10
+ import { OperationGenerator } from './OperationGenerator.ts'
11
+ import { SchemaGenerator } from './SchemaGenerator.ts'
12
+ import { jsonGenerator } from './generators'
12
13
  import type { PluginOas } from './types.ts'
13
- import { parseFromConfig } from './utils/parseFromConfig.ts'
14
14
 
15
15
  export const pluginOasName = 'plugin-oas' satisfies PluginOas['name']
16
16
 
17
17
  export const pluginOas = createPlugin<PluginOas>((options) => {
18
18
  const {
19
- output = { path: 'schemas', export: false },
20
- experimentalFilter: filter,
21
- experimentalSort: sort,
19
+ output = {
20
+ path: 'schemas',
21
+ },
22
22
  validate = true,
23
- serverIndex = 0,
23
+ generators = [jsonGenerator],
24
+ serverIndex,
24
25
  contentType,
25
26
  oasClass,
26
27
  } = options
27
28
 
28
- const getOas = async ({ config, logger, formatOptions }: { config: Config; logger: Logger; formatOptions?: FormatOptions }): Promise<Oas> => {
29
+ const getOas = async ({ config, logger }: { config: Config; logger: Logger }): Promise<Oas> => {
29
30
  try {
30
31
  // needs to be in a different variable or the catch here will not work(return of a promise instead)
31
- const oas = await parseFromConfig(config, formatOptions, oasClass)
32
+ const oas = await parseFromConfig(config, oasClass)
32
33
 
33
34
  if (validate) {
34
35
  await oas.valdiate()
@@ -39,20 +40,22 @@ export const pluginOas = createPlugin<PluginOas>((options) => {
39
40
  const error = e as Error
40
41
 
41
42
  logger.emit('warning', error?.message)
42
- return parseFromConfig(config, {}, oasClass)
43
+ return parseFromConfig(config, oasClass)
43
44
  }
44
45
  }
45
46
 
46
47
  return {
47
48
  name: pluginOasName,
48
- options,
49
-
50
- api() {
49
+ options: {
50
+ output,
51
+ ...options,
52
+ },
53
+ context() {
51
54
  const { config, logger } = this
52
55
 
53
56
  return {
54
- getOas(formatOptions) {
55
- return getOas({ config, logger, formatOptions })
57
+ getOas() {
58
+ return getOas({ config, logger })
56
59
  },
57
60
  async getSchemas({ includes } = {}) {
58
61
  const oas = await this.getOas()
@@ -60,30 +63,28 @@ export const pluginOas = createPlugin<PluginOas>((options) => {
60
63
  },
61
64
  async getBaseURL() {
62
65
  const oasInstance = await this.getOas()
63
- const baseURL = oasInstance.api.servers?.at(serverIndex)?.url
64
- return baseURL
66
+ if (serverIndex) {
67
+ return oasInstance.api.servers?.at(serverIndex)?.url
68
+ }
69
+
70
+ return undefined
65
71
  },
66
72
  contentType,
67
73
  }
68
74
  },
69
- resolvePath(baseName) {
70
- if (output === false) {
71
- return undefined
72
- }
73
-
75
+ resolvePath(baseName, pathMode, options) {
74
76
  const root = path.resolve(this.config.root, this.config.output.path)
75
-
76
- return path.resolve(root, output.path, baseName)
77
- },
78
- resolveName(name, type) {
79
- return camelCase(name, { isFile: type === 'file' })
80
- },
81
- async writeFile(path, source) {
82
- if (!path.endsWith('.json') || !source) {
83
- return
77
+ const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path))
78
+
79
+ if (mode === 'single') {
80
+ /**
81
+ * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend
82
+ * Other plugins then need to call addOrAppend instead of just add from the fileManager class
83
+ */
84
+ return path.resolve(root, output.path)
84
85
  }
85
86
 
86
- return this.fileManager.write(path, source, { sanity: false })
87
+ return path.resolve(root, output.path, baseName)
87
88
  },
88
89
  async buildStart() {
89
90
  if (!output) {
@@ -93,42 +94,45 @@ export const pluginOas = createPlugin<PluginOas>((options) => {
93
94
  const oas = await getOas({
94
95
  config: this.config,
95
96
  logger: this.logger,
96
- formatOptions: {
97
- filterSet: filter,
98
- sortSet: sort,
99
- },
100
97
  })
101
98
  await oas.dereference()
102
- const schemas = getSchemas({ oas, contentType })
103
-
104
- const mapSchema = async ([name, schema]: [string, OasTypes.SchemaObject]) => {
105
- const resolvedPath = this.resolvePath({
106
- baseName: `${name}.json`,
107
- pluginKey: this.plugin.key,
108
- })
109
-
110
- const resvoledFileName = this.resolveName({
111
- name: `${name}.json`,
112
- pluginKey: [pluginOasName],
113
- type: 'file',
114
- }) as `${string}.json`
115
-
116
- if (!resolvedPath) {
117
- return
118
- }
119
-
120
- await this.addFile({
121
- path: resolvedPath,
122
- baseName: resvoledFileName,
123
- source: JSON.stringify(schema),
124
- meta: {
125
- pluginKey: this.plugin.key,
126
- },
127
- })
128
- }
129
99
 
130
- const promises = Object.entries(schemas).map(mapSchema)
131
- await Promise.all(promises)
100
+ const schemaGenerator = new SchemaGenerator(
101
+ {
102
+ unknownType: 'unknown',
103
+ dateType: 'date',
104
+ transformers: {},
105
+ ...this.plugin.options,
106
+ },
107
+ {
108
+ oas,
109
+ pluginManager: this.pluginManager,
110
+ plugin: this.plugin,
111
+ contentType,
112
+ include: undefined,
113
+ override: undefined,
114
+ mode: 'split',
115
+ output: output.path,
116
+ },
117
+ )
118
+
119
+ const schemaFiles = await schemaGenerator.build(...generators)
120
+ await this.addFile(...schemaFiles)
121
+
122
+ const operationGenerator = new OperationGenerator(this.plugin.options, {
123
+ oas,
124
+ pluginManager: this.pluginManager,
125
+ plugin: this.plugin,
126
+ contentType,
127
+ exclude: undefined,
128
+ include: undefined,
129
+ override: undefined,
130
+ mode: 'split',
131
+ })
132
+
133
+ const operationFiles = await operationGenerator.build(...generators)
134
+
135
+ await this.addFile(...operationFiles)
132
136
  },
133
137
  }
134
138
  })
package/src/types.ts CHANGED
@@ -1,9 +1,9 @@
1
- import type { Plugin } from '@kubb/core'
1
+ import type { Output, Plugin } from '@kubb/core'
2
2
  import type { PluginFactoryOptions, ResolveNameParams } from '@kubb/core'
3
3
  import type * as KubbFile from '@kubb/fs/types'
4
4
 
5
5
  import type { HttpMethod, Oas, Operation, SchemaObject, contentType } from '@kubb/oas'
6
- import type { FormatOptions } from '@kubb/oas/parser'
6
+ import type { Generator } from './generator.tsx'
7
7
  import type { GetSchemasProps } from './utils/getSchemas.ts'
8
8
 
9
9
  export type ResolvePathOptions = {
@@ -13,7 +13,7 @@ export type ResolvePathOptions = {
13
13
  }
14
14
 
15
15
  export type API = {
16
- getOas: (formatOptions?: FormatOptions) => Promise<Oas>
16
+ getOas: () => Promise<Oas>
17
17
  getSchemas: (options?: Pick<GetSchemasProps, 'includes'>) => Promise<Record<string, SchemaObject>>
18
18
  getBaseURL: () => Promise<string | undefined>
19
19
  contentType?: contentType
@@ -25,44 +25,42 @@ export type Options = {
25
25
  * @default true
26
26
  */
27
27
  validate?: boolean
28
- output?:
29
- | {
30
- /**
31
- * Relative path to save the JSON models.
32
- * False will not generate the schema JSON's.
33
- * @default 'schemas'
34
- */
35
- path: string
36
- }
37
- | false
28
+ /**
29
+ * Specify the export location for the files and define the behavior of the output
30
+ * @default { path: 'schemas', barrelType: 'named' }
31
+ */
32
+ output?: Output
38
33
  /**
39
34
  * Which server to use from the array of `servers.url[serverIndex]`
40
35
  * @example
41
36
  * - `0` will return `http://petstore.swagger.io/api`
42
37
  * - `1` will return `http://localhost:3000`
43
- * @default 0
44
38
  */
45
39
  serverIndex?: number
46
40
  /**
47
41
  * Define which contentType should be used.
48
- * By default, this is set based on the first used contentType..
42
+ * By default, this is set based on the contentType being found.
49
43
  */
50
44
  contentType?: contentType
51
- experimentalFilter?: FormatOptions['filterSet']
52
- experimentalSort?: FormatOptions['sortSet']
45
+ /**
46
+ * Override some behaviour of the Oas class instance, see '@kubb/oas'
47
+ */
53
48
  oasClass?: typeof Oas
49
+ /**
50
+ * Define some generators next to the JSON generation
51
+ */
52
+ generators?: Array<Generator<PluginOas>>
54
53
  }
55
54
 
56
55
  /**
57
56
  * `propertyName` is the ref name + resolved with the nameResolver
58
- * @example `import { Pet } from './Pet'`
57
+ * @example import { Pet } from './Pet'
59
58
  *
60
59
  * `originalName` is the original name used(in PascalCase), only used to remove duplicates
61
60
  *
62
61
  * `pluginKey` can be used to override the current plugin being used, handy when you want to import a type/schema out of another plugin
63
- * @example import a type(swagger-ts) for a mock file(swagger-faker)
62
+ * @example import a type(plugin-ts) for a mock file(swagger-faker)
64
63
  */
65
-
66
64
  export type Ref = {
67
65
  propertyName: string
68
66
  originalName: string
@@ -90,7 +88,7 @@ export type OperationSchema = {
90
88
  /**
91
89
  * OperationName in PascalCase, only being used in OperationGenerator
92
90
  */
93
- operationName?: string
91
+ operationName: string
94
92
  description?: string
95
93
  statusCode?: number
96
94
  keys?: string[]
@@ -104,6 +102,7 @@ export type OperationSchemas = {
104
102
  headerParams?: OperationSchema & { keysToOmit?: never }
105
103
  request?: OperationSchema
106
104
  response: OperationSchema
105
+ responses: Array<OperationSchema>
107
106
  statusCodes?: Array<OperationSchema>
108
107
  errors?: Array<OperationSchema>
109
108
  }
@@ -128,6 +127,11 @@ type ByMethod = {
128
127
  type: 'method'
129
128
  pattern: HttpMethod | RegExp
130
129
  }
130
+ // TODO implement as alternative for ByMethod
131
+ type ByMethods = {
132
+ type: 'methods'
133
+ pattern: Array<HttpMethod>
134
+ }
131
135
 
132
136
  type BySchemaName = {
133
137
  type: 'schemaName'
@@ -141,10 +145,8 @@ export type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | By
141
145
  options: Partial<TOptions>
142
146
  }
143
147
 
144
- export type PluginOas = PluginFactoryOptions<'plugin-oas', Options, Options, API, never>
145
-
146
- declare module '@kubb/core' {
147
- export interface _Register {
148
- ['@kubb/plugin-oas']: PluginOas
149
- }
148
+ type ResolvedOptions = Options & {
149
+ output: Output
150
150
  }
151
+
152
+ export type PluginOas = PluginFactoryOptions<'plugin-oas', Options, ResolvedOptions, API, never>
@@ -1,10 +1,10 @@
1
1
  import { isParameterObject } from '@kubb/oas'
2
2
 
3
+ import { camelCase } from '@kubb/core/transformers'
3
4
  import type { FunctionParamsAST } from '@kubb/core/utils'
4
5
  import type { OasTypes } from '@kubb/oas'
5
- import type { Params } from '@kubb/react'
6
+ import type { Params } from '@kubb/react/types'
6
7
  import type { OperationSchema } from '../types.ts'
7
- import { camelCase } from '@kubb/core/transformers'
8
8
  /**
9
9
  *
10
10
  * @deprecated
@@ -26,7 +26,7 @@ export function getSchemaFactory<TWithRef extends boolean = false>(oas: Oas): (s
26
26
  const version = isOpenApiV3_1Document(oas.api) ? '3.1' : '3.0'
27
27
 
28
28
  return {
29
- schema,
29
+ schema: oas.dereferenceWithRef(schema),
30
30
  version,
31
31
  } as SchemaResult<TWithRef>
32
32
  }
@@ -1,8 +1,8 @@
1
1
  export { getComments } from './getComments.ts'
2
- export { getGroupedByTagFiles } from './getGroupedByTagFiles.ts'
3
2
  export { getASTParams, getPathParams } from './getParams.ts'
4
3
  export { getSchemaFactory } from './getSchemaFactory.ts'
5
4
  export type { GetSchemasProps } from './getSchemas.ts'
6
5
  export { getSchemas } from './getSchemas.ts'
7
- export { refsSorter } from './refSorter.ts'
8
6
  export { parseFromConfig } from './parseFromConfig.ts'
7
+
8
+ export { isOptional } from '@kubb/oas'
@@ -2,35 +2,35 @@ import { resolve } from 'node:path'
2
2
 
3
3
  import { URLPath } from '@kubb/core/utils'
4
4
 
5
- import { type FormatOptions, parse } from '@kubb/oas/parser'
5
+ import { parse } from '@kubb/oas/parser'
6
6
 
7
7
  import type { Config } from '@kubb/core'
8
8
  import { Oas, type OasTypes } from '@kubb/oas'
9
9
  import yaml from '@stoplight/yaml'
10
10
 
11
- export function parseFromConfig(config: Config, options: FormatOptions = {}, oasClass: typeof Oas = Oas): Promise<Oas> {
11
+ export function parseFromConfig(config: Config, oasClass: typeof Oas = Oas): Promise<Oas> {
12
12
  if ('data' in config.input) {
13
13
  if (typeof config.input.data === 'object') {
14
14
  const api: OasTypes.OASDocument = JSON.parse(JSON.stringify(config.input.data)) as OasTypes.OASDocument
15
- return parse(api, options, oasClass)
15
+ return parse(api, oasClass)
16
16
  }
17
17
 
18
18
  try {
19
19
  const api: string = yaml.parse(config.input.data as string) as string
20
20
 
21
- return parse(api, options, oasClass)
21
+ return parse(api, oasClass)
22
22
  } catch (e) {
23
23
  /* empty */
24
24
  }
25
25
 
26
26
  const api: OasTypes.OASDocument = JSON.parse(JSON.stringify(config.input.data)) as OasTypes.OASDocument
27
27
 
28
- return parse(api, options, oasClass)
28
+ return parse(api, oasClass)
29
29
  }
30
30
 
31
31
  if (new URLPath(config.input.path).isURL) {
32
- return parse(config.input.path, options, oasClass)
32
+ return parse(config.input.path, oasClass)
33
33
  }
34
34
 
35
- return parse(resolve(config.root, config.input.path), options, oasClass)
35
+ return parse(resolve(config.root, config.input.path), oasClass)
36
36
  }
@@ -1,60 +0,0 @@
1
- import { FileMetaBase, PluginFactoryOptions, Generator, PluginManager, Plugin } from '@kubb/core';
2
- import * as KubbFile from '@kubb/fs/types';
3
- import { Operation, Oas, contentType } from '@kubb/oas';
4
- import { g as OperationsByMethod, f as OperationSchemas, E as Exclude, I as Include, b as Override } from './types-Db0qp8u-.cjs';
5
-
6
- type GetOperationGeneratorOptions<T extends OperationGenerator<any, any, any>> = T extends OperationGenerator<infer Options, any, any> ? Options : never;
7
- type OperationMethodResult<TFileMeta extends FileMetaBase> = Promise<KubbFile.File<TFileMeta> | Array<KubbFile.File<TFileMeta>> | null>;
8
- type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
9
- oas: Oas;
10
- exclude: Array<Exclude> | undefined;
11
- include: Array<Include> | undefined;
12
- override: Array<Override<TOptions>> | undefined;
13
- contentType: contentType | undefined;
14
- pluginManager: PluginManager;
15
- /**
16
- * Current plugin
17
- */
18
- plugin: Plugin<TPluginOptions>;
19
- mode: KubbFile.Mode;
20
- };
21
- declare abstract class OperationGenerator<TOptions = unknown, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends Generator<TOptions, Context<TOptions, TPluginOptions>> {
22
- #private;
23
- get operationsByMethod(): OperationsByMethod;
24
- set operationsByMethod(paths: OperationsByMethod);
25
- getSchemas(operation: Operation, { forStatusCode, resolveName }?: {
26
- forStatusCode?: string | number;
27
- resolveName?: (name: string) => string;
28
- }): OperationSchemas;
29
- build(): Promise<Array<KubbFile.File<TFileMeta>>>;
30
- /**
31
- * Operation
32
- */
33
- operation(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta>;
34
- /**
35
- * GET
36
- */
37
- get(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta>;
38
- /**
39
- * POST
40
- */
41
- post(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta>;
42
- /**
43
- * PATCH
44
- */
45
- patch(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta>;
46
- /**
47
- * PUT
48
- */
49
- put(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta>;
50
- /**
51
- * DELETE
52
- */
53
- delete(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta>;
54
- /**
55
- * Combination of GET, POST, PATCH, PUT, DELETE
56
- */
57
- all(operations: Operation[], paths: OperationsByMethod): OperationMethodResult<TFileMeta>;
58
- }
59
-
60
- export { type GetOperationGeneratorOptions as G, type OperationMethodResult as O, OperationGenerator as a };
@@ -1,60 +0,0 @@
1
- import { FileMetaBase, PluginFactoryOptions, Generator, PluginManager, Plugin } from '@kubb/core';
2
- import * as KubbFile from '@kubb/fs/types';
3
- import { Operation, Oas, contentType } from '@kubb/oas';
4
- import { g as OperationsByMethod, f as OperationSchemas, E as Exclude, I as Include, b as Override } from './types-Db0qp8u-.js';
5
-
6
- type GetOperationGeneratorOptions<T extends OperationGenerator<any, any, any>> = T extends OperationGenerator<infer Options, any, any> ? Options : never;
7
- type OperationMethodResult<TFileMeta extends FileMetaBase> = Promise<KubbFile.File<TFileMeta> | Array<KubbFile.File<TFileMeta>> | null>;
8
- type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
9
- oas: Oas;
10
- exclude: Array<Exclude> | undefined;
11
- include: Array<Include> | undefined;
12
- override: Array<Override<TOptions>> | undefined;
13
- contentType: contentType | undefined;
14
- pluginManager: PluginManager;
15
- /**
16
- * Current plugin
17
- */
18
- plugin: Plugin<TPluginOptions>;
19
- mode: KubbFile.Mode;
20
- };
21
- declare abstract class OperationGenerator<TOptions = unknown, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends Generator<TOptions, Context<TOptions, TPluginOptions>> {
22
- #private;
23
- get operationsByMethod(): OperationsByMethod;
24
- set operationsByMethod(paths: OperationsByMethod);
25
- getSchemas(operation: Operation, { forStatusCode, resolveName }?: {
26
- forStatusCode?: string | number;
27
- resolveName?: (name: string) => string;
28
- }): OperationSchemas;
29
- build(): Promise<Array<KubbFile.File<TFileMeta>>>;
30
- /**
31
- * Operation
32
- */
33
- operation(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta>;
34
- /**
35
- * GET
36
- */
37
- get(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta>;
38
- /**
39
- * POST
40
- */
41
- post(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta>;
42
- /**
43
- * PATCH
44
- */
45
- patch(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta>;
46
- /**
47
- * PUT
48
- */
49
- put(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta>;
50
- /**
51
- * DELETE
52
- */
53
- delete(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta>;
54
- /**
55
- * Combination of GET, POST, PATCH, PUT, DELETE
56
- */
57
- all(operations: Operation[], paths: OperationsByMethod): OperationMethodResult<TFileMeta>;
58
- }
59
-
60
- export { type GetOperationGeneratorOptions as G, type OperationMethodResult as O, OperationGenerator as a };
@@ -1,35 +0,0 @@
1
- import * as react from 'react';
2
- import { ReactNode } from 'react';
3
- import * as KubbFile from '@kubb/fs/types';
4
- import { SchemaObject } from '@kubb/oas';
5
- import { KubbNode } from '@kubb/react';
6
- import { S as Schema$1 } from './SchemaMapper-CsBQ6eEx.js';
7
-
8
- type SchemaContextProps = {
9
- name: string;
10
- schema?: SchemaObject;
11
- tree: Array<Schema$1>;
12
- };
13
- type Props = {
14
- name: string;
15
- value?: SchemaObject;
16
- tree?: Array<Schema$1>;
17
- children?: KubbNode;
18
- };
19
- declare function Schema({ name, value, tree, children }: Props): KubbNode;
20
- declare namespace Schema {
21
- var File: ({ output, isTypeOnly, children }: FileProps) => ReactNode;
22
- var Imports: ({ isTypeOnly, extName }: SchemaImportsProps) => ReactNode;
23
- var Context: react.Context<SchemaContextProps>;
24
- }
25
- type FileProps = {
26
- isTypeOnly?: boolean;
27
- output: string | undefined;
28
- children?: KubbNode;
29
- };
30
- type SchemaImportsProps = {
31
- isTypeOnly?: boolean;
32
- extName?: KubbFile.Extname;
33
- };
34
-
35
- export { Schema as S, type SchemaContextProps as a };
@@ -1,35 +0,0 @@
1
- import * as react from 'react';
2
- import { ReactNode } from 'react';
3
- import * as KubbFile from '@kubb/fs/types';
4
- import { SchemaObject } from '@kubb/oas';
5
- import { KubbNode } from '@kubb/react';
6
- import { S as Schema$1 } from './SchemaMapper-CsBQ6eEx.cjs';
7
-
8
- type SchemaContextProps = {
9
- name: string;
10
- schema?: SchemaObject;
11
- tree: Array<Schema$1>;
12
- };
13
- type Props = {
14
- name: string;
15
- value?: SchemaObject;
16
- tree?: Array<Schema$1>;
17
- children?: KubbNode;
18
- };
19
- declare function Schema({ name, value, tree, children }: Props): KubbNode;
20
- declare namespace Schema {
21
- var File: ({ output, isTypeOnly, children }: FileProps) => ReactNode;
22
- var Imports: ({ isTypeOnly, extName }: SchemaImportsProps) => ReactNode;
23
- var Context: react.Context<SchemaContextProps>;
24
- }
25
- type FileProps = {
26
- isTypeOnly?: boolean;
27
- output: string | undefined;
28
- children?: KubbNode;
29
- };
30
- type SchemaImportsProps = {
31
- isTypeOnly?: boolean;
32
- extName?: KubbFile.Extname;
33
- };
34
-
35
- export { Schema as S, type SchemaContextProps as a };