@kubb/plugin-oas 3.0.0-alpha.13 → 3.0.0-alpha.15

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 (64) hide show
  1. package/dist/OperationGenerator-BqfyX5-8.d.cts +554 -0
  2. package/dist/OperationGenerator-BqfyX5-8.d.ts +554 -0
  3. package/dist/{Schema-B1vcPGiK.d.ts → Schema-BgpIlA79.d.cts} +2 -2
  4. package/dist/{Schema-DoSFh7Qd.d.cts → Schema-ExMIJOhD.d.ts} +2 -2
  5. package/dist/chunk-2PMRS7PB.cjs +8 -0
  6. package/dist/{chunk-KW7GCBTZ.cjs.map → chunk-2PMRS7PB.cjs.map} +1 -1
  7. package/dist/{chunk-TEEWKGS3.js → chunk-2V64GHQ4.js} +3 -3
  8. package/dist/{chunk-TEEWKGS3.js.map → chunk-2V64GHQ4.js.map} +1 -1
  9. package/dist/chunk-4JIFKRM5.js +6 -0
  10. package/dist/{chunk-N3GACHZX.js.map → chunk-4JIFKRM5.js.map} +1 -1
  11. package/dist/{chunk-JRZ3YURA.cjs → chunk-5ULY3TQB.cjs} +4 -4
  12. package/dist/{chunk-JRZ3YURA.cjs.map → chunk-5ULY3TQB.cjs.map} +1 -1
  13. package/dist/{chunk-FFFMYESV.cjs → chunk-AAIEMW6V.cjs} +27 -27
  14. package/dist/chunk-AAIEMW6V.cjs.map +1 -0
  15. package/dist/{chunk-G35AGMCZ.cjs → chunk-CFU6KMOB.cjs} +4 -4
  16. package/dist/{chunk-G35AGMCZ.cjs.map → chunk-CFU6KMOB.cjs.map} +1 -1
  17. package/dist/{chunk-NW6726BC.js → chunk-GAPWY2CE.js} +4 -4
  18. package/dist/{chunk-NW6726BC.js.map → chunk-GAPWY2CE.js.map} +1 -1
  19. package/dist/chunk-I3ZL3GUQ.cjs +97 -0
  20. package/dist/chunk-I3ZL3GUQ.cjs.map +1 -0
  21. package/dist/{chunk-5QUCRUOD.js → chunk-M3V3WMCW.js} +4 -4
  22. package/dist/chunk-M3V3WMCW.js.map +1 -0
  23. package/dist/chunk-PZTS5YZV.js +93 -0
  24. package/dist/chunk-PZTS5YZV.js.map +1 -0
  25. package/dist/components.cjs +6 -6
  26. package/dist/components.d.cts +3 -5
  27. package/dist/components.d.ts +3 -5
  28. package/dist/components.js +3 -3
  29. package/dist/generators.cjs +15 -0
  30. package/dist/generators.cjs.map +1 -0
  31. package/dist/generators.d.cts +10 -0
  32. package/dist/generators.d.ts +10 -0
  33. package/dist/generators.js +6 -0
  34. package/dist/generators.js.map +1 -0
  35. package/dist/hooks.cjs +12 -12
  36. package/dist/hooks.d.cts +3 -4
  37. package/dist/hooks.d.ts +3 -4
  38. package/dist/hooks.js +3 -3
  39. package/dist/index.cjs +69 -100
  40. package/dist/index.cjs.map +1 -1
  41. package/dist/index.d.cts +2 -4
  42. package/dist/index.d.ts +2 -4
  43. package/dist/index.js +57 -93
  44. package/dist/index.js.map +1 -1
  45. package/dist/utils.cjs +9 -9
  46. package/dist/utils.d.cts +2 -2
  47. package/dist/utils.d.ts +2 -2
  48. package/dist/utils.js +3 -3
  49. package/package.json +18 -10
  50. package/src/components/Schema.tsx +1 -2
  51. package/src/generators/index.ts +1 -0
  52. package/src/generators/jsonGenerator.ts +30 -0
  53. package/src/plugin.ts +63 -43
  54. package/src/types.ts +23 -12
  55. package/dist/OperationGenerator-By5WOmWB.d.ts +0 -165
  56. package/dist/OperationGenerator-Gd1X7wUz.d.cts +0 -165
  57. package/dist/SchemaMapper-sGcY1xL5.d.cts +0 -247
  58. package/dist/SchemaMapper-sGcY1xL5.d.ts +0 -247
  59. package/dist/chunk-5QUCRUOD.js.map +0 -1
  60. package/dist/chunk-FFFMYESV.cjs.map +0 -1
  61. package/dist/chunk-KW7GCBTZ.cjs +0 -8
  62. package/dist/chunk-N3GACHZX.js +0 -6
  63. package/dist/types-CZTUCaE5.d.cts +0 -145
  64. package/dist/types-CZTUCaE5.d.ts +0 -145
package/dist/utils.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunkG35AGMCZ_cjs = require('./chunk-G35AGMCZ.cjs');
4
- var chunkJRZ3YURA_cjs = require('./chunk-JRZ3YURA.cjs');
3
+ var chunkCFU6KMOB_cjs = require('./chunk-CFU6KMOB.cjs');
4
+ var chunk5ULY3TQB_cjs = require('./chunk-5ULY3TQB.cjs');
5
5
  var transformers = require('@kubb/core/transformers');
6
6
  var utils = require('@kubb/core/utils');
7
7
  var oas = require('@kubb/oas');
@@ -11,10 +11,10 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
11
11
  var transformers__default = /*#__PURE__*/_interopDefault(transformers);
12
12
 
13
13
  // src/utils/index.ts
14
- chunkJRZ3YURA_cjs.init_cjs_shims();
14
+ chunk5ULY3TQB_cjs.init_cjs_shims();
15
15
 
16
16
  // src/utils/getComments.ts
17
- chunkJRZ3YURA_cjs.init_cjs_shims();
17
+ chunk5ULY3TQB_cjs.init_cjs_shims();
18
18
  function getComments(operation) {
19
19
  return [
20
20
  operation.getDescription() && `@description ${operation.getDescription()}`,
@@ -25,7 +25,7 @@ function getComments(operation) {
25
25
  }
26
26
 
27
27
  // src/utils/getParams.ts
28
- chunkJRZ3YURA_cjs.init_cjs_shims();
28
+ chunk5ULY3TQB_cjs.init_cjs_shims();
29
29
  function getASTParams(operationSchema, {
30
30
  typed = false,
31
31
  override
@@ -58,7 +58,7 @@ function getPathParams(operationSchema, options = {}) {
58
58
  }
59
59
 
60
60
  // src/utils/refSorter.ts
61
- chunkJRZ3YURA_cjs.init_cjs_shims();
61
+ chunk5ULY3TQB_cjs.init_cjs_shims();
62
62
  function refsSorter(a, b) {
63
63
  if (Object.keys(a.import.refs)?.length < Object.keys(b.import.refs)?.length) {
64
64
  return -1;
@@ -71,15 +71,15 @@ function refsSorter(a, b) {
71
71
 
72
72
  Object.defineProperty(exports, "parseFromConfig", {
73
73
  enumerable: true,
74
- get: function () { return chunkG35AGMCZ_cjs.parseFromConfig; }
74
+ get: function () { return chunkCFU6KMOB_cjs.parseFromConfig; }
75
75
  });
76
76
  Object.defineProperty(exports, "getSchemaFactory", {
77
77
  enumerable: true,
78
- get: function () { return chunkJRZ3YURA_cjs.getSchemaFactory; }
78
+ get: function () { return chunk5ULY3TQB_cjs.getSchemaFactory; }
79
79
  });
80
80
  Object.defineProperty(exports, "getSchemas", {
81
81
  enumerable: true,
82
- get: function () { return chunkJRZ3YURA_cjs.getSchemas; }
82
+ get: function () { return chunk5ULY3TQB_cjs.getSchemas; }
83
83
  });
84
84
  Object.defineProperty(exports, "isOptional", {
85
85
  enumerable: true,
package/dist/utils.d.cts CHANGED
@@ -2,8 +2,8 @@ import { Operation, Oas, SchemaObject, OpenAPIV3, OpenAPIV3_1 } from '@kubb/oas'
2
2
  export { isOptional } from '@kubb/oas';
3
3
  import { FunctionParamsAST } from '@kubb/core/utils';
4
4
  import { Params } from '@kubb/react/types';
5
- import { d as OperationSchema, b as Refs } from './types-CZTUCaE5.cjs';
6
- export { G as GetSchemasProps, h as getSchemas } from './types-CZTUCaE5.cjs';
5
+ import { v as OperationSchema, t as Refs } from './OperationGenerator-BqfyX5-8.cjs';
6
+ export { z as GetSchemasProps, B as getSchemas } from './OperationGenerator-BqfyX5-8.cjs';
7
7
  import { FormatOptions } from '@kubb/oas/parser';
8
8
  import { Config } from '@kubb/core';
9
9
  import '@kubb/fs/types';
package/dist/utils.d.ts CHANGED
@@ -2,8 +2,8 @@ import { Operation, Oas, SchemaObject, OpenAPIV3, OpenAPIV3_1 } from '@kubb/oas'
2
2
  export { isOptional } from '@kubb/oas';
3
3
  import { FunctionParamsAST } from '@kubb/core/utils';
4
4
  import { Params } from '@kubb/react/types';
5
- import { d as OperationSchema, b as Refs } from './types-CZTUCaE5.js';
6
- export { G as GetSchemasProps, h as getSchemas } from './types-CZTUCaE5.js';
5
+ import { v as OperationSchema, t as Refs } from './OperationGenerator-BqfyX5-8.js';
6
+ export { z as GetSchemasProps, B as getSchemas } from './OperationGenerator-BqfyX5-8.js';
7
7
  import { FormatOptions } from '@kubb/oas/parser';
8
8
  import { Config } from '@kubb/core';
9
9
  import '@kubb/fs/types';
package/dist/utils.js CHANGED
@@ -1,6 +1,6 @@
1
- export { parseFromConfig } from './chunk-TEEWKGS3.js';
2
- import { init_esm_shims } from './chunk-NW6726BC.js';
3
- export { getSchemaFactory, getSchemas } from './chunk-NW6726BC.js';
1
+ export { parseFromConfig } from './chunk-2V64GHQ4.js';
2
+ import { init_esm_shims } from './chunk-GAPWY2CE.js';
3
+ export { getSchemaFactory, getSchemas } from './chunk-GAPWY2CE.js';
4
4
  import transformers, { camelCase } from '@kubb/core/transformers';
5
5
  import { URLPath } from '@kubb/core/utils';
6
6
  import { isParameterObject } from '@kubb/oas';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-oas",
3
- "version": "3.0.0-alpha.13",
3
+ "version": "3.0.0-alpha.15",
4
4
  "description": "Generator swagger",
5
5
  "keywords": [
6
6
  "typescript",
@@ -25,6 +25,11 @@
25
25
  "require": "./dist/index.cjs",
26
26
  "default": "./dist/index.cjs"
27
27
  },
28
+ "./generators": {
29
+ "import": "./dist/generators.js",
30
+ "require": "./dist/generators.cjs",
31
+ "default": "./dist/generators.cjs"
32
+ },
28
33
  "./utils": {
29
34
  "import": "./dist/utils.js",
30
35
  "require": "./dist/utils.cjs",
@@ -56,6 +61,9 @@
56
61
  ],
57
62
  "components": [
58
63
  "./dist/components.d.ts"
64
+ ],
65
+ "generators": [
66
+ "./dist/generators.d.ts"
59
67
  ]
60
68
  }
61
69
  },
@@ -68,11 +76,11 @@
68
76
  "dependencies": {
69
77
  "@stoplight/yaml": "^4.3.0",
70
78
  "execa": "^9.3.1",
71
- "remeda": "^2.11.0",
72
- "@kubb/core": "3.0.0-alpha.13",
73
- "@kubb/fs": "3.0.0-alpha.13",
74
- "@kubb/oas": "3.0.0-alpha.13",
75
- "@kubb/react": "3.0.0-alpha.13"
79
+ "remeda": "^2.12.0",
80
+ "@kubb/core": "3.0.0-alpha.15",
81
+ "@kubb/fs": "3.0.0-alpha.15",
82
+ "@kubb/oas": "3.0.0-alpha.15",
83
+ "@kubb/react": "3.0.0-alpha.15"
76
84
  },
77
85
  "devDependencies": {
78
86
  "@types/react": "^18.3.5",
@@ -80,12 +88,12 @@
80
88
  "react": "^18.3.1",
81
89
  "tsup": "^8.2.4",
82
90
  "typescript": "^5.5.4",
83
- "@kubb/config-biome": "3.0.0-alpha.13",
84
- "@kubb/config-ts": "3.0.0-alpha.13",
85
- "@kubb/config-tsup": "3.0.0-alpha.13"
91
+ "@kubb/config-biome": "3.0.0-alpha.15",
92
+ "@kubb/config-ts": "3.0.0-alpha.15",
93
+ "@kubb/config-tsup": "3.0.0-alpha.15"
86
94
  },
87
95
  "peerDependencies": {
88
- "@kubb/react": "3.0.0-alpha.13"
96
+ "@kubb/react": "3.0.0-alpha.15"
89
97
  },
90
98
  "engines": {
91
99
  "node": ">=20"
@@ -3,7 +3,6 @@ import { File, createContext, useApp, useFile } from '@kubb/react'
3
3
  import { schemaKeywords } from '../SchemaMapper.ts'
4
4
  import { useSchema } from '../hooks/useSchema.ts'
5
5
 
6
- import type * as KubbFile from '@kubb/fs/types'
7
6
  import type { SchemaObject } from '@kubb/oas'
8
7
  import type { KubbNode } from '@kubb/react/types'
9
8
  import type { ReactNode } from 'react'
@@ -39,7 +38,7 @@ type FileProps = {
39
38
  children?: KubbNode
40
39
  }
41
40
 
42
- Schema.File = function ({ output, isTypeOnly, children }: FileProps): ReactNode {
41
+ Schema.File = function ({ isTypeOnly, children }: FileProps): ReactNode {
43
42
  const { plugin, pluginManager, mode } = useApp<PluginOas>()
44
43
  const { name } = useSchema()
45
44
 
@@ -0,0 +1 @@
1
+ export { jsonGenerator } from './jsonGenerator.ts'
@@ -0,0 +1,30 @@
1
+ import { camelCase } from '@kubb/core/transformers'
2
+ import { createGenerator } from '../generator.tsx'
3
+ import type { PluginOas } from '../types.ts'
4
+
5
+ export const jsonGenerator = createGenerator<PluginOas>({
6
+ name: 'plugin-oas',
7
+ async schema({ schema, name, instance }) {
8
+ const { pluginManager, plugin } = instance.context
9
+ const file = pluginManager.getFile({
10
+ name: camelCase(name),
11
+ extName: '.json',
12
+ mode: 'split',
13
+ pluginKey: plugin.key,
14
+ })
15
+
16
+ return [
17
+ {
18
+ ...file,
19
+ sources: [
20
+ {
21
+ name: camelCase(name),
22
+ isExportable: false,
23
+ isIndexable: false,
24
+ value: JSON.stringify(schema),
25
+ },
26
+ ],
27
+ },
28
+ ]
29
+ },
30
+ })
package/src/plugin.ts CHANGED
@@ -1,25 +1,31 @@
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'
7
4
  import { parseFromConfig } from './utils/parseFromConfig.ts'
8
5
 
6
+ import path from 'node:path'
9
7
  import type { Config } from '@kubb/core'
10
8
  import type { Logger } from '@kubb/core/logger'
11
- import type { Oas, OasTypes } from '@kubb/oas'
9
+ import type { Oas } from '@kubb/oas'
12
10
  import type { FormatOptions } from '@kubb/oas/parser'
11
+ import { OperationGenerator } from './OperationGenerator.ts'
12
+ import { SchemaGenerator } from './SchemaGenerator.ts'
13
+ import { jsonGenerator } from './generators'
13
14
  import type { PluginOas } from './types.ts'
14
15
 
15
16
  export const pluginOasName = 'plugin-oas' satisfies PluginOas['name']
16
17
 
17
18
  export const pluginOas = createPlugin<PluginOas>((options) => {
18
19
  const {
19
- output = { path: 'schemas', export: false },
20
+ output = {
21
+ path: 'schemas',
22
+ export: false,
23
+ exportType: 'barrelNamed',
24
+ },
20
25
  experimentalFilter: filter,
21
26
  experimentalSort: sort,
22
27
  validate = true,
28
+ generators = [jsonGenerator],
23
29
  serverIndex = 0,
24
30
  contentType,
25
31
  oasClass,
@@ -45,16 +51,7 @@ export const pluginOas = createPlugin<PluginOas>((options) => {
45
51
 
46
52
  return {
47
53
  name: pluginOasName,
48
- output:
49
- output === false
50
- ? {
51
- path: '',
52
- exportType: false,
53
- }
54
- : {
55
- exportType: 'barrelNamed',
56
- ...output,
57
- },
54
+ output,
58
55
  options,
59
56
  context() {
60
57
  const { config, logger } = this
@@ -69,12 +66,25 @@ export const pluginOas = createPlugin<PluginOas>((options) => {
69
66
  },
70
67
  async getBaseURL() {
71
68
  const oasInstance = await this.getOas()
72
- const baseURL = oasInstance.api.servers?.at(serverIndex)?.url
73
- return baseURL
69
+ return oasInstance.api.servers?.at(serverIndex)?.url
74
70
  },
75
71
  contentType,
76
72
  }
77
73
  },
74
+ resolvePath(baseName, pathMode, options) {
75
+ const root = path.resolve(this.config.root, this.config.output.path)
76
+ const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path))
77
+
78
+ if (mode === 'single') {
79
+ /**
80
+ * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend
81
+ * Other plugins then need to call addOrAppend instead of just add from the fileManager class
82
+ */
83
+ return path.resolve(root, output.path)
84
+ }
85
+
86
+ return path.resolve(root, output.path, baseName)
87
+ },
78
88
  async buildStart() {
79
89
  if (!output) {
80
90
  return
@@ -90,32 +100,42 @@ export const pluginOas = createPlugin<PluginOas>((options) => {
90
100
  })
91
101
  await oas.dereference()
92
102
 
93
- const root = path.resolve(this.config.root, this.config.output.path)
94
- const schemas = getSchemas({ oas, contentType })
95
-
96
- const mapSchema = async ([name, schema]: [string, OasTypes.SchemaObject]) => {
97
- const baseName = `${camelCase(name)}.json` as `${string}.json`
98
- const resolvedPath = path.resolve(root, output.path, baseName)
99
-
100
- await this.addFile({
101
- path: resolvedPath,
102
- baseName,
103
- meta: {
104
- pluginKey: this.plugin.key,
105
- },
106
- sources: [
107
- {
108
- name: camelCase(name),
109
- isExportable: false,
110
- isIndexable: false,
111
- value: JSON.stringify(schema),
112
- },
113
- ],
114
- })
115
- }
103
+ const schemaGenerator = new SchemaGenerator(
104
+ {
105
+ unknownType: 'unknown',
106
+ dateType: 'date',
107
+ transformers: {},
108
+ ...this.plugin.options,
109
+ },
110
+ {
111
+ oas,
112
+ pluginManager: this.pluginManager,
113
+ plugin: this.plugin,
114
+ contentType,
115
+ include: undefined,
116
+ override: undefined,
117
+ mode: 'split',
118
+ output: output.path,
119
+ },
120
+ )
121
+
122
+ const schemaFiles = await schemaGenerator.build(...generators)
123
+ await this.addFile(...schemaFiles)
124
+
125
+ const operationGenerator = new OperationGenerator(this.plugin.options, {
126
+ oas,
127
+ pluginManager: this.pluginManager,
128
+ plugin: this.plugin,
129
+ contentType,
130
+ exclude: undefined,
131
+ include: undefined,
132
+ override: undefined,
133
+ mode: 'split',
134
+ })
135
+
136
+ const operationFiles = await operationGenerator.build(...generators)
116
137
 
117
- const promises = Object.entries(schemas).map(mapSchema)
118
- await Promise.all(promises)
138
+ await this.addFile(...operationFiles)
119
139
  },
120
140
  }
121
141
  })
package/src/types.ts CHANGED
@@ -4,6 +4,7 @@ import type * as KubbFile from '@kubb/fs/types'
4
4
 
5
5
  import type { HttpMethod, Oas, Operation, SchemaObject, contentType } from '@kubb/oas'
6
6
  import type { FormatOptions } from '@kubb/oas/parser'
7
+ import type { Generator } from './generator.tsx'
7
8
  import type { GetSchemasProps } from './utils/getSchemas.ts'
8
9
 
9
10
  export type ResolvePathOptions = {
@@ -25,18 +26,16 @@ export type Options = {
25
26
  * @default true
26
27
  */
27
28
  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
- extName?: KubbFile.Extname
37
- exportType?: 'barrel' | 'barrelNamed' | false
38
- }
39
- | false
29
+ output?: {
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
+ extName?: KubbFile.Extname
37
+ exportType?: 'barrel' | 'barrelNamed' | false
38
+ }
40
39
  /**
41
40
  * Which server to use from the array of `servers.url[serverIndex]`
42
41
  * @example
@@ -52,7 +51,14 @@ export type Options = {
52
51
  contentType?: contentType
53
52
  experimentalFilter?: FormatOptions['filterSet']
54
53
  experimentalSort?: FormatOptions['sortSet']
54
+ /**
55
+ * Override some behaviour of the Oas class instance, see '@kubb/oas'
56
+ */
55
57
  oasClass?: typeof Oas
58
+ /**
59
+ * Define some generators next to the JSON generation
60
+ */
61
+ generators?: Array<Generator<PluginOas>>
56
62
  }
57
63
 
58
64
  /**
@@ -130,6 +136,11 @@ type ByMethod = {
130
136
  type: 'method'
131
137
  pattern: HttpMethod | RegExp
132
138
  }
139
+ // TODO implement as alternative for ByMethod
140
+ type ByMethods = {
141
+ type: 'methods'
142
+ pattern: Array<HttpMethod>
143
+ }
133
144
 
134
145
  type BySchemaName = {
135
146
  type: 'schemaName'
@@ -1,165 +0,0 @@
1
- import { FileMetaBase, ResolveNameParams, PluginFactoryOptions, BaseGenerator, PluginManager, Plugin } from '@kubb/core';
2
- import * as KubbFile from '@kubb/fs/types';
3
- import { SchemaObject, Oas, contentType, Operation } from '@kubb/oas';
4
- import { KubbNode } from '@kubb/react/types';
5
- import { d as OperationSchema, b as Refs, g as Override, f as OperationsByMethod, e as OperationSchemas, E as Exclude, I as Include } from './types-CZTUCaE5.js';
6
- import { S as Schema, c as SchemaKeywordMapper } from './SchemaMapper-sGcY1xL5.js';
7
-
8
- type GetSchemaGeneratorOptions<T extends SchemaGenerator<any, any, any>> = T extends SchemaGenerator<infer Options, any, any> ? Options : never;
9
- type SchemaMethodResult<TFileMeta extends FileMetaBase> = Promise<KubbFile.File<TFileMeta> | Array<KubbFile.File<TFileMeta>> | null>;
10
- type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
11
- oas: Oas;
12
- pluginManager: PluginManager;
13
- /**
14
- * Current plugin
15
- */
16
- plugin: Plugin<TPluginOptions>;
17
- mode: KubbFile.Mode;
18
- include?: Array<'schemas' | 'responses' | 'requestBodies'>;
19
- override: Array<Override<TOptions>> | undefined;
20
- contentType?: contentType;
21
- output?: string;
22
- };
23
- type SchemaGeneratorOptions = {
24
- dateType: false | 'string' | 'stringOffset' | 'stringLocal' | 'date';
25
- unknownType: 'any' | 'unknown';
26
- enumType?: 'enum' | 'asConst' | 'asPascalConst' | 'constEnum' | 'literal';
27
- enumSuffix?: string;
28
- usedEnumNames?: Record<string, number>;
29
- mapper?: Record<string, string>;
30
- typed?: boolean;
31
- transformers: {
32
- /**
33
- * Customize the names based on the type that is provided by the plugin.
34
- */
35
- name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
36
- /**
37
- * Receive schema and name(propertName) and return FakerMeta array
38
- * TODO TODO add docs
39
- * @beta
40
- */
41
- schema?: (schemaProps: SchemaProps$1, defaultSchemas: Schema[]) => Schema[] | undefined;
42
- };
43
- };
44
- type SchemaGeneratorBuildOptions = Omit<OperationSchema, 'name' | 'schema'>;
45
- type SchemaProps$1 = {
46
- schema?: SchemaObject;
47
- name?: string;
48
- parentName?: string;
49
- };
50
- declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions, Context$1<TOptions, TPluginOptions>> {
51
- #private;
52
- refs: Refs;
53
- /**
54
- * Creates a type node from a given schema.
55
- * Delegates to getBaseTypeFromSchema internally and
56
- * optionally adds a union with null.
57
- */
58
- parse(props: SchemaProps$1): Schema[];
59
- deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T][];
60
- find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
61
- static deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T][];
62
- static findInObject<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
63
- static find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
64
- build(...generators: Array<Generator<Extract<TOptions, PluginFactoryOptions>>>): Promise<Array<KubbFile.File<TFileMeta>>>;
65
- /**
66
- * Schema
67
- */
68
- schema(name: string, object: SchemaObject, options: TOptions): SchemaMethodResult<TFileMeta>;
69
- }
70
-
71
- type OperationsProps<TOptions extends PluginFactoryOptions> = {
72
- instance: Omit<OperationGenerator<TOptions>, 'build'>;
73
- options: TOptions['resolvedOptions'];
74
- operations: Array<Operation>;
75
- operationsByMethod: OperationsByMethod;
76
- };
77
- type OperationProps<TOptions extends PluginFactoryOptions> = {
78
- instance: Omit<OperationGenerator<TOptions>, 'build'>;
79
- options: TOptions['resolvedOptions'];
80
- operation: Operation;
81
- };
82
- type SchemaProps<TOptions extends PluginFactoryOptions> = {
83
- instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>;
84
- name: string;
85
- schema: SchemaObject;
86
- options: TOptions['resolvedOptions'];
87
- };
88
- type GeneratorOptions<TOptions extends PluginFactoryOptions> = {
89
- name: string;
90
- operations?: (props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>;
91
- operation?: (props: OperationProps<TOptions>) => Promise<KubbFile.File[]>;
92
- schema?: (props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>;
93
- };
94
- type Generator<TOptions extends PluginFactoryOptions> = GeneratorOptions<TOptions>;
95
- declare function createGenerator<TOptions extends PluginFactoryOptions>(parseOptions: GeneratorOptions<TOptions>): Generator<TOptions>;
96
- type ReactGeneratorOptions<TOptions extends PluginFactoryOptions> = {
97
- name: string;
98
- Operations?: (props: OperationsProps<TOptions>) => KubbNode;
99
- Operation?: (props: OperationProps<TOptions>) => KubbNode;
100
- Schema?: (props: SchemaProps<TOptions>) => KubbNode;
101
- /**
102
- * Combine all react nodes and only render ones(to string or render)
103
- */
104
- render?: () => any;
105
- };
106
- declare function createReactGenerator<TOptions extends PluginFactoryOptions>(parseOptions: ReactGeneratorOptions<TOptions>): Generator<TOptions>;
107
-
108
- /**
109
- * @deprecated
110
- */
111
- type GetOperationGeneratorOptions<T extends OperationGenerator<any, any, any>> = T extends OperationGenerator<infer Options, any, any> ? Options : never;
112
- type OperationMethodResult<TFileMeta extends FileMetaBase> = Promise<KubbFile.File<TFileMeta> | Array<KubbFile.File<TFileMeta>> | null>;
113
- type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
114
- oas: Oas;
115
- exclude: Array<Exclude> | undefined;
116
- include: Array<Include> | undefined;
117
- override: Array<Override<TOptions>> | undefined;
118
- contentType: contentType | undefined;
119
- pluginManager: PluginManager;
120
- /**
121
- * Current plugin
122
- */
123
- plugin: Plugin<TPluginOptions>;
124
- mode: KubbFile.Mode;
125
- };
126
- declare class OperationGenerator<TOptions = unknown, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions, Context<TOptions, TPluginOptions>> {
127
- #private;
128
- get operationsByMethod(): OperationsByMethod;
129
- set operationsByMethod(paths: OperationsByMethod);
130
- getSchemas(operation: Operation, { forStatusCode, resolveName, }?: {
131
- forStatusCode?: string | number;
132
- resolveName?: (name: string) => string;
133
- }): OperationSchemas;
134
- build(...generators: Array<Generator<Extract<TOptions, PluginFactoryOptions>>>): Promise<Array<KubbFile.File<TFileMeta>>>;
135
- /**
136
- * Operation
137
- */
138
- operation(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta>;
139
- /**
140
- * GET
141
- */
142
- get(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta>;
143
- /**
144
- * POST
145
- */
146
- post(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta>;
147
- /**
148
- * PATCH
149
- */
150
- patch(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta>;
151
- /**
152
- * PUT
153
- */
154
- put(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta>;
155
- /**
156
- * DELETE
157
- */
158
- delete(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta>;
159
- /**
160
- * Combination of GET, POST, PATCH, PUT, DELETE
161
- */
162
- all(operations: Operation[], paths: OperationsByMethod): OperationMethodResult<TFileMeta>;
163
- }
164
-
165
- export { type GetOperationGeneratorOptions as G, type OperationMethodResult as O, type ReactGeneratorOptions as R, type SchemaGeneratorBuildOptions as S, OperationGenerator as a, type GetSchemaGeneratorOptions as b, type SchemaGeneratorOptions as c, type SchemaMethodResult as d, SchemaGenerator as e, createGenerator as f, createReactGenerator as g, type Generator as h, type GeneratorOptions as i };