@kubb/plugin-oas 3.0.0-alpha.15 → 3.0.0-alpha.17
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/{OperationGenerator-BqfyX5-8.d.cts → OperationGenerator-B5CoXmjA.d.cts} +22 -20
- package/dist/{OperationGenerator-BqfyX5-8.d.ts → OperationGenerator-B5CoXmjA.d.ts} +22 -20
- package/dist/{Schema-BgpIlA79.d.cts → Schema-BsgDay0E.d.cts} +1 -12
- package/dist/{Schema-ExMIJOhD.d.ts → Schema-Dvt6i_X3.d.ts} +1 -12
- package/dist/{chunk-PZTS5YZV.js → chunk-AWRVBD2X.js} +15 -13
- package/dist/chunk-AWRVBD2X.js.map +1 -0
- package/dist/chunk-BEKIIF6H.cjs +1110 -0
- package/dist/chunk-BEKIIF6H.cjs.map +1 -0
- package/dist/chunk-CQMUJN22.cjs +42 -0
- package/dist/chunk-CQMUJN22.cjs.map +1 -0
- package/dist/chunk-FGOPORE3.js +38 -0
- package/dist/chunk-FGOPORE3.js.map +1 -0
- package/dist/{chunk-AAIEMW6V.cjs → chunk-FZABPEYO.cjs} +28 -798
- package/dist/chunk-FZABPEYO.cjs.map +1 -0
- package/dist/{chunk-M3V3WMCW.js → chunk-I6N3YPCE.js} +11 -773
- package/dist/chunk-I6N3YPCE.js.map +1 -0
- package/dist/chunk-IVSE3A7W.cjs +84 -0
- package/dist/chunk-IVSE3A7W.cjs.map +1 -0
- package/dist/chunk-VLHK3XAR.js +1098 -0
- package/dist/chunk-VLHK3XAR.js.map +1 -0
- package/dist/chunk-XIFGKAM3.js +76 -0
- package/dist/chunk-XIFGKAM3.js.map +1 -0
- package/dist/{chunk-I3ZL3GUQ.cjs → chunk-XON3FUPP.cjs} +19 -17
- package/dist/chunk-XON3FUPP.cjs.map +1 -0
- package/dist/components.cjs +5 -6
- package/dist/components.d.cts +2 -2
- package/dist/components.d.ts +2 -2
- package/dist/components.js +2 -3
- package/dist/generators.cjs +4 -5
- package/dist/generators.d.cts +1 -1
- package/dist/generators.d.ts +1 -1
- package/dist/generators.js +3 -4
- package/dist/hooks.cjs +102 -31
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.cts +39 -6
- package/dist/hooks.d.ts +39 -6
- package/dist/hooks.js +92 -20
- package/dist/hooks.js.map +1 -1
- package/dist/index.cjs +25 -410
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +5 -400
- package/dist/index.js.map +1 -1
- package/dist/utils.cjs +12 -12
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +2 -2
- package/dist/utils.d.ts +2 -2
- package/dist/utils.js +2 -3
- package/dist/utils.js.map +1 -1
- package/package.json +10 -10
- package/src/OperationGenerator.ts +11 -15
- package/src/SchemaGenerator.ts +15 -6
- package/src/components/Schema.tsx +1 -98
- package/src/generator.tsx +22 -14
- package/src/generators/jsonGenerator.ts +4 -4
- package/src/hooks/index.ts +2 -0
- package/src/hooks/useOperationManager.ts +76 -29
- package/src/hooks/useSchemaManager.ts +76 -0
- package/src/utils/getParams.ts +1 -1
- package/dist/chunk-2PMRS7PB.cjs +0 -8
- package/dist/chunk-2PMRS7PB.cjs.map +0 -1
- package/dist/chunk-2V64GHQ4.js +0 -32
- package/dist/chunk-2V64GHQ4.js.map +0 -1
- package/dist/chunk-4JIFKRM5.js +0 -6
- package/dist/chunk-4JIFKRM5.js.map +0 -1
- package/dist/chunk-5ULY3TQB.cjs +0 -90
- package/dist/chunk-5ULY3TQB.cjs.map +0 -1
- package/dist/chunk-AAIEMW6V.cjs.map +0 -1
- package/dist/chunk-CFU6KMOB.cjs +0 -38
- package/dist/chunk-CFU6KMOB.cjs.map +0 -1
- package/dist/chunk-GAPWY2CE.js +0 -84
- package/dist/chunk-GAPWY2CE.js.map +0 -1
- package/dist/chunk-I3ZL3GUQ.cjs.map +0 -1
- package/dist/chunk-M3V3WMCW.js.map +0 -1
- package/dist/chunk-PZTS5YZV.js.map +0 -1
|
@@ -450,7 +450,7 @@ declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGe
|
|
|
450
450
|
static deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T][];
|
|
451
451
|
static findInObject<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
452
452
|
static find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
453
|
-
build(...generators: Array<Generator<
|
|
453
|
+
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
454
454
|
/**
|
|
455
455
|
* Schema
|
|
456
456
|
*/
|
|
@@ -470,23 +470,26 @@ type OperationProps<TOptions extends PluginFactoryOptions> = {
|
|
|
470
470
|
};
|
|
471
471
|
type SchemaProps<TOptions extends PluginFactoryOptions> = {
|
|
472
472
|
instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>;
|
|
473
|
-
|
|
474
|
-
|
|
473
|
+
schema: {
|
|
474
|
+
name: string;
|
|
475
|
+
tree: Array<Schema>;
|
|
476
|
+
value: SchemaObject;
|
|
477
|
+
};
|
|
475
478
|
options: TOptions['resolvedOptions'];
|
|
476
479
|
};
|
|
477
480
|
type GeneratorOptions<TOptions extends PluginFactoryOptions> = {
|
|
478
481
|
name: string;
|
|
479
|
-
operations?: (props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
480
|
-
operation?: (props: OperationProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
481
|
-
schema?: (props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
482
|
+
operations?: (this: GeneratorOptions<TOptions>, props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
483
|
+
operation?: (this: GeneratorOptions<TOptions>, props: OperationProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
484
|
+
schema?: (this: GeneratorOptions<TOptions>, props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
482
485
|
};
|
|
483
486
|
type Generator<TOptions extends PluginFactoryOptions> = GeneratorOptions<TOptions>;
|
|
484
487
|
declare function createGenerator<TOptions extends PluginFactoryOptions>(parseOptions: GeneratorOptions<TOptions>): Generator<TOptions>;
|
|
485
488
|
type ReactGeneratorOptions<TOptions extends PluginFactoryOptions> = {
|
|
486
489
|
name: string;
|
|
487
|
-
Operations?: (props: OperationsProps<TOptions>) => KubbNode;
|
|
488
|
-
Operation?: (props: OperationProps<TOptions>) => KubbNode;
|
|
489
|
-
Schema?: (props: SchemaProps<TOptions>) => KubbNode;
|
|
490
|
+
Operations?: (this: ReactGeneratorOptions<TOptions>, props: OperationsProps<TOptions>) => KubbNode;
|
|
491
|
+
Operation?: (this: ReactGeneratorOptions<TOptions>, props: OperationProps<TOptions>) => KubbNode;
|
|
492
|
+
Schema?: (this: ReactGeneratorOptions<TOptions>, props: SchemaProps<TOptions>) => KubbNode;
|
|
490
493
|
/**
|
|
491
494
|
* Combine all react nodes and only render ones(to string or render)
|
|
492
495
|
*/
|
|
@@ -497,7 +500,7 @@ declare function createReactGenerator<TOptions extends PluginFactoryOptions>(par
|
|
|
497
500
|
/**
|
|
498
501
|
* @deprecated
|
|
499
502
|
*/
|
|
500
|
-
type GetOperationGeneratorOptions<T
|
|
503
|
+
type GetOperationGeneratorOptions<T = any> = any;
|
|
501
504
|
type OperationMethodResult<TFileMeta extends FileMetaBase> = Promise<KubbFile.File<TFileMeta> | Array<KubbFile.File<TFileMeta>> | null>;
|
|
502
505
|
type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
503
506
|
oas: Oas;
|
|
@@ -512,39 +515,38 @@ type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
|
512
515
|
plugin: Plugin<TPluginOptions>;
|
|
513
516
|
mode: KubbFile.Mode;
|
|
514
517
|
};
|
|
515
|
-
declare class OperationGenerator<
|
|
518
|
+
declare class OperationGenerator<TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TPluginOptions['resolvedOptions'], Context<TPluginOptions['resolvedOptions'], TPluginOptions>> {
|
|
516
519
|
#private;
|
|
517
520
|
get operationsByMethod(): OperationsByMethod;
|
|
518
521
|
set operationsByMethod(paths: OperationsByMethod);
|
|
519
|
-
getSchemas(operation: Operation, {
|
|
520
|
-
forStatusCode?: string | number;
|
|
522
|
+
getSchemas(operation: Operation, { resolveName, }?: {
|
|
521
523
|
resolveName?: (name: string) => string;
|
|
522
524
|
}): OperationSchemas;
|
|
523
|
-
build(...generators: Array<Generator<
|
|
525
|
+
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
524
526
|
/**
|
|
525
527
|
* Operation
|
|
526
528
|
*/
|
|
527
|
-
operation(operation: Operation, options:
|
|
529
|
+
operation(operation: Operation, options: TPluginOptions['resolvedOptions']): OperationMethodResult<TFileMeta>;
|
|
528
530
|
/**
|
|
529
531
|
* GET
|
|
530
532
|
*/
|
|
531
|
-
get(operation: Operation, options:
|
|
533
|
+
get(operation: Operation, options: TPluginOptions['resolvedOptions']): OperationMethodResult<TFileMeta>;
|
|
532
534
|
/**
|
|
533
535
|
* POST
|
|
534
536
|
*/
|
|
535
|
-
post(operation: Operation, options:
|
|
537
|
+
post(operation: Operation, options: TPluginOptions['resolvedOptions']): OperationMethodResult<TFileMeta>;
|
|
536
538
|
/**
|
|
537
539
|
* PATCH
|
|
538
540
|
*/
|
|
539
|
-
patch(operation: Operation, options:
|
|
541
|
+
patch(operation: Operation, options: TPluginOptions['resolvedOptions']): OperationMethodResult<TFileMeta>;
|
|
540
542
|
/**
|
|
541
543
|
* PUT
|
|
542
544
|
*/
|
|
543
|
-
put(operation: Operation, options:
|
|
545
|
+
put(operation: Operation, options: TPluginOptions['resolvedOptions']): OperationMethodResult<TFileMeta>;
|
|
544
546
|
/**
|
|
545
547
|
* DELETE
|
|
546
548
|
*/
|
|
547
|
-
delete(operation: Operation, options:
|
|
549
|
+
delete(operation: Operation, options: TPluginOptions['resolvedOptions']): OperationMethodResult<TFileMeta>;
|
|
548
550
|
/**
|
|
549
551
|
* Combination of GET, POST, PATCH, PUT, DELETE
|
|
550
552
|
*/
|
|
@@ -450,7 +450,7 @@ declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGe
|
|
|
450
450
|
static deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T][];
|
|
451
451
|
static findInObject<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
452
452
|
static find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
453
|
-
build(...generators: Array<Generator<
|
|
453
|
+
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
454
454
|
/**
|
|
455
455
|
* Schema
|
|
456
456
|
*/
|
|
@@ -470,23 +470,26 @@ type OperationProps<TOptions extends PluginFactoryOptions> = {
|
|
|
470
470
|
};
|
|
471
471
|
type SchemaProps<TOptions extends PluginFactoryOptions> = {
|
|
472
472
|
instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>;
|
|
473
|
-
|
|
474
|
-
|
|
473
|
+
schema: {
|
|
474
|
+
name: string;
|
|
475
|
+
tree: Array<Schema>;
|
|
476
|
+
value: SchemaObject;
|
|
477
|
+
};
|
|
475
478
|
options: TOptions['resolvedOptions'];
|
|
476
479
|
};
|
|
477
480
|
type GeneratorOptions<TOptions extends PluginFactoryOptions> = {
|
|
478
481
|
name: string;
|
|
479
|
-
operations?: (props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
480
|
-
operation?: (props: OperationProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
481
|
-
schema?: (props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
482
|
+
operations?: (this: GeneratorOptions<TOptions>, props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
483
|
+
operation?: (this: GeneratorOptions<TOptions>, props: OperationProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
484
|
+
schema?: (this: GeneratorOptions<TOptions>, props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>;
|
|
482
485
|
};
|
|
483
486
|
type Generator<TOptions extends PluginFactoryOptions> = GeneratorOptions<TOptions>;
|
|
484
487
|
declare function createGenerator<TOptions extends PluginFactoryOptions>(parseOptions: GeneratorOptions<TOptions>): Generator<TOptions>;
|
|
485
488
|
type ReactGeneratorOptions<TOptions extends PluginFactoryOptions> = {
|
|
486
489
|
name: string;
|
|
487
|
-
Operations?: (props: OperationsProps<TOptions>) => KubbNode;
|
|
488
|
-
Operation?: (props: OperationProps<TOptions>) => KubbNode;
|
|
489
|
-
Schema?: (props: SchemaProps<TOptions>) => KubbNode;
|
|
490
|
+
Operations?: (this: ReactGeneratorOptions<TOptions>, props: OperationsProps<TOptions>) => KubbNode;
|
|
491
|
+
Operation?: (this: ReactGeneratorOptions<TOptions>, props: OperationProps<TOptions>) => KubbNode;
|
|
492
|
+
Schema?: (this: ReactGeneratorOptions<TOptions>, props: SchemaProps<TOptions>) => KubbNode;
|
|
490
493
|
/**
|
|
491
494
|
* Combine all react nodes and only render ones(to string or render)
|
|
492
495
|
*/
|
|
@@ -497,7 +500,7 @@ declare function createReactGenerator<TOptions extends PluginFactoryOptions>(par
|
|
|
497
500
|
/**
|
|
498
501
|
* @deprecated
|
|
499
502
|
*/
|
|
500
|
-
type GetOperationGeneratorOptions<T
|
|
503
|
+
type GetOperationGeneratorOptions<T = any> = any;
|
|
501
504
|
type OperationMethodResult<TFileMeta extends FileMetaBase> = Promise<KubbFile.File<TFileMeta> | Array<KubbFile.File<TFileMeta>> | null>;
|
|
502
505
|
type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
503
506
|
oas: Oas;
|
|
@@ -512,39 +515,38 @@ type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
|
512
515
|
plugin: Plugin<TPluginOptions>;
|
|
513
516
|
mode: KubbFile.Mode;
|
|
514
517
|
};
|
|
515
|
-
declare class OperationGenerator<
|
|
518
|
+
declare class OperationGenerator<TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TPluginOptions['resolvedOptions'], Context<TPluginOptions['resolvedOptions'], TPluginOptions>> {
|
|
516
519
|
#private;
|
|
517
520
|
get operationsByMethod(): OperationsByMethod;
|
|
518
521
|
set operationsByMethod(paths: OperationsByMethod);
|
|
519
|
-
getSchemas(operation: Operation, {
|
|
520
|
-
forStatusCode?: string | number;
|
|
522
|
+
getSchemas(operation: Operation, { resolveName, }?: {
|
|
521
523
|
resolveName?: (name: string) => string;
|
|
522
524
|
}): OperationSchemas;
|
|
523
|
-
build(...generators: Array<Generator<
|
|
525
|
+
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
524
526
|
/**
|
|
525
527
|
* Operation
|
|
526
528
|
*/
|
|
527
|
-
operation(operation: Operation, options:
|
|
529
|
+
operation(operation: Operation, options: TPluginOptions['resolvedOptions']): OperationMethodResult<TFileMeta>;
|
|
528
530
|
/**
|
|
529
531
|
* GET
|
|
530
532
|
*/
|
|
531
|
-
get(operation: Operation, options:
|
|
533
|
+
get(operation: Operation, options: TPluginOptions['resolvedOptions']): OperationMethodResult<TFileMeta>;
|
|
532
534
|
/**
|
|
533
535
|
* POST
|
|
534
536
|
*/
|
|
535
|
-
post(operation: Operation, options:
|
|
537
|
+
post(operation: Operation, options: TPluginOptions['resolvedOptions']): OperationMethodResult<TFileMeta>;
|
|
536
538
|
/**
|
|
537
539
|
* PATCH
|
|
538
540
|
*/
|
|
539
|
-
patch(operation: Operation, options:
|
|
541
|
+
patch(operation: Operation, options: TPluginOptions['resolvedOptions']): OperationMethodResult<TFileMeta>;
|
|
540
542
|
/**
|
|
541
543
|
* PUT
|
|
542
544
|
*/
|
|
543
|
-
put(operation: Operation, options:
|
|
545
|
+
put(operation: Operation, options: TPluginOptions['resolvedOptions']): OperationMethodResult<TFileMeta>;
|
|
544
546
|
/**
|
|
545
547
|
* DELETE
|
|
546
548
|
*/
|
|
547
|
-
delete(operation: Operation, options:
|
|
549
|
+
delete(operation: Operation, options: TPluginOptions['resolvedOptions']): OperationMethodResult<TFileMeta>;
|
|
548
550
|
/**
|
|
549
551
|
* Combination of GET, POST, PATCH, PUT, DELETE
|
|
550
552
|
*/
|
|
@@ -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 { g as Schema$1 } from './OperationGenerator-
|
|
4
|
+
import { g as Schema$1 } from './OperationGenerator-B5CoXmjA.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: ({ 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 { g as Schema$1 } from './OperationGenerator-
|
|
4
|
+
import { g as Schema$1 } from './OperationGenerator-B5CoXmjA.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: ({ 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,5 +1,5 @@
|
|
|
1
|
-
import { require_jsx_runtime, Oas } from './chunk-
|
|
2
|
-
import { init_esm_shims, __toESM } from './chunk-
|
|
1
|
+
import { require_jsx_runtime, Oas } from './chunk-I6N3YPCE.js';
|
|
2
|
+
import { init_esm_shims, __toESM } from './chunk-FGOPORE3.js';
|
|
3
3
|
import { camelCase } from '@kubb/core/transformers';
|
|
4
4
|
import { createRoot, App } from '@kubb/react';
|
|
5
5
|
|
|
@@ -26,8 +26,9 @@ function createReactGenerator(parseOptions) {
|
|
|
26
26
|
const root = createRoot({
|
|
27
27
|
logger: pluginManager.logger
|
|
28
28
|
});
|
|
29
|
+
const Component = parseOptions.Operations.bind(this);
|
|
29
30
|
root.render(
|
|
30
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, { pluginManager, plugin, mode, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Oas, { oas, operations, generator: instance, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
31
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, { pluginManager, plugin, mode, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Oas, { oas, operations, generator: instance, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, { operations, instance, operationsByMethod, options }) }) })
|
|
31
32
|
);
|
|
32
33
|
return root.files;
|
|
33
34
|
},
|
|
@@ -39,12 +40,13 @@ function createReactGenerator(parseOptions) {
|
|
|
39
40
|
const root = createRoot({
|
|
40
41
|
logger: pluginManager.logger
|
|
41
42
|
});
|
|
43
|
+
const Component = parseOptions.Operation.bind(this);
|
|
42
44
|
root.render(
|
|
43
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, { pluginManager, plugin: { ...plugin, options }, mode, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Oas, { oas, operations: [operation], generator: instance, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Oas.Operation, { operation, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
45
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, { pluginManager, plugin: { ...plugin, options }, mode, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Oas, { oas, operations: [operation], generator: instance, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Oas.Operation, { operation, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, { operation, options, instance }) }) }) })
|
|
44
46
|
);
|
|
45
47
|
return root.files;
|
|
46
48
|
},
|
|
47
|
-
async schema({ instance, schema,
|
|
49
|
+
async schema({ instance, schema, options }) {
|
|
48
50
|
if (!parseOptions.Schema) {
|
|
49
51
|
return [];
|
|
50
52
|
}
|
|
@@ -52,9 +54,9 @@ function createReactGenerator(parseOptions) {
|
|
|
52
54
|
const root = createRoot({
|
|
53
55
|
logger: pluginManager.logger
|
|
54
56
|
});
|
|
55
|
-
const
|
|
57
|
+
const Component = parseOptions.Schema.bind(this);
|
|
56
58
|
root.render(
|
|
57
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, { pluginManager, plugin: { ...plugin, options }, mode, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Oas, { oas, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Oas.Schema, { name, value: schema, tree, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
59
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, { pluginManager, plugin: { ...plugin, options }, mode, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Oas, { oas, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Oas.Schema, { name: schema.name, value: schema.value, tree: schema.tree, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, { schema, options, instance }) }) }) })
|
|
58
60
|
);
|
|
59
61
|
return root.files;
|
|
60
62
|
}
|
|
@@ -64,10 +66,10 @@ function createReactGenerator(parseOptions) {
|
|
|
64
66
|
// src/generators/jsonGenerator.ts
|
|
65
67
|
var jsonGenerator = createGenerator({
|
|
66
68
|
name: "plugin-oas",
|
|
67
|
-
async schema({ schema,
|
|
69
|
+
async schema({ schema, instance }) {
|
|
68
70
|
const { pluginManager, plugin } = instance.context;
|
|
69
71
|
const file = pluginManager.getFile({
|
|
70
|
-
name: camelCase(name),
|
|
72
|
+
name: camelCase(schema.name),
|
|
71
73
|
extName: ".json",
|
|
72
74
|
mode: "split",
|
|
73
75
|
pluginKey: plugin.key
|
|
@@ -77,10 +79,10 @@ var jsonGenerator = createGenerator({
|
|
|
77
79
|
...file,
|
|
78
80
|
sources: [
|
|
79
81
|
{
|
|
80
|
-
name: camelCase(name),
|
|
82
|
+
name: camelCase(schema.name),
|
|
81
83
|
isExportable: false,
|
|
82
84
|
isIndexable: false,
|
|
83
|
-
value: JSON.stringify(schema)
|
|
85
|
+
value: JSON.stringify(schema.value)
|
|
84
86
|
}
|
|
85
87
|
]
|
|
86
88
|
}
|
|
@@ -89,5 +91,5 @@ var jsonGenerator = createGenerator({
|
|
|
89
91
|
});
|
|
90
92
|
|
|
91
93
|
export { createGenerator, createReactGenerator, jsonGenerator };
|
|
92
|
-
//# sourceMappingURL=chunk-
|
|
93
|
-
//# sourceMappingURL=chunk-
|
|
94
|
+
//# sourceMappingURL=chunk-AWRVBD2X.js.map
|
|
95
|
+
//# sourceMappingURL=chunk-AWRVBD2X.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/generators/index.ts","../src/generators/jsonGenerator.ts","../src/generator.tsx"],"names":[],"mappings":";;;;;;AAAA,cAAA,EAAA,CAAA;;;ACAA,cAAA,EAAA,CAAA;;;ACAA,cAAA,EAAA,CAAA;AA4EY,IAAA,kBAAA,GAAA,OAAA,CAAA,mBAAA,EAAA,EAAA,CAAA,CAAA,CAAA;AAjCL,SAAS,gBAAuD,YAA+D,EAAA;AACpI,EAAO,OAAA,YAAA,CAAA;AACT,CAAA;AAaO,SAAS,qBAA4D,YAAoE,EAAA;AAC9I,EAAO,OAAA;AAAA,IACL,GAAG,YAAA;AAAA,IACH,MAAM,UAAW,CAAA,EAAE,UAAU,OAAS,EAAA,UAAA,EAAY,oBAAsB,EAAA;AACtE,MAAI,IAAA,CAAC,aAAa,UAAY,EAAA;AAC5B,QAAA,OAAO,EAAC,CAAA;AAAA,OACV;AAEA,MAAA,MAAM,EAAE,aAAe,EAAA,GAAA,EAAK,MAAQ,EAAA,IAAA,KAAS,QAAS,CAAA,OAAA,CAAA;AACtD,MAAA,MAAM,OAAO,UAAW,CAAA;AAAA,QACtB,QAAQ,aAAc,CAAA,MAAA;AAAA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AAO,IAAK,CAAA,KAAA,CAAA;AAAA,KACd;AAAA,GACF,CAAA;AACF,CAAA;;;ADhIO,IAAM,gBAAgB,eAA2B,CAAA;AAAA,EACtD,IAAM,EAAA,YAAA;AAAA,EACN,MAAM,MAAA,CAAO,EAAE,MAAA,EAAQ,UAAY,EAAA;AACjC,IAAA,MAAM,EAAE,aAAA,EAAe,MAAO,EAAA,GAAI,QAAS,CAAA,OAAA,CAAA;AAC3C,IAAM,MAAA,IAAA,GAAO,cAAc,OAAQ,CAAA;AAAA,MACjC,IAAA,EAAM,SAAU,CAAA,MAAA,CAAO,IAAI,CAAA;AAAA,MAC3B,OAAS,EAAA,OAAA;AAAA,MACT,IAAM,EAAA,OAAA;AAAA,MACN,WAAW,MAAO,CAAA,GAAA;AAAA,KACnB,CAAA,CAAA;AAED,IAAO,OAAA;AAAA,MACL;AAAA,QACE,GAAG,IAAA;AAAA,QACH,OAAS,EAAA;AAAA,UACP;AAAA,YACE,IAAA,EAAM,SAAU,CAAA,MAAA,CAAO,IAAI,CAAA;AAAA,YAC3B,YAAc,EAAA,KAAA;AAAA,YACd,WAAa,EAAA,KAAA;AAAA,YACb,KAAO,EAAA,IAAA,CAAK,SAAU,CAAA,MAAA,CAAO,KAAK,CAAA;AAAA,WACpC;AAAA,SACF;AAAA,OACF;AAAA,KACF,CAAA;AAAA,GACF;AACF,CAAC","file":"chunk-AWRVBD2X.js","sourcesContent":["export { jsonGenerator } from './jsonGenerator.ts'\n","import { camelCase } from '@kubb/core/transformers'\nimport { createGenerator } from '../generator.tsx'\nimport type { PluginOas } from '../types.ts'\n\nexport const jsonGenerator = createGenerator<PluginOas>({\n name: 'plugin-oas',\n async schema({ schema, instance }) {\n const { pluginManager, plugin } = instance.context\n const file = pluginManager.getFile({\n name: camelCase(schema.name),\n extName: '.json',\n mode: 'split',\n pluginKey: plugin.key,\n })\n\n return [\n {\n ...file,\n sources: [\n {\n name: camelCase(schema.name),\n isExportable: false,\n isIndexable: false,\n value: JSON.stringify(schema.value),\n },\n ],\n },\n ]\n },\n})\n","import type { PluginFactoryOptions } from '@kubb/core'\nimport type * as KubbFile from '@kubb/fs/types'\nimport type { Operation, SchemaObject } from '@kubb/oas'\nimport { Oas } from '@kubb/plugin-oas/components'\nimport { App, createRoot } from '@kubb/react'\nimport type { KubbNode } from '@kubb/react/types'\nimport type { OperationGenerator } from './OperationGenerator.ts'\nimport type { SchemaGenerator, SchemaGeneratorOptions } from './SchemaGenerator.ts'\nimport type { Schema } from './SchemaMapper.ts'\nimport type { OperationsByMethod } from './types.ts'\n\ntype OperationsProps<TOptions extends PluginFactoryOptions> = {\n instance: Omit<OperationGenerator<TOptions>, 'build'>\n options: TOptions['resolvedOptions']\n operations: Array<Operation>\n operationsByMethod: OperationsByMethod\n}\n\ntype OperationProps<TOptions extends PluginFactoryOptions> = {\n instance: Omit<OperationGenerator<TOptions>, 'build'>\n options: TOptions['resolvedOptions']\n operation: Operation\n}\n\ntype SchemaProps<TOptions extends PluginFactoryOptions> = {\n instance: Omit<SchemaGenerator<SchemaGeneratorOptions, TOptions>, 'build'>\n schema: {\n name: string\n tree: Array<Schema>\n value: SchemaObject\n }\n options: TOptions['resolvedOptions']\n}\n\nexport type GeneratorOptions<TOptions extends PluginFactoryOptions> = {\n name: string\n operations?: (this: GeneratorOptions<TOptions>, props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>\n operation?: (this: GeneratorOptions<TOptions>, props: OperationProps<TOptions>) => Promise<KubbFile.File[]>\n schema?: (this: GeneratorOptions<TOptions>, props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>\n}\n\nexport type Generator<TOptions extends PluginFactoryOptions> = GeneratorOptions<TOptions>\n\nexport function createGenerator<TOptions extends PluginFactoryOptions>(parseOptions: GeneratorOptions<TOptions>): Generator<TOptions> {\n return parseOptions\n}\n\nexport type ReactGeneratorOptions<TOptions extends PluginFactoryOptions> = {\n name: string\n Operations?: (this: ReactGeneratorOptions<TOptions>, props: OperationsProps<TOptions>) => KubbNode\n Operation?: (this: ReactGeneratorOptions<TOptions>, props: OperationProps<TOptions>) => KubbNode\n Schema?: (this: ReactGeneratorOptions<TOptions>, props: SchemaProps<TOptions>) => KubbNode\n /**\n * Combine all react nodes and only render ones(to string or render)\n */\n render?: () => any\n}\n\nexport function createReactGenerator<TOptions extends PluginFactoryOptions>(parseOptions: ReactGeneratorOptions<TOptions>): Generator<TOptions> {\n return {\n ...parseOptions,\n async operations({ instance, options, operations, operationsByMethod }) {\n if (!parseOptions.Operations) {\n return []\n }\n\n const { pluginManager, oas, plugin, mode } = instance.context\n const root = createRoot({\n logger: pluginManager.logger,\n })\n\n const Component = parseOptions.Operations.bind(this)\n\n root.render(\n <App pluginManager={pluginManager} plugin={plugin} mode={mode}>\n <Oas oas={oas} operations={operations} generator={instance}>\n <Component operations={operations} instance={instance} operationsByMethod={operationsByMethod} options={options} />\n </Oas>\n </App>,\n )\n\n return root.files\n },\n async operation({ instance, operation, options }) {\n if (!parseOptions.Operation) {\n return []\n }\n\n const { pluginManager, oas, plugin, mode } = instance.context\n const root = createRoot({\n logger: pluginManager.logger,\n })\n\n const Component = parseOptions.Operation.bind(this)\n\n root.render(\n <App pluginManager={pluginManager} plugin={{ ...plugin, options }} mode={mode}>\n <Oas oas={oas} operations={[operation]} generator={instance}>\n <Oas.Operation operation={operation}>\n <Component operation={operation} options={options} instance={instance} />\n </Oas.Operation>\n </Oas>\n </App>,\n )\n\n return root.files\n },\n async schema({ instance, schema, options }) {\n if (!parseOptions.Schema) {\n return []\n }\n\n const { pluginManager, oas, plugin, mode } = instance.context\n const root = createRoot({\n logger: pluginManager.logger,\n })\n\n const Component = parseOptions.Schema.bind(this)\n\n root.render(\n <App pluginManager={pluginManager} plugin={{ ...plugin, options }} mode={mode}>\n <Oas oas={oas}>\n <Oas.Schema name={schema.name} value={schema.value} tree={schema.tree}>\n <Component schema={schema} options={options} instance={instance} />\n </Oas.Schema>\n </Oas>\n </App>,\n )\n\n return root.files\n },\n }\n}\n"]}
|