@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.
Files changed (105) hide show
  1. package/README.md +13 -4
  2. package/dist/OperationGenerator-DhPriVDJ.d.cts +554 -0
  3. package/dist/OperationGenerator-DhPriVDJ.d.ts +554 -0
  4. package/dist/Schema-BfZVq77f.d.cts +22 -0
  5. package/dist/Schema-IlDbvlbP.d.ts +22 -0
  6. package/dist/chunk-4H2KTGZM.cjs +92 -0
  7. package/dist/chunk-4H2KTGZM.cjs.map +1 -0
  8. package/dist/chunk-ABIWUCV7.js +88 -0
  9. package/dist/chunk-ABIWUCV7.js.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-PADR76WZ.cjs +4 -0
  17. package/dist/chunk-PADR76WZ.cjs.map +1 -0
  18. package/dist/chunk-QAFBZLJA.cjs +48 -0
  19. package/dist/chunk-QAFBZLJA.cjs.map +1 -0
  20. package/dist/chunk-QT6ZFRNJ.cjs +752 -0
  21. package/dist/chunk-QT6ZFRNJ.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-V2JO6RHI.js +744 -0
  25. package/dist/chunk-V2JO6RHI.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 -12
  31. package/dist/components.cjs.map +1 -1
  32. package/dist/components.d.cts +4 -7
  33. package/dist/components.d.ts +4 -7
  34. package/dist/components.js +3 -12
  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 +102 -57
  43. package/dist/hooks.cjs.map +1 -1
  44. package/dist/hooks.d.cts +41 -10
  45. package/dist/hooks.d.ts +41 -10
  46. package/dist/hooks.js +91 -53
  47. package/dist/hooks.js.map +1 -1
  48. package/dist/index.cjs +192 -258
  49. package/dist/index.cjs.map +1 -1
  50. package/dist/index.d.cts +3 -6
  51. package/dist/index.d.ts +3 -6
  52. package/dist/index.js +135 -228
  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 +20 -14
  61. package/src/OperationGenerator.ts +23 -30
  62. package/src/SchemaGenerator.ts +80 -23
  63. package/src/SchemaMapper.ts +7 -5
  64. package/src/components/Oas.tsx +1 -1
  65. package/src/components/Operation.tsx +1 -1
  66. package/src/components/Schema.tsx +2 -102
  67. package/src/{parser.tsx → generator.tsx} +35 -22
  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 +77 -29
  72. package/src/hooks/useSchemaManager.ts +77 -0
  73. package/src/index.ts +3 -3
  74. package/src/plugin.ts +67 -59
  75. package/src/types.ts +24 -16
  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-D7rSlflc.d.cts +0 -158
  81. package/dist/OperationGenerator-vw0Zf-Mi.d.ts +0 -158
  82. package/dist/Schema-DxyOIX7q.d.cts +0 -35
  83. package/dist/Schema-gHgN14i2.d.ts +0 -35
  84. package/dist/SchemaMapper-BM1IGWqD.d.cts +0 -248
  85. package/dist/SchemaMapper-BM1IGWqD.d.ts +0 -248
  86. package/dist/chunk-264TCCJF.cjs +0 -3973
  87. package/dist/chunk-264TCCJF.cjs.map +0 -1
  88. package/dist/chunk-7KIEQOVZ.cjs +0 -7
  89. package/dist/chunk-7KIEQOVZ.cjs.map +0 -1
  90. package/dist/chunk-FZN3PBEK.js +0 -3973
  91. package/dist/chunk-FZN3PBEK.js.map +0 -1
  92. package/dist/chunk-P42X362U.cjs +0 -101
  93. package/dist/chunk-P42X362U.cjs.map +0 -1
  94. package/dist/chunk-QLJIL3U5.cjs +0 -35
  95. package/dist/chunk-QLJIL3U5.cjs.map +0 -1
  96. package/dist/chunk-TWKZEVSM.js +0 -7
  97. package/dist/chunk-TWKZEVSM.js.map +0 -1
  98. package/dist/chunk-UB552H4J.js +0 -101
  99. package/dist/chunk-UB552H4J.js.map +0 -1
  100. package/dist/chunk-Y4V7HHX7.js +0 -35
  101. package/dist/chunk-Y4V7HHX7.js.map +0 -1
  102. package/dist/types-C2RXaY0_.d.cts +0 -143
  103. package/dist/types-C2RXaY0_.d.ts +0 -143
  104. package/src/utils/getGroupedByTagFiles.ts +0 -82
  105. 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
- }
@@ -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
- }