@kubb/plugin-oas 3.0.0-alpha.9 → 3.0.0-beta.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/README.md +14 -5
- package/dist/OperationGenerator-Dko8Xtd7.d.cts +561 -0
- package/dist/OperationGenerator-Dko8Xtd7.d.ts +561 -0
- package/dist/{Schema-B1vcPGiK.d.ts → Schema-C2cbPYX1.d.cts} +1 -12
- package/dist/{Schema-DoSFh7Qd.d.cts → Schema-CbtIvprh.d.ts} +1 -12
- package/dist/chunk-2TGWPVZN.cjs +92 -0
- package/dist/chunk-2TGWPVZN.cjs.map +1 -0
- package/dist/chunk-A3ROGKLW.cjs +752 -0
- package/dist/chunk-A3ROGKLW.cjs.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-JA75IPYU.js +744 -0
- package/dist/chunk-JA75IPYU.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-SZDO532A.js.map → chunk-QAFBZLJA.cjs.map} +1 -1
- package/dist/chunk-R47XMJ32.js +3 -0
- package/dist/chunk-R47XMJ32.js.map +1 -0
- package/dist/chunk-TNWNNVQW.js +88 -0
- package/dist/chunk-TNWNNVQW.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 +3 -6
- package/dist/components.d.ts +3 -6
- 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 +90 -57
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.cts +37 -10
- package/dist/hooks.d.ts +37 -10
- package/dist/hooks.js +79 -53
- package/dist/hooks.js.map +1 -1
- package/dist/index.cjs +142 -189
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -5
- package/dist/index.d.ts +2 -5
- package/dist/index.js +82 -156
- package/dist/index.js.map +1 -1
- package/dist/utils.cjs +32 -45
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +4 -13
- package/dist/utils.d.ts +4 -13
- package/dist/utils.js +8 -44
- package/dist/utils.js.map +1 -1
- package/package.json +20 -14
- package/src/OperationGenerator.ts +30 -39
- package/src/SchemaGenerator.ts +70 -11
- package/src/SchemaMapper.ts +24 -5
- package/src/components/Schema.tsx +1 -99
- package/src/generator.tsx +22 -18
- 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 +56 -31
- package/src/hooks/useSchemaManager.ts +77 -0
- package/src/index.ts +2 -4
- package/src/plugin.ts +69 -56
- package/src/types.ts +29 -22
- package/src/utils/getParams.ts +1 -1
- package/src/utils/getSchemaFactory.ts +1 -1
- package/src/utils/index.ts +0 -1
- package/src/utils/parseFromConfig.ts +7 -7
- package/dist/OperationGenerator-By5WOmWB.d.ts +0 -165
- package/dist/OperationGenerator-Gd1X7wUz.d.cts +0 -165
- package/dist/SchemaMapper-sGcY1xL5.d.cts +0 -247
- package/dist/SchemaMapper-sGcY1xL5.d.ts +0 -247
- package/dist/chunk-75BIOXB7.cjs +0 -7
- package/dist/chunk-75BIOXB7.cjs.map +0 -1
- package/dist/chunk-IAUV3UKH.cjs +0 -3965
- package/dist/chunk-IAUV3UKH.cjs.map +0 -1
- package/dist/chunk-M347763D.js +0 -3965
- package/dist/chunk-M347763D.js.map +0 -1
- package/dist/chunk-N7EEVJA6.js +0 -35
- package/dist/chunk-N7EEVJA6.js.map +0 -1
- package/dist/chunk-NU4F7G47.cjs +0 -89
- package/dist/chunk-NU4F7G47.cjs.map +0 -1
- package/dist/chunk-O76YQFZB.cjs +0 -35
- package/dist/chunk-O76YQFZB.cjs.map +0 -1
- package/dist/chunk-SQ64ESS4.js +0 -7
- package/dist/chunk-SQ64ESS4.js.map +0 -1
- package/dist/chunk-SZDO532A.js +0 -89
- package/dist/types-CZTUCaE5.d.cts +0 -145
- package/dist/types-CZTUCaE5.d.ts +0 -145
- package/src/utils/refSorter.ts +0 -13
|
@@ -0,0 +1,561 @@
|
|
|
1
|
+
import { Plugin, ResolveNameParams, Output, PluginFactoryOptions, FileMetaBase, BaseGenerator, PluginManager } from '@kubb/core';
|
|
2
|
+
import * as KubbFile from '@kubb/fs/types';
|
|
3
|
+
import { Oas, contentType, OasTypes, SchemaObject, Operation, HttpMethod } from '@kubb/oas';
|
|
4
|
+
import { KubbNode } from '@kubb/react/types';
|
|
5
|
+
|
|
6
|
+
type SchemaKeywordMapper = {
|
|
7
|
+
object: {
|
|
8
|
+
keyword: 'object';
|
|
9
|
+
args: {
|
|
10
|
+
properties: {
|
|
11
|
+
[x: string]: Schema[];
|
|
12
|
+
};
|
|
13
|
+
additionalProperties: Schema[];
|
|
14
|
+
strict?: boolean;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
strict: {
|
|
18
|
+
keyword: 'strict';
|
|
19
|
+
};
|
|
20
|
+
url: {
|
|
21
|
+
keyword: 'url';
|
|
22
|
+
};
|
|
23
|
+
readOnly: {
|
|
24
|
+
keyword: 'readOnly';
|
|
25
|
+
};
|
|
26
|
+
writeOnly: {
|
|
27
|
+
keyword: 'writeOnly';
|
|
28
|
+
};
|
|
29
|
+
uuid: {
|
|
30
|
+
keyword: 'uuid';
|
|
31
|
+
};
|
|
32
|
+
email: {
|
|
33
|
+
keyword: 'email';
|
|
34
|
+
};
|
|
35
|
+
firstName: {
|
|
36
|
+
keyword: 'firstName';
|
|
37
|
+
};
|
|
38
|
+
lastName: {
|
|
39
|
+
keyword: 'lastName';
|
|
40
|
+
};
|
|
41
|
+
phone: {
|
|
42
|
+
keyword: 'phone';
|
|
43
|
+
};
|
|
44
|
+
password: {
|
|
45
|
+
keyword: 'password';
|
|
46
|
+
};
|
|
47
|
+
date: {
|
|
48
|
+
keyword: 'date';
|
|
49
|
+
args: {
|
|
50
|
+
type?: 'date' | 'string';
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
time: {
|
|
54
|
+
keyword: 'time';
|
|
55
|
+
args: {
|
|
56
|
+
type?: 'date' | 'string';
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
datetime: {
|
|
60
|
+
keyword: 'datetime';
|
|
61
|
+
args: {
|
|
62
|
+
offset?: boolean;
|
|
63
|
+
local?: boolean;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
tuple: {
|
|
67
|
+
keyword: 'tuple';
|
|
68
|
+
args: {
|
|
69
|
+
items: Schema[];
|
|
70
|
+
min?: number;
|
|
71
|
+
max?: number;
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
array: {
|
|
75
|
+
keyword: 'array';
|
|
76
|
+
args: {
|
|
77
|
+
items: Schema[];
|
|
78
|
+
min?: number;
|
|
79
|
+
max?: number;
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
enum: {
|
|
83
|
+
keyword: 'enum';
|
|
84
|
+
args: {
|
|
85
|
+
name: string;
|
|
86
|
+
typeName: string;
|
|
87
|
+
asConst: boolean;
|
|
88
|
+
items: Array<{
|
|
89
|
+
name: string | number;
|
|
90
|
+
format: 'string' | 'number' | 'boolean';
|
|
91
|
+
value?: string | number | boolean;
|
|
92
|
+
}>;
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
and: {
|
|
96
|
+
keyword: 'and';
|
|
97
|
+
args: Schema[];
|
|
98
|
+
};
|
|
99
|
+
const: {
|
|
100
|
+
keyword: 'const';
|
|
101
|
+
args: {
|
|
102
|
+
name: string | number;
|
|
103
|
+
format: 'string' | 'number' | 'boolean';
|
|
104
|
+
value?: string | number | boolean;
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
union: {
|
|
108
|
+
keyword: 'union';
|
|
109
|
+
args: Schema[];
|
|
110
|
+
};
|
|
111
|
+
ref: {
|
|
112
|
+
keyword: 'ref';
|
|
113
|
+
args: {
|
|
114
|
+
name: string;
|
|
115
|
+
/**
|
|
116
|
+
* Full qualified path.
|
|
117
|
+
*/
|
|
118
|
+
path: KubbFile.OptionalPath;
|
|
119
|
+
/**
|
|
120
|
+
* When true `File.Import` will be used.
|
|
121
|
+
* When false a reference will be used inside the current file.
|
|
122
|
+
*/
|
|
123
|
+
isImportable: boolean;
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
matches: {
|
|
127
|
+
keyword: 'matches';
|
|
128
|
+
args?: string;
|
|
129
|
+
};
|
|
130
|
+
boolean: {
|
|
131
|
+
keyword: 'boolean';
|
|
132
|
+
};
|
|
133
|
+
default: {
|
|
134
|
+
keyword: 'default';
|
|
135
|
+
args: string | number | boolean;
|
|
136
|
+
};
|
|
137
|
+
string: {
|
|
138
|
+
keyword: 'string';
|
|
139
|
+
};
|
|
140
|
+
integer: {
|
|
141
|
+
keyword: 'integer';
|
|
142
|
+
};
|
|
143
|
+
number: {
|
|
144
|
+
keyword: 'number';
|
|
145
|
+
};
|
|
146
|
+
max: {
|
|
147
|
+
keyword: 'max';
|
|
148
|
+
args: number;
|
|
149
|
+
};
|
|
150
|
+
min: {
|
|
151
|
+
keyword: 'min';
|
|
152
|
+
args: number;
|
|
153
|
+
};
|
|
154
|
+
describe: {
|
|
155
|
+
keyword: 'describe';
|
|
156
|
+
args: string;
|
|
157
|
+
};
|
|
158
|
+
example: {
|
|
159
|
+
keyword: 'example';
|
|
160
|
+
args: string;
|
|
161
|
+
};
|
|
162
|
+
deprecated: {
|
|
163
|
+
keyword: 'deprecated';
|
|
164
|
+
};
|
|
165
|
+
optional: {
|
|
166
|
+
keyword: 'optional';
|
|
167
|
+
};
|
|
168
|
+
undefined: {
|
|
169
|
+
keyword: 'undefined';
|
|
170
|
+
};
|
|
171
|
+
nullish: {
|
|
172
|
+
keyword: 'nullish';
|
|
173
|
+
};
|
|
174
|
+
nullable: {
|
|
175
|
+
keyword: 'nullable';
|
|
176
|
+
};
|
|
177
|
+
null: {
|
|
178
|
+
keyword: 'null';
|
|
179
|
+
};
|
|
180
|
+
any: {
|
|
181
|
+
keyword: 'any';
|
|
182
|
+
};
|
|
183
|
+
unknown: {
|
|
184
|
+
keyword: 'unknown';
|
|
185
|
+
};
|
|
186
|
+
blob: {
|
|
187
|
+
keyword: 'blob';
|
|
188
|
+
};
|
|
189
|
+
schema: {
|
|
190
|
+
keyword: 'schema';
|
|
191
|
+
args: {
|
|
192
|
+
type: 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'object';
|
|
193
|
+
format?: string;
|
|
194
|
+
};
|
|
195
|
+
};
|
|
196
|
+
name: {
|
|
197
|
+
keyword: 'name';
|
|
198
|
+
args: string;
|
|
199
|
+
};
|
|
200
|
+
catchall: {
|
|
201
|
+
keyword: 'catchall';
|
|
202
|
+
};
|
|
203
|
+
};
|
|
204
|
+
declare const schemaKeywords: {
|
|
205
|
+
any: "any";
|
|
206
|
+
strict: "strict";
|
|
207
|
+
unknown: "unknown";
|
|
208
|
+
number: "number";
|
|
209
|
+
integer: "integer";
|
|
210
|
+
string: "string";
|
|
211
|
+
boolean: "boolean";
|
|
212
|
+
undefined: "undefined";
|
|
213
|
+
nullable: "nullable";
|
|
214
|
+
null: "null";
|
|
215
|
+
nullish: "nullish";
|
|
216
|
+
array: "array";
|
|
217
|
+
tuple: "tuple";
|
|
218
|
+
enum: "enum";
|
|
219
|
+
union: "union";
|
|
220
|
+
datetime: "datetime";
|
|
221
|
+
date: "date";
|
|
222
|
+
email: "email";
|
|
223
|
+
uuid: "uuid";
|
|
224
|
+
url: "url";
|
|
225
|
+
default: "default";
|
|
226
|
+
const: "const";
|
|
227
|
+
and: "and";
|
|
228
|
+
describe: "describe";
|
|
229
|
+
min: "min";
|
|
230
|
+
max: "max";
|
|
231
|
+
optional: "optional";
|
|
232
|
+
readOnly: "readOnly";
|
|
233
|
+
writeOnly: "writeOnly";
|
|
234
|
+
object: "object";
|
|
235
|
+
ref: "ref";
|
|
236
|
+
matches: "matches";
|
|
237
|
+
firstName: "firstName";
|
|
238
|
+
lastName: "lastName";
|
|
239
|
+
password: "password";
|
|
240
|
+
phone: "phone";
|
|
241
|
+
blob: "blob";
|
|
242
|
+
deprecated: "deprecated";
|
|
243
|
+
example: "example";
|
|
244
|
+
schema: "schema";
|
|
245
|
+
catchall: "catchall";
|
|
246
|
+
time: "time";
|
|
247
|
+
name: "name";
|
|
248
|
+
};
|
|
249
|
+
type SchemaKeyword = keyof SchemaKeywordMapper;
|
|
250
|
+
type SchemaMapper<T = string | null | undefined> = {
|
|
251
|
+
[K in keyof SchemaKeywordMapper]: (() => T | undefined) | undefined;
|
|
252
|
+
};
|
|
253
|
+
type SchemaKeywordBase<T> = {
|
|
254
|
+
keyword: SchemaKeyword;
|
|
255
|
+
args: T;
|
|
256
|
+
};
|
|
257
|
+
type Schema = {
|
|
258
|
+
keyword: string;
|
|
259
|
+
} | SchemaKeywordMapper[keyof SchemaKeywordMapper];
|
|
260
|
+
type SchemaTree = {
|
|
261
|
+
parent: Schema | undefined;
|
|
262
|
+
current: Schema;
|
|
263
|
+
siblings: Schema[];
|
|
264
|
+
};
|
|
265
|
+
declare function isKeyword<T extends Schema, K extends keyof SchemaKeywordMapper>(meta: T, keyword: K): meta is Extract<T, SchemaKeywordMapper[K]>;
|
|
266
|
+
|
|
267
|
+
type Mode = 'schemas' | 'responses' | 'requestBodies';
|
|
268
|
+
type GetSchemasProps = {
|
|
269
|
+
oas: Oas;
|
|
270
|
+
contentType?: contentType;
|
|
271
|
+
includes?: Mode[];
|
|
272
|
+
};
|
|
273
|
+
declare function getSchemas({ oas, contentType, includes }: GetSchemasProps): Record<string, OasTypes.SchemaObject>;
|
|
274
|
+
|
|
275
|
+
type ResolvePathOptions = {
|
|
276
|
+
pluginKey?: Plugin['key'];
|
|
277
|
+
tag?: string;
|
|
278
|
+
type?: ResolveNameParams['type'];
|
|
279
|
+
};
|
|
280
|
+
type API = {
|
|
281
|
+
getOas: () => Promise<Oas>;
|
|
282
|
+
getSchemas: (options?: Pick<GetSchemasProps, 'includes'>) => Promise<Record<string, SchemaObject>>;
|
|
283
|
+
getBaseURL: () => Promise<string | undefined>;
|
|
284
|
+
contentType?: contentType;
|
|
285
|
+
};
|
|
286
|
+
type Options = {
|
|
287
|
+
/**
|
|
288
|
+
* Validate your input(see kubb.config) based on '@readme/openapi-parser'.
|
|
289
|
+
* @default true
|
|
290
|
+
*/
|
|
291
|
+
validate?: boolean;
|
|
292
|
+
/**
|
|
293
|
+
* Specify the export location for the files and define the behavior of the output
|
|
294
|
+
* @default { path: 'schemas', barrelType: 'named' }
|
|
295
|
+
*/
|
|
296
|
+
output?: Output;
|
|
297
|
+
/**
|
|
298
|
+
* Which server to use from the array of `servers.url[serverIndex]`
|
|
299
|
+
* @example
|
|
300
|
+
* - `0` will return `http://petstore.swagger.io/api`
|
|
301
|
+
* - `1` will return `http://localhost:3000`
|
|
302
|
+
* @default 0
|
|
303
|
+
*/
|
|
304
|
+
serverIndex?: number;
|
|
305
|
+
/**
|
|
306
|
+
* Define which contentType should be used.
|
|
307
|
+
* By default, this is set based on the contentType being found.
|
|
308
|
+
*/
|
|
309
|
+
contentType?: contentType;
|
|
310
|
+
/**
|
|
311
|
+
* Override some behaviour of the Oas class instance, see '@kubb/oas'
|
|
312
|
+
*/
|
|
313
|
+
oasClass?: typeof Oas;
|
|
314
|
+
/**
|
|
315
|
+
* Define some generators next to the JSON generation
|
|
316
|
+
*/
|
|
317
|
+
generators?: Array<Generator<PluginOas>>;
|
|
318
|
+
};
|
|
319
|
+
/**
|
|
320
|
+
* `propertyName` is the ref name + resolved with the nameResolver
|
|
321
|
+
* @example import { Pet } from './Pet'
|
|
322
|
+
*
|
|
323
|
+
* `originalName` is the original name used(in PascalCase), only used to remove duplicates
|
|
324
|
+
*
|
|
325
|
+
* `pluginKey` can be used to override the current plugin being used, handy when you want to import a type/schema out of another plugin
|
|
326
|
+
* @example import a type(plugin-ts) for a mock file(swagger-faker)
|
|
327
|
+
*/
|
|
328
|
+
type Ref = {
|
|
329
|
+
propertyName: string;
|
|
330
|
+
originalName: string;
|
|
331
|
+
path: KubbFile.OptionalPath;
|
|
332
|
+
pluginKey?: Plugin['key'];
|
|
333
|
+
};
|
|
334
|
+
type Refs = Record<string, Ref>;
|
|
335
|
+
type Resolver = {
|
|
336
|
+
/**
|
|
337
|
+
* Original name or name resolved by `resolveName({ name: operation?.getOperationId() as string, pluginName })`
|
|
338
|
+
*/
|
|
339
|
+
name: string;
|
|
340
|
+
baseName: KubbFile.BaseName;
|
|
341
|
+
path: KubbFile.Path;
|
|
342
|
+
};
|
|
343
|
+
type OperationSchema = {
|
|
344
|
+
/**
|
|
345
|
+
* Converted name, contains already `PathParams`, `QueryParams`, ...
|
|
346
|
+
*/
|
|
347
|
+
name: string;
|
|
348
|
+
schema: SchemaObject;
|
|
349
|
+
operation?: Operation;
|
|
350
|
+
/**
|
|
351
|
+
* OperationName in PascalCase, only being used in OperationGenerator
|
|
352
|
+
*/
|
|
353
|
+
operationName: string;
|
|
354
|
+
description?: string;
|
|
355
|
+
statusCode?: number;
|
|
356
|
+
keys?: string[];
|
|
357
|
+
keysToOmit?: string[];
|
|
358
|
+
withData?: boolean;
|
|
359
|
+
};
|
|
360
|
+
type OperationSchemas = {
|
|
361
|
+
pathParams?: OperationSchema & {
|
|
362
|
+
keysToOmit?: never;
|
|
363
|
+
};
|
|
364
|
+
queryParams?: OperationSchema & {
|
|
365
|
+
keysToOmit?: never;
|
|
366
|
+
};
|
|
367
|
+
headerParams?: OperationSchema & {
|
|
368
|
+
keysToOmit?: never;
|
|
369
|
+
};
|
|
370
|
+
request?: OperationSchema;
|
|
371
|
+
response: OperationSchema;
|
|
372
|
+
responses: Array<OperationSchema>;
|
|
373
|
+
statusCodes?: Array<OperationSchema>;
|
|
374
|
+
errors?: Array<OperationSchema>;
|
|
375
|
+
};
|
|
376
|
+
type OperationsByMethod = Record<string, Record<HttpMethod, {
|
|
377
|
+
operation: Operation;
|
|
378
|
+
schemas: OperationSchemas;
|
|
379
|
+
}>>;
|
|
380
|
+
type ByTag = {
|
|
381
|
+
type: 'tag';
|
|
382
|
+
pattern: string | RegExp;
|
|
383
|
+
};
|
|
384
|
+
type ByOperationId = {
|
|
385
|
+
type: 'operationId';
|
|
386
|
+
pattern: string | RegExp;
|
|
387
|
+
};
|
|
388
|
+
type ByPath = {
|
|
389
|
+
type: 'path';
|
|
390
|
+
pattern: string | RegExp;
|
|
391
|
+
};
|
|
392
|
+
type ByMethod = {
|
|
393
|
+
type: 'method';
|
|
394
|
+
pattern: HttpMethod | RegExp;
|
|
395
|
+
};
|
|
396
|
+
type BySchemaName = {
|
|
397
|
+
type: 'schemaName';
|
|
398
|
+
pattern: string | RegExp;
|
|
399
|
+
};
|
|
400
|
+
type Exclude = ByTag | ByOperationId | ByPath | ByMethod;
|
|
401
|
+
type Include = ByTag | ByOperationId | ByPath | ByMethod;
|
|
402
|
+
type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName) & {
|
|
403
|
+
options: Partial<TOptions>;
|
|
404
|
+
};
|
|
405
|
+
type ResolvedOptions = Options & {
|
|
406
|
+
output: Output;
|
|
407
|
+
};
|
|
408
|
+
type PluginOas = PluginFactoryOptions<'plugin-oas', Options, ResolvedOptions, API, never>;
|
|
409
|
+
|
|
410
|
+
type GetSchemaGeneratorOptions<T extends SchemaGenerator<any, any, any>> = T extends SchemaGenerator<infer Options, any, any> ? Options : never;
|
|
411
|
+
type SchemaMethodResult<TFileMeta extends FileMetaBase> = Promise<KubbFile.File<TFileMeta> | Array<KubbFile.File<TFileMeta>> | null>;
|
|
412
|
+
type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
413
|
+
oas: Oas;
|
|
414
|
+
pluginManager: PluginManager;
|
|
415
|
+
/**
|
|
416
|
+
* Current plugin
|
|
417
|
+
*/
|
|
418
|
+
plugin: Plugin<TPluginOptions>;
|
|
419
|
+
mode: KubbFile.Mode;
|
|
420
|
+
include?: Array<'schemas' | 'responses' | 'requestBodies'>;
|
|
421
|
+
override: Array<Override<TOptions>> | undefined;
|
|
422
|
+
contentType?: contentType;
|
|
423
|
+
output?: string;
|
|
424
|
+
};
|
|
425
|
+
type SchemaGeneratorOptions = {
|
|
426
|
+
dateType: false | 'string' | 'stringOffset' | 'stringLocal' | 'date';
|
|
427
|
+
unknownType: 'any' | 'unknown';
|
|
428
|
+
enumType?: 'enum' | 'asConst' | 'asPascalConst' | 'constEnum' | 'literal';
|
|
429
|
+
enumSuffix?: string;
|
|
430
|
+
usedEnumNames?: Record<string, number>;
|
|
431
|
+
mapper?: Record<string, string>;
|
|
432
|
+
typed?: boolean;
|
|
433
|
+
transformers: {
|
|
434
|
+
/**
|
|
435
|
+
* Customize the names based on the type that is provided by the plugin.
|
|
436
|
+
*/
|
|
437
|
+
name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
438
|
+
/**
|
|
439
|
+
* Receive schema and name(propertName) and return FakerMeta array
|
|
440
|
+
* TODO TODO add docs
|
|
441
|
+
* @beta
|
|
442
|
+
*/
|
|
443
|
+
schema?: (schemaProps: SchemaProps$1, defaultSchemas: Schema[]) => Schema[] | undefined;
|
|
444
|
+
};
|
|
445
|
+
};
|
|
446
|
+
type SchemaGeneratorBuildOptions = Omit<OperationSchema, 'name' | 'schema'>;
|
|
447
|
+
type SchemaProps$1 = {
|
|
448
|
+
schema?: SchemaObject;
|
|
449
|
+
name?: string;
|
|
450
|
+
parentName?: string;
|
|
451
|
+
};
|
|
452
|
+
declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions, Context$1<TOptions, TPluginOptions>> {
|
|
453
|
+
#private;
|
|
454
|
+
refs: Refs;
|
|
455
|
+
/**
|
|
456
|
+
* Creates a type node from a given schema.
|
|
457
|
+
* Delegates to getBaseTypeFromSchema internally and
|
|
458
|
+
* optionally adds a union with null.
|
|
459
|
+
*/
|
|
460
|
+
parse(props: SchemaProps$1): Schema[];
|
|
461
|
+
deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T][];
|
|
462
|
+
find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
463
|
+
static deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T][];
|
|
464
|
+
static findInObject<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
465
|
+
static find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
466
|
+
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
467
|
+
/**
|
|
468
|
+
* Schema
|
|
469
|
+
*/
|
|
470
|
+
schema(name: string, object: SchemaObject, options: TOptions): SchemaMethodResult<TFileMeta>;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
type OperationsProps<TOptions extends PluginFactoryOptions> = {
|
|
474
|
+
instance: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
475
|
+
options: TOptions['resolvedOptions'];
|
|
476
|
+
operations: Array<Operation>;
|
|
477
|
+
operationsByMethod: OperationsByMethod;
|
|
478
|
+
};
|
|
479
|
+
type OperationProps<TOptions extends PluginFactoryOptions> = {
|
|
480
|
+
instance: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
481
|
+
options: TOptions['resolvedOptions'];
|
|
482
|
+
operation: Operation;
|
|
483
|
+
};
|
|
484
|
+
type SchemaProps<TOptions extends PluginFactoryOptions> = {
|
|
485
|
+
instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>;
|
|
486
|
+
options: TOptions['resolvedOptions'];
|
|
487
|
+
schema: {
|
|
488
|
+
name: string;
|
|
489
|
+
tree: Array<Schema>;
|
|
490
|
+
value: SchemaObject;
|
|
491
|
+
};
|
|
492
|
+
};
|
|
493
|
+
type GeneratorOptions<TOptions extends PluginFactoryOptions> = {
|
|
494
|
+
name: string;
|
|
495
|
+
operations?: (this: GeneratorOptions<TOptions>, props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
496
|
+
operation?: (this: GeneratorOptions<TOptions>, props: OperationProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
497
|
+
schema?: (this: GeneratorOptions<TOptions>, props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
498
|
+
};
|
|
499
|
+
type Generator<TOptions extends PluginFactoryOptions> = GeneratorOptions<TOptions>;
|
|
500
|
+
declare function createGenerator<TOptions extends PluginFactoryOptions>(parseOptions: GeneratorOptions<TOptions>): Generator<TOptions>;
|
|
501
|
+
type ReactGeneratorOptions<TOptions extends PluginFactoryOptions> = {
|
|
502
|
+
name: string;
|
|
503
|
+
Operations?: (this: ReactGeneratorOptions<TOptions>, props: OperationsProps<TOptions>) => KubbNode;
|
|
504
|
+
Operation?: (this: ReactGeneratorOptions<TOptions>, props: OperationProps<TOptions>) => KubbNode;
|
|
505
|
+
Schema?: (this: ReactGeneratorOptions<TOptions>, props: SchemaProps<TOptions>) => KubbNode;
|
|
506
|
+
};
|
|
507
|
+
declare function createReactGenerator<TOptions extends PluginFactoryOptions>(parseOptions: ReactGeneratorOptions<TOptions>): Generator<TOptions>;
|
|
508
|
+
|
|
509
|
+
type OperationMethodResult<TFileMeta extends FileMetaBase> = Promise<KubbFile.File<TFileMeta> | Array<KubbFile.File<TFileMeta>> | null>;
|
|
510
|
+
type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
511
|
+
oas: Oas;
|
|
512
|
+
exclude: Array<Exclude> | undefined;
|
|
513
|
+
include: Array<Include> | undefined;
|
|
514
|
+
override: Array<Override<TOptions>> | undefined;
|
|
515
|
+
contentType: contentType | undefined;
|
|
516
|
+
pluginManager: PluginManager;
|
|
517
|
+
/**
|
|
518
|
+
* Current plugin
|
|
519
|
+
*/
|
|
520
|
+
plugin: Plugin<TPluginOptions>;
|
|
521
|
+
mode: KubbFile.Mode;
|
|
522
|
+
};
|
|
523
|
+
declare class OperationGenerator<TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TPluginOptions['resolvedOptions'], Context<TPluginOptions['resolvedOptions'], TPluginOptions>> {
|
|
524
|
+
#private;
|
|
525
|
+
get operationsByMethod(): OperationsByMethod;
|
|
526
|
+
set operationsByMethod(paths: OperationsByMethod);
|
|
527
|
+
getSchemas(operation: Operation, { resolveName, }?: {
|
|
528
|
+
resolveName?: (name: string) => string;
|
|
529
|
+
}): OperationSchemas;
|
|
530
|
+
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
531
|
+
/**
|
|
532
|
+
* Operation
|
|
533
|
+
*/
|
|
534
|
+
operation(operation: Operation, options: TPluginOptions['resolvedOptions']): OperationMethodResult<TFileMeta>;
|
|
535
|
+
/**
|
|
536
|
+
* GET
|
|
537
|
+
*/
|
|
538
|
+
get(operation: Operation, options: TPluginOptions['resolvedOptions']): OperationMethodResult<TFileMeta>;
|
|
539
|
+
/**
|
|
540
|
+
* POST
|
|
541
|
+
*/
|
|
542
|
+
post(operation: Operation, options: TPluginOptions['resolvedOptions']): OperationMethodResult<TFileMeta>;
|
|
543
|
+
/**
|
|
544
|
+
* PATCH
|
|
545
|
+
*/
|
|
546
|
+
patch(operation: Operation, options: TPluginOptions['resolvedOptions']): OperationMethodResult<TFileMeta>;
|
|
547
|
+
/**
|
|
548
|
+
* PUT
|
|
549
|
+
*/
|
|
550
|
+
put(operation: Operation, options: TPluginOptions['resolvedOptions']): OperationMethodResult<TFileMeta>;
|
|
551
|
+
/**
|
|
552
|
+
* DELETE
|
|
553
|
+
*/
|
|
554
|
+
delete(operation: Operation, options: TPluginOptions['resolvedOptions']): OperationMethodResult<TFileMeta>;
|
|
555
|
+
/**
|
|
556
|
+
* Combination of GET, POST, PATCH, PUT, DELETE
|
|
557
|
+
*/
|
|
558
|
+
all(operations: Operation[], paths: OperationsByMethod): OperationMethodResult<TFileMeta>;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
export { type API as A, getSchemas as B, type Exclude as E, type GetSchemaGeneratorOptions as G, type Include as I, type Options as O, type PluginOas as P, type ReactGeneratorOptions as R, type SchemaGeneratorBuildOptions as S, type OperationMethodResult as a, OperationGenerator as b, type SchemaGeneratorOptions as c, type SchemaMethodResult as d, SchemaGenerator as e, type Schema as f, type SchemaTree as g, type SchemaKeyword as h, type SchemaKeywordBase as i, type SchemaKeywordMapper as j, type SchemaMapper as k, isKeyword as l, createGenerator as m, createReactGenerator as n, type Generator as o, type GeneratorOptions as p, type ResolvePathOptions as q, type Ref as r, schemaKeywords as s, type Refs as t, type Resolver as u, type OperationSchema as v, type OperationSchemas as w, type OperationsByMethod as x, type Override as y, type GetSchemasProps as z };
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { ReactNode } from 'react';
|
|
3
2
|
import { SchemaObject } from '@kubb/oas';
|
|
4
3
|
import { KubbNode } from '@kubb/react/types';
|
|
5
|
-
import {
|
|
4
|
+
import { f as Schema$1 } from './OperationGenerator-Dko8Xtd7.cjs';
|
|
6
5
|
|
|
7
6
|
type SchemaContextProps = {
|
|
8
7
|
name: string;
|
|
@@ -17,17 +16,7 @@ type Props = {
|
|
|
17
16
|
};
|
|
18
17
|
declare function Schema({ name, value, tree, children }: Props): KubbNode;
|
|
19
18
|
declare namespace Schema {
|
|
20
|
-
var File: ({ output, isTypeOnly, children }: FileProps) => ReactNode;
|
|
21
|
-
var Imports: ({ isTypeOnly }: SchemaImportsProps) => ReactNode;
|
|
22
19
|
var Context: react.Context<SchemaContextProps>;
|
|
23
20
|
}
|
|
24
|
-
type FileProps = {
|
|
25
|
-
isTypeOnly?: boolean;
|
|
26
|
-
output: string | undefined;
|
|
27
|
-
children?: KubbNode;
|
|
28
|
-
};
|
|
29
|
-
type SchemaImportsProps = {
|
|
30
|
-
isTypeOnly?: boolean;
|
|
31
|
-
};
|
|
32
21
|
|
|
33
22
|
export { Schema as S, type SchemaContextProps as a };
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { ReactNode } from 'react';
|
|
3
2
|
import { SchemaObject } from '@kubb/oas';
|
|
4
3
|
import { KubbNode } from '@kubb/react/types';
|
|
5
|
-
import {
|
|
4
|
+
import { f as Schema$1 } from './OperationGenerator-Dko8Xtd7.js';
|
|
6
5
|
|
|
7
6
|
type SchemaContextProps = {
|
|
8
7
|
name: string;
|
|
@@ -17,17 +16,7 @@ type Props = {
|
|
|
17
16
|
};
|
|
18
17
|
declare function Schema({ name, value, tree, children }: Props): KubbNode;
|
|
19
18
|
declare namespace Schema {
|
|
20
|
-
var File: ({ output, isTypeOnly, children }: FileProps) => ReactNode;
|
|
21
|
-
var Imports: ({ isTypeOnly }: SchemaImportsProps) => ReactNode;
|
|
22
19
|
var Context: react.Context<SchemaContextProps>;
|
|
23
20
|
}
|
|
24
|
-
type FileProps = {
|
|
25
|
-
isTypeOnly?: boolean;
|
|
26
|
-
output: string | undefined;
|
|
27
|
-
children?: KubbNode;
|
|
28
|
-
};
|
|
29
|
-
type SchemaImportsProps = {
|
|
30
|
-
isTypeOnly?: boolean;
|
|
31
|
-
};
|
|
32
21
|
|
|
33
22
|
export { Schema as S, type SchemaContextProps as a };
|