@kubb/plugin-oas 3.0.0-alpha.1 → 3.0.0-alpha.10
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.
- package/dist/OperationGenerator-By5WOmWB.d.ts +165 -0
- package/dist/OperationGenerator-Gd1X7wUz.d.cts +165 -0
- package/dist/{Schema-DefwBJMc.d.ts → Schema-B1vcPGiK.d.ts} +3 -5
- package/dist/{Schema-an5hOrjZ.d.cts → Schema-DoSFh7Qd.d.cts} +3 -5
- package/dist/{SchemaMapper-CsBQ6eEx.d.cts → SchemaMapper-sGcY1xL5.d.cts} +1 -2
- package/dist/{SchemaMapper-CsBQ6eEx.d.ts → SchemaMapper-sGcY1xL5.d.ts} +1 -2
- package/dist/chunk-75BIOXB7.cjs +7 -0
- package/dist/chunk-75BIOXB7.cjs.map +1 -0
- package/dist/{chunk-DRLYORTT.cjs → chunk-IAUV3UKH.cjs} +735 -35
- package/dist/chunk-IAUV3UKH.cjs.map +1 -0
- package/dist/{chunk-LEACSHKT.js → chunk-M347763D.js} +714 -14
- package/dist/chunk-M347763D.js.map +1 -0
- package/dist/{chunk-Y4V7HHX7.js → chunk-N7EEVJA6.js} +3 -3
- package/dist/{chunk-P42X362U.cjs → chunk-NU4F7G47.cjs} +4 -16
- package/dist/chunk-NU4F7G47.cjs.map +1 -0
- package/dist/{chunk-QLJIL3U5.cjs → chunk-O76YQFZB.cjs} +3 -3
- package/dist/{chunk-QLJIL3U5.cjs.map → chunk-O76YQFZB.cjs.map} +1 -1
- package/dist/chunk-SQ64ESS4.js +7 -0
- package/dist/chunk-SQ64ESS4.js.map +1 -0
- package/dist/{chunk-UB552H4J.js → chunk-SZDO532A.js} +3 -15
- package/dist/{chunk-UB552H4J.js.map → chunk-SZDO532A.js.map} +1 -1
- package/dist/components.cjs +4 -9
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +13 -7
- package/dist/components.d.ts +13 -7
- package/dist/components.js +3 -8
- package/dist/components.js.map +1 -1
- package/dist/hooks.cjs +12 -13
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.cts +4 -4
- package/dist/hooks.d.ts +4 -4
- package/dist/hooks.js +2 -3
- package/dist/hooks.js.map +1 -1
- package/dist/index.cjs +282 -231
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -77
- package/dist/index.d.ts +8 -77
- package/dist/index.js +274 -223
- package/dist/index.js.map +1 -1
- package/dist/{types-Dte3MA6H.d.cts → types-CZTUCaE5.d.cts} +3 -1
- package/dist/{types-Dte3MA6H.d.ts → types-CZTUCaE5.d.ts} +3 -1
- package/dist/utils.cjs +12 -54
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +7 -33
- package/dist/utils.d.ts +7 -33
- package/dist/utils.js +6 -48
- package/dist/utils.js.map +1 -1
- package/package.json +11 -10
- package/src/OperationGenerator.ts +68 -32
- package/src/SchemaGenerator.ts +32 -15
- package/src/SchemaMapper.ts +1 -1
- package/src/components/Oas.tsx +9 -3
- package/src/components/Operation.tsx +1 -1
- package/src/components/Schema.tsx +29 -31
- package/src/generator.tsx +125 -0
- package/src/hooks/useOperationManager.ts +1 -0
- package/src/index.ts +3 -9
- package/src/plugin.ts +25 -38
- package/src/types.ts +2 -0
- package/src/utils/getParams.ts +1 -1
- package/src/utils/index.ts +2 -1
- package/dist/OperationGenerator-CeM_9pxW.d.cts +0 -60
- package/dist/OperationGenerator-DhUhvRJE.d.ts +0 -60
- package/dist/chunk-CJXRFYEF.cjs +0 -698
- package/dist/chunk-CJXRFYEF.cjs.map +0 -1
- package/dist/chunk-DRLYORTT.cjs.map +0 -1
- package/dist/chunk-K6KUETAI.js +0 -698
- package/dist/chunk-K6KUETAI.js.map +0 -1
- package/dist/chunk-LEACSHKT.js.map +0 -1
- package/dist/chunk-P42X362U.cjs.map +0 -1
- package/src/utils/getGroupedByTagFiles.ts +0 -82
- /package/dist/{chunk-Y4V7HHX7.js.map → chunk-N7EEVJA6.js.map} +0 -0
package/src/plugin.ts
CHANGED
|
@@ -4,13 +4,13 @@ import { createPlugin } from '@kubb/core'
|
|
|
4
4
|
import { camelCase } from '@kubb/core/transformers'
|
|
5
5
|
|
|
6
6
|
import { getSchemas } from './utils/getSchemas.ts'
|
|
7
|
+
import { parseFromConfig } from './utils/parseFromConfig.ts'
|
|
7
8
|
|
|
8
9
|
import type { Config } from '@kubb/core'
|
|
9
10
|
import type { Logger } from '@kubb/core/logger'
|
|
10
11
|
import type { Oas, OasTypes } from '@kubb/oas'
|
|
11
12
|
import type { FormatOptions } from '@kubb/oas/parser'
|
|
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
|
|
|
@@ -45,9 +45,18 @@ export const pluginOas = createPlugin<PluginOas>((options) => {
|
|
|
45
45
|
|
|
46
46
|
return {
|
|
47
47
|
name: pluginOasName,
|
|
48
|
+
output:
|
|
49
|
+
output === false
|
|
50
|
+
? {
|
|
51
|
+
path: '',
|
|
52
|
+
exportType: false,
|
|
53
|
+
}
|
|
54
|
+
: {
|
|
55
|
+
exportType: 'barrelNamed',
|
|
56
|
+
...output,
|
|
57
|
+
},
|
|
48
58
|
options,
|
|
49
|
-
|
|
50
|
-
api() {
|
|
59
|
+
context() {
|
|
51
60
|
const { config, logger } = this
|
|
52
61
|
|
|
53
62
|
return {
|
|
@@ -66,25 +75,6 @@ export const pluginOas = createPlugin<PluginOas>((options) => {
|
|
|
66
75
|
contentType,
|
|
67
76
|
}
|
|
68
77
|
},
|
|
69
|
-
resolvePath(baseName) {
|
|
70
|
-
if (output === false) {
|
|
71
|
-
return undefined
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
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
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return this.fileManager.write(path, source, { sanity: false })
|
|
87
|
-
},
|
|
88
78
|
async buildStart() {
|
|
89
79
|
if (!output) {
|
|
90
80
|
return
|
|
@@ -99,31 +89,28 @@ export const pluginOas = createPlugin<PluginOas>((options) => {
|
|
|
99
89
|
},
|
|
100
90
|
})
|
|
101
91
|
await oas.dereference()
|
|
92
|
+
|
|
93
|
+
const root = path.resolve(this.config.root, this.config.output.path)
|
|
102
94
|
const schemas = getSchemas({ oas, contentType })
|
|
103
95
|
|
|
104
96
|
const mapSchema = async ([name, schema]: [string, OasTypes.SchemaObject]) => {
|
|
105
|
-
const
|
|
106
|
-
|
|
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
|
-
}
|
|
97
|
+
const baseName = `${camelCase(name)}.json` as `${string}.json`
|
|
98
|
+
const resolvedPath = path.resolve(root, output.path, baseName)
|
|
119
99
|
|
|
120
100
|
await this.addFile({
|
|
121
101
|
path: resolvedPath,
|
|
122
|
-
baseName
|
|
123
|
-
source: JSON.stringify(schema),
|
|
102
|
+
baseName,
|
|
124
103
|
meta: {
|
|
125
104
|
pluginKey: this.plugin.key,
|
|
126
105
|
},
|
|
106
|
+
sources: [
|
|
107
|
+
{
|
|
108
|
+
name: camelCase(name),
|
|
109
|
+
isExportable: false,
|
|
110
|
+
isIndexable: false,
|
|
111
|
+
value: JSON.stringify(schema),
|
|
112
|
+
},
|
|
113
|
+
],
|
|
127
114
|
})
|
|
128
115
|
}
|
|
129
116
|
|
package/src/types.ts
CHANGED
package/src/utils/getParams.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { isParameterObject } from '@kubb/oas'
|
|
|
2
2
|
|
|
3
3
|
import type { FunctionParamsAST } from '@kubb/core/utils'
|
|
4
4
|
import type { OasTypes } from '@kubb/oas'
|
|
5
|
-
import type { Params } from '@kubb/react'
|
|
5
|
+
import type { Params } from '@kubb/react/types'
|
|
6
6
|
import type { OperationSchema } from '../types.ts'
|
|
7
7
|
import { camelCase } from '@kubb/core/transformers'
|
|
8
8
|
/**
|
package/src/utils/index.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
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
6
|
export { refsSorter } from './refSorter.ts'
|
|
8
7
|
export { parseFromConfig } from './parseFromConfig.ts'
|
|
8
|
+
|
|
9
|
+
export { isOptional } from '@kubb/oas'
|
|
@@ -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-Dte3MA6H.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-Dte3MA6H.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 };
|