@kubb/plugin-oas 3.0.0-alpha.8 → 3.0.0-beta.1

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 (100) hide show
  1. package/README.md +14 -5
  2. package/dist/OperationGenerator-BgQeGRzk.d.cts +550 -0
  3. package/dist/OperationGenerator-BgQeGRzk.d.ts +550 -0
  4. package/dist/{Schema-B1vcPGiK.d.ts → Schema-1iM2I0dK.d.ts} +1 -12
  5. package/dist/{Schema-DoSFh7Qd.d.cts → Schema-5o-c5UOy.d.cts} +1 -12
  6. package/dist/chunk-ABOQ73FL.cjs +36 -0
  7. package/dist/chunk-ABOQ73FL.cjs.map +1 -0
  8. package/dist/chunk-BG77DP54.js +30 -0
  9. package/dist/chunk-BG77DP54.js.map +1 -0
  10. package/dist/chunk-GF26SDHQ.js +28 -0
  11. package/dist/chunk-GF26SDHQ.js.map +1 -0
  12. package/dist/chunk-PADR76WZ.cjs +4 -0
  13. package/dist/chunk-PADR76WZ.cjs.map +1 -0
  14. package/dist/chunk-QAFBZLJA.cjs +48 -0
  15. package/dist/chunk-QAFBZLJA.cjs.map +1 -0
  16. package/dist/chunk-QT6ZFRNJ.cjs +752 -0
  17. package/dist/chunk-QT6ZFRNJ.cjs.map +1 -0
  18. package/dist/chunk-QWO5NQGQ.js +88 -0
  19. package/dist/chunk-QWO5NQGQ.js.map +1 -0
  20. package/dist/chunk-R47XMJ32.js +3 -0
  21. package/dist/chunk-R47XMJ32.js.map +1 -0
  22. package/dist/chunk-SR63CBLH.cjs +92 -0
  23. package/dist/chunk-SR63CBLH.cjs.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 +3 -6
  33. package/dist/components.d.ts +3 -6
  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 +137 -187
  49. package/dist/index.cjs.map +1 -1
  50. package/dist/index.d.cts +2 -5
  51. package/dist/index.d.ts +2 -5
  52. package/dist/index.js +76 -153
  53. package/dist/index.js.map +1 -1
  54. package/dist/utils.cjs +32 -41
  55. package/dist/utils.cjs.map +1 -1
  56. package/dist/utils.d.cts +5 -13
  57. package/dist/utils.d.ts +5 -13
  58. package/dist/utils.js +8 -40
  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 +79 -22
  63. package/src/SchemaMapper.ts +6 -4
  64. package/src/components/Schema.tsx +1 -99
  65. package/src/{parser.tsx → generator.tsx} +30 -22
  66. package/src/generators/index.ts +1 -0
  67. package/src/generators/jsonGenerator.ts +32 -0
  68. package/src/hooks/index.ts +2 -0
  69. package/src/hooks/useOperationManager.ts +77 -30
  70. package/src/hooks/useSchemaManager.ts +77 -0
  71. package/src/index.ts +3 -3
  72. package/src/plugin.ts +69 -56
  73. package/src/types.ts +24 -18
  74. package/src/utils/getParams.ts +1 -1
  75. package/src/utils/getSchemaFactory.ts +1 -1
  76. package/src/utils/index.ts +2 -1
  77. package/src/utils/parseFromConfig.ts +7 -7
  78. package/dist/OperationGenerator-DeXrfGDC.d.ts +0 -158
  79. package/dist/OperationGenerator-DhJ0MBKc.d.cts +0 -158
  80. package/dist/SchemaMapper-sGcY1xL5.d.cts +0 -247
  81. package/dist/SchemaMapper-sGcY1xL5.d.ts +0 -247
  82. package/dist/chunk-75BIOXB7.cjs +0 -7
  83. package/dist/chunk-75BIOXB7.cjs.map +0 -1
  84. package/dist/chunk-MUI5DWM3.js +0 -3966
  85. package/dist/chunk-MUI5DWM3.js.map +0 -1
  86. package/dist/chunk-N7EEVJA6.js +0 -35
  87. package/dist/chunk-N7EEVJA6.js.map +0 -1
  88. package/dist/chunk-NU4F7G47.cjs +0 -89
  89. package/dist/chunk-NU4F7G47.cjs.map +0 -1
  90. package/dist/chunk-O76YQFZB.cjs +0 -35
  91. package/dist/chunk-O76YQFZB.cjs.map +0 -1
  92. package/dist/chunk-SQ64ESS4.js +0 -7
  93. package/dist/chunk-SQ64ESS4.js.map +0 -1
  94. package/dist/chunk-SZDO532A.js +0 -89
  95. package/dist/chunk-SZDO532A.js.map +0 -1
  96. package/dist/chunk-VSVVTCQB.cjs +0 -3966
  97. package/dist/chunk-VSVVTCQB.cjs.map +0 -1
  98. package/dist/types-CZTUCaE5.d.cts +0 -145
  99. package/dist/types-CZTUCaE5.d.ts +0 -145
  100. package/src/utils/refSorter.ts +0 -13
@@ -1,145 +0,0 @@
1
- import { Plugin, ResolveNameParams, PluginFactoryOptions } from '@kubb/core';
2
- import * as KubbFile from '@kubb/fs/types';
3
- import { Oas, contentType, OasTypes, SchemaObject, Operation, HttpMethod } from '@kubb/oas';
4
- import { FormatOptions } from '@kubb/oas/parser';
5
-
6
- type Mode = 'schemas' | 'responses' | 'requestBodies';
7
- type GetSchemasProps = {
8
- oas: Oas;
9
- contentType?: contentType;
10
- includes?: Mode[];
11
- };
12
- declare function getSchemas({ oas, contentType, includes }: GetSchemasProps): Record<string, OasTypes.SchemaObject>;
13
-
14
- type ResolvePathOptions = {
15
- pluginKey?: Plugin['key'];
16
- tag?: string;
17
- type?: ResolveNameParams['type'];
18
- };
19
- type API = {
20
- getOas: (formatOptions?: FormatOptions) => Promise<Oas>;
21
- getSchemas: (options?: Pick<GetSchemasProps, 'includes'>) => Promise<Record<string, SchemaObject>>;
22
- getBaseURL: () => Promise<string | undefined>;
23
- contentType?: contentType;
24
- };
25
- type Options = {
26
- /**
27
- * Validate your input(see kubb.config) based on '@readme/openapi-parser'.
28
- * @default true
29
- */
30
- validate?: boolean;
31
- output?: {
32
- /**
33
- * Relative path to save the JSON models.
34
- * False will not generate the schema JSON's.
35
- * @default 'schemas'
36
- */
37
- path: string;
38
- extName?: KubbFile.Extname;
39
- exportType?: 'barrel' | 'barrelNamed' | false;
40
- } | false;
41
- /**
42
- * Which server to use from the array of `servers.url[serverIndex]`
43
- * @example
44
- * - `0` will return `http://petstore.swagger.io/api`
45
- * - `1` will return `http://localhost:3000`
46
- * @default 0
47
- */
48
- serverIndex?: number;
49
- /**
50
- * Define which contentType should be used.
51
- * By default, this is set based on the first used contentType..
52
- */
53
- contentType?: contentType;
54
- experimentalFilter?: FormatOptions['filterSet'];
55
- experimentalSort?: FormatOptions['sortSet'];
56
- oasClass?: typeof Oas;
57
- };
58
- /**
59
- * `propertyName` is the ref name + resolved with the nameResolver
60
- * @example `import { Pet } from './Pet'`
61
- *
62
- * `originalName` is the original name used(in PascalCase), only used to remove duplicates
63
- *
64
- * `pluginKey` can be used to override the current plugin being used, handy when you want to import a type/schema out of another plugin
65
- * @example import a type(plugin-ts) for a mock file(swagger-faker)
66
- */
67
- type Ref = {
68
- propertyName: string;
69
- originalName: string;
70
- path: KubbFile.OptionalPath;
71
- pluginKey?: Plugin['key'];
72
- };
73
- type Refs = Record<string, Ref>;
74
- type Resolver = {
75
- /**
76
- * Original name or name resolved by `resolveName({ name: operation?.getOperationId() as string, pluginName })`
77
- */
78
- name: string;
79
- baseName: KubbFile.BaseName;
80
- path: KubbFile.Path;
81
- };
82
- type OperationSchema = {
83
- /**
84
- * Converted name, contains already `PathParams`, `QueryParams`, ...
85
- */
86
- name: string;
87
- schema: SchemaObject;
88
- operation?: Operation;
89
- /**
90
- * OperationName in PascalCase, only being used in OperationGenerator
91
- */
92
- operationName?: string;
93
- description?: string;
94
- statusCode?: number;
95
- keys?: string[];
96
- keysToOmit?: string[];
97
- withData?: boolean;
98
- };
99
- type OperationSchemas = {
100
- pathParams?: OperationSchema & {
101
- keysToOmit?: never;
102
- };
103
- queryParams?: OperationSchema & {
104
- keysToOmit?: never;
105
- };
106
- headerParams?: OperationSchema & {
107
- keysToOmit?: never;
108
- };
109
- request?: OperationSchema;
110
- response: OperationSchema;
111
- statusCodes?: Array<OperationSchema>;
112
- errors?: Array<OperationSchema>;
113
- };
114
- type OperationsByMethod = Record<string, Record<HttpMethod, {
115
- operation: Operation;
116
- schemas: OperationSchemas;
117
- }>>;
118
- type ByTag = {
119
- type: 'tag';
120
- pattern: string | RegExp;
121
- };
122
- type ByOperationId = {
123
- type: 'operationId';
124
- pattern: string | RegExp;
125
- };
126
- type ByPath = {
127
- type: 'path';
128
- pattern: string | RegExp;
129
- };
130
- type ByMethod = {
131
- type: 'method';
132
- pattern: HttpMethod | RegExp;
133
- };
134
- type BySchemaName = {
135
- type: 'schemaName';
136
- pattern: string | RegExp;
137
- };
138
- type Exclude = ByTag | ByOperationId | ByPath | ByMethod;
139
- type Include = ByTag | ByOperationId | ByPath | ByMethod;
140
- type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName) & {
141
- options: Partial<TOptions>;
142
- };
143
- type PluginOas = PluginFactoryOptions<'plugin-oas', Options, Options, API, never>;
144
-
145
- export { type API as A, type Exclude as E, type GetSchemasProps as G, type Include as I, type Options as O, type PluginOas as P, type ResolvePathOptions as R, type Ref as a, type Refs as b, type Resolver as c, type OperationSchema as d, type OperationSchemas as e, type OperationsByMethod as f, type Override as g, getSchemas as h };
@@ -1,145 +0,0 @@
1
- import { Plugin, ResolveNameParams, PluginFactoryOptions } from '@kubb/core';
2
- import * as KubbFile from '@kubb/fs/types';
3
- import { Oas, contentType, OasTypes, SchemaObject, Operation, HttpMethod } from '@kubb/oas';
4
- import { FormatOptions } from '@kubb/oas/parser';
5
-
6
- type Mode = 'schemas' | 'responses' | 'requestBodies';
7
- type GetSchemasProps = {
8
- oas: Oas;
9
- contentType?: contentType;
10
- includes?: Mode[];
11
- };
12
- declare function getSchemas({ oas, contentType, includes }: GetSchemasProps): Record<string, OasTypes.SchemaObject>;
13
-
14
- type ResolvePathOptions = {
15
- pluginKey?: Plugin['key'];
16
- tag?: string;
17
- type?: ResolveNameParams['type'];
18
- };
19
- type API = {
20
- getOas: (formatOptions?: FormatOptions) => Promise<Oas>;
21
- getSchemas: (options?: Pick<GetSchemasProps, 'includes'>) => Promise<Record<string, SchemaObject>>;
22
- getBaseURL: () => Promise<string | undefined>;
23
- contentType?: contentType;
24
- };
25
- type Options = {
26
- /**
27
- * Validate your input(see kubb.config) based on '@readme/openapi-parser'.
28
- * @default true
29
- */
30
- validate?: boolean;
31
- output?: {
32
- /**
33
- * Relative path to save the JSON models.
34
- * False will not generate the schema JSON's.
35
- * @default 'schemas'
36
- */
37
- path: string;
38
- extName?: KubbFile.Extname;
39
- exportType?: 'barrel' | 'barrelNamed' | false;
40
- } | false;
41
- /**
42
- * Which server to use from the array of `servers.url[serverIndex]`
43
- * @example
44
- * - `0` will return `http://petstore.swagger.io/api`
45
- * - `1` will return `http://localhost:3000`
46
- * @default 0
47
- */
48
- serverIndex?: number;
49
- /**
50
- * Define which contentType should be used.
51
- * By default, this is set based on the first used contentType..
52
- */
53
- contentType?: contentType;
54
- experimentalFilter?: FormatOptions['filterSet'];
55
- experimentalSort?: FormatOptions['sortSet'];
56
- oasClass?: typeof Oas;
57
- };
58
- /**
59
- * `propertyName` is the ref name + resolved with the nameResolver
60
- * @example `import { Pet } from './Pet'`
61
- *
62
- * `originalName` is the original name used(in PascalCase), only used to remove duplicates
63
- *
64
- * `pluginKey` can be used to override the current plugin being used, handy when you want to import a type/schema out of another plugin
65
- * @example import a type(plugin-ts) for a mock file(swagger-faker)
66
- */
67
- type Ref = {
68
- propertyName: string;
69
- originalName: string;
70
- path: KubbFile.OptionalPath;
71
- pluginKey?: Plugin['key'];
72
- };
73
- type Refs = Record<string, Ref>;
74
- type Resolver = {
75
- /**
76
- * Original name or name resolved by `resolveName({ name: operation?.getOperationId() as string, pluginName })`
77
- */
78
- name: string;
79
- baseName: KubbFile.BaseName;
80
- path: KubbFile.Path;
81
- };
82
- type OperationSchema = {
83
- /**
84
- * Converted name, contains already `PathParams`, `QueryParams`, ...
85
- */
86
- name: string;
87
- schema: SchemaObject;
88
- operation?: Operation;
89
- /**
90
- * OperationName in PascalCase, only being used in OperationGenerator
91
- */
92
- operationName?: string;
93
- description?: string;
94
- statusCode?: number;
95
- keys?: string[];
96
- keysToOmit?: string[];
97
- withData?: boolean;
98
- };
99
- type OperationSchemas = {
100
- pathParams?: OperationSchema & {
101
- keysToOmit?: never;
102
- };
103
- queryParams?: OperationSchema & {
104
- keysToOmit?: never;
105
- };
106
- headerParams?: OperationSchema & {
107
- keysToOmit?: never;
108
- };
109
- request?: OperationSchema;
110
- response: OperationSchema;
111
- statusCodes?: Array<OperationSchema>;
112
- errors?: Array<OperationSchema>;
113
- };
114
- type OperationsByMethod = Record<string, Record<HttpMethod, {
115
- operation: Operation;
116
- schemas: OperationSchemas;
117
- }>>;
118
- type ByTag = {
119
- type: 'tag';
120
- pattern: string | RegExp;
121
- };
122
- type ByOperationId = {
123
- type: 'operationId';
124
- pattern: string | RegExp;
125
- };
126
- type ByPath = {
127
- type: 'path';
128
- pattern: string | RegExp;
129
- };
130
- type ByMethod = {
131
- type: 'method';
132
- pattern: HttpMethod | RegExp;
133
- };
134
- type BySchemaName = {
135
- type: 'schemaName';
136
- pattern: string | RegExp;
137
- };
138
- type Exclude = ByTag | ByOperationId | ByPath | ByMethod;
139
- type Include = ByTag | ByOperationId | ByPath | ByMethod;
140
- type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName) & {
141
- options: Partial<TOptions>;
142
- };
143
- type PluginOas = PluginFactoryOptions<'plugin-oas', Options, Options, API, never>;
144
-
145
- export { type API as A, type Exclude as E, type GetSchemasProps as G, type Include as I, type Options as O, type PluginOas as P, type ResolvePathOptions as R, type Ref as a, type Refs as b, type Resolver as c, type OperationSchema as d, type OperationSchemas as e, type OperationsByMethod as f, type Override as g, getSchemas as h };
@@ -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
- }