@kubb/plugin-oas 3.0.0-alpha.3 → 3.0.0-alpha.30
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/README.md +13 -4
- package/dist/OperationGenerator-DhPriVDJ.d.cts +554 -0
- package/dist/OperationGenerator-DhPriVDJ.d.ts +554 -0
- package/dist/Schema-BfZVq77f.d.cts +22 -0
- package/dist/Schema-IlDbvlbP.d.ts +22 -0
- package/dist/chunk-4H2KTGZM.cjs +92 -0
- package/dist/chunk-4H2KTGZM.cjs.map +1 -0
- package/dist/chunk-ABIWUCV7.js +88 -0
- package/dist/chunk-ABIWUCV7.js.map +1 -0
- package/dist/chunk-ABOQ73FL.cjs +36 -0
- package/dist/chunk-ABOQ73FL.cjs.map +1 -0
- package/dist/chunk-BG77DP54.js +30 -0
- package/dist/chunk-BG77DP54.js.map +1 -0
- package/dist/chunk-GF26SDHQ.js +28 -0
- package/dist/chunk-GF26SDHQ.js.map +1 -0
- package/dist/chunk-PADR76WZ.cjs +4 -0
- package/dist/chunk-PADR76WZ.cjs.map +1 -0
- package/dist/chunk-QAFBZLJA.cjs +48 -0
- package/dist/chunk-QAFBZLJA.cjs.map +1 -0
- package/dist/chunk-QT6ZFRNJ.cjs +752 -0
- package/dist/chunk-QT6ZFRNJ.cjs.map +1 -0
- package/dist/chunk-R47XMJ32.js +3 -0
- package/dist/chunk-R47XMJ32.js.map +1 -0
- package/dist/chunk-V2JO6RHI.js +744 -0
- package/dist/chunk-V2JO6RHI.js.map +1 -0
- package/dist/chunk-XNCEFOE6.js +45 -0
- package/dist/chunk-XNCEFOE6.js.map +1 -0
- package/dist/chunk-ZWHQ54JM.cjs +32 -0
- package/dist/chunk-ZWHQ54JM.cjs.map +1 -0
- package/dist/components.cjs +20 -12
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +4 -7
- package/dist/components.d.ts +4 -7
- package/dist/components.js +3 -12
- package/dist/components.js.map +1 -1
- package/dist/generators.cjs +14 -0
- package/dist/generators.cjs.map +1 -0
- package/dist/generators.d.cts +9 -0
- package/dist/generators.d.ts +9 -0
- package/dist/generators.js +5 -0
- package/dist/generators.js.map +1 -0
- package/dist/hooks.cjs +102 -57
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.cts +41 -10
- package/dist/hooks.d.ts +41 -10
- package/dist/hooks.js +91 -53
- package/dist/hooks.js.map +1 -1
- package/dist/index.cjs +192 -258
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -6
- package/dist/index.d.ts +3 -6
- package/dist/index.js +135 -228
- package/dist/index.js.map +1 -1
- package/dist/utils.cjs +32 -87
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +8 -43
- package/dist/utils.d.ts +8 -43
- package/dist/utils.js +8 -86
- package/dist/utils.js.map +1 -1
- package/package.json +20 -14
- package/src/OperationGenerator.ts +23 -30
- package/src/SchemaGenerator.ts +80 -23
- package/src/SchemaMapper.ts +7 -5
- package/src/components/Oas.tsx +1 -1
- package/src/components/Operation.tsx +1 -1
- package/src/components/Schema.tsx +2 -102
- package/src/{parser.tsx → generator.tsx} +35 -22
- package/src/generators/index.ts +1 -0
- package/src/generators/jsonGenerator.ts +32 -0
- package/src/hooks/index.ts +2 -0
- package/src/hooks/useOperationManager.ts +77 -29
- package/src/hooks/useSchemaManager.ts +77 -0
- package/src/index.ts +3 -3
- package/src/plugin.ts +67 -59
- package/src/types.ts +24 -16
- package/src/utils/getParams.ts +2 -2
- package/src/utils/getSchemaFactory.ts +1 -1
- package/src/utils/index.ts +2 -2
- package/src/utils/parseFromConfig.ts +7 -7
- package/dist/OperationGenerator-D7rSlflc.d.cts +0 -158
- package/dist/OperationGenerator-vw0Zf-Mi.d.ts +0 -158
- package/dist/Schema-DxyOIX7q.d.cts +0 -35
- package/dist/Schema-gHgN14i2.d.ts +0 -35
- package/dist/SchemaMapper-BM1IGWqD.d.cts +0 -248
- package/dist/SchemaMapper-BM1IGWqD.d.ts +0 -248
- package/dist/chunk-264TCCJF.cjs +0 -3973
- package/dist/chunk-264TCCJF.cjs.map +0 -1
- package/dist/chunk-7KIEQOVZ.cjs +0 -7
- package/dist/chunk-7KIEQOVZ.cjs.map +0 -1
- package/dist/chunk-FZN3PBEK.js +0 -3973
- package/dist/chunk-FZN3PBEK.js.map +0 -1
- package/dist/chunk-P42X362U.cjs +0 -101
- package/dist/chunk-P42X362U.cjs.map +0 -1
- package/dist/chunk-QLJIL3U5.cjs +0 -35
- package/dist/chunk-QLJIL3U5.cjs.map +0 -1
- package/dist/chunk-TWKZEVSM.js +0 -7
- package/dist/chunk-TWKZEVSM.js.map +0 -1
- package/dist/chunk-UB552H4J.js +0 -101
- package/dist/chunk-UB552H4J.js.map +0 -1
- package/dist/chunk-Y4V7HHX7.js +0 -35
- package/dist/chunk-Y4V7HHX7.js.map +0 -1
- package/dist/types-C2RXaY0_.d.cts +0 -143
- package/dist/types-C2RXaY0_.d.ts +0 -143
- package/src/utils/getGroupedByTagFiles.ts +0 -82
- package/src/utils/refSorter.ts +0 -13
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { resolve } from 'node:path'
|
|
2
|
-
|
|
3
|
-
import { FileManager } from '@kubb/core'
|
|
4
|
-
import transformers from '@kubb/core/transformers'
|
|
5
|
-
import { renderTemplate } from '@kubb/core/utils'
|
|
6
|
-
import { getRelativePath } from '@kubb/fs'
|
|
7
|
-
|
|
8
|
-
import type { Plugin } from '@kubb/core'
|
|
9
|
-
import type { Logger } from '@kubb/core/logger'
|
|
10
|
-
import type * as KubbFile from '@kubb/fs/types'
|
|
11
|
-
|
|
12
|
-
type Options = {
|
|
13
|
-
logger: Logger
|
|
14
|
-
files: Array<KubbFile.File<FileMeta>>
|
|
15
|
-
plugin: Plugin
|
|
16
|
-
template: string
|
|
17
|
-
exportAs: string
|
|
18
|
-
/**
|
|
19
|
-
* Root based on root and output.path specified in the config
|
|
20
|
-
*/
|
|
21
|
-
root: string
|
|
22
|
-
/**
|
|
23
|
-
* Output for plugin
|
|
24
|
-
*/
|
|
25
|
-
output: {
|
|
26
|
-
path: string
|
|
27
|
-
exportAs?: string
|
|
28
|
-
extName?: KubbFile.Extname
|
|
29
|
-
exportType?: 'barrel' | 'barrelNamed' | false
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
type FileMeta = {
|
|
34
|
-
pluginKey?: Plugin['key']
|
|
35
|
-
tag?: string
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export async function getGroupedByTagFiles({ logger, files, plugin, template, exportAs, root, output }: Options): Promise<KubbFile.File<FileMeta>[]> {
|
|
39
|
-
const { path, exportType = 'barrel' } = output
|
|
40
|
-
const mode = FileManager.getMode(resolve(root, path))
|
|
41
|
-
|
|
42
|
-
if (mode === 'single' || exportType === false) {
|
|
43
|
-
return []
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return files
|
|
47
|
-
.filter((file) => {
|
|
48
|
-
const name = file.meta?.pluginKey?.[0]
|
|
49
|
-
return name === plugin.name
|
|
50
|
-
})
|
|
51
|
-
.map((file: KubbFile.File<FileMeta>) => {
|
|
52
|
-
if (!file.meta?.tag) {
|
|
53
|
-
logger?.emit('debug', [`Could not find a tagName for ${JSON.stringify(file, undefined, 2)}`])
|
|
54
|
-
|
|
55
|
-
return
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const tag = file.meta?.tag && transformers.camelCase(file.meta.tag)
|
|
59
|
-
const tagPath = getRelativePath(resolve(root, output.path), resolve(root, renderTemplate(template, { tag })))
|
|
60
|
-
const tagName = renderTemplate(exportAs, { tag })
|
|
61
|
-
|
|
62
|
-
if (tagName) {
|
|
63
|
-
return {
|
|
64
|
-
baseName: 'index.ts' as const,
|
|
65
|
-
path: resolve(root, output.path, 'index.ts'),
|
|
66
|
-
source: '',
|
|
67
|
-
exports: [
|
|
68
|
-
{
|
|
69
|
-
path: output.extName ? `${tagPath}/index${output.extName}` : `${tagPath}/index`,
|
|
70
|
-
asAlias: true,
|
|
71
|
-
name: tagName,
|
|
72
|
-
},
|
|
73
|
-
],
|
|
74
|
-
meta: {
|
|
75
|
-
pluginKey: plugin.key,
|
|
76
|
-
},
|
|
77
|
-
exportable: true,
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
})
|
|
81
|
-
.filter(Boolean)
|
|
82
|
-
}
|
package/src/utils/refSorter.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { Refs } from '../types.ts'
|
|
2
|
-
|
|
3
|
-
type Generated = { import: { refs: Refs; name: string } }
|
|
4
|
-
|
|
5
|
-
export function refsSorter<T extends Generated>(a: T, b: T): number {
|
|
6
|
-
if (Object.keys(a.import.refs)?.length < Object.keys(b.import.refs)?.length) {
|
|
7
|
-
return -1
|
|
8
|
-
}
|
|
9
|
-
if (Object.keys(a.import.refs)?.length > Object.keys(b.import.refs)?.length) {
|
|
10
|
-
return 1
|
|
11
|
-
}
|
|
12
|
-
return 0
|
|
13
|
-
}
|