@kubb/plugin-oas 4.3.1 → 4.4.0
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/{Oas--cvTRMTA.cjs → Oas-BzrQ6RGC.cjs} +11 -11
- package/dist/Oas-BzrQ6RGC.cjs.map +1 -0
- package/dist/{Oas-DoN76W2_.js → Oas-CIeHKOo0.js} +3 -3
- package/dist/Oas-CIeHKOo0.js.map +1 -0
- package/dist/{OperationGenerator-ki8g970_.d.ts → OperationGenerator-BZPWkxw4.d.ts} +164 -92
- package/dist/{OperationGenerator-XkW6FZJh.d.cts → OperationGenerator-CJTAer7l.d.cts} +163 -91
- package/dist/{Schema-CHstINXC.d.ts → Schema-CjraJhJi.d.ts} +7 -6
- package/dist/{Schema-BXYfUkqN.d.cts → Schema-zcZF0UIp.d.cts} +6 -5
- package/dist/{SchemaGenerator-B07tXh1b.js → SchemaGenerator-7wBwdv8G.js} +21 -4
- package/dist/{SchemaGenerator-B07tXh1b.js.map → SchemaGenerator-7wBwdv8G.js.map} +1 -1
- package/dist/{SchemaGenerator-DsK0wuii.cjs → SchemaGenerator-DzVHk6OP.cjs} +22 -5
- package/dist/SchemaGenerator-DzVHk6OP.cjs.map +1 -0
- package/dist/{SchemaMapper-qjB3rBph.d.ts → SchemaMapper-CqBW0VOy.d.ts} +1 -1
- package/dist/{SchemaMapper-CM1eXksi.js → SchemaMapper-Cx4X1al6.js} +1 -1
- package/dist/{SchemaMapper-CM1eXksi.js.map → SchemaMapper-Cx4X1al6.js.map} +1 -1
- package/dist/{SchemaMapper-CpAbmGiH.cjs → SchemaMapper-DoL-a6qq.cjs} +1 -1
- package/dist/{SchemaMapper-CpAbmGiH.cjs.map → SchemaMapper-DoL-a6qq.cjs.map} +1 -1
- package/dist/chunk-BEV-X5tz.js +27 -0
- package/dist/components.cjs +1 -1
- package/dist/components.d.cts +7 -6
- package/dist/components.d.ts +8 -7
- package/dist/components.js +1 -1
- package/dist/generators-B27La9Vd.cjs +99 -0
- package/dist/generators-B27La9Vd.cjs.map +1 -0
- package/dist/generators-C61FxVIj.js +80 -0
- package/dist/generators-C61FxVIj.js.map +1 -0
- package/dist/generators.cjs +9 -3
- package/dist/generators.d.cts +2 -7
- package/dist/generators.d.ts +3 -8
- package/dist/generators.js +5 -4
- package/dist/{getFooter-pQXwqM81.cjs → getFooter-CwjCW4h5.cjs} +3 -3
- package/dist/{getFooter-pQXwqM81.cjs.map → getFooter-CwjCW4h5.cjs.map} +1 -1
- package/dist/{getFooter-CvTKkK7-.js → getFooter-D5MdeUVv.js} +2 -2
- package/dist/{getFooter-CvTKkK7-.js.map → getFooter-D5MdeUVv.js.map} +1 -1
- package/dist/{getSchemas-CvUX0jWa.js → getSchemas-Bdg6n9Qk.js} +1 -1
- package/dist/{getSchemas-CvUX0jWa.js.map → getSchemas-Bdg6n9Qk.js.map} +1 -1
- package/dist/{getSchemas-08CU8KWq.cjs → getSchemas-DY8s2CSl.cjs} +1 -1
- package/dist/{getSchemas-08CU8KWq.cjs.map → getSchemas-DY8s2CSl.cjs.map} +1 -1
- package/dist/hooks.cjs +12 -11
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.cts +2 -2
- package/dist/hooks.d.ts +3 -3
- package/dist/hooks.js +6 -5
- package/dist/hooks.js.map +1 -1
- package/dist/index.cjs +37 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -8
- package/dist/index.d.ts +3 -9
- package/dist/index.js +33 -9
- package/dist/index.js.map +1 -1
- package/dist/mocks.cjs +1 -1
- package/dist/mocks.d.ts +1 -1
- package/dist/mocks.js +1 -1
- package/dist/{parseFromConfig-DSI6Meg0.js → parseFromConfig-CqiiLCPe.js} +1 -1
- package/dist/{parseFromConfig-DSI6Meg0.js.map → parseFromConfig-CqiiLCPe.js.map} +1 -1
- package/dist/{parseFromConfig-o3tU1XJt.cjs → parseFromConfig-RR31a98-.cjs} +1 -1
- package/dist/{parseFromConfig-o3tU1XJt.cjs.map → parseFromConfig-RR31a98-.cjs.map} +1 -1
- package/dist/utils-BnkB1ikY.js +99 -0
- package/dist/utils-BnkB1ikY.js.map +1 -0
- package/dist/utils-nzdccPlU.cjs +119 -0
- package/dist/utils-nzdccPlU.cjs.map +1 -0
- package/dist/utils.cjs +3 -3
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +3 -2
- package/dist/utils.d.ts +4 -3
- package/dist/utils.js +3 -3
- package/dist/utils.js.map +1 -1
- package/package.json +6 -7
- package/src/OperationGenerator.ts +36 -7
- package/src/SchemaGenerator.ts +25 -1
- package/src/components/Oas.tsx +5 -7
- package/src/components/Operation.tsx +3 -3
- package/src/components/Schema.tsx +3 -4
- package/src/generators/createGenerator.ts +34 -0
- package/src/generators/createReactGenerator.ts +41 -0
- package/src/generators/index.ts +4 -0
- package/src/generators/jsonGenerator.ts +1 -1
- package/src/generators/types.ts +35 -0
- package/src/generators/utils.tsx +114 -0
- package/src/hooks/useOas.ts +1 -1
- package/src/hooks/useOperation.ts +1 -1
- package/src/hooks/useOperationManager.ts +1 -1
- package/src/hooks/useOperations.ts +1 -1
- package/src/hooks/useSchema.ts +1 -1
- package/src/index.ts +3 -5
- package/src/plugin.ts +2 -0
- package/src/types.ts +1 -1
- package/src/utils/getParams.ts +1 -1
- package/dist/Oas--cvTRMTA.cjs.map +0 -1
- package/dist/Oas-DoN76W2_.js.map +0 -1
- package/dist/SchemaGenerator-DsK0wuii.cjs.map +0 -1
- package/dist/generators-BUNmB1lx.js +0 -154
- package/dist/generators-BUNmB1lx.js.map +0 -1
- package/dist/generators-CoiXCnDY.cjs +0 -175
- package/dist/generators-CoiXCnDY.cjs.map +0 -1
- package/src/generator.tsx +0 -139
|
@@ -5,11 +5,10 @@ import { Operation, Operation as Operation$1 } from "oas/operation";
|
|
|
5
5
|
import { OpenAPIV3, OpenAPIV3 as OpenAPIV3$1, OpenAPIV3_1 } from "openapi-types";
|
|
6
6
|
import * as oas_normalize_lib_types0 from "oas-normalize/lib/types";
|
|
7
7
|
import BaseOas from "oas";
|
|
8
|
+
import { KubbNode } from "@kubb/react-fabric/types";
|
|
9
|
+
import { Fabric, FileManager } from "@kubb/react-fabric";
|
|
8
10
|
import { ConsolaInstance, LogLevel } from "consola";
|
|
9
|
-
import { FileManager } from "@kubb/fabric-core";
|
|
10
11
|
|
|
11
|
-
//#region rolldown:runtime
|
|
12
|
-
//#endregion
|
|
13
12
|
//#region ../oas/src/types.d.ts
|
|
14
13
|
type contentType = 'application/json' | (string & {});
|
|
15
14
|
type SchemaObject$1 = OasTypes.SchemaObject & {
|
|
@@ -44,19 +43,18 @@ declare class Oas<const TOAS = unknown> extends BaseOas {
|
|
|
44
43
|
getParametersSchema(operation: Operation, inKey: 'path' | 'query' | 'header'): SchemaObject | null;
|
|
45
44
|
valdiate(): Promise<oas_normalize_lib_types0.ValidationResult>;
|
|
46
45
|
}
|
|
47
|
-
import * as import___kubb_react_fabric_types from "@kubb/react-fabric/types";
|
|
48
46
|
//#endregion
|
|
49
47
|
//#region ../core/src/BaseGenerator.d.ts
|
|
50
48
|
/**
|
|
51
49
|
* Abstract class that contains the building blocks for plugins to create their own Generator
|
|
52
50
|
* @link idea based on https://github.com/colinhacks/zod/blob/master/src/types.ts#L137
|
|
53
51
|
*/
|
|
54
|
-
declare abstract class BaseGenerator<TOptions
|
|
52
|
+
declare abstract class BaseGenerator<TOptions = unknown, TContext = unknown> {
|
|
55
53
|
#private;
|
|
56
|
-
constructor(options?: TOptions
|
|
57
|
-
get options(): TOptions
|
|
54
|
+
constructor(options?: TOptions, context?: TContext);
|
|
55
|
+
get options(): TOptions;
|
|
58
56
|
get context(): TContext;
|
|
59
|
-
set options(options: TOptions
|
|
57
|
+
set options(options: TOptions);
|
|
60
58
|
abstract build(...params: unknown[]): unknown;
|
|
61
59
|
}
|
|
62
60
|
//#endregion
|
|
@@ -109,7 +107,7 @@ type Logger = {
|
|
|
109
107
|
};
|
|
110
108
|
//#endregion
|
|
111
109
|
//#region ../core/src/utils/types.d.ts
|
|
112
|
-
type PossiblePromise<T
|
|
110
|
+
type PossiblePromise<T> = Promise<T> | T;
|
|
113
111
|
//#endregion
|
|
114
112
|
//#region ../core/src/types.d.ts
|
|
115
113
|
type InputPath = {
|
|
@@ -222,11 +220,11 @@ TName extends string = string,
|
|
|
222
220
|
/**
|
|
223
221
|
* Options of the plugin.
|
|
224
222
|
*/
|
|
225
|
-
TOptions
|
|
223
|
+
TOptions extends object = object,
|
|
226
224
|
/**
|
|
227
225
|
* Options of the plugin that can be used later on, see `options` inside your plugin config.
|
|
228
226
|
*/
|
|
229
|
-
TResolvedOptions extends object = TOptions
|
|
227
|
+
TResolvedOptions extends object = TOptions,
|
|
230
228
|
/**
|
|
231
229
|
* Context that you want to expose to other plugins.
|
|
232
230
|
*/
|
|
@@ -240,23 +238,23 @@ TResolvePathOptions extends object = object> = {
|
|
|
240
238
|
* Same behaviour like what has been done with `QueryKey` in `@tanstack/react-query`
|
|
241
239
|
*/
|
|
242
240
|
key: PluginKey<TName | string>;
|
|
243
|
-
options: TOptions
|
|
241
|
+
options: TOptions;
|
|
244
242
|
resolvedOptions: TResolvedOptions;
|
|
245
243
|
context: TContext;
|
|
246
244
|
resolvePathOptions: TResolvePathOptions;
|
|
247
245
|
};
|
|
248
246
|
type PluginKey<TName> = [name: TName, identifier?: string | number];
|
|
249
|
-
type UserPlugin<TOptions
|
|
247
|
+
type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
250
248
|
/**
|
|
251
249
|
* Unique name used for the plugin
|
|
252
250
|
* The name of the plugin follows the format scope:foo-bar or foo-bar, adding scope: can avoid naming conflicts with other plugins.
|
|
253
251
|
* @example @kubb/typescript
|
|
254
252
|
*/
|
|
255
|
-
name: TOptions
|
|
253
|
+
name: TOptions['name'];
|
|
256
254
|
/**
|
|
257
255
|
* Options set for a specific plugin(see kubb.config.js), passthrough of options.
|
|
258
256
|
*/
|
|
259
|
-
options: TOptions
|
|
257
|
+
options: TOptions['resolvedOptions'];
|
|
260
258
|
/**
|
|
261
259
|
* Specifies the preceding plugins for the current plugin. You can pass an array of preceding plugin names, and the current plugin will be executed after these plugins.
|
|
262
260
|
* Can be used to validate dependent plugins.
|
|
@@ -266,23 +264,23 @@ type UserPlugin<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions>
|
|
|
266
264
|
* Specifies the succeeding plugins for the current plugin. You can pass an array of succeeding plugin names, and the current plugin will be executed before these plugins.
|
|
267
265
|
*/
|
|
268
266
|
post?: Array<string>;
|
|
269
|
-
} & (TOptions
|
|
267
|
+
} & (TOptions['context'] extends never ? {
|
|
270
268
|
context?: never;
|
|
271
269
|
} : {
|
|
272
|
-
context: (this: TOptions
|
|
270
|
+
context: (this: TOptions['name'] extends 'core' ? null : Omit<PluginContext<TOptions>, 'addFile'>) => TOptions['context'];
|
|
273
271
|
});
|
|
274
|
-
type UserPluginWithLifeCycle<TOptions
|
|
275
|
-
type Plugin<TOptions
|
|
272
|
+
type UserPluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = UserPlugin<TOptions> & PluginLifecycle<TOptions>;
|
|
273
|
+
type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
276
274
|
/**
|
|
277
275
|
* Unique name used for the plugin
|
|
278
276
|
* @example @kubb/typescript
|
|
279
277
|
*/
|
|
280
|
-
name: TOptions
|
|
278
|
+
name: TOptions['name'];
|
|
281
279
|
/**
|
|
282
280
|
* Internal key used when a developer uses more than one of the same plugin
|
|
283
281
|
* @private
|
|
284
282
|
*/
|
|
285
|
-
key: TOptions
|
|
283
|
+
key: TOptions['key'];
|
|
286
284
|
/**
|
|
287
285
|
* Specifies the preceding plugins for the current plugin. You can pass an array of preceding plugin names, and the current plugin will be executed after these plugins.
|
|
288
286
|
* Can be used to validate dependent plugins.
|
|
@@ -295,49 +293,49 @@ type Plugin<TOptions$1 extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
|
295
293
|
/**
|
|
296
294
|
* Options set for a specific plugin(see kubb.config.js), passthrough of options.
|
|
297
295
|
*/
|
|
298
|
-
options: TOptions
|
|
299
|
-
} & (TOptions
|
|
296
|
+
options: TOptions['resolvedOptions'];
|
|
297
|
+
} & (TOptions['context'] extends never ? {
|
|
300
298
|
context?: never;
|
|
301
299
|
} : {
|
|
302
|
-
context: TOptions
|
|
300
|
+
context: TOptions['context'];
|
|
303
301
|
});
|
|
304
|
-
type PluginWithLifeCycle<TOptions
|
|
305
|
-
type PluginLifecycle<TOptions
|
|
302
|
+
type PluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions> & PluginLifecycle<TOptions>;
|
|
303
|
+
type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
306
304
|
/**
|
|
307
305
|
* Start of the lifecycle of a plugin.
|
|
308
306
|
* @type hookParallel
|
|
309
307
|
*/
|
|
310
|
-
buildStart?: (this: PluginContext<TOptions
|
|
308
|
+
buildStart?: (this: PluginContext<TOptions>, Config: Config) => PossiblePromise<void>;
|
|
311
309
|
/**
|
|
312
310
|
* Resolve to a Path based on a baseName(example: `./Pet.ts`) and directory(example: `./models`).
|
|
313
311
|
* Options can als be included.
|
|
314
312
|
* @type hookFirst
|
|
315
313
|
* @example ('./Pet.ts', './src/gen/') => '/src/gen/Pet.ts'
|
|
316
314
|
*/
|
|
317
|
-
resolvePath?: (this: PluginContext<TOptions
|
|
315
|
+
resolvePath?: (this: PluginContext<TOptions>, baseName: BaseName, mode?: Mode, options?: TOptions['resolvePathOptions']) => OptionalPath;
|
|
318
316
|
/**
|
|
319
317
|
* Resolve to a name based on a string.
|
|
320
318
|
* Useful when converting to PascalCase or camelCase.
|
|
321
319
|
* @type hookFirst
|
|
322
320
|
* @example ('pet') => 'Pet'
|
|
323
321
|
*/
|
|
324
|
-
resolveName?: (this: PluginContext<TOptions
|
|
322
|
+
resolveName?: (this: PluginContext<TOptions>, name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
325
323
|
/**
|
|
326
324
|
* End of the plugin lifecycle.
|
|
327
325
|
* @type hookParallel
|
|
328
326
|
*/
|
|
329
|
-
buildEnd?: (this: PluginContext<TOptions
|
|
327
|
+
buildEnd?: (this: PluginContext<TOptions>) => PossiblePromise<void>;
|
|
330
328
|
};
|
|
331
329
|
type PluginLifecycleHooks = keyof PluginLifecycle;
|
|
332
|
-
type PluginParameter<H
|
|
333
|
-
type ResolvePathParams<TOptions
|
|
330
|
+
type PluginParameter<H extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H]>;
|
|
331
|
+
type ResolvePathParams<TOptions = object> = {
|
|
334
332
|
pluginKey?: Plugin['key'];
|
|
335
333
|
baseName: BaseName;
|
|
336
334
|
mode?: Mode;
|
|
337
335
|
/**
|
|
338
336
|
* Options to be passed to 'resolvePath' 3th parameter
|
|
339
337
|
*/
|
|
340
|
-
options?: TOptions
|
|
338
|
+
options?: TOptions;
|
|
341
339
|
};
|
|
342
340
|
type ResolveNameParams = {
|
|
343
341
|
name: string;
|
|
@@ -350,7 +348,8 @@ type ResolveNameParams = {
|
|
|
350
348
|
*/
|
|
351
349
|
type?: 'file' | 'function' | 'type' | 'const';
|
|
352
350
|
};
|
|
353
|
-
type PluginContext<TOptions
|
|
351
|
+
type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
352
|
+
fabric: Fabric;
|
|
354
353
|
config: Config;
|
|
355
354
|
/**
|
|
356
355
|
* @deprecated
|
|
@@ -358,7 +357,7 @@ type PluginContext<TOptions$1 extends PluginFactoryOptions = PluginFactoryOption
|
|
|
358
357
|
fileManager: FileManager;
|
|
359
358
|
pluginManager: PluginManager;
|
|
360
359
|
addFile: (...file: Array<File>) => Promise<Array<ResolvedFile>>;
|
|
361
|
-
resolvePath: (params: ResolvePathParams<TOptions
|
|
360
|
+
resolvePath: (params: ResolvePathParams<TOptions['resolvePathOptions']>) => OptionalPath;
|
|
362
361
|
resolveName: (params: ResolveNameParams) => string;
|
|
363
362
|
logger: Logger;
|
|
364
363
|
/**
|
|
@@ -368,12 +367,12 @@ type PluginContext<TOptions$1 extends PluginFactoryOptions = PluginFactoryOption
|
|
|
368
367
|
/**
|
|
369
368
|
* Current plugin
|
|
370
369
|
*/
|
|
371
|
-
plugin: Plugin<TOptions
|
|
370
|
+
plugin: Plugin<TOptions>;
|
|
372
371
|
};
|
|
373
372
|
/**
|
|
374
373
|
* Specify the export location for the files and define the behavior of the output
|
|
375
374
|
*/
|
|
376
|
-
type Output<TOptions
|
|
375
|
+
type Output<TOptions> = {
|
|
377
376
|
/**
|
|
378
377
|
* Path to the output folder or file that will contain the generated code
|
|
379
378
|
*/
|
|
@@ -386,11 +385,11 @@ type Output<TOptions$1> = {
|
|
|
386
385
|
/**
|
|
387
386
|
* Add a banner text in the beginning of every file
|
|
388
387
|
*/
|
|
389
|
-
banner?: string | ((options: TOptions
|
|
388
|
+
banner?: string | ((options: TOptions) => string);
|
|
390
389
|
/**
|
|
391
390
|
* Add a footer text in the beginning of every file
|
|
392
391
|
*/
|
|
393
|
-
footer?: string | ((options: TOptions
|
|
392
|
+
footer?: string | ((options: TOptions) => string);
|
|
394
393
|
};
|
|
395
394
|
type GroupContext = {
|
|
396
395
|
group: string;
|
|
@@ -409,20 +408,21 @@ type Group = {
|
|
|
409
408
|
//#region ../core/src/PluginManager.d.ts
|
|
410
409
|
type RequiredPluginLifecycle = Required<PluginLifecycle>;
|
|
411
410
|
type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq';
|
|
412
|
-
type Executer<H
|
|
411
|
+
type Executer<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
413
412
|
message: string;
|
|
414
413
|
strategy: Strategy;
|
|
415
|
-
hookName: H
|
|
414
|
+
hookName: H;
|
|
416
415
|
plugin: Plugin;
|
|
417
416
|
parameters?: unknown[] | undefined;
|
|
418
417
|
output?: unknown;
|
|
419
418
|
};
|
|
420
|
-
type ParseResult<H
|
|
421
|
-
type SafeParseResult<H
|
|
419
|
+
type ParseResult<H extends PluginLifecycleHooks> = RequiredPluginLifecycle[H];
|
|
420
|
+
type SafeParseResult<H extends PluginLifecycleHooks, Result = ReturnType<ParseResult<H>>> = {
|
|
422
421
|
result: Result;
|
|
423
422
|
plugin: Plugin;
|
|
424
423
|
};
|
|
425
424
|
type Options$2 = {
|
|
425
|
+
fabric: Fabric;
|
|
426
426
|
logger: Logger;
|
|
427
427
|
/**
|
|
428
428
|
* @default Number.POSITIVE_INFINITY
|
|
@@ -434,20 +434,16 @@ type Events = {
|
|
|
434
434
|
executed: [executer: Executer];
|
|
435
435
|
error: [error: Error];
|
|
436
436
|
};
|
|
437
|
-
type GetFileProps<TOptions
|
|
437
|
+
type GetFileProps<TOptions = object> = {
|
|
438
438
|
name: string;
|
|
439
439
|
mode?: Mode;
|
|
440
440
|
extname: Extname;
|
|
441
441
|
pluginKey: Plugin['key'];
|
|
442
|
-
options?: TOptions
|
|
442
|
+
options?: TOptions;
|
|
443
443
|
};
|
|
444
444
|
declare class PluginManager {
|
|
445
445
|
#private;
|
|
446
446
|
readonly plugins: Set<Plugin<PluginFactoryOptions<string, object, object, any, object>>>;
|
|
447
|
-
/**
|
|
448
|
-
* @deprecated do not use from pluginManager
|
|
449
|
-
*/
|
|
450
|
-
readonly fileManager: FileManager;
|
|
451
447
|
readonly events: EventEmitter<Events>;
|
|
452
448
|
readonly config: Config;
|
|
453
449
|
readonly executed: Array<Executer>;
|
|
@@ -560,6 +556,45 @@ type FileMetaBase = {
|
|
|
560
556
|
pluginKey?: Plugin['key'];
|
|
561
557
|
};
|
|
562
558
|
//#endregion
|
|
559
|
+
//#region src/generators/createGenerator.d.ts
|
|
560
|
+
type UserGenerator$1<TOptions extends PluginFactoryOptions> = {
|
|
561
|
+
name: string;
|
|
562
|
+
operations?: (props: OperationsProps<TOptions>) => Promise<File[]>;
|
|
563
|
+
operation?: (props: OperationProps<TOptions>) => Promise<File[]>;
|
|
564
|
+
schema?: (props: SchemaProps<TOptions>) => Promise<File[]>;
|
|
565
|
+
};
|
|
566
|
+
type CoreGenerator<TOptions extends PluginFactoryOptions> = {
|
|
567
|
+
name: string;
|
|
568
|
+
type: 'core';
|
|
569
|
+
operations: (props: OperationsProps<TOptions>) => Promise<File[]>;
|
|
570
|
+
operation: (props: OperationProps<TOptions>) => Promise<File[]>;
|
|
571
|
+
schema: (props: SchemaProps<TOptions>) => Promise<File[]>;
|
|
572
|
+
};
|
|
573
|
+
declare function createGenerator<TOptions extends PluginFactoryOptions>(generator: UserGenerator$1<TOptions>): CoreGenerator<TOptions>;
|
|
574
|
+
//#endregion
|
|
575
|
+
//#region src/generators/createReactGenerator.d.ts
|
|
576
|
+
type UserGenerator<TOptions extends PluginFactoryOptions> = {
|
|
577
|
+
name: string;
|
|
578
|
+
Operations?: (props: OperationsProps<TOptions>) => KubbNode;
|
|
579
|
+
Operation?: (props: OperationProps<TOptions>) => KubbNode;
|
|
580
|
+
Schema?: (props: SchemaProps<TOptions>) => KubbNode;
|
|
581
|
+
};
|
|
582
|
+
type ReactGenerator<TOptions extends PluginFactoryOptions> = {
|
|
583
|
+
name: string;
|
|
584
|
+
type: 'react';
|
|
585
|
+
Operations: (props: OperationsProps<TOptions>) => KubbNode;
|
|
586
|
+
Operation: (props: OperationProps<TOptions>) => KubbNode;
|
|
587
|
+
Schema: (props: SchemaProps<TOptions>) => KubbNode;
|
|
588
|
+
};
|
|
589
|
+
/****
|
|
590
|
+
* Creates a generator that uses React component functions to generate files for OpenAPI operations and schemas.
|
|
591
|
+
*
|
|
592
|
+
* The returned generator exposes async methods for generating files from operations, a single operation, or a schema, using the corresponding React components if provided. If a component is not defined, the method returns an empty array.
|
|
593
|
+
*
|
|
594
|
+
* @returns A generator object with async methods for operations, operation, and schema file generation.
|
|
595
|
+
*/
|
|
596
|
+
declare function createReactGenerator<TOptions extends PluginFactoryOptions>(generator: UserGenerator<TOptions>): ReactGenerator<TOptions>;
|
|
597
|
+
//#endregion
|
|
563
598
|
//#region src/types.d.ts
|
|
564
599
|
type ResolvePathOptions = {
|
|
565
600
|
pluginKey?: Plugin['key'];
|
|
@@ -704,18 +739,22 @@ type ByContentType = {
|
|
|
704
739
|
};
|
|
705
740
|
type Exclude$1 = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
|
|
706
741
|
type Include = ByTag | ByOperationId | ByPath | ByMethod | ByContentType;
|
|
707
|
-
type Override<TOptions
|
|
708
|
-
options: Partial<TOptions
|
|
742
|
+
type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | BySchemaName | ByContentType) & {
|
|
743
|
+
options: Partial<TOptions>;
|
|
709
744
|
};
|
|
710
745
|
type ResolvedOptions = Options$1 & {
|
|
711
746
|
output: Output<Oas>;
|
|
712
747
|
};
|
|
713
748
|
type PluginOas = PluginFactoryOptions<'plugin-oas', Options$1, ResolvedOptions, API, ResolvePathOptions>;
|
|
714
749
|
//#endregion
|
|
750
|
+
//#region src/generators/jsonGenerator.d.ts
|
|
751
|
+
declare const jsonGenerator: CoreGenerator<PluginOas>;
|
|
752
|
+
//#endregion
|
|
715
753
|
//#region src/SchemaGenerator.d.ts
|
|
716
|
-
type GetSchemaGeneratorOptions<T
|
|
754
|
+
type GetSchemaGeneratorOptions<T extends SchemaGenerator<any, any, any>> = T extends SchemaGenerator<infer Options, any, any> ? Options : never;
|
|
717
755
|
type SchemaMethodResult<TFileMeta extends FileMetaBase> = Promise<File<TFileMeta> | Array<File<TFileMeta>> | null>;
|
|
718
|
-
type Context$1<TOptions
|
|
756
|
+
type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
757
|
+
fabric: Fabric;
|
|
719
758
|
oas: Oas;
|
|
720
759
|
pluginManager: PluginManager;
|
|
721
760
|
/**
|
|
@@ -724,7 +763,7 @@ type Context$1<TOptions$1, TPluginOptions extends PluginFactoryOptions> = {
|
|
|
724
763
|
plugin: Plugin<TPluginOptions>;
|
|
725
764
|
mode: Mode;
|
|
726
765
|
include?: Array<'schemas' | 'responses' | 'requestBodies'>;
|
|
727
|
-
override: Array<Override<TOptions
|
|
766
|
+
override: Array<Override<TOptions>> | undefined;
|
|
728
767
|
contentType?: contentType;
|
|
729
768
|
output?: string;
|
|
730
769
|
};
|
|
@@ -756,7 +795,7 @@ type SchemaProps$1 = {
|
|
|
756
795
|
name?: string;
|
|
757
796
|
parentName?: string;
|
|
758
797
|
};
|
|
759
|
-
declare class SchemaGenerator<TOptions
|
|
798
|
+
declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions, Context$1<TOptions, TPluginOptions>> {
|
|
760
799
|
#private;
|
|
761
800
|
refs: Refs;
|
|
762
801
|
/**
|
|
@@ -774,56 +813,89 @@ declare class SchemaGenerator<TOptions$1 extends SchemaGeneratorOptions = Schema
|
|
|
774
813
|
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<File<TFileMeta>>>;
|
|
775
814
|
}
|
|
776
815
|
//#endregion
|
|
777
|
-
//#region src/
|
|
778
|
-
type
|
|
779
|
-
|
|
780
|
-
|
|
816
|
+
//#region src/generators/utils.d.ts
|
|
817
|
+
type BuildOperationsOptions<TOptions extends PluginFactoryOptions> = {
|
|
818
|
+
fabric: Fabric;
|
|
819
|
+
generator: ReactGenerator<any>;
|
|
820
|
+
/**
|
|
821
|
+
* @deprecated
|
|
822
|
+
*/
|
|
823
|
+
instance: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
824
|
+
options: TOptions['resolvedOptions'];
|
|
825
|
+
};
|
|
826
|
+
declare function buildOperations<TOptions extends PluginFactoryOptions>(operations: Array<Operation$1>, {
|
|
827
|
+
fabric,
|
|
828
|
+
options,
|
|
829
|
+
instance,
|
|
830
|
+
generator
|
|
831
|
+
}: BuildOperationsOptions<TOptions>): Promise<void>;
|
|
832
|
+
type BuildOperationOptions<TOptions extends PluginFactoryOptions> = BuildOperationsOptions<TOptions>;
|
|
833
|
+
declare function buildOperation<TOptions extends PluginFactoryOptions>(operation: Operation$1, {
|
|
834
|
+
fabric,
|
|
835
|
+
options,
|
|
836
|
+
instance,
|
|
837
|
+
generator
|
|
838
|
+
}: BuildOperationOptions<TOptions>): Promise<void>;
|
|
839
|
+
type BuildSchemaOptions<TOptions extends PluginFactoryOptions> = {
|
|
840
|
+
fabric: Fabric;
|
|
841
|
+
generator: ReactGenerator<any>;
|
|
842
|
+
/**
|
|
843
|
+
* @deprecated
|
|
844
|
+
*/
|
|
845
|
+
instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>;
|
|
846
|
+
options: TOptions['resolvedOptions'];
|
|
847
|
+
};
|
|
848
|
+
declare function buildSchema<TOptions extends PluginFactoryOptions>(schema: {
|
|
849
|
+
name: string;
|
|
850
|
+
tree: Array<Schema>;
|
|
851
|
+
value: SchemaObject$1;
|
|
852
|
+
}, {
|
|
853
|
+
fabric,
|
|
854
|
+
options,
|
|
855
|
+
instance,
|
|
856
|
+
generator
|
|
857
|
+
}: BuildSchemaOptions<TOptions>): Promise<void>;
|
|
858
|
+
//#endregion
|
|
859
|
+
//#region src/plugin.d.ts
|
|
860
|
+
declare const pluginOasName = "plugin-oas";
|
|
861
|
+
declare const pluginOas: (options?: Options$1 | undefined) => UserPluginWithLifeCycle<PluginOas>;
|
|
862
|
+
//#endregion
|
|
863
|
+
//#region src/generators/types.d.ts
|
|
864
|
+
type OperationsProps<TOptions extends PluginFactoryOptions> = {
|
|
865
|
+
/**
|
|
866
|
+
* @deprecated
|
|
867
|
+
*/
|
|
868
|
+
instance: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
869
|
+
options: TOptions['resolvedOptions'];
|
|
781
870
|
operations: Array<Operation$1>;
|
|
782
871
|
};
|
|
783
|
-
type OperationProps<TOptions
|
|
784
|
-
|
|
785
|
-
|
|
872
|
+
type OperationProps<TOptions extends PluginFactoryOptions> = {
|
|
873
|
+
/**
|
|
874
|
+
* @deprecated
|
|
875
|
+
*/
|
|
876
|
+
instance: Omit<OperationGenerator<TOptions>, 'build'>;
|
|
877
|
+
options: TOptions['resolvedOptions'];
|
|
786
878
|
operation: Operation$1;
|
|
787
879
|
};
|
|
788
|
-
type SchemaProps<TOptions
|
|
789
|
-
instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions
|
|
790
|
-
options: TOptions
|
|
880
|
+
type SchemaProps<TOptions extends PluginFactoryOptions> = {
|
|
881
|
+
instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>;
|
|
882
|
+
options: TOptions['resolvedOptions'];
|
|
791
883
|
schema: {
|
|
792
884
|
name: string;
|
|
793
885
|
tree: Array<Schema>;
|
|
794
886
|
value: SchemaObject$1;
|
|
795
887
|
};
|
|
796
888
|
};
|
|
797
|
-
type
|
|
798
|
-
name: string;
|
|
799
|
-
operations?: (this: GeneratorOptions<TOptions$1>, props: OperationsProps<TOptions$1>) => Promise<File[]>;
|
|
800
|
-
operation?: (this: GeneratorOptions<TOptions$1>, props: OperationProps<TOptions$1>) => Promise<File[]>;
|
|
801
|
-
schema?: (this: GeneratorOptions<TOptions$1>, props: SchemaProps<TOptions$1>) => Promise<File[]>;
|
|
802
|
-
};
|
|
803
|
-
type Generator<TOptions$1 extends PluginFactoryOptions> = GeneratorOptions<TOptions$1>;
|
|
804
|
-
declare function createGenerator<TOptions$1 extends PluginFactoryOptions>(parseOptions: GeneratorOptions<TOptions$1>): Generator<TOptions$1>;
|
|
805
|
-
type ReactGeneratorOptions<TOptions$1 extends PluginFactoryOptions> = {
|
|
806
|
-
name: string;
|
|
807
|
-
Operations?: (this: ReactGeneratorOptions<TOptions$1>, props: OperationsProps<TOptions$1>) => types_d_exports$1.KubbNode;
|
|
808
|
-
Operation?: (this: ReactGeneratorOptions<TOptions$1>, props: OperationProps<TOptions$1>) => types_d_exports$1.KubbNode;
|
|
809
|
-
Schema?: (this: ReactGeneratorOptions<TOptions$1>, props: SchemaProps<TOptions$1>) => types_d_exports$1.KubbNode;
|
|
810
|
-
};
|
|
811
|
-
/****
|
|
812
|
-
* Creates a generator that uses React component functions to generate files for OpenAPI operations and schemas.
|
|
813
|
-
*
|
|
814
|
-
* The returned generator exposes async methods for generating files from operations, a single operation, or a schema, using the corresponding React components if provided. If a component is not defined, the method returns an empty array.
|
|
815
|
-
*
|
|
816
|
-
* @returns A generator object with async methods for operations, operation, and schema file generation.
|
|
817
|
-
*/
|
|
818
|
-
declare function createReactGenerator<TOptions$1 extends PluginFactoryOptions>(parseOptions: ReactGeneratorOptions<TOptions$1>): Generator<TOptions$1>;
|
|
889
|
+
type Generator<TOptions extends PluginFactoryOptions> = CoreGenerator<TOptions> | ReactGenerator<TOptions>;
|
|
819
890
|
//#endregion
|
|
820
891
|
//#region src/OperationGenerator.d.ts
|
|
821
892
|
type OperationMethodResult<TFileMeta extends FileMetaBase> = Promise<File<TFileMeta> | Array<File<TFileMeta>> | null>;
|
|
822
|
-
type Context<TOptions
|
|
893
|
+
type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
894
|
+
fabric: Fabric;
|
|
823
895
|
oas: Oas;
|
|
824
896
|
exclude: Array<Exclude$1> | undefined;
|
|
825
897
|
include: Array<Include> | undefined;
|
|
826
|
-
override: Array<Override<TOptions
|
|
898
|
+
override: Array<Override<TOptions>> | undefined;
|
|
827
899
|
contentType: contentType | undefined;
|
|
828
900
|
pluginManager: PluginManager;
|
|
829
901
|
/**
|
|
@@ -847,5 +919,5 @@ declare class OperationGenerator<TPluginOptions extends PluginFactoryOptions = P
|
|
|
847
919
|
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<File<TFileMeta>>>;
|
|
848
920
|
}
|
|
849
921
|
//#endregion
|
|
850
|
-
export {
|
|
851
|
-
//# sourceMappingURL=OperationGenerator-
|
|
922
|
+
export { Config as A, SchemaObject$1 as B, Ref as C, createReactGenerator as D, Resolver as E, HttpMethod as F, OasTypes as I, OpenAPIV3$1 as L, Plugin as M, ResolveNameParams as N, createGenerator as O, Oas as P, OpenAPIV3_1 as R, PluginOas as S, ResolvePathOptions as T, contentType as V, Include as _, pluginOasName as a, Options$1 as b, buildSchema as c, SchemaGeneratorBuildOptions as d, SchemaGeneratorOptions as f, Exclude$1 as g, API as h, pluginOas as i, Output as j, FileMetaBase as k, GetSchemaGeneratorOptions as l, jsonGenerator as m, OperationMethodResult as n, buildOperation as o, SchemaMethodResult as p, Generator as r, buildOperations as s, OperationGenerator as t, SchemaGenerator as u, OperationSchema as v, Refs as w, Override as x, OperationSchemas as y, Operation$1 as z };
|
|
923
|
+
//# sourceMappingURL=OperationGenerator-CJTAer7l.d.cts.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as Schema } from "./SchemaMapper-
|
|
1
|
+
import { B as SchemaObject } from "./OperationGenerator-BZPWkxw4.js";
|
|
2
|
+
import { t as Schema } from "./SchemaMapper-CqBW0VOy.js";
|
|
3
|
+
import { Key, KubbNode } from "@kubb/react-fabric/types";
|
|
3
4
|
|
|
4
5
|
//#region src/components/Schema.d.ts
|
|
5
6
|
type SchemaContextProps = {
|
|
@@ -8,11 +9,11 @@ type SchemaContextProps = {
|
|
|
8
9
|
tree: Array<Schema>;
|
|
9
10
|
};
|
|
10
11
|
type Props = {
|
|
11
|
-
key?:
|
|
12
|
+
key?: Key;
|
|
12
13
|
name: string;
|
|
13
14
|
schemaObject?: SchemaObject;
|
|
14
15
|
tree?: Array<Schema>;
|
|
15
|
-
children?:
|
|
16
|
+
children?: KubbNode;
|
|
16
17
|
};
|
|
17
18
|
/**
|
|
18
19
|
* Provides schema-related context to descendant components.
|
|
@@ -28,10 +29,10 @@ declare function Schema$1({
|
|
|
28
29
|
schemaObject,
|
|
29
30
|
tree,
|
|
30
31
|
children
|
|
31
|
-
}: Props):
|
|
32
|
+
}: Props): KubbNode;
|
|
32
33
|
declare namespace Schema$1 {
|
|
33
34
|
var Context;
|
|
34
35
|
}
|
|
35
36
|
//#endregion
|
|
36
37
|
export { SchemaContextProps as n, Schema$1 as t };
|
|
37
|
-
//# sourceMappingURL=Schema-
|
|
38
|
+
//# sourceMappingURL=Schema-CjraJhJi.d.ts.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { B as SchemaObject } from "./OperationGenerator-CJTAer7l.cjs";
|
|
2
2
|
import { t as Schema } from "./SchemaMapper-MiRB5_Zp.cjs";
|
|
3
|
+
import { Key, KubbNode } from "@kubb/react-fabric/types";
|
|
3
4
|
|
|
4
5
|
//#region src/components/Schema.d.ts
|
|
5
6
|
type SchemaContextProps = {
|
|
@@ -8,11 +9,11 @@ type SchemaContextProps = {
|
|
|
8
9
|
tree: Array<Schema>;
|
|
9
10
|
};
|
|
10
11
|
type Props = {
|
|
11
|
-
key?:
|
|
12
|
+
key?: Key;
|
|
12
13
|
name: string;
|
|
13
14
|
schemaObject?: SchemaObject;
|
|
14
15
|
tree?: Array<Schema>;
|
|
15
|
-
children?:
|
|
16
|
+
children?: KubbNode;
|
|
16
17
|
};
|
|
17
18
|
/**
|
|
18
19
|
* Provides schema-related context to descendant components.
|
|
@@ -28,10 +29,10 @@ declare function Schema$1({
|
|
|
28
29
|
schemaObject,
|
|
29
30
|
tree,
|
|
30
31
|
children
|
|
31
|
-
}: Props):
|
|
32
|
+
}: Props): KubbNode;
|
|
32
33
|
declare namespace Schema$1 {
|
|
33
34
|
var Context;
|
|
34
35
|
}
|
|
35
36
|
//#endregion
|
|
36
37
|
export { SchemaContextProps as n, Schema$1 as t };
|
|
37
|
-
//# sourceMappingURL=Schema-
|
|
38
|
+
//# sourceMappingURL=Schema-zcZF0UIp.d.cts.map
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as
|
|
3
|
-
import {
|
|
1
|
+
import { r as buildSchema } from "./utils-BnkB1ikY.js";
|
|
2
|
+
import { n as schemaKeywords, t as isKeyword } from "./SchemaMapper-Cx4X1al6.js";
|
|
3
|
+
import { n as getSchemaFactory, t as getSchemas } from "./getSchemas-Bdg6n9Qk.js";
|
|
4
4
|
import transformers, { pascalCase } from "@kubb/core/transformers";
|
|
5
5
|
import { isDeepEqual, isNumber, uniqueWith } from "remeda";
|
|
6
|
+
import { BaseGenerator } from "@kubb/core";
|
|
6
7
|
import { getUniqueName } from "@kubb/core/utils";
|
|
7
8
|
import { isDiscriminator, isNullable, isReference } from "@kubb/oas";
|
|
8
9
|
|
|
@@ -908,6 +909,22 @@ var SchemaGenerator = class SchemaGenerator extends BaseGenerator {
|
|
|
908
909
|
name,
|
|
909
910
|
schemaObject
|
|
910
911
|
});
|
|
912
|
+
if (generator.type === "react") {
|
|
913
|
+
await buildSchema({
|
|
914
|
+
name,
|
|
915
|
+
value: schemaObject,
|
|
916
|
+
tree
|
|
917
|
+
}, {
|
|
918
|
+
fabric: this.context.fabric,
|
|
919
|
+
generator,
|
|
920
|
+
instance: this,
|
|
921
|
+
options: {
|
|
922
|
+
...this.options,
|
|
923
|
+
...options
|
|
924
|
+
}
|
|
925
|
+
});
|
|
926
|
+
return [];
|
|
927
|
+
}
|
|
911
928
|
return await generator.schema?.({
|
|
912
929
|
instance: this,
|
|
913
930
|
schema: {
|
|
@@ -929,4 +946,4 @@ var SchemaGenerator = class SchemaGenerator extends BaseGenerator {
|
|
|
929
946
|
|
|
930
947
|
//#endregion
|
|
931
948
|
export { pLimit as n, SchemaGenerator as t };
|
|
932
|
-
//# sourceMappingURL=SchemaGenerator-
|
|
949
|
+
//# sourceMappingURL=SchemaGenerator-7wBwdv8G.js.map
|