@kubb/plugin-oas 3.0.0-alpha.7 → 3.0.0-alpha.9

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.
@@ -1,8 +1,8 @@
1
- import { FileMetaBase, ResolveNameParams, PluginFactoryOptions, Generator, PluginManager, Plugin } from '@kubb/core';
1
+ import { FileMetaBase, ResolveNameParams, PluginFactoryOptions, BaseGenerator, PluginManager, Plugin } from '@kubb/core';
2
2
  import * as KubbFile from '@kubb/fs/types';
3
3
  import { SchemaObject, Oas, contentType, Operation } from '@kubb/oas';
4
- import { d as OperationSchema, b as Refs, g as Override, f as OperationsByMethod, e as OperationSchemas, E as Exclude, I as Include } from './types-CZTUCaE5.js';
5
4
  import { KubbNode } from '@kubb/react/types';
5
+ import { d as OperationSchema, b as Refs, g as Override, f as OperationsByMethod, e as OperationSchemas, E as Exclude, I as Include } from './types-CZTUCaE5.js';
6
6
  import { S as Schema, c as SchemaKeywordMapper } from './SchemaMapper-sGcY1xL5.js';
7
7
 
8
8
  type GetSchemaGeneratorOptions<T extends SchemaGenerator<any, any, any>> = T extends SchemaGenerator<infer Options, any, any> ? Options : never;
@@ -47,7 +47,7 @@ type SchemaProps$1 = {
47
47
  name?: string;
48
48
  parentName?: string;
49
49
  };
50
- declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends Generator<TOptions, Context$1<TOptions, TPluginOptions>> {
50
+ declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions, Context$1<TOptions, TPluginOptions>> {
51
51
  #private;
52
52
  refs: Refs;
53
53
  /**
@@ -61,7 +61,7 @@ declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGe
61
61
  static deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T][];
62
62
  static findInObject<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
63
63
  static find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
64
- build(...parsers: Array<Parser<Extract<TOptions, PluginFactoryOptions>>>): Promise<Array<KubbFile.File<TFileMeta>>>;
64
+ build(...generators: Array<Generator<Extract<TOptions, PluginFactoryOptions>>>): Promise<Array<KubbFile.File<TFileMeta>>>;
65
65
  /**
66
66
  * Schema
67
67
  */
@@ -85,22 +85,29 @@ type SchemaProps<TOptions extends PluginFactoryOptions> = {
85
85
  schema: SchemaObject;
86
86
  options: TOptions['resolvedOptions'];
87
87
  };
88
- type ParserOptions<TOptions extends PluginFactoryOptions> = {
88
+ type GeneratorOptions<TOptions extends PluginFactoryOptions> = {
89
89
  name: string;
90
90
  operations?: (props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>;
91
91
  operation?: (props: OperationProps<TOptions>) => Promise<KubbFile.File[]>;
92
92
  schema?: (props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>;
93
93
  };
94
- type Parser<TOptions extends PluginFactoryOptions> = ParserOptions<TOptions>;
95
- declare function createParser<TOptions extends PluginFactoryOptions>(parseOptions: ParserOptions<TOptions>): Parser<TOptions>;
96
- type ParserReactOptions<TOptions extends PluginFactoryOptions> = {
94
+ type Generator<TOptions extends PluginFactoryOptions> = GeneratorOptions<TOptions>;
95
+ declare function createGenerator<TOptions extends PluginFactoryOptions>(parseOptions: GeneratorOptions<TOptions>): Generator<TOptions>;
96
+ type ReactGeneratorOptions<TOptions extends PluginFactoryOptions> = {
97
97
  name: string;
98
98
  Operations?: (props: OperationsProps<TOptions>) => KubbNode;
99
99
  Operation?: (props: OperationProps<TOptions>) => KubbNode;
100
100
  Schema?: (props: SchemaProps<TOptions>) => KubbNode;
101
+ /**
102
+ * Combine all react nodes and only render ones(to string or render)
103
+ */
104
+ render?: () => any;
101
105
  };
102
- declare function createReactParser<TOptions extends PluginFactoryOptions>(parseOptions: ParserReactOptions<TOptions>): Parser<TOptions>;
106
+ declare function createReactGenerator<TOptions extends PluginFactoryOptions>(parseOptions: ReactGeneratorOptions<TOptions>): Generator<TOptions>;
103
107
 
108
+ /**
109
+ * @deprecated
110
+ */
104
111
  type GetOperationGeneratorOptions<T extends OperationGenerator<any, any, any>> = T extends OperationGenerator<infer Options, any, any> ? Options : never;
105
112
  type OperationMethodResult<TFileMeta extends FileMetaBase> = Promise<KubbFile.File<TFileMeta> | Array<KubbFile.File<TFileMeta>> | null>;
106
113
  type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
@@ -116,7 +123,7 @@ type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
116
123
  plugin: Plugin<TPluginOptions>;
117
124
  mode: KubbFile.Mode;
118
125
  };
119
- declare class OperationGenerator<TOptions = unknown, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends Generator<TOptions, Context<TOptions, TPluginOptions>> {
126
+ declare class OperationGenerator<TOptions = unknown, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions, Context<TOptions, TPluginOptions>> {
120
127
  #private;
121
128
  get operationsByMethod(): OperationsByMethod;
122
129
  set operationsByMethod(paths: OperationsByMethod);
@@ -124,7 +131,7 @@ declare class OperationGenerator<TOptions = unknown, TPluginOptions extends Plug
124
131
  forStatusCode?: string | number;
125
132
  resolveName?: (name: string) => string;
126
133
  }): OperationSchemas;
127
- build(...parsers: Array<Parser<Extract<TOptions, PluginFactoryOptions>>>): Promise<Array<KubbFile.File<TFileMeta>>>;
134
+ build(...generators: Array<Generator<Extract<TOptions, PluginFactoryOptions>>>): Promise<Array<KubbFile.File<TFileMeta>>>;
128
135
  /**
129
136
  * Operation
130
137
  */
@@ -155,4 +162,4 @@ declare class OperationGenerator<TOptions = unknown, TPluginOptions extends Plug
155
162
  all(operations: Operation[], paths: OperationsByMethod): OperationMethodResult<TFileMeta>;
156
163
  }
157
164
 
158
- export { type GetOperationGeneratorOptions as G, type OperationMethodResult as O, type ParserReactOptions as P, type SchemaGeneratorBuildOptions as S, OperationGenerator as a, type GetSchemaGeneratorOptions as b, type SchemaGeneratorOptions as c, type SchemaMethodResult as d, SchemaGenerator as e, createParser as f, createReactParser as g, type Parser as h, type ParserOptions as i };
165
+ export { type GetOperationGeneratorOptions as G, type OperationMethodResult as O, type ReactGeneratorOptions as R, type SchemaGeneratorBuildOptions as S, OperationGenerator as a, type GetSchemaGeneratorOptions as b, type SchemaGeneratorOptions as c, type SchemaMethodResult as d, SchemaGenerator as e, createGenerator as f, createReactGenerator as g, type Generator as h, type GeneratorOptions as i };
@@ -1,8 +1,8 @@
1
- import { FileMetaBase, ResolveNameParams, PluginFactoryOptions, Generator, PluginManager, Plugin } from '@kubb/core';
1
+ import { FileMetaBase, ResolveNameParams, PluginFactoryOptions, BaseGenerator, PluginManager, Plugin } from '@kubb/core';
2
2
  import * as KubbFile from '@kubb/fs/types';
3
3
  import { SchemaObject, Oas, contentType, Operation } from '@kubb/oas';
4
- import { d as OperationSchema, b as Refs, g as Override, f as OperationsByMethod, e as OperationSchemas, E as Exclude, I as Include } from './types-CZTUCaE5.cjs';
5
4
  import { KubbNode } from '@kubb/react/types';
5
+ import { d as OperationSchema, b as Refs, g as Override, f as OperationsByMethod, e as OperationSchemas, E as Exclude, I as Include } from './types-CZTUCaE5.cjs';
6
6
  import { S as Schema, c as SchemaKeywordMapper } from './SchemaMapper-sGcY1xL5.cjs';
7
7
 
8
8
  type GetSchemaGeneratorOptions<T extends SchemaGenerator<any, any, any>> = T extends SchemaGenerator<infer Options, any, any> ? Options : never;
@@ -47,7 +47,7 @@ type SchemaProps$1 = {
47
47
  name?: string;
48
48
  parentName?: string;
49
49
  };
50
- declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends Generator<TOptions, Context$1<TOptions, TPluginOptions>> {
50
+ declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions, Context$1<TOptions, TPluginOptions>> {
51
51
  #private;
52
52
  refs: Refs;
53
53
  /**
@@ -61,7 +61,7 @@ declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGe
61
61
  static deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T][];
62
62
  static findInObject<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
63
63
  static find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
64
- build(...parsers: Array<Parser<Extract<TOptions, PluginFactoryOptions>>>): Promise<Array<KubbFile.File<TFileMeta>>>;
64
+ build(...generators: Array<Generator<Extract<TOptions, PluginFactoryOptions>>>): Promise<Array<KubbFile.File<TFileMeta>>>;
65
65
  /**
66
66
  * Schema
67
67
  */
@@ -85,22 +85,29 @@ type SchemaProps<TOptions extends PluginFactoryOptions> = {
85
85
  schema: SchemaObject;
86
86
  options: TOptions['resolvedOptions'];
87
87
  };
88
- type ParserOptions<TOptions extends PluginFactoryOptions> = {
88
+ type GeneratorOptions<TOptions extends PluginFactoryOptions> = {
89
89
  name: string;
90
90
  operations?: (props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>;
91
91
  operation?: (props: OperationProps<TOptions>) => Promise<KubbFile.File[]>;
92
92
  schema?: (props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>;
93
93
  };
94
- type Parser<TOptions extends PluginFactoryOptions> = ParserOptions<TOptions>;
95
- declare function createParser<TOptions extends PluginFactoryOptions>(parseOptions: ParserOptions<TOptions>): Parser<TOptions>;
96
- type ParserReactOptions<TOptions extends PluginFactoryOptions> = {
94
+ type Generator<TOptions extends PluginFactoryOptions> = GeneratorOptions<TOptions>;
95
+ declare function createGenerator<TOptions extends PluginFactoryOptions>(parseOptions: GeneratorOptions<TOptions>): Generator<TOptions>;
96
+ type ReactGeneratorOptions<TOptions extends PluginFactoryOptions> = {
97
97
  name: string;
98
98
  Operations?: (props: OperationsProps<TOptions>) => KubbNode;
99
99
  Operation?: (props: OperationProps<TOptions>) => KubbNode;
100
100
  Schema?: (props: SchemaProps<TOptions>) => KubbNode;
101
+ /**
102
+ * Combine all react nodes and only render ones(to string or render)
103
+ */
104
+ render?: () => any;
101
105
  };
102
- declare function createReactParser<TOptions extends PluginFactoryOptions>(parseOptions: ParserReactOptions<TOptions>): Parser<TOptions>;
106
+ declare function createReactGenerator<TOptions extends PluginFactoryOptions>(parseOptions: ReactGeneratorOptions<TOptions>): Generator<TOptions>;
103
107
 
108
+ /**
109
+ * @deprecated
110
+ */
104
111
  type GetOperationGeneratorOptions<T extends OperationGenerator<any, any, any>> = T extends OperationGenerator<infer Options, any, any> ? Options : never;
105
112
  type OperationMethodResult<TFileMeta extends FileMetaBase> = Promise<KubbFile.File<TFileMeta> | Array<KubbFile.File<TFileMeta>> | null>;
106
113
  type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
@@ -116,7 +123,7 @@ type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
116
123
  plugin: Plugin<TPluginOptions>;
117
124
  mode: KubbFile.Mode;
118
125
  };
119
- declare class OperationGenerator<TOptions = unknown, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends Generator<TOptions, Context<TOptions, TPluginOptions>> {
126
+ declare class OperationGenerator<TOptions = unknown, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions, Context<TOptions, TPluginOptions>> {
120
127
  #private;
121
128
  get operationsByMethod(): OperationsByMethod;
122
129
  set operationsByMethod(paths: OperationsByMethod);
@@ -124,7 +131,7 @@ declare class OperationGenerator<TOptions = unknown, TPluginOptions extends Plug
124
131
  forStatusCode?: string | number;
125
132
  resolveName?: (name: string) => string;
126
133
  }): OperationSchemas;
127
- build(...parsers: Array<Parser<Extract<TOptions, PluginFactoryOptions>>>): Promise<Array<KubbFile.File<TFileMeta>>>;
134
+ build(...generators: Array<Generator<Extract<TOptions, PluginFactoryOptions>>>): Promise<Array<KubbFile.File<TFileMeta>>>;
128
135
  /**
129
136
  * Operation
130
137
  */
@@ -155,4 +162,4 @@ declare class OperationGenerator<TOptions = unknown, TPluginOptions extends Plug
155
162
  all(operations: Operation[], paths: OperationsByMethod): OperationMethodResult<TFileMeta>;
156
163
  }
157
164
 
158
- export { type GetOperationGeneratorOptions as G, type OperationMethodResult as O, type ParserReactOptions as P, type SchemaGeneratorBuildOptions as S, OperationGenerator as a, type GetSchemaGeneratorOptions as b, type SchemaGeneratorOptions as c, type SchemaMethodResult as d, SchemaGenerator as e, createParser as f, createReactParser as g, type Parser as h, type ParserOptions as i };
165
+ export { type GetOperationGeneratorOptions as G, type OperationMethodResult as O, type ReactGeneratorOptions as R, type SchemaGeneratorBuildOptions as S, OperationGenerator as a, type GetSchemaGeneratorOptions as b, type SchemaGeneratorOptions as c, type SchemaMethodResult as d, SchemaGenerator as e, createGenerator as f, createReactGenerator as g, type Generator as h, type GeneratorOptions as i };
@@ -3160,7 +3160,7 @@ var _transformers = require('@kubb/core/transformers'); var _transformers2 = _in
3160
3160
  var _utils = require('@kubb/core/utils');
3161
3161
  var _oas = require('@kubb/oas');
3162
3162
  var _remeda = require('remeda');
3163
- var SchemaGenerator = (_class = class _SchemaGenerator extends _core.Generator {constructor(...args2) { super(...args2); _class.prototype.__init.call(this); }
3163
+ var SchemaGenerator = (_class = class _SchemaGenerator extends _core.BaseGenerator {constructor(...args2) { super(...args2); _class.prototype.__init.call(this); }
3164
3164
  // Collect the types of all referenced schemas, so we can export them later
3165
3165
  __init() {this.refs = {}}
3166
3166
  // Keep track of already used type aliases
@@ -3404,11 +3404,6 @@ var SchemaGenerator = (_class = class _SchemaGenerator extends _core.Generator {
3404
3404
  const options = this.#getOptions({ schema: _schema, name });
3405
3405
  const unknownReturn = this.#getUnknownReturn({ schema: _schema, name });
3406
3406
  const { schema, version } = this.#getParsedSchemaObject(_schema);
3407
- const resolvedName = this.context.pluginManager.resolveName({
3408
- name: `${parentName || ""} ${name}`,
3409
- pluginKey: this.context.plugin.key,
3410
- type: "type"
3411
- });
3412
3407
  if (!schema) {
3413
3408
  return [{ keyword: unknownReturn }];
3414
3409
  }
@@ -3430,12 +3425,16 @@ var SchemaGenerator = (_class = class _SchemaGenerator extends _core.Generator {
3430
3425
  keyword: schemaKeywords.default,
3431
3426
  args: _transformers2.default.stringify(schema.default)
3432
3427
  });
3433
- }
3434
- if (typeof schema.default === "boolean") {
3428
+ } else if (typeof schema.default === "boolean") {
3435
3429
  baseItems.push({
3436
3430
  keyword: schemaKeywords.default,
3437
3431
  args: _nullishCoalesce(schema.default, () => ( false))
3438
3432
  });
3433
+ } else {
3434
+ baseItems.push({
3435
+ keyword: schemaKeywords.default,
3436
+ args: schema.default
3437
+ });
3439
3438
  }
3440
3439
  }
3441
3440
  if (schema.description) {
@@ -3757,7 +3756,7 @@ var SchemaGenerator = (_class = class _SchemaGenerator extends _core.Generator {
3757
3756
  }
3758
3757
  return [{ keyword: unknownReturn }];
3759
3758
  }
3760
- async build(...parsers) {
3759
+ async build(...generators) {
3761
3760
  const { oas, contentType, include } = this.context;
3762
3761
  const schemas = _chunkNU4F7G47cjs.getSchemas.call(void 0, { oas, contentType, includes: include });
3763
3762
  const promises = Object.entries(schemas).reduce((acc, [name, schema]) => {
@@ -3769,8 +3768,8 @@ var SchemaGenerator = (_class = class _SchemaGenerator extends _core.Generator {
3769
3768
  if (promiseOperation) {
3770
3769
  acc.push(promiseOperation);
3771
3770
  }
3772
- _optionalChain([parsers, 'optionalAccess', _36 => _36.forEach, 'call', _37 => _37((parser) => {
3773
- const promise = _optionalChain([parser, 'access', _38 => _38.schema, 'optionalCall', _39 => _39({
3771
+ _optionalChain([generators, 'optionalAccess', _36 => _36.forEach, 'call', _37 => _37((generator) => {
3772
+ const promise = _optionalChain([generator, 'access', _38 => _38.schema, 'optionalCall', _39 => _39({
3774
3773
  instance: this,
3775
3774
  name,
3776
3775
  schema,
@@ -3963,4 +3962,4 @@ react/cjs/react-jsx-runtime.development.js:
3963
3962
  * LICENSE file in the root directory of this source tree.
3964
3963
  *)
3965
3964
  */
3966
- //# sourceMappingURL=chunk-VSVVTCQB.cjs.map
3965
+ //# sourceMappingURL=chunk-IAUV3UKH.cjs.map