@kubb/plugin-oas 4.33.0 → 4.33.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{SchemaMapper-CEvL7_hg.cjs → SchemaMapper-CeavHZlp.cjs} +1 -1
- package/dist/{SchemaMapper-CEvL7_hg.cjs.map → SchemaMapper-CeavHZlp.cjs.map} +1 -1
- package/dist/{SchemaMapper-ClUmzpCc.js → SchemaMapper-CqMkO2T1.js} +1 -1
- package/dist/{SchemaMapper-ClUmzpCc.js.map → SchemaMapper-CqMkO2T1.js.map} +1 -1
- package/dist/{createGenerator-BPVBbTHR.d.ts → createGenerator-B98OshdQ.d.ts} +43 -7
- package/dist/{generators-BvfaSMp3.cjs → generators-CBlzDhTh.cjs} +4 -5
- package/dist/generators-CBlzDhTh.cjs.map +1 -0
- package/dist/{generators-BrYP9z4D.js → generators-DRPPf38p.js} +2 -3
- package/dist/{generators-BrYP9z4D.js.map → generators-DRPPf38p.js.map} +1 -1
- package/dist/generators.cjs +1 -1
- package/dist/generators.d.ts +1 -1
- package/dist/generators.js +1 -1
- package/dist/getFooter-BBzsC616.cjs +136 -0
- package/dist/getFooter-BBzsC616.cjs.map +1 -0
- package/dist/getFooter-Pw3tLCiV.js +112 -0
- package/dist/getFooter-Pw3tLCiV.js.map +1 -0
- package/dist/hooks.cjs +2 -2
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.ts +2 -2
- package/dist/hooks.js +2 -2
- package/dist/hooks.js.map +1 -1
- package/dist/index.cjs +59 -65
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +46 -51
- package/dist/index.js.map +1 -1
- package/dist/mocks.cjs +1 -1
- package/dist/mocks.js +1 -1
- package/dist/{resolveServerUrl-CxAWmztf.cjs → requestBody-Bj_bewuH.cjs} +110 -56
- package/dist/requestBody-Bj_bewuH.cjs.map +1 -0
- package/dist/{resolveServerUrl-sGGjx0hA.js → requestBody-ll35LC6-.js} +110 -49
- package/dist/requestBody-ll35LC6-.js.map +1 -0
- package/dist/utils.cjs +139 -25
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.ts +3 -21
- package/dist/utils.js +130 -14
- package/dist/utils.js.map +1 -1
- package/package.json +5 -4
- package/src/OperationGenerator.ts +56 -79
- package/src/SchemaGenerator.ts +49 -29
- package/src/generators/jsonGenerator.ts +1 -1
- package/src/hooks/useOperationManager.ts +2 -2
- package/src/plugin.ts +3 -4
- package/src/utils/getComments.ts +3 -6
- package/src/utils/getImports.ts +5 -3
- package/src/utils/getParams.ts +2 -2
- package/src/utils/index.ts +0 -1
- package/src/utils/paramsCasing.ts +5 -5
- package/src/utils/requestBody.ts +7 -1
- package/dist/generators-BvfaSMp3.cjs.map +0 -1
- package/dist/getFooter-DGVGGyRc.js +0 -57
- package/dist/getFooter-DGVGGyRc.js.map +0 -1
- package/dist/getFooter-WAZDOcmk.cjs +0 -69
- package/dist/getFooter-WAZDOcmk.cjs.map +0 -1
- package/dist/resolveServerUrl-CxAWmztf.cjs.map +0 -1
- package/dist/resolveServerUrl-sGGjx0hA.js.map +0 -1
- package/src/utils/resolveServerUrl.ts +0 -37
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaMapper-
|
|
1
|
+
{"version":3,"file":"SchemaMapper-CeavHZlp.cjs","names":[],"sources":["../src/SchemaMapper.ts"],"sourcesContent":["import type { KubbFile } from '@kubb/fabric-core/types'\nimport type { SchemaObject } from '@kubb/oas'\n\nexport type SchemaKeywordMapper = {\n object: {\n keyword: 'object'\n args: {\n properties: { [x: string]: Schema[] }\n additionalProperties: Schema[]\n patternProperties?: Record<string, Schema[]>\n strict?: boolean\n }\n }\n url: { keyword: 'url' }\n readOnly: { keyword: 'readOnly' }\n writeOnly: { keyword: 'writeOnly' }\n uuid: { keyword: 'uuid' }\n email: { keyword: 'email' }\n firstName: { keyword: 'firstName' }\n lastName: { keyword: 'lastName' }\n phone: { keyword: 'phone' }\n password: { keyword: 'password' }\n date: { keyword: 'date'; args: { type?: 'date' | 'string' } }\n time: { keyword: 'time'; args: { type?: 'date' | 'string' } }\n datetime: { keyword: 'datetime'; args: { offset?: boolean; local?: boolean } }\n tuple: { keyword: 'tuple'; args: { items: Schema[]; min?: number; max?: number; rest?: Schema } }\n array: {\n keyword: 'array'\n args: { items: Schema[]; min?: number; max?: number; unique?: boolean }\n }\n enum: {\n keyword: 'enum'\n args: {\n name: string\n typeName: string\n asConst: boolean\n items: Array<{\n name: string | number\n format: 'string' | 'number' | 'boolean'\n value?: string | number | boolean\n }>\n }\n }\n and: { keyword: 'and'; args: Schema[] }\n const: {\n keyword: 'const'\n args: {\n name: string | number\n format: 'string' | 'number' | 'boolean'\n value?: string | number | boolean\n }\n }\n union: { keyword: 'union'; args: Schema[] }\n ref: {\n keyword: 'ref'\n args: {\n name: string\n $ref: string\n /**\n * Full qualified path.\n */\n path: KubbFile.Path\n /**\n * When true `File.Import` is used.\n * When false a reference is used inside the current file.\n */\n isImportable: boolean\n }\n }\n matches: { keyword: 'matches'; args?: string }\n boolean: { keyword: 'boolean' }\n default: { keyword: 'default'; args: string | number | boolean }\n string: { keyword: 'string' }\n integer: { keyword: 'integer' }\n bigint: { keyword: 'bigint' }\n number: { keyword: 'number' }\n max: { keyword: 'max'; args: number }\n min: { keyword: 'min'; args: number }\n exclusiveMaximum: { keyword: 'exclusiveMaximum'; args: number }\n exclusiveMinimum: { keyword: 'exclusiveMinimum'; args: number }\n describe: { keyword: 'describe'; args: string }\n example: { keyword: 'example'; args: string }\n deprecated: { keyword: 'deprecated' }\n optional: { keyword: 'optional' }\n undefined: { keyword: 'undefined' }\n nullish: { keyword: 'nullish' }\n nullable: { keyword: 'nullable' }\n null: { keyword: 'null' }\n any: { keyword: 'any' }\n unknown: { keyword: 'unknown' }\n void: { keyword: 'void' }\n blob: { keyword: 'blob' }\n schema: { keyword: 'schema'; args: { type: 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'object'; format?: string } }\n name: { keyword: 'name'; args: string }\n catchall: { keyword: 'catchall' }\n interface: { keyword: 'interface' }\n}\n\nexport const schemaKeywords = {\n any: 'any',\n unknown: 'unknown',\n number: 'number',\n integer: 'integer',\n bigint: 'bigint',\n string: 'string',\n boolean: 'boolean',\n undefined: 'undefined',\n nullable: 'nullable',\n null: 'null',\n nullish: 'nullish',\n array: 'array',\n tuple: 'tuple',\n enum: 'enum',\n union: 'union',\n datetime: 'datetime',\n date: 'date',\n email: 'email',\n uuid: 'uuid',\n url: 'url',\n void: 'void',\n /* intersection */\n default: 'default',\n const: 'const',\n and: 'and',\n describe: 'describe',\n min: 'min',\n max: 'max',\n exclusiveMinimum: 'exclusiveMinimum',\n exclusiveMaximum: 'exclusiveMaximum',\n optional: 'optional',\n readOnly: 'readOnly',\n writeOnly: 'writeOnly',\n\n // custom ones\n object: 'object',\n ref: 'ref',\n matches: 'matches',\n firstName: 'firstName',\n lastName: 'lastName',\n password: 'password',\n phone: 'phone',\n blob: 'blob',\n deprecated: 'deprecated',\n example: 'example',\n schema: 'schema',\n catchall: 'catchall',\n time: 'time',\n name: 'name',\n interface: 'interface',\n} satisfies {\n [K in keyof SchemaKeywordMapper]: SchemaKeywordMapper[K]['keyword']\n}\n\nexport type SchemaKeyword = keyof SchemaKeywordMapper\n\nexport type SchemaMapper<T = string | null | undefined> = {\n [K in keyof SchemaKeywordMapper]: (() => T | undefined) | undefined\n}\n\nexport type SchemaKeywordBase<T> = {\n keyword: SchemaKeyword\n args: T\n}\n\nexport type Schema = { keyword: string } | SchemaKeywordMapper[keyof SchemaKeywordMapper]\n\nexport type SchemaTree = {\n schema: SchemaObject\n parent: Schema | undefined\n current: Schema\n siblings: Schema[]\n /**\n * this is equal to the key of a property(object)\n */\n name?: string\n}\n\nexport function isKeyword<T extends Schema, K extends keyof SchemaKeywordMapper>(meta: T, keyword: K): meta is Extract<T, SchemaKeywordMapper[K]> {\n return meta.keyword === keyword\n}\n"],"mappings":";;AAkGA,MAAa,iBAAiB;CAC5B,KAAK;CACL,SAAS;CACT,QAAQ;CACR,SAAS;CACT,QAAQ;CACR,QAAQ;CACR,SAAS;CACT,WAAW;CACX,UAAU;CACV,MAAM;CACN,SAAS;CACT,OAAO;CACP,OAAO;CACP,MAAM;CACN,OAAO;CACP,UAAU;CACV,MAAM;CACN,OAAO;CACP,MAAM;CACN,KAAK;CACL,MAAM;CAEN,SAAS;CACT,OAAO;CACP,KAAK;CACL,UAAU;CACV,KAAK;CACL,KAAK;CACL,kBAAkB;CAClB,kBAAkB;CAClB,UAAU;CACV,UAAU;CACV,WAAW;CAGX,QAAQ;CACR,KAAK;CACL,SAAS;CACT,WAAW;CACX,UAAU;CACV,UAAU;CACV,OAAO;CACP,MAAM;CACN,YAAY;CACZ,SAAS;CACT,QAAQ;CACR,UAAU;CACV,MAAM;CACN,MAAM;CACN,WAAW;CACZ;AA4BD,SAAgB,UAAiE,MAAS,SAAwD;AAChJ,QAAO,KAAK,YAAY"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaMapper-
|
|
1
|
+
{"version":3,"file":"SchemaMapper-CqMkO2T1.js","names":[],"sources":["../src/SchemaMapper.ts"],"sourcesContent":["import type { KubbFile } from '@kubb/fabric-core/types'\nimport type { SchemaObject } from '@kubb/oas'\n\nexport type SchemaKeywordMapper = {\n object: {\n keyword: 'object'\n args: {\n properties: { [x: string]: Schema[] }\n additionalProperties: Schema[]\n patternProperties?: Record<string, Schema[]>\n strict?: boolean\n }\n }\n url: { keyword: 'url' }\n readOnly: { keyword: 'readOnly' }\n writeOnly: { keyword: 'writeOnly' }\n uuid: { keyword: 'uuid' }\n email: { keyword: 'email' }\n firstName: { keyword: 'firstName' }\n lastName: { keyword: 'lastName' }\n phone: { keyword: 'phone' }\n password: { keyword: 'password' }\n date: { keyword: 'date'; args: { type?: 'date' | 'string' } }\n time: { keyword: 'time'; args: { type?: 'date' | 'string' } }\n datetime: { keyword: 'datetime'; args: { offset?: boolean; local?: boolean } }\n tuple: { keyword: 'tuple'; args: { items: Schema[]; min?: number; max?: number; rest?: Schema } }\n array: {\n keyword: 'array'\n args: { items: Schema[]; min?: number; max?: number; unique?: boolean }\n }\n enum: {\n keyword: 'enum'\n args: {\n name: string\n typeName: string\n asConst: boolean\n items: Array<{\n name: string | number\n format: 'string' | 'number' | 'boolean'\n value?: string | number | boolean\n }>\n }\n }\n and: { keyword: 'and'; args: Schema[] }\n const: {\n keyword: 'const'\n args: {\n name: string | number\n format: 'string' | 'number' | 'boolean'\n value?: string | number | boolean\n }\n }\n union: { keyword: 'union'; args: Schema[] }\n ref: {\n keyword: 'ref'\n args: {\n name: string\n $ref: string\n /**\n * Full qualified path.\n */\n path: KubbFile.Path\n /**\n * When true `File.Import` is used.\n * When false a reference is used inside the current file.\n */\n isImportable: boolean\n }\n }\n matches: { keyword: 'matches'; args?: string }\n boolean: { keyword: 'boolean' }\n default: { keyword: 'default'; args: string | number | boolean }\n string: { keyword: 'string' }\n integer: { keyword: 'integer' }\n bigint: { keyword: 'bigint' }\n number: { keyword: 'number' }\n max: { keyword: 'max'; args: number }\n min: { keyword: 'min'; args: number }\n exclusiveMaximum: { keyword: 'exclusiveMaximum'; args: number }\n exclusiveMinimum: { keyword: 'exclusiveMinimum'; args: number }\n describe: { keyword: 'describe'; args: string }\n example: { keyword: 'example'; args: string }\n deprecated: { keyword: 'deprecated' }\n optional: { keyword: 'optional' }\n undefined: { keyword: 'undefined' }\n nullish: { keyword: 'nullish' }\n nullable: { keyword: 'nullable' }\n null: { keyword: 'null' }\n any: { keyword: 'any' }\n unknown: { keyword: 'unknown' }\n void: { keyword: 'void' }\n blob: { keyword: 'blob' }\n schema: { keyword: 'schema'; args: { type: 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'object'; format?: string } }\n name: { keyword: 'name'; args: string }\n catchall: { keyword: 'catchall' }\n interface: { keyword: 'interface' }\n}\n\nexport const schemaKeywords = {\n any: 'any',\n unknown: 'unknown',\n number: 'number',\n integer: 'integer',\n bigint: 'bigint',\n string: 'string',\n boolean: 'boolean',\n undefined: 'undefined',\n nullable: 'nullable',\n null: 'null',\n nullish: 'nullish',\n array: 'array',\n tuple: 'tuple',\n enum: 'enum',\n union: 'union',\n datetime: 'datetime',\n date: 'date',\n email: 'email',\n uuid: 'uuid',\n url: 'url',\n void: 'void',\n /* intersection */\n default: 'default',\n const: 'const',\n and: 'and',\n describe: 'describe',\n min: 'min',\n max: 'max',\n exclusiveMinimum: 'exclusiveMinimum',\n exclusiveMaximum: 'exclusiveMaximum',\n optional: 'optional',\n readOnly: 'readOnly',\n writeOnly: 'writeOnly',\n\n // custom ones\n object: 'object',\n ref: 'ref',\n matches: 'matches',\n firstName: 'firstName',\n lastName: 'lastName',\n password: 'password',\n phone: 'phone',\n blob: 'blob',\n deprecated: 'deprecated',\n example: 'example',\n schema: 'schema',\n catchall: 'catchall',\n time: 'time',\n name: 'name',\n interface: 'interface',\n} satisfies {\n [K in keyof SchemaKeywordMapper]: SchemaKeywordMapper[K]['keyword']\n}\n\nexport type SchemaKeyword = keyof SchemaKeywordMapper\n\nexport type SchemaMapper<T = string | null | undefined> = {\n [K in keyof SchemaKeywordMapper]: (() => T | undefined) | undefined\n}\n\nexport type SchemaKeywordBase<T> = {\n keyword: SchemaKeyword\n args: T\n}\n\nexport type Schema = { keyword: string } | SchemaKeywordMapper[keyof SchemaKeywordMapper]\n\nexport type SchemaTree = {\n schema: SchemaObject\n parent: Schema | undefined\n current: Schema\n siblings: Schema[]\n /**\n * this is equal to the key of a property(object)\n */\n name?: string\n}\n\nexport function isKeyword<T extends Schema, K extends keyof SchemaKeywordMapper>(meta: T, keyword: K): meta is Extract<T, SchemaKeywordMapper[K]> {\n return meta.keyword === keyword\n}\n"],"mappings":";;AAkGA,MAAa,iBAAiB;CAC5B,KAAK;CACL,SAAS;CACT,QAAQ;CACR,SAAS;CACT,QAAQ;CACR,QAAQ;CACR,SAAS;CACT,WAAW;CACX,UAAU;CACV,MAAM;CACN,SAAS;CACT,OAAO;CACP,OAAO;CACP,MAAM;CACN,OAAO;CACP,UAAU;CACV,MAAM;CACN,OAAO;CACP,MAAM;CACN,KAAK;CACL,MAAM;CAEN,SAAS;CACT,OAAO;CACP,KAAK;CACL,UAAU;CACV,KAAK;CACL,KAAK;CACL,kBAAkB;CAClB,kBAAkB;CAClB,UAAU;CACV,UAAU;CACV,WAAW;CAGX,QAAQ;CACR,KAAK;CACL,SAAS;CACT,WAAW;CACX,UAAU;CACV,UAAU;CACV,OAAO;CACP,MAAM;CACN,YAAY;CACZ,SAAS;CACT,QAAQ;CACR,UAAU;CACV,MAAM;CACN,MAAM;CACN,WAAW;CACZ;AA4BD,SAAgB,UAAiE,MAAS,SAAwD;AAChJ,QAAO,KAAK,YAAY"}
|
|
@@ -1,12 +1,40 @@
|
|
|
1
1
|
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
2
|
import { i as SchemaKeywordMapper, t as Schema } from "./SchemaMapper-SneuY1wg.js";
|
|
3
|
-
import { BaseGenerator, Config, FileMetaBase, Group, KubbEvents, Output, Plugin, PluginFactoryOptions, PluginManager, ResolveNameParams } from "@kubb/core";
|
|
4
|
-
import { AsyncEventEmitter } from "@kubb/core/utils";
|
|
5
3
|
import { HttpMethod, Oas, Operation, SchemaObject, contentType } from "@kubb/oas";
|
|
6
4
|
import { Fabric } from "@kubb/react-fabric";
|
|
5
|
+
import { Config, FileMetaBase, Group, KubbEvents, Output, Plugin, PluginFactoryOptions, PluginManager, ResolveNameParams } from "@kubb/core";
|
|
7
6
|
import { KubbFile } from "@kubb/fabric-core/types";
|
|
8
7
|
import { FabricReactNode } from "@kubb/react-fabric/types";
|
|
9
8
|
|
|
9
|
+
//#region ../../internals/utils/src/asyncEventEmitter.d.ts
|
|
10
|
+
/** A function that can be registered as an event listener, synchronous or async. */
|
|
11
|
+
type AsyncListener<TArgs extends unknown[]> = (...args: TArgs) => void | Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* A typed EventEmitter that awaits all async listeners before resolving.
|
|
14
|
+
* Wraps Node's `EventEmitter` with full TypeScript event-map inference.
|
|
15
|
+
*/
|
|
16
|
+
declare class AsyncEventEmitter<TEvents extends { [K in keyof TEvents]: unknown[] }> {
|
|
17
|
+
#private;
|
|
18
|
+
/**
|
|
19
|
+
* `maxListener` controls the maximum number of listeners per event before Node emits a memory-leak warning.
|
|
20
|
+
* @default 10
|
|
21
|
+
*/
|
|
22
|
+
constructor(maxListener?: number);
|
|
23
|
+
/**
|
|
24
|
+
* Emits an event and awaits all registered listeners in parallel.
|
|
25
|
+
* Throws if any listener rejects, wrapping the cause with the event name and serialized arguments.
|
|
26
|
+
*/
|
|
27
|
+
emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArgs: TEvents[TEventName]): Promise<void>;
|
|
28
|
+
/** Registers a persistent listener for the given event. */
|
|
29
|
+
on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: AsyncListener<TEvents[TEventName]>): void;
|
|
30
|
+
/** Registers a one-shot listener that removes itself after the first invocation. */
|
|
31
|
+
onOnce<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: AsyncListener<TEvents[TEventName]>): void;
|
|
32
|
+
/** Removes a previously registered listener. */
|
|
33
|
+
off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: AsyncListener<TEvents[TEventName]>): void;
|
|
34
|
+
/** Removes all listeners from every event channel. */
|
|
35
|
+
removeAll(): void;
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
10
38
|
//#region src/types.d.ts
|
|
11
39
|
type GetOasOptions = {
|
|
12
40
|
validate?: boolean;
|
|
@@ -238,8 +266,12 @@ type Context$1<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
|
238
266
|
mode: KubbFile.Mode;
|
|
239
267
|
UNSTABLE_NAMING?: true;
|
|
240
268
|
};
|
|
241
|
-
declare class OperationGenerator<TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase>
|
|
269
|
+
declare class OperationGenerator<TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> {
|
|
242
270
|
#private;
|
|
271
|
+
constructor(options: TPluginOptions['resolvedOptions'], context: Context$1<TPluginOptions['resolvedOptions'], TPluginOptions>);
|
|
272
|
+
get options(): TPluginOptions['resolvedOptions'];
|
|
273
|
+
set options(options: TPluginOptions['resolvedOptions']);
|
|
274
|
+
get context(): Context$1<TPluginOptions['resolvedOptions'], TPluginOptions>;
|
|
243
275
|
getOptions(operation: Operation, method: HttpMethod): Partial<TPluginOptions['resolvedOptions']>;
|
|
244
276
|
getSchemas(operation: Operation, {
|
|
245
277
|
resolveName
|
|
@@ -293,8 +325,8 @@ type SchemaGeneratorOptions = {
|
|
|
293
325
|
*/
|
|
294
326
|
name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
295
327
|
/**
|
|
296
|
-
* Receive schema and name(propertyName) and return
|
|
297
|
-
*
|
|
328
|
+
* Receive schema and name(propertyName) and return Schema array.
|
|
329
|
+
* Return `undefined` to fall through to default schema generation.
|
|
298
330
|
* @beta
|
|
299
331
|
*/
|
|
300
332
|
schema?: (schemaProps: SchemaProps$1, defaultSchemas: Schema[]) => Array<Schema> | undefined;
|
|
@@ -307,8 +339,12 @@ type SchemaProps$1 = {
|
|
|
307
339
|
parentName: string | null;
|
|
308
340
|
rootName?: string | null;
|
|
309
341
|
};
|
|
310
|
-
declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase>
|
|
342
|
+
declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> {
|
|
311
343
|
#private;
|
|
344
|
+
constructor(options: TOptions, context: Context<TOptions, TPluginOptions>);
|
|
345
|
+
get options(): TOptions;
|
|
346
|
+
set options(options: TOptions);
|
|
347
|
+
get context(): Context<TOptions, TPluginOptions>;
|
|
312
348
|
refs: Refs;
|
|
313
349
|
/**
|
|
314
350
|
* Creates a type node from a given schema.
|
|
@@ -387,4 +423,4 @@ type CoreGenerator<TOptions extends PluginFactoryOptions> = {
|
|
|
387
423
|
declare function createGenerator<TOptions extends PluginFactoryOptions>(generator: UserGenerator<TOptions>): CoreGenerator<TOptions>;
|
|
388
424
|
//#endregion
|
|
389
425
|
export { Resolver as C, ResolvePathOptions as S, Options as _, createReactGenerator as a, Ref as b, SchemaGeneratorBuildOptions as c, OperationGenerator as d, OperationMethodResult as f, OperationSchemas as g, OperationSchema as h, ReactGenerator as i, SchemaGeneratorOptions as l, Include as m, createGenerator as n, GetSchemaGeneratorOptions as o, Exclude as p, Generator as r, SchemaGenerator as s, CoreGenerator as t, SchemaMethodResult as u, Override as v, Refs as x, PluginOas as y };
|
|
390
|
-
//# sourceMappingURL=createGenerator-
|
|
426
|
+
//# sourceMappingURL=createGenerator-B98OshdQ.d.ts.map
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
require("./chunk-ByKO4r7w.cjs");
|
|
2
|
-
const require_getFooter = require("./getFooter-
|
|
3
|
-
let _kubb_core_transformers = require("@kubb/core/transformers");
|
|
2
|
+
const require_getFooter = require("./getFooter-BBzsC616.cjs");
|
|
4
3
|
//#region src/generators/createGenerator.ts
|
|
5
4
|
function createGenerator(generator) {
|
|
6
5
|
return {
|
|
@@ -49,13 +48,13 @@ const jsonGenerator = createGenerator({
|
|
|
49
48
|
const { pluginManager, plugin } = generator.context;
|
|
50
49
|
return [{
|
|
51
50
|
...pluginManager.getFile({
|
|
52
|
-
name:
|
|
51
|
+
name: require_getFooter.camelCase(schema.name),
|
|
53
52
|
extname: ".json",
|
|
54
53
|
mode: "split",
|
|
55
54
|
pluginKey: plugin.key
|
|
56
55
|
}),
|
|
57
56
|
sources: [{
|
|
58
|
-
name:
|
|
57
|
+
name: require_getFooter.camelCase(schema.name),
|
|
59
58
|
isExportable: false,
|
|
60
59
|
isIndexable: false,
|
|
61
60
|
value: JSON.stringify(schema.value)
|
|
@@ -92,4 +91,4 @@ Object.defineProperty(exports, "jsonGenerator", {
|
|
|
92
91
|
}
|
|
93
92
|
});
|
|
94
93
|
|
|
95
|
-
//# sourceMappingURL=generators-
|
|
94
|
+
//# sourceMappingURL=generators-CBlzDhTh.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generators-CBlzDhTh.cjs","names":["camelCase","getBanner","getFooter"],"sources":["../src/generators/createGenerator.ts","../src/generators/createReactGenerator.ts","../src/generators/jsonGenerator.ts"],"sourcesContent":["import type { PluginFactoryOptions } from '@kubb/core'\nimport type { KubbFile } from '@kubb/fabric-core/types'\nimport type { OperationProps, OperationsProps, SchemaProps } from './types.ts'\n\ntype UserGenerator<TOptions extends PluginFactoryOptions> = {\n name: string\n operations?: (props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>\n operation?: (props: OperationProps<TOptions>) => Promise<KubbFile.File[]>\n schema?: (props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>\n}\n\nexport type CoreGenerator<TOptions extends PluginFactoryOptions> = {\n name: string\n type: 'core'\n operations: (props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>\n operation: (props: OperationProps<TOptions>) => Promise<KubbFile.File[]>\n schema: (props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>\n}\n\nexport function createGenerator<TOptions extends PluginFactoryOptions>(generator: UserGenerator<TOptions>): CoreGenerator<TOptions> {\n return {\n type: 'core',\n async operations() {\n return []\n },\n async operation() {\n return []\n },\n async schema() {\n return []\n },\n ...generator,\n }\n}\n","import type { PluginFactoryOptions } from '@kubb/core'\nimport type { FabricReactNode } from '@kubb/react-fabric/types'\nimport type { OperationProps, OperationsProps, SchemaProps } from './types.ts'\n\ntype UserGenerator<TOptions extends PluginFactoryOptions> = {\n name: string\n Operations?: (props: OperationsProps<TOptions>) => FabricReactNode\n Operation?: (props: OperationProps<TOptions>) => FabricReactNode\n Schema?: (props: SchemaProps<TOptions>) => FabricReactNode\n}\n\nexport type ReactGenerator<TOptions extends PluginFactoryOptions> = {\n name: string\n type: 'react'\n Operations: (props: OperationsProps<TOptions>) => FabricReactNode\n Operation: (props: OperationProps<TOptions>) => FabricReactNode\n Schema: (props: SchemaProps<TOptions>) => FabricReactNode\n}\n\n/****\n * Creates a generator that uses React component functions to generate files for OpenAPI operations and schemas.\n *\n * 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.\n *\n * @returns A generator object with async methods for operations, operation, and schema file generation.\n */\nexport function createReactGenerator<TOptions extends PluginFactoryOptions>(generator: UserGenerator<TOptions>): ReactGenerator<TOptions> {\n return {\n type: 'react',\n Operations() {\n return null\n },\n Operation() {\n return null\n },\n Schema() {\n return null\n },\n ...generator,\n }\n}\n","import { camelCase } from '@internals/utils'\nimport type { PluginOas } from '../types.ts'\nimport { getBanner } from '../utils/getBanner.ts'\nimport { getFooter } from '../utils/getFooter.ts'\nimport { createGenerator } from './createGenerator.ts'\n\nexport const jsonGenerator = createGenerator<PluginOas>({\n name: 'plugin-oas',\n async schema({ schema, generator }) {\n const { pluginManager, plugin } = generator.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 banner: getBanner({\n oas: generator.context.oas,\n output: plugin.options.output,\n config: pluginManager.config,\n }),\n format: getFooter({ oas: generator.context.oas, output: plugin.options.output }),\n },\n ]\n },\n})\n"],"mappings":";;;AAmBA,SAAgB,gBAAuD,WAA6D;AAClI,QAAO;EACL,MAAM;EACN,MAAM,aAAa;AACjB,UAAO,EAAE;;EAEX,MAAM,YAAY;AAChB,UAAO,EAAE;;EAEX,MAAM,SAAS;AACb,UAAO,EAAE;;EAEX,GAAG;EACJ;;;;;;;;;;;ACNH,SAAgB,qBAA4D,WAA8D;AACxI,QAAO;EACL,MAAM;EACN,aAAa;AACX,UAAO;;EAET,YAAY;AACV,UAAO;;EAET,SAAS;AACP,UAAO;;EAET,GAAG;EACJ;;;;ACjCH,MAAa,gBAAgB,gBAA2B;CACtD,MAAM;CACN,MAAM,OAAO,EAAE,QAAQ,aAAa;EAClC,MAAM,EAAE,eAAe,WAAW,UAAU;AAQ5C,SAAO,CACL;GACE,GATS,cAAc,QAAQ;IACjC,MAAMA,kBAAAA,UAAU,OAAO,KAAK;IAC5B,SAAS;IACT,MAAM;IACN,WAAW,OAAO;IACnB,CAAC;GAKE,SAAS,CACP;IACE,MAAMA,kBAAAA,UAAU,OAAO,KAAK;IAC5B,cAAc;IACd,aAAa;IACb,OAAO,KAAK,UAAU,OAAO,MAAM;IACpC,CACF;GACD,QAAQC,kBAAAA,UAAU;IAChB,KAAK,UAAU,QAAQ;IACvB,QAAQ,OAAO,QAAQ;IACvB,QAAQ,cAAc;IACvB,CAAC;GACF,QAAQC,kBAAAA,UAAU;IAAE,KAAK,UAAU,QAAQ;IAAK,QAAQ,OAAO,QAAQ;IAAQ,CAAC;GACjF,CACF;;CAEJ,CAAC"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import "./chunk--u3MIqq1.js";
|
|
2
|
-
import { n as getBanner, t as getFooter } from "./getFooter-
|
|
3
|
-
import { camelCase } from "@kubb/core/transformers";
|
|
2
|
+
import { n as getBanner, r as camelCase, t as getFooter } from "./getFooter-Pw3tLCiV.js";
|
|
4
3
|
//#region src/generators/createGenerator.ts
|
|
5
4
|
function createGenerator(generator) {
|
|
6
5
|
return {
|
|
@@ -75,4 +74,4 @@ const jsonGenerator = createGenerator({
|
|
|
75
74
|
//#endregion
|
|
76
75
|
export { createReactGenerator as n, createGenerator as r, jsonGenerator as t };
|
|
77
76
|
|
|
78
|
-
//# sourceMappingURL=generators-
|
|
77
|
+
//# sourceMappingURL=generators-DRPPf38p.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generators-
|
|
1
|
+
{"version":3,"file":"generators-DRPPf38p.js","names":[],"sources":["../src/generators/createGenerator.ts","../src/generators/createReactGenerator.ts","../src/generators/jsonGenerator.ts"],"sourcesContent":["import type { PluginFactoryOptions } from '@kubb/core'\nimport type { KubbFile } from '@kubb/fabric-core/types'\nimport type { OperationProps, OperationsProps, SchemaProps } from './types.ts'\n\ntype UserGenerator<TOptions extends PluginFactoryOptions> = {\n name: string\n operations?: (props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>\n operation?: (props: OperationProps<TOptions>) => Promise<KubbFile.File[]>\n schema?: (props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>\n}\n\nexport type CoreGenerator<TOptions extends PluginFactoryOptions> = {\n name: string\n type: 'core'\n operations: (props: OperationsProps<TOptions>) => Promise<KubbFile.File[]>\n operation: (props: OperationProps<TOptions>) => Promise<KubbFile.File[]>\n schema: (props: SchemaProps<TOptions>) => Promise<KubbFile.File[]>\n}\n\nexport function createGenerator<TOptions extends PluginFactoryOptions>(generator: UserGenerator<TOptions>): CoreGenerator<TOptions> {\n return {\n type: 'core',\n async operations() {\n return []\n },\n async operation() {\n return []\n },\n async schema() {\n return []\n },\n ...generator,\n }\n}\n","import type { PluginFactoryOptions } from '@kubb/core'\nimport type { FabricReactNode } from '@kubb/react-fabric/types'\nimport type { OperationProps, OperationsProps, SchemaProps } from './types.ts'\n\ntype UserGenerator<TOptions extends PluginFactoryOptions> = {\n name: string\n Operations?: (props: OperationsProps<TOptions>) => FabricReactNode\n Operation?: (props: OperationProps<TOptions>) => FabricReactNode\n Schema?: (props: SchemaProps<TOptions>) => FabricReactNode\n}\n\nexport type ReactGenerator<TOptions extends PluginFactoryOptions> = {\n name: string\n type: 'react'\n Operations: (props: OperationsProps<TOptions>) => FabricReactNode\n Operation: (props: OperationProps<TOptions>) => FabricReactNode\n Schema: (props: SchemaProps<TOptions>) => FabricReactNode\n}\n\n/****\n * Creates a generator that uses React component functions to generate files for OpenAPI operations and schemas.\n *\n * 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.\n *\n * @returns A generator object with async methods for operations, operation, and schema file generation.\n */\nexport function createReactGenerator<TOptions extends PluginFactoryOptions>(generator: UserGenerator<TOptions>): ReactGenerator<TOptions> {\n return {\n type: 'react',\n Operations() {\n return null\n },\n Operation() {\n return null\n },\n Schema() {\n return null\n },\n ...generator,\n }\n}\n","import { camelCase } from '@internals/utils'\nimport type { PluginOas } from '../types.ts'\nimport { getBanner } from '../utils/getBanner.ts'\nimport { getFooter } from '../utils/getFooter.ts'\nimport { createGenerator } from './createGenerator.ts'\n\nexport const jsonGenerator = createGenerator<PluginOas>({\n name: 'plugin-oas',\n async schema({ schema, generator }) {\n const { pluginManager, plugin } = generator.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 banner: getBanner({\n oas: generator.context.oas,\n output: plugin.options.output,\n config: pluginManager.config,\n }),\n format: getFooter({ oas: generator.context.oas, output: plugin.options.output }),\n },\n ]\n },\n})\n"],"mappings":";;;AAmBA,SAAgB,gBAAuD,WAA6D;AAClI,QAAO;EACL,MAAM;EACN,MAAM,aAAa;AACjB,UAAO,EAAE;;EAEX,MAAM,YAAY;AAChB,UAAO,EAAE;;EAEX,MAAM,SAAS;AACb,UAAO,EAAE;;EAEX,GAAG;EACJ;;;;;;;;;;;ACNH,SAAgB,qBAA4D,WAA8D;AACxI,QAAO;EACL,MAAM;EACN,aAAa;AACX,UAAO;;EAET,YAAY;AACV,UAAO;;EAET,SAAS;AACP,UAAO;;EAET,GAAG;EACJ;;;;ACjCH,MAAa,gBAAgB,gBAA2B;CACtD,MAAM;CACN,MAAM,OAAO,EAAE,QAAQ,aAAa;EAClC,MAAM,EAAE,eAAe,WAAW,UAAU;AAQ5C,SAAO,CACL;GACE,GATS,cAAc,QAAQ;IACjC,MAAM,UAAU,OAAO,KAAK;IAC5B,SAAS;IACT,MAAM;IACN,WAAW,OAAO;IACnB,CAAC;GAKE,SAAS,CACP;IACE,MAAM,UAAU,OAAO,KAAK;IAC5B,cAAc;IACd,aAAa;IACb,OAAO,KAAK,UAAU,OAAO,MAAM;IACpC,CACF;GACD,QAAQ,UAAU;IAChB,KAAK,UAAU,QAAQ;IACvB,QAAQ,OAAO,QAAQ;IACvB,QAAQ,cAAc;IACvB,CAAC;GACF,QAAQ,UAAU;IAAE,KAAK,UAAU,QAAQ;IAAK,QAAQ,OAAO,QAAQ;IAAQ,CAAC;GACjF,CACF;;CAEJ,CAAC"}
|
package/dist/generators.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_generators = require("./generators-
|
|
2
|
+
const require_generators = require("./generators-CBlzDhTh.cjs");
|
|
3
3
|
exports.createGenerator = require_generators.createGenerator;
|
|
4
4
|
exports.createReactGenerator = require_generators.createReactGenerator;
|
|
5
5
|
exports.jsonGenerator = require_generators.jsonGenerator;
|
package/dist/generators.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
|
-
import { a as createReactGenerator, n as createGenerator, r as Generator, t as CoreGenerator, y as PluginOas } from "./createGenerator-
|
|
2
|
+
import { a as createReactGenerator, n as createGenerator, r as Generator, t as CoreGenerator, y as PluginOas } from "./createGenerator-B98OshdQ.js";
|
|
3
3
|
//#region src/generators/jsonGenerator.d.ts
|
|
4
4
|
declare const jsonGenerator: CoreGenerator<PluginOas>;
|
|
5
5
|
//#endregion
|
package/dist/generators.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as createReactGenerator, r as createGenerator, t as jsonGenerator } from "./generators-
|
|
1
|
+
import { n as createReactGenerator, r as createGenerator, t as jsonGenerator } from "./generators-DRPPf38p.js";
|
|
2
2
|
export { createGenerator, createReactGenerator, jsonGenerator };
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
const require_chunk = require("./chunk-ByKO4r7w.cjs");
|
|
2
|
+
let node_path = require("node:path");
|
|
3
|
+
node_path = require_chunk.__toESM(node_path);
|
|
4
|
+
let remeda = require("remeda");
|
|
5
|
+
//#region ../../internals/utils/src/casing.ts
|
|
6
|
+
/**
|
|
7
|
+
* Shared implementation for camelCase and PascalCase conversion.
|
|
8
|
+
* Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)
|
|
9
|
+
* and capitalizes each word according to `pascal`.
|
|
10
|
+
*
|
|
11
|
+
* When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.
|
|
12
|
+
*/
|
|
13
|
+
function toCamelOrPascal(text, pascal) {
|
|
14
|
+
return text.trim().replace(/([a-z\d])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").replace(/(\d)([a-z])/g, "$1 $2").split(/[\s\-_./\\:]+/).filter(Boolean).map((word, i) => {
|
|
15
|
+
if (word.length > 1 && word === word.toUpperCase()) return word;
|
|
16
|
+
if (i === 0 && !pascal) return word.charAt(0).toLowerCase() + word.slice(1);
|
|
17
|
+
return word.charAt(0).toUpperCase() + word.slice(1);
|
|
18
|
+
}).join("").replace(/[^a-zA-Z0-9]/g, "");
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Splits `text` on `.` and applies `transformPart` to each segment.
|
|
22
|
+
* The last segment receives `isLast = true`, all earlier segments receive `false`.
|
|
23
|
+
* Segments are joined with `/` to form a file path.
|
|
24
|
+
*/
|
|
25
|
+
function applyToFileParts(text, transformPart) {
|
|
26
|
+
const parts = text.split(".");
|
|
27
|
+
return parts.map((part, i) => transformPart(part, i === parts.length - 1)).join("/");
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Converts `text` to camelCase.
|
|
31
|
+
* When `isFile` is `true`, dot-separated segments are each cased independently and joined with `/`.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* camelCase('hello-world') // 'helloWorld'
|
|
35
|
+
* camelCase('pet.petId', { isFile: true }) // 'pet/petId'
|
|
36
|
+
*/
|
|
37
|
+
function camelCase(text, { isFile, prefix = "", suffix = "" } = {}) {
|
|
38
|
+
if (isFile) return applyToFileParts(text, (part, isLast) => camelCase(part, isLast ? {
|
|
39
|
+
prefix,
|
|
40
|
+
suffix
|
|
41
|
+
} : {}));
|
|
42
|
+
return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Converts `text` to PascalCase.
|
|
46
|
+
* When `isFile` is `true`, the last dot-separated segment is PascalCased and earlier segments are camelCased.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* pascalCase('hello-world') // 'HelloWorld'
|
|
50
|
+
* pascalCase('pet.petId', { isFile: true }) // 'pet/PetId'
|
|
51
|
+
*/
|
|
52
|
+
function pascalCase(text, { isFile, prefix = "", suffix = "" } = {}) {
|
|
53
|
+
if (isFile) return applyToFileParts(text, (part, isLast) => isLast ? pascalCase(part, {
|
|
54
|
+
prefix,
|
|
55
|
+
suffix
|
|
56
|
+
}) : camelCase(part));
|
|
57
|
+
return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true);
|
|
58
|
+
}
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region src/utils/getBanner.ts
|
|
61
|
+
/**
|
|
62
|
+
* Generate a default banner for files created by Kubb
|
|
63
|
+
* @returns A string with the default banner
|
|
64
|
+
*/
|
|
65
|
+
function getDefaultBanner({ title, description, version, config }) {
|
|
66
|
+
try {
|
|
67
|
+
let source = "";
|
|
68
|
+
if ("path" in config.input) source = node_path.default.basename(config.input.path);
|
|
69
|
+
else if ("data" in config.input) source = "text content";
|
|
70
|
+
let banner = "/**\n* Generated by Kubb (https://kubb.dev/).\n* Do not edit manually.\n";
|
|
71
|
+
if (config.output.defaultBanner === "simple") {
|
|
72
|
+
banner += "*/\n";
|
|
73
|
+
return banner;
|
|
74
|
+
}
|
|
75
|
+
if (source) banner += `* Source: ${source}\n`;
|
|
76
|
+
if (title) banner += `* Title: ${title}\n`;
|
|
77
|
+
if (description) {
|
|
78
|
+
const formattedDescription = description.replace(/\n/gm, "\n* ");
|
|
79
|
+
banner += `* Description: ${formattedDescription}\n`;
|
|
80
|
+
}
|
|
81
|
+
if (version) banner += `* OpenAPI spec version: ${version}\n`;
|
|
82
|
+
banner += "*/\n";
|
|
83
|
+
return banner;
|
|
84
|
+
} catch (_error) {
|
|
85
|
+
return "/**\n* Generated by Kubb (https://kubb.dev/).\n* Do not edit manually.\n*/";
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function getBanner({ output, oas, config }) {
|
|
89
|
+
let banner = "";
|
|
90
|
+
if (config?.output?.defaultBanner !== false && config) {
|
|
91
|
+
const { title, description, version } = oas.api?.info || {};
|
|
92
|
+
banner = getDefaultBanner({
|
|
93
|
+
title,
|
|
94
|
+
description,
|
|
95
|
+
version,
|
|
96
|
+
config
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
if (!output.banner) return banner;
|
|
100
|
+
if ((0, remeda.isFunction)(output.banner)) return `${output.banner(oas)}\n${banner}`;
|
|
101
|
+
return `${output.banner}\n${banner}`;
|
|
102
|
+
}
|
|
103
|
+
//#endregion
|
|
104
|
+
//#region src/utils/getFooter.ts
|
|
105
|
+
function getFooter({ output, oas }) {
|
|
106
|
+
if (!output.footer) return;
|
|
107
|
+
if ((0, remeda.isFunction)(output.footer)) return output.footer(oas);
|
|
108
|
+
return output.footer;
|
|
109
|
+
}
|
|
110
|
+
//#endregion
|
|
111
|
+
Object.defineProperty(exports, "camelCase", {
|
|
112
|
+
enumerable: true,
|
|
113
|
+
get: function() {
|
|
114
|
+
return camelCase;
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
Object.defineProperty(exports, "getBanner", {
|
|
118
|
+
enumerable: true,
|
|
119
|
+
get: function() {
|
|
120
|
+
return getBanner;
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
Object.defineProperty(exports, "getFooter", {
|
|
124
|
+
enumerable: true,
|
|
125
|
+
get: function() {
|
|
126
|
+
return getFooter;
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
Object.defineProperty(exports, "pascalCase", {
|
|
130
|
+
enumerable: true,
|
|
131
|
+
get: function() {
|
|
132
|
+
return pascalCase;
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
//# sourceMappingURL=getFooter-BBzsC616.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getFooter-BBzsC616.cjs","names":["path"],"sources":["../../../internals/utils/src/casing.ts","../src/utils/getBanner.ts","../src/utils/getFooter.ts"],"sourcesContent":["type Options = {\n /** When `true`, dot-separated segments are split on `.` and joined with `/` after casing. */\n isFile?: boolean\n /** Text prepended before casing is applied. */\n prefix?: string\n /** Text appended before casing is applied. */\n suffix?: string\n}\n\n/**\n * Shared implementation for camelCase and PascalCase conversion.\n * Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)\n * and capitalizes each word according to `pascal`.\n *\n * When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.\n */\nfunction toCamelOrPascal(text: string, pascal: boolean): string {\n const normalized = text\n .trim()\n .replace(/([a-z\\d])([A-Z])/g, '$1 $2')\n .replace(/([A-Z]+)([A-Z][a-z])/g, '$1 $2')\n .replace(/(\\d)([a-z])/g, '$1 $2')\n\n const words = normalized.split(/[\\s\\-_./\\\\:]+/).filter(Boolean)\n\n return words\n .map((word, i) => {\n const allUpper = word.length > 1 && word === word.toUpperCase()\n if (allUpper) return word\n if (i === 0 && !pascal) return word.charAt(0).toLowerCase() + word.slice(1)\n return word.charAt(0).toUpperCase() + word.slice(1)\n })\n .join('')\n .replace(/[^a-zA-Z0-9]/g, '')\n}\n\n/**\n * Splits `text` on `.` and applies `transformPart` to each segment.\n * The last segment receives `isLast = true`, all earlier segments receive `false`.\n * Segments are joined with `/` to form a file path.\n */\nfunction applyToFileParts(text: string, transformPart: (part: string, isLast: boolean) => string): string {\n const parts = text.split('.')\n return parts.map((part, i) => transformPart(part, i === parts.length - 1)).join('/')\n}\n\n/**\n * Converts `text` to camelCase.\n * When `isFile` is `true`, dot-separated segments are each cased independently and joined with `/`.\n *\n * @example\n * camelCase('hello-world') // 'helloWorld'\n * camelCase('pet.petId', { isFile: true }) // 'pet/petId'\n */\nexport function camelCase(text: string, { isFile, prefix = '', suffix = '' }: Options = {}): string {\n if (isFile) {\n return applyToFileParts(text, (part, isLast) => camelCase(part, isLast ? { prefix, suffix } : {}))\n }\n\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false)\n}\n\n/**\n * Converts `text` to PascalCase.\n * When `isFile` is `true`, the last dot-separated segment is PascalCased and earlier segments are camelCased.\n *\n * @example\n * pascalCase('hello-world') // 'HelloWorld'\n * pascalCase('pet.petId', { isFile: true }) // 'pet/PetId'\n */\nexport function pascalCase(text: string, { isFile, prefix = '', suffix = '' }: Options = {}): string {\n if (isFile) {\n return applyToFileParts(text, (part, isLast) => (isLast ? pascalCase(part, { prefix, suffix }) : camelCase(part)))\n }\n\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true)\n}\n\n/**\n * Converts `text` to snake_case.\n *\n * @example\n * snakeCase('helloWorld') // 'hello_world'\n * snakeCase('Hello-World') // 'hello_world'\n */\nexport function snakeCase(text: string, { prefix = '', suffix = '' }: Omit<Options, 'isFile'> = {}): string {\n const processed = `${prefix} ${text} ${suffix}`.trim()\n return processed\n .replace(/([a-z])([A-Z])/g, '$1_$2')\n .replace(/[\\s\\-.]+/g, '_')\n .replace(/[^a-zA-Z0-9_]/g, '')\n .toLowerCase()\n .split('_')\n .filter(Boolean)\n .join('_')\n}\n\n/**\n * Converts `text` to SCREAMING_SNAKE_CASE.\n *\n * @example\n * screamingSnakeCase('helloWorld') // 'HELLO_WORLD'\n */\nexport function screamingSnakeCase(text: string, { prefix = '', suffix = '' }: Omit<Options, 'isFile'> = {}): string {\n return snakeCase(text, { prefix, suffix }).toUpperCase()\n}\n","import path from 'node:path'\nimport type { Config, Output } from '@kubb/core'\nimport type { Oas } from '@kubb/oas'\nimport { isFunction } from 'remeda'\n\ntype Props<TOas extends Oas> = {\n oas: TOas\n output: Output<any>\n config?: Config\n}\n\n/**\n * Generate a default banner for files created by Kubb\n * @returns A string with the default banner\n */\nfunction getDefaultBanner({ title, description, version, config }: { title?: string; description?: string; version?: string; config: Config }): string {\n try {\n let source = ''\n if ('path' in config.input) {\n source = path.basename(config.input.path)\n } else if ('data' in config.input) {\n source = 'text content'\n }\n\n let banner = '/**\\n* Generated by Kubb (https://kubb.dev/).\\n* Do not edit manually.\\n'\n\n if (config.output.defaultBanner === 'simple') {\n banner += '*/\\n'\n return banner\n }\n\n if (source) {\n banner += `* Source: ${source}\\n`\n }\n\n if (title) {\n banner += `* Title: ${title}\\n`\n }\n\n if (description) {\n const formattedDescription = description.replace(/\\n/gm, '\\n* ')\n banner += `* Description: ${formattedDescription}\\n`\n }\n\n if (version) {\n banner += `* OpenAPI spec version: ${version}\\n`\n }\n\n banner += '*/\\n'\n return banner\n } catch (_error) {\n // If there's any error in parsing the Oas data, return a simpler banner\n return '/**\\n* Generated by Kubb (https://kubb.dev/).\\n* Do not edit manually.\\n*/'\n }\n}\n\nexport function getBanner<TOas extends Oas>({ output, oas, config }: Props<TOas>): string {\n let banner = ''\n if (config?.output?.defaultBanner !== false && config) {\n const { title, description, version } = oas.api?.info || {}\n\n banner = getDefaultBanner({ title, description, version, config })\n }\n\n if (!output.banner) {\n return banner\n }\n\n if (isFunction(output.banner)) {\n return `${output.banner(oas)}\\n${banner}`\n }\n\n return `${output.banner}\\n${banner}`\n}\n","import type { Output } from '@kubb/core'\nimport type { Oas } from '@kubb/oas'\nimport { isFunction } from 'remeda'\n\ntype Props<TOas extends Oas> = {\n oas: TOas\n output: Output<any>\n}\n\nexport function getFooter<TOas extends Oas>({ output, oas }: Props<TOas>) {\n if (!output.footer) {\n return undefined\n }\n\n if (isFunction(output.footer)) {\n return output.footer(oas)\n }\n\n return output.footer\n}\n"],"mappings":";;;;;;;;;;;;AAgBA,SAAS,gBAAgB,MAAc,QAAyB;AAS9D,QARmB,KAChB,MAAM,CACN,QAAQ,qBAAqB,QAAQ,CACrC,QAAQ,yBAAyB,QAAQ,CACzC,QAAQ,gBAAgB,QAAQ,CAEV,MAAM,gBAAgB,CAAC,OAAO,QAAQ,CAG5D,KAAK,MAAM,MAAM;AAEhB,MADiB,KAAK,SAAS,KAAK,SAAS,KAAK,aAAa,CACjD,QAAO;AACrB,MAAI,MAAM,KAAK,CAAC,OAAQ,QAAO,KAAK,OAAO,EAAE,CAAC,aAAa,GAAG,KAAK,MAAM,EAAE;AAC3E,SAAO,KAAK,OAAO,EAAE,CAAC,aAAa,GAAG,KAAK,MAAM,EAAE;GACnD,CACD,KAAK,GAAG,CACR,QAAQ,iBAAiB,GAAG;;;;;;;AAQjC,SAAS,iBAAiB,MAAc,eAAkE;CACxG,MAAM,QAAQ,KAAK,MAAM,IAAI;AAC7B,QAAO,MAAM,KAAK,MAAM,MAAM,cAAc,MAAM,MAAM,MAAM,SAAS,EAAE,CAAC,CAAC,KAAK,IAAI;;;;;;;;;;AAWtF,SAAgB,UAAU,MAAc,EAAE,QAAQ,SAAS,IAAI,SAAS,OAAgB,EAAE,EAAU;AAClG,KAAI,OACF,QAAO,iBAAiB,OAAO,MAAM,WAAW,UAAU,MAAM,SAAS;EAAE;EAAQ;EAAQ,GAAG,EAAE,CAAC,CAAC;AAGpG,QAAO,gBAAgB,GAAG,OAAO,GAAG,KAAK,GAAG,UAAU,MAAM;;;;;;;;;;AAW9D,SAAgB,WAAW,MAAc,EAAE,QAAQ,SAAS,IAAI,SAAS,OAAgB,EAAE,EAAU;AACnG,KAAI,OACF,QAAO,iBAAiB,OAAO,MAAM,WAAY,SAAS,WAAW,MAAM;EAAE;EAAQ;EAAQ,CAAC,GAAG,UAAU,KAAK,CAAE;AAGpH,QAAO,gBAAgB,GAAG,OAAO,GAAG,KAAK,GAAG,UAAU,KAAK;;;;;;;;AC5D7D,SAAS,iBAAiB,EAAE,OAAO,aAAa,SAAS,UAA8F;AACrJ,KAAI;EACF,IAAI,SAAS;AACb,MAAI,UAAU,OAAO,MACnB,UAASA,UAAAA,QAAK,SAAS,OAAO,MAAM,KAAK;WAChC,UAAU,OAAO,MAC1B,UAAS;EAGX,IAAI,SAAS;AAEb,MAAI,OAAO,OAAO,kBAAkB,UAAU;AAC5C,aAAU;AACV,UAAO;;AAGT,MAAI,OACF,WAAU,aAAa,OAAO;AAGhC,MAAI,MACF,WAAU,YAAY,MAAM;AAG9B,MAAI,aAAa;GACf,MAAM,uBAAuB,YAAY,QAAQ,QAAQ,OAAO;AAChE,aAAU,kBAAkB,qBAAqB;;AAGnD,MAAI,QACF,WAAU,2BAA2B,QAAQ;AAG/C,YAAU;AACV,SAAO;UACA,QAAQ;AAEf,SAAO;;;AAIX,SAAgB,UAA4B,EAAE,QAAQ,KAAK,UAA+B;CACxF,IAAI,SAAS;AACb,KAAI,QAAQ,QAAQ,kBAAkB,SAAS,QAAQ;EACrD,MAAM,EAAE,OAAO,aAAa,YAAY,IAAI,KAAK,QAAQ,EAAE;AAE3D,WAAS,iBAAiB;GAAE;GAAO;GAAa;GAAS;GAAQ,CAAC;;AAGpE,KAAI,CAAC,OAAO,OACV,QAAO;AAGT,MAAA,GAAA,OAAA,YAAe,OAAO,OAAO,CAC3B,QAAO,GAAG,OAAO,OAAO,IAAI,CAAC,IAAI;AAGnC,QAAO,GAAG,OAAO,OAAO,IAAI;;;;AC/D9B,SAAgB,UAA4B,EAAE,QAAQ,OAAoB;AACxE,KAAI,CAAC,OAAO,OACV;AAGF,MAAA,GAAA,OAAA,YAAe,OAAO,OAAO,CAC3B,QAAO,OAAO,OAAO,IAAI;AAG3B,QAAO,OAAO"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import "./chunk--u3MIqq1.js";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { isFunction } from "remeda";
|
|
4
|
+
//#region ../../internals/utils/src/casing.ts
|
|
5
|
+
/**
|
|
6
|
+
* Shared implementation for camelCase and PascalCase conversion.
|
|
7
|
+
* Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)
|
|
8
|
+
* and capitalizes each word according to `pascal`.
|
|
9
|
+
*
|
|
10
|
+
* When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.
|
|
11
|
+
*/
|
|
12
|
+
function toCamelOrPascal(text, pascal) {
|
|
13
|
+
return text.trim().replace(/([a-z\d])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").replace(/(\d)([a-z])/g, "$1 $2").split(/[\s\-_./\\:]+/).filter(Boolean).map((word, i) => {
|
|
14
|
+
if (word.length > 1 && word === word.toUpperCase()) return word;
|
|
15
|
+
if (i === 0 && !pascal) return word.charAt(0).toLowerCase() + word.slice(1);
|
|
16
|
+
return word.charAt(0).toUpperCase() + word.slice(1);
|
|
17
|
+
}).join("").replace(/[^a-zA-Z0-9]/g, "");
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Splits `text` on `.` and applies `transformPart` to each segment.
|
|
21
|
+
* The last segment receives `isLast = true`, all earlier segments receive `false`.
|
|
22
|
+
* Segments are joined with `/` to form a file path.
|
|
23
|
+
*/
|
|
24
|
+
function applyToFileParts(text, transformPart) {
|
|
25
|
+
const parts = text.split(".");
|
|
26
|
+
return parts.map((part, i) => transformPart(part, i === parts.length - 1)).join("/");
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Converts `text` to camelCase.
|
|
30
|
+
* When `isFile` is `true`, dot-separated segments are each cased independently and joined with `/`.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* camelCase('hello-world') // 'helloWorld'
|
|
34
|
+
* camelCase('pet.petId', { isFile: true }) // 'pet/petId'
|
|
35
|
+
*/
|
|
36
|
+
function camelCase(text, { isFile, prefix = "", suffix = "" } = {}) {
|
|
37
|
+
if (isFile) return applyToFileParts(text, (part, isLast) => camelCase(part, isLast ? {
|
|
38
|
+
prefix,
|
|
39
|
+
suffix
|
|
40
|
+
} : {}));
|
|
41
|
+
return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Converts `text` to PascalCase.
|
|
45
|
+
* When `isFile` is `true`, the last dot-separated segment is PascalCased and earlier segments are camelCased.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* pascalCase('hello-world') // 'HelloWorld'
|
|
49
|
+
* pascalCase('pet.petId', { isFile: true }) // 'pet/PetId'
|
|
50
|
+
*/
|
|
51
|
+
function pascalCase(text, { isFile, prefix = "", suffix = "" } = {}) {
|
|
52
|
+
if (isFile) return applyToFileParts(text, (part, isLast) => isLast ? pascalCase(part, {
|
|
53
|
+
prefix,
|
|
54
|
+
suffix
|
|
55
|
+
}) : camelCase(part));
|
|
56
|
+
return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true);
|
|
57
|
+
}
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region src/utils/getBanner.ts
|
|
60
|
+
/**
|
|
61
|
+
* Generate a default banner for files created by Kubb
|
|
62
|
+
* @returns A string with the default banner
|
|
63
|
+
*/
|
|
64
|
+
function getDefaultBanner({ title, description, version, config }) {
|
|
65
|
+
try {
|
|
66
|
+
let source = "";
|
|
67
|
+
if ("path" in config.input) source = path.basename(config.input.path);
|
|
68
|
+
else if ("data" in config.input) source = "text content";
|
|
69
|
+
let banner = "/**\n* Generated by Kubb (https://kubb.dev/).\n* Do not edit manually.\n";
|
|
70
|
+
if (config.output.defaultBanner === "simple") {
|
|
71
|
+
banner += "*/\n";
|
|
72
|
+
return banner;
|
|
73
|
+
}
|
|
74
|
+
if (source) banner += `* Source: ${source}\n`;
|
|
75
|
+
if (title) banner += `* Title: ${title}\n`;
|
|
76
|
+
if (description) {
|
|
77
|
+
const formattedDescription = description.replace(/\n/gm, "\n* ");
|
|
78
|
+
banner += `* Description: ${formattedDescription}\n`;
|
|
79
|
+
}
|
|
80
|
+
if (version) banner += `* OpenAPI spec version: ${version}\n`;
|
|
81
|
+
banner += "*/\n";
|
|
82
|
+
return banner;
|
|
83
|
+
} catch (_error) {
|
|
84
|
+
return "/**\n* Generated by Kubb (https://kubb.dev/).\n* Do not edit manually.\n*/";
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function getBanner({ output, oas, config }) {
|
|
88
|
+
let banner = "";
|
|
89
|
+
if (config?.output?.defaultBanner !== false && config) {
|
|
90
|
+
const { title, description, version } = oas.api?.info || {};
|
|
91
|
+
banner = getDefaultBanner({
|
|
92
|
+
title,
|
|
93
|
+
description,
|
|
94
|
+
version,
|
|
95
|
+
config
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
if (!output.banner) return banner;
|
|
99
|
+
if (isFunction(output.banner)) return `${output.banner(oas)}\n${banner}`;
|
|
100
|
+
return `${output.banner}\n${banner}`;
|
|
101
|
+
}
|
|
102
|
+
//#endregion
|
|
103
|
+
//#region src/utils/getFooter.ts
|
|
104
|
+
function getFooter({ output, oas }) {
|
|
105
|
+
if (!output.footer) return;
|
|
106
|
+
if (isFunction(output.footer)) return output.footer(oas);
|
|
107
|
+
return output.footer;
|
|
108
|
+
}
|
|
109
|
+
//#endregion
|
|
110
|
+
export { pascalCase as i, getBanner as n, camelCase as r, getFooter as t };
|
|
111
|
+
|
|
112
|
+
//# sourceMappingURL=getFooter-Pw3tLCiV.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getFooter-Pw3tLCiV.js","names":[],"sources":["../../../internals/utils/src/casing.ts","../src/utils/getBanner.ts","../src/utils/getFooter.ts"],"sourcesContent":["type Options = {\n /** When `true`, dot-separated segments are split on `.` and joined with `/` after casing. */\n isFile?: boolean\n /** Text prepended before casing is applied. */\n prefix?: string\n /** Text appended before casing is applied. */\n suffix?: string\n}\n\n/**\n * Shared implementation for camelCase and PascalCase conversion.\n * Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)\n * and capitalizes each word according to `pascal`.\n *\n * When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.\n */\nfunction toCamelOrPascal(text: string, pascal: boolean): string {\n const normalized = text\n .trim()\n .replace(/([a-z\\d])([A-Z])/g, '$1 $2')\n .replace(/([A-Z]+)([A-Z][a-z])/g, '$1 $2')\n .replace(/(\\d)([a-z])/g, '$1 $2')\n\n const words = normalized.split(/[\\s\\-_./\\\\:]+/).filter(Boolean)\n\n return words\n .map((word, i) => {\n const allUpper = word.length > 1 && word === word.toUpperCase()\n if (allUpper) return word\n if (i === 0 && !pascal) return word.charAt(0).toLowerCase() + word.slice(1)\n return word.charAt(0).toUpperCase() + word.slice(1)\n })\n .join('')\n .replace(/[^a-zA-Z0-9]/g, '')\n}\n\n/**\n * Splits `text` on `.` and applies `transformPart` to each segment.\n * The last segment receives `isLast = true`, all earlier segments receive `false`.\n * Segments are joined with `/` to form a file path.\n */\nfunction applyToFileParts(text: string, transformPart: (part: string, isLast: boolean) => string): string {\n const parts = text.split('.')\n return parts.map((part, i) => transformPart(part, i === parts.length - 1)).join('/')\n}\n\n/**\n * Converts `text` to camelCase.\n * When `isFile` is `true`, dot-separated segments are each cased independently and joined with `/`.\n *\n * @example\n * camelCase('hello-world') // 'helloWorld'\n * camelCase('pet.petId', { isFile: true }) // 'pet/petId'\n */\nexport function camelCase(text: string, { isFile, prefix = '', suffix = '' }: Options = {}): string {\n if (isFile) {\n return applyToFileParts(text, (part, isLast) => camelCase(part, isLast ? { prefix, suffix } : {}))\n }\n\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false)\n}\n\n/**\n * Converts `text` to PascalCase.\n * When `isFile` is `true`, the last dot-separated segment is PascalCased and earlier segments are camelCased.\n *\n * @example\n * pascalCase('hello-world') // 'HelloWorld'\n * pascalCase('pet.petId', { isFile: true }) // 'pet/PetId'\n */\nexport function pascalCase(text: string, { isFile, prefix = '', suffix = '' }: Options = {}): string {\n if (isFile) {\n return applyToFileParts(text, (part, isLast) => (isLast ? pascalCase(part, { prefix, suffix }) : camelCase(part)))\n }\n\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true)\n}\n\n/**\n * Converts `text` to snake_case.\n *\n * @example\n * snakeCase('helloWorld') // 'hello_world'\n * snakeCase('Hello-World') // 'hello_world'\n */\nexport function snakeCase(text: string, { prefix = '', suffix = '' }: Omit<Options, 'isFile'> = {}): string {\n const processed = `${prefix} ${text} ${suffix}`.trim()\n return processed\n .replace(/([a-z])([A-Z])/g, '$1_$2')\n .replace(/[\\s\\-.]+/g, '_')\n .replace(/[^a-zA-Z0-9_]/g, '')\n .toLowerCase()\n .split('_')\n .filter(Boolean)\n .join('_')\n}\n\n/**\n * Converts `text` to SCREAMING_SNAKE_CASE.\n *\n * @example\n * screamingSnakeCase('helloWorld') // 'HELLO_WORLD'\n */\nexport function screamingSnakeCase(text: string, { prefix = '', suffix = '' }: Omit<Options, 'isFile'> = {}): string {\n return snakeCase(text, { prefix, suffix }).toUpperCase()\n}\n","import path from 'node:path'\nimport type { Config, Output } from '@kubb/core'\nimport type { Oas } from '@kubb/oas'\nimport { isFunction } from 'remeda'\n\ntype Props<TOas extends Oas> = {\n oas: TOas\n output: Output<any>\n config?: Config\n}\n\n/**\n * Generate a default banner for files created by Kubb\n * @returns A string with the default banner\n */\nfunction getDefaultBanner({ title, description, version, config }: { title?: string; description?: string; version?: string; config: Config }): string {\n try {\n let source = ''\n if ('path' in config.input) {\n source = path.basename(config.input.path)\n } else if ('data' in config.input) {\n source = 'text content'\n }\n\n let banner = '/**\\n* Generated by Kubb (https://kubb.dev/).\\n* Do not edit manually.\\n'\n\n if (config.output.defaultBanner === 'simple') {\n banner += '*/\\n'\n return banner\n }\n\n if (source) {\n banner += `* Source: ${source}\\n`\n }\n\n if (title) {\n banner += `* Title: ${title}\\n`\n }\n\n if (description) {\n const formattedDescription = description.replace(/\\n/gm, '\\n* ')\n banner += `* Description: ${formattedDescription}\\n`\n }\n\n if (version) {\n banner += `* OpenAPI spec version: ${version}\\n`\n }\n\n banner += '*/\\n'\n return banner\n } catch (_error) {\n // If there's any error in parsing the Oas data, return a simpler banner\n return '/**\\n* Generated by Kubb (https://kubb.dev/).\\n* Do not edit manually.\\n*/'\n }\n}\n\nexport function getBanner<TOas extends Oas>({ output, oas, config }: Props<TOas>): string {\n let banner = ''\n if (config?.output?.defaultBanner !== false && config) {\n const { title, description, version } = oas.api?.info || {}\n\n banner = getDefaultBanner({ title, description, version, config })\n }\n\n if (!output.banner) {\n return banner\n }\n\n if (isFunction(output.banner)) {\n return `${output.banner(oas)}\\n${banner}`\n }\n\n return `${output.banner}\\n${banner}`\n}\n","import type { Output } from '@kubb/core'\nimport type { Oas } from '@kubb/oas'\nimport { isFunction } from 'remeda'\n\ntype Props<TOas extends Oas> = {\n oas: TOas\n output: Output<any>\n}\n\nexport function getFooter<TOas extends Oas>({ output, oas }: Props<TOas>) {\n if (!output.footer) {\n return undefined\n }\n\n if (isFunction(output.footer)) {\n return output.footer(oas)\n }\n\n return output.footer\n}\n"],"mappings":";;;;;;;;;;;AAgBA,SAAS,gBAAgB,MAAc,QAAyB;AAS9D,QARmB,KAChB,MAAM,CACN,QAAQ,qBAAqB,QAAQ,CACrC,QAAQ,yBAAyB,QAAQ,CACzC,QAAQ,gBAAgB,QAAQ,CAEV,MAAM,gBAAgB,CAAC,OAAO,QAAQ,CAG5D,KAAK,MAAM,MAAM;AAEhB,MADiB,KAAK,SAAS,KAAK,SAAS,KAAK,aAAa,CACjD,QAAO;AACrB,MAAI,MAAM,KAAK,CAAC,OAAQ,QAAO,KAAK,OAAO,EAAE,CAAC,aAAa,GAAG,KAAK,MAAM,EAAE;AAC3E,SAAO,KAAK,OAAO,EAAE,CAAC,aAAa,GAAG,KAAK,MAAM,EAAE;GACnD,CACD,KAAK,GAAG,CACR,QAAQ,iBAAiB,GAAG;;;;;;;AAQjC,SAAS,iBAAiB,MAAc,eAAkE;CACxG,MAAM,QAAQ,KAAK,MAAM,IAAI;AAC7B,QAAO,MAAM,KAAK,MAAM,MAAM,cAAc,MAAM,MAAM,MAAM,SAAS,EAAE,CAAC,CAAC,KAAK,IAAI;;;;;;;;;;AAWtF,SAAgB,UAAU,MAAc,EAAE,QAAQ,SAAS,IAAI,SAAS,OAAgB,EAAE,EAAU;AAClG,KAAI,OACF,QAAO,iBAAiB,OAAO,MAAM,WAAW,UAAU,MAAM,SAAS;EAAE;EAAQ;EAAQ,GAAG,EAAE,CAAC,CAAC;AAGpG,QAAO,gBAAgB,GAAG,OAAO,GAAG,KAAK,GAAG,UAAU,MAAM;;;;;;;;;;AAW9D,SAAgB,WAAW,MAAc,EAAE,QAAQ,SAAS,IAAI,SAAS,OAAgB,EAAE,EAAU;AACnG,KAAI,OACF,QAAO,iBAAiB,OAAO,MAAM,WAAY,SAAS,WAAW,MAAM;EAAE;EAAQ;EAAQ,CAAC,GAAG,UAAU,KAAK,CAAE;AAGpH,QAAO,gBAAgB,GAAG,OAAO,GAAG,KAAK,GAAG,UAAU,KAAK;;;;;;;;AC5D7D,SAAS,iBAAiB,EAAE,OAAO,aAAa,SAAS,UAA8F;AACrJ,KAAI;EACF,IAAI,SAAS;AACb,MAAI,UAAU,OAAO,MACnB,UAAS,KAAK,SAAS,OAAO,MAAM,KAAK;WAChC,UAAU,OAAO,MAC1B,UAAS;EAGX,IAAI,SAAS;AAEb,MAAI,OAAO,OAAO,kBAAkB,UAAU;AAC5C,aAAU;AACV,UAAO;;AAGT,MAAI,OACF,WAAU,aAAa,OAAO;AAGhC,MAAI,MACF,WAAU,YAAY,MAAM;AAG9B,MAAI,aAAa;GACf,MAAM,uBAAuB,YAAY,QAAQ,QAAQ,OAAO;AAChE,aAAU,kBAAkB,qBAAqB;;AAGnD,MAAI,QACF,WAAU,2BAA2B,QAAQ;AAG/C,YAAU;AACV,SAAO;UACA,QAAQ;AAEf,SAAO;;;AAIX,SAAgB,UAA4B,EAAE,QAAQ,KAAK,UAA+B;CACxF,IAAI,SAAS;AACb,KAAI,QAAQ,QAAQ,kBAAkB,SAAS,QAAQ;EACrD,MAAM,EAAE,OAAO,aAAa,YAAY,IAAI,KAAK,QAAQ,EAAE;AAE3D,WAAS,iBAAiB;GAAE;GAAO;GAAa;GAAS;GAAQ,CAAC;;AAGpE,KAAI,CAAC,OAAO,OACV,QAAO;AAGT,KAAI,WAAW,OAAO,OAAO,CAC3B,QAAO,GAAG,OAAO,OAAO,IAAI,CAAC,IAAI;AAGnC,QAAO,GAAG,OAAO,OAAO,IAAI;;;;AC/D9B,SAAgB,UAA4B,EAAE,QAAQ,OAAoB;AACxE,KAAI,CAAC,OAAO,OACV;AAGF,KAAI,WAAW,OAAO,OAAO,CAC3B,QAAO,OAAO,OAAO,IAAI;AAG3B,QAAO,OAAO"}
|
package/dist/hooks.cjs
CHANGED
|
@@ -29,7 +29,7 @@ function useOperationManager(generator) {
|
|
|
29
29
|
};
|
|
30
30
|
};
|
|
31
31
|
const getSchemas = (operation, params) => {
|
|
32
|
-
if (!generator) throw new Error(`'generator' is not
|
|
32
|
+
if (!generator) throw new Error(`useOperationManager: 'generator' parameter is required but was not provided`);
|
|
33
33
|
return generator.getSchemas(operation, { resolveName: (name) => pluginManager.resolveName({
|
|
34
34
|
name,
|
|
35
35
|
pluginKey: params?.pluginKey,
|
|
@@ -65,7 +65,7 @@ function useOperationManager(generator) {
|
|
|
65
65
|
};
|
|
66
66
|
};
|
|
67
67
|
const groupSchemasByName = (operation, { pluginKey = plugin.key, type }) => {
|
|
68
|
-
if (!generator) throw new Error(`'generator' is not
|
|
68
|
+
if (!generator) throw new Error(`useOperationManager: 'generator' parameter is required but was not provided`);
|
|
69
69
|
const schemas = generator.getSchemas(operation);
|
|
70
70
|
const errors = (schemas.errors || []).reduce((prev, acc) => {
|
|
71
71
|
if (!acc.statusCode) return prev;
|