@kubb/plugin-oas 4.3.0 → 4.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{Oas--cvTRMTA.cjs → Oas-BzrQ6RGC.cjs} +11 -11
- package/dist/Oas-BzrQ6RGC.cjs.map +1 -0
- package/dist/{Oas-DoN76W2_.js → Oas-CIeHKOo0.js} +3 -3
- package/dist/Oas-CIeHKOo0.js.map +1 -0
- package/dist/{OperationGenerator-ki8g970_.d.ts → OperationGenerator-BZPWkxw4.d.ts} +164 -92
- package/dist/{OperationGenerator-XkW6FZJh.d.cts → OperationGenerator-CJTAer7l.d.cts} +163 -91
- package/dist/{Schema-CHstINXC.d.ts → Schema-CjraJhJi.d.ts} +7 -6
- package/dist/{Schema-BXYfUkqN.d.cts → Schema-zcZF0UIp.d.cts} +6 -5
- package/dist/{SchemaGenerator-B07tXh1b.js → SchemaGenerator-7wBwdv8G.js} +21 -4
- package/dist/{SchemaGenerator-B07tXh1b.js.map → SchemaGenerator-7wBwdv8G.js.map} +1 -1
- package/dist/{SchemaGenerator-DsK0wuii.cjs → SchemaGenerator-DzVHk6OP.cjs} +22 -5
- package/dist/SchemaGenerator-DzVHk6OP.cjs.map +1 -0
- package/dist/{SchemaMapper-qjB3rBph.d.ts → SchemaMapper-CqBW0VOy.d.ts} +1 -1
- package/dist/{SchemaMapper-CM1eXksi.js → SchemaMapper-Cx4X1al6.js} +1 -1
- package/dist/{SchemaMapper-CM1eXksi.js.map → SchemaMapper-Cx4X1al6.js.map} +1 -1
- package/dist/{SchemaMapper-CpAbmGiH.cjs → SchemaMapper-DoL-a6qq.cjs} +1 -1
- package/dist/{SchemaMapper-CpAbmGiH.cjs.map → SchemaMapper-DoL-a6qq.cjs.map} +1 -1
- package/dist/chunk-BEV-X5tz.js +27 -0
- package/dist/components.cjs +1 -1
- package/dist/components.d.cts +7 -6
- package/dist/components.d.ts +8 -7
- package/dist/components.js +1 -1
- package/dist/generators-B27La9Vd.cjs +99 -0
- package/dist/generators-B27La9Vd.cjs.map +1 -0
- package/dist/generators-C61FxVIj.js +80 -0
- package/dist/generators-C61FxVIj.js.map +1 -0
- package/dist/generators.cjs +9 -3
- package/dist/generators.d.cts +2 -7
- package/dist/generators.d.ts +3 -8
- package/dist/generators.js +5 -4
- package/dist/{getFooter-pQXwqM81.cjs → getFooter-CwjCW4h5.cjs} +3 -3
- package/dist/{getFooter-pQXwqM81.cjs.map → getFooter-CwjCW4h5.cjs.map} +1 -1
- package/dist/{getFooter-CvTKkK7-.js → getFooter-D5MdeUVv.js} +2 -2
- package/dist/{getFooter-CvTKkK7-.js.map → getFooter-D5MdeUVv.js.map} +1 -1
- package/dist/{getSchemas-CvUX0jWa.js → getSchemas-Bdg6n9Qk.js} +1 -1
- package/dist/{getSchemas-CvUX0jWa.js.map → getSchemas-Bdg6n9Qk.js.map} +1 -1
- package/dist/{getSchemas-08CU8KWq.cjs → getSchemas-DY8s2CSl.cjs} +1 -1
- package/dist/{getSchemas-08CU8KWq.cjs.map → getSchemas-DY8s2CSl.cjs.map} +1 -1
- package/dist/hooks.cjs +12 -11
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.cts +2 -2
- package/dist/hooks.d.ts +3 -3
- package/dist/hooks.js +6 -5
- package/dist/hooks.js.map +1 -1
- package/dist/index.cjs +37 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -8
- package/dist/index.d.ts +3 -9
- package/dist/index.js +33 -9
- package/dist/index.js.map +1 -1
- package/dist/mocks.cjs +1 -1
- package/dist/mocks.d.ts +1 -1
- package/dist/mocks.js +1 -1
- package/dist/{parseFromConfig-DSI6Meg0.js → parseFromConfig-CqiiLCPe.js} +1 -1
- package/dist/{parseFromConfig-DSI6Meg0.js.map → parseFromConfig-CqiiLCPe.js.map} +1 -1
- package/dist/{parseFromConfig-o3tU1XJt.cjs → parseFromConfig-RR31a98-.cjs} +1 -1
- package/dist/{parseFromConfig-o3tU1XJt.cjs.map → parseFromConfig-RR31a98-.cjs.map} +1 -1
- package/dist/utils-BnkB1ikY.js +99 -0
- package/dist/utils-BnkB1ikY.js.map +1 -0
- package/dist/utils-nzdccPlU.cjs +119 -0
- package/dist/utils-nzdccPlU.cjs.map +1 -0
- package/dist/utils.cjs +3 -3
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +3 -2
- package/dist/utils.d.ts +4 -3
- package/dist/utils.js +3 -3
- package/dist/utils.js.map +1 -1
- package/package.json +6 -7
- package/src/OperationGenerator.ts +36 -7
- package/src/SchemaGenerator.ts +25 -1
- package/src/components/Oas.tsx +5 -7
- package/src/components/Operation.tsx +3 -3
- package/src/components/Schema.tsx +3 -4
- package/src/generators/createGenerator.ts +34 -0
- package/src/generators/createReactGenerator.ts +41 -0
- package/src/generators/index.ts +4 -0
- package/src/generators/jsonGenerator.ts +1 -1
- package/src/generators/types.ts +35 -0
- package/src/generators/utils.tsx +114 -0
- package/src/hooks/useOas.ts +1 -1
- package/src/hooks/useOperation.ts +1 -1
- package/src/hooks/useOperationManager.ts +1 -1
- package/src/hooks/useOperations.ts +1 -1
- package/src/hooks/useSchema.ts +1 -1
- package/src/index.ts +3 -5
- package/src/plugin.ts +2 -0
- package/src/types.ts +1 -1
- package/src/utils/getParams.ts +1 -1
- package/dist/Oas--cvTRMTA.cjs.map +0 -1
- package/dist/Oas-DoN76W2_.js.map +0 -1
- package/dist/SchemaGenerator-DsK0wuii.cjs.map +0 -1
- package/dist/generators-BUNmB1lx.js +0 -154
- package/dist/generators-BUNmB1lx.js.map +0 -1
- package/dist/generators-CoiXCnDY.cjs +0 -175
- package/dist/generators-CoiXCnDY.cjs.map +0 -1
- package/src/generator.tsx +0 -139
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaMapper-
|
|
1
|
+
{"version":3,"file":"SchemaMapper-DoL-a6qq.cjs","names":[],"sources":["../src/SchemaMapper.ts"],"sourcesContent":["import type { KubbFile } from '@kubb/core/fs'\n\nexport type SchemaKeywordMapper = {\n object: {\n keyword: 'object'\n args: {\n properties: { [x: string]: Schema[] }\n additionalProperties: 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.OptionalPath\n /**\n * When true `File.Import` will be used.\n * When false a reference will be 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 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 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 parent: Schema | undefined\n current: Schema\n siblings: Schema[]\n /**\n * this will be 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":";;AA+FA,MAAa,iBAAiB;CAC5B,KAAK;CACL,SAAS;CACT,QAAQ;CACR,SAAS;CACT,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;AA2BD,SAAgB,UAAiE,MAAS,SAAwD;AAChJ,QAAO,KAAK,YAAY"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
|
|
3
|
+
//#region rolldown:runtime
|
|
4
|
+
var __create = Object.create;
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
12
|
+
key = keys[i];
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
21
|
+
value: mod,
|
|
22
|
+
enumerable: true
|
|
23
|
+
}) : target, mod));
|
|
24
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
export { };
|
package/dist/components.cjs
CHANGED
package/dist/components.d.cts
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { P as Oas$1, t as OperationGenerator, z as Operation$1 } from "./OperationGenerator-CJTAer7l.cjs";
|
|
2
2
|
import "./SchemaMapper-MiRB5_Zp.cjs";
|
|
3
|
-
import { t as Schema } from "./Schema-
|
|
3
|
+
import { t as Schema } from "./Schema-zcZF0UIp.cjs";
|
|
4
|
+
import { KubbNode } from "@kubb/react-fabric/types";
|
|
4
5
|
|
|
5
6
|
//#region src/components/Operation.d.ts
|
|
6
7
|
type Props$1 = {
|
|
7
8
|
operation: Operation$1;
|
|
8
|
-
children?:
|
|
9
|
+
children?: KubbNode;
|
|
9
10
|
};
|
|
10
11
|
declare function Operation({
|
|
11
12
|
operation,
|
|
12
13
|
children
|
|
13
|
-
}: Props$1):
|
|
14
|
+
}: Props$1): KubbNode;
|
|
14
15
|
declare namespace Operation {
|
|
15
16
|
var Context;
|
|
16
17
|
}
|
|
@@ -23,14 +24,14 @@ type Props = {
|
|
|
23
24
|
* @deprecated
|
|
24
25
|
*/
|
|
25
26
|
generator?: Omit<OperationGenerator, 'build'>;
|
|
26
|
-
children?:
|
|
27
|
+
children?: KubbNode;
|
|
27
28
|
};
|
|
28
29
|
declare function Oas({
|
|
29
30
|
oas,
|
|
30
31
|
children,
|
|
31
32
|
operations,
|
|
32
33
|
generator
|
|
33
|
-
}: Props):
|
|
34
|
+
}: Props): KubbNode;
|
|
34
35
|
declare namespace Oas {
|
|
35
36
|
var Context;
|
|
36
37
|
var Operation: typeof Operation;
|
package/dist/components.d.ts
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./SchemaMapper-
|
|
3
|
-
import { t as Schema } from "./Schema-
|
|
1
|
+
import { P as Oas$1, t as OperationGenerator, z as Operation$1 } from "./OperationGenerator-BZPWkxw4.js";
|
|
2
|
+
import "./SchemaMapper-CqBW0VOy.js";
|
|
3
|
+
import { t as Schema } from "./Schema-CjraJhJi.js";
|
|
4
|
+
import { KubbNode } from "@kubb/react-fabric/types";
|
|
4
5
|
|
|
5
6
|
//#region src/components/Operation.d.ts
|
|
6
7
|
type Props$1 = {
|
|
7
8
|
operation: Operation$1;
|
|
8
|
-
children?:
|
|
9
|
+
children?: KubbNode;
|
|
9
10
|
};
|
|
10
11
|
declare function Operation({
|
|
11
12
|
operation,
|
|
12
13
|
children
|
|
13
|
-
}: Props$1):
|
|
14
|
+
}: Props$1): KubbNode;
|
|
14
15
|
declare namespace Operation {
|
|
15
16
|
var Context;
|
|
16
17
|
}
|
|
@@ -23,14 +24,14 @@ type Props = {
|
|
|
23
24
|
* @deprecated
|
|
24
25
|
*/
|
|
25
26
|
generator?: Omit<OperationGenerator, 'build'>;
|
|
26
|
-
children?:
|
|
27
|
+
children?: KubbNode;
|
|
27
28
|
};
|
|
28
29
|
declare function Oas({
|
|
29
30
|
oas,
|
|
30
31
|
children,
|
|
31
32
|
operations,
|
|
32
33
|
generator
|
|
33
|
-
}: Props):
|
|
34
|
+
}: Props): KubbNode;
|
|
34
35
|
declare namespace Oas {
|
|
35
36
|
var Context;
|
|
36
37
|
var Operation: typeof Operation;
|
package/dist/components.js
CHANGED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
|
+
const require_getFooter = require('./getFooter-CwjCW4h5.cjs');
|
|
3
|
+
let __kubb_core_transformers = require("@kubb/core/transformers");
|
|
4
|
+
__kubb_core_transformers = require_chunk.__toESM(__kubb_core_transformers);
|
|
5
|
+
|
|
6
|
+
//#region src/generators/createGenerator.ts
|
|
7
|
+
function createGenerator(generator) {
|
|
8
|
+
return {
|
|
9
|
+
type: "core",
|
|
10
|
+
async operations() {
|
|
11
|
+
return [];
|
|
12
|
+
},
|
|
13
|
+
async operation() {
|
|
14
|
+
return [];
|
|
15
|
+
},
|
|
16
|
+
async schema() {
|
|
17
|
+
return [];
|
|
18
|
+
},
|
|
19
|
+
...generator
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region src/generators/createReactGenerator.ts
|
|
25
|
+
/****
|
|
26
|
+
* Creates a generator that uses React component functions to generate files for OpenAPI operations and schemas.
|
|
27
|
+
*
|
|
28
|
+
* 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.
|
|
29
|
+
*
|
|
30
|
+
* @returns A generator object with async methods for operations, operation, and schema file generation.
|
|
31
|
+
*/
|
|
32
|
+
function createReactGenerator(generator) {
|
|
33
|
+
return {
|
|
34
|
+
type: "react",
|
|
35
|
+
Operations() {
|
|
36
|
+
return null;
|
|
37
|
+
},
|
|
38
|
+
Operation() {
|
|
39
|
+
return null;
|
|
40
|
+
},
|
|
41
|
+
Schema() {
|
|
42
|
+
return null;
|
|
43
|
+
},
|
|
44
|
+
...generator
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region src/generators/jsonGenerator.ts
|
|
50
|
+
const jsonGenerator = createGenerator({
|
|
51
|
+
name: "plugin-oas",
|
|
52
|
+
async schema({ schema, instance }) {
|
|
53
|
+
const { pluginManager, plugin } = instance.context;
|
|
54
|
+
return [{
|
|
55
|
+
...pluginManager.getFile({
|
|
56
|
+
name: (0, __kubb_core_transformers.camelCase)(schema.name),
|
|
57
|
+
extname: ".json",
|
|
58
|
+
mode: "split",
|
|
59
|
+
pluginKey: plugin.key
|
|
60
|
+
}),
|
|
61
|
+
sources: [{
|
|
62
|
+
name: (0, __kubb_core_transformers.camelCase)(schema.name),
|
|
63
|
+
isExportable: false,
|
|
64
|
+
isIndexable: false,
|
|
65
|
+
value: JSON.stringify(schema.value)
|
|
66
|
+
}],
|
|
67
|
+
banner: require_getFooter.getBanner({
|
|
68
|
+
oas: instance.context.oas,
|
|
69
|
+
output: plugin.options.output,
|
|
70
|
+
config: pluginManager.config
|
|
71
|
+
}),
|
|
72
|
+
format: require_getFooter.getFooter({
|
|
73
|
+
oas: instance.context.oas,
|
|
74
|
+
output: plugin.options.output
|
|
75
|
+
})
|
|
76
|
+
}];
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
//#endregion
|
|
81
|
+
Object.defineProperty(exports, 'createGenerator', {
|
|
82
|
+
enumerable: true,
|
|
83
|
+
get: function () {
|
|
84
|
+
return createGenerator;
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
Object.defineProperty(exports, 'createReactGenerator', {
|
|
88
|
+
enumerable: true,
|
|
89
|
+
get: function () {
|
|
90
|
+
return createReactGenerator;
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
Object.defineProperty(exports, 'jsonGenerator', {
|
|
94
|
+
enumerable: true,
|
|
95
|
+
get: function () {
|
|
96
|
+
return jsonGenerator;
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
//# sourceMappingURL=generators-B27La9Vd.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generators-B27La9Vd.cjs","names":["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/core/fs'\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 { KubbNode } 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>) => KubbNode\n Operation?: (props: OperationProps<TOptions>) => KubbNode\n Schema?: (props: SchemaProps<TOptions>) => KubbNode\n}\n\nexport type ReactGenerator<TOptions extends PluginFactoryOptions> = {\n name: string\n type: 'react'\n Operations: (props: OperationsProps<TOptions>) => KubbNode\n Operation: (props: OperationProps<TOptions>) => KubbNode\n Schema: (props: SchemaProps<TOptions>) => KubbNode\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 '@kubb/core/transformers'\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, 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 banner: getBanner({\n oas: instance.context.oas,\n output: plugin.options.output,\n config: pluginManager.config,\n }),\n format: getFooter({ oas: instance.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,YAAY;EACjC,MAAM,EAAE,eAAe,WAAW,SAAS;AAQ3C,SAAO,CACL;GACE,GATS,cAAc,QAAQ;IACjC,8CAAgB,OAAO,KAAK;IAC5B,SAAS;IACT,MAAM;IACN,WAAW,OAAO;IACnB,CAAC;GAKE,SAAS,CACP;IACE,8CAAgB,OAAO,KAAK;IAC5B,cAAc;IACd,aAAa;IACb,OAAO,KAAK,UAAU,OAAO,MAAM;IACpC,CACF;GACD,QAAQA,4BAAU;IAChB,KAAK,SAAS,QAAQ;IACtB,QAAQ,OAAO,QAAQ;IACvB,QAAQ,cAAc;IACvB,CAAC;GACF,QAAQC,4BAAU;IAAE,KAAK,SAAS,QAAQ;IAAK,QAAQ,OAAO,QAAQ;IAAQ,CAAC;GAChF,CACF;;CAEJ,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { n as getBanner, t as getFooter } from "./getFooter-D5MdeUVv.js";
|
|
2
|
+
import { camelCase } from "@kubb/core/transformers";
|
|
3
|
+
|
|
4
|
+
//#region src/generators/createGenerator.ts
|
|
5
|
+
function createGenerator(generator) {
|
|
6
|
+
return {
|
|
7
|
+
type: "core",
|
|
8
|
+
async operations() {
|
|
9
|
+
return [];
|
|
10
|
+
},
|
|
11
|
+
async operation() {
|
|
12
|
+
return [];
|
|
13
|
+
},
|
|
14
|
+
async schema() {
|
|
15
|
+
return [];
|
|
16
|
+
},
|
|
17
|
+
...generator
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/generators/createReactGenerator.ts
|
|
23
|
+
/****
|
|
24
|
+
* Creates a generator that uses React component functions to generate files for OpenAPI operations and schemas.
|
|
25
|
+
*
|
|
26
|
+
* 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.
|
|
27
|
+
*
|
|
28
|
+
* @returns A generator object with async methods for operations, operation, and schema file generation.
|
|
29
|
+
*/
|
|
30
|
+
function createReactGenerator(generator) {
|
|
31
|
+
return {
|
|
32
|
+
type: "react",
|
|
33
|
+
Operations() {
|
|
34
|
+
return null;
|
|
35
|
+
},
|
|
36
|
+
Operation() {
|
|
37
|
+
return null;
|
|
38
|
+
},
|
|
39
|
+
Schema() {
|
|
40
|
+
return null;
|
|
41
|
+
},
|
|
42
|
+
...generator
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region src/generators/jsonGenerator.ts
|
|
48
|
+
const jsonGenerator = createGenerator({
|
|
49
|
+
name: "plugin-oas",
|
|
50
|
+
async schema({ schema, instance }) {
|
|
51
|
+
const { pluginManager, plugin } = instance.context;
|
|
52
|
+
return [{
|
|
53
|
+
...pluginManager.getFile({
|
|
54
|
+
name: camelCase(schema.name),
|
|
55
|
+
extname: ".json",
|
|
56
|
+
mode: "split",
|
|
57
|
+
pluginKey: plugin.key
|
|
58
|
+
}),
|
|
59
|
+
sources: [{
|
|
60
|
+
name: camelCase(schema.name),
|
|
61
|
+
isExportable: false,
|
|
62
|
+
isIndexable: false,
|
|
63
|
+
value: JSON.stringify(schema.value)
|
|
64
|
+
}],
|
|
65
|
+
banner: getBanner({
|
|
66
|
+
oas: instance.context.oas,
|
|
67
|
+
output: plugin.options.output,
|
|
68
|
+
config: pluginManager.config
|
|
69
|
+
}),
|
|
70
|
+
format: getFooter({
|
|
71
|
+
oas: instance.context.oas,
|
|
72
|
+
output: plugin.options.output
|
|
73
|
+
})
|
|
74
|
+
}];
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
//#endregion
|
|
79
|
+
export { createReactGenerator as n, createGenerator as r, jsonGenerator as t };
|
|
80
|
+
//# sourceMappingURL=generators-C61FxVIj.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generators-C61FxVIj.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/core/fs'\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 { KubbNode } 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>) => KubbNode\n Operation?: (props: OperationProps<TOptions>) => KubbNode\n Schema?: (props: SchemaProps<TOptions>) => KubbNode\n}\n\nexport type ReactGenerator<TOptions extends PluginFactoryOptions> = {\n name: string\n type: 'react'\n Operations: (props: OperationsProps<TOptions>) => KubbNode\n Operation: (props: OperationProps<TOptions>) => KubbNode\n Schema: (props: SchemaProps<TOptions>) => KubbNode\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 '@kubb/core/transformers'\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, 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 banner: getBanner({\n oas: instance.context.oas,\n output: plugin.options.output,\n config: pluginManager.config,\n }),\n format: getFooter({ oas: instance.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,YAAY;EACjC,MAAM,EAAE,eAAe,WAAW,SAAS;AAQ3C,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,SAAS,QAAQ;IACtB,QAAQ,OAAO,QAAQ;IACvB,QAAQ,cAAc;IACvB,CAAC;GACF,QAAQ,UAAU;IAAE,KAAK,SAAS,QAAQ;IAAK,QAAQ,OAAO,QAAQ;IAAQ,CAAC;GAChF,CACF;;CAEJ,CAAC"}
|
package/dist/generators.cjs
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
require('./
|
|
2
|
-
|
|
3
|
-
require('./
|
|
1
|
+
const require_generators = require('./generators-B27La9Vd.cjs');
|
|
2
|
+
require('./getFooter-CwjCW4h5.cjs');
|
|
3
|
+
require('./Oas-BzrQ6RGC.cjs');
|
|
4
|
+
const require_utils = require('./utils-nzdccPlU.cjs');
|
|
4
5
|
|
|
6
|
+
exports.buildOperation = require_utils.buildOperation;
|
|
7
|
+
exports.buildOperations = require_utils.buildOperations;
|
|
8
|
+
exports.buildSchema = require_utils.buildSchema;
|
|
9
|
+
exports.createGenerator = require_generators.createGenerator;
|
|
10
|
+
exports.createReactGenerator = require_generators.createReactGenerator;
|
|
5
11
|
exports.jsonGenerator = require_generators.jsonGenerator;
|
package/dist/generators.d.cts
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { D as createReactGenerator, O as createGenerator, c as buildSchema, m as jsonGenerator, o as buildOperation, r as Generator, s as buildOperations } from "./OperationGenerator-CJTAer7l.cjs";
|
|
2
2
|
import "./SchemaMapper-MiRB5_Zp.cjs";
|
|
3
|
-
|
|
4
|
-
//#region src/generators/jsonGenerator.d.ts
|
|
5
|
-
declare const jsonGenerator: Generator<PluginOas>;
|
|
6
|
-
//#endregion
|
|
7
|
-
export { jsonGenerator };
|
|
8
|
-
//# sourceMappingURL=generators.d.cts.map
|
|
3
|
+
export { Generator, buildOperation, buildOperations, buildSchema, createGenerator, createReactGenerator, jsonGenerator };
|
package/dist/generators.d.ts
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./SchemaMapper-
|
|
3
|
-
|
|
4
|
-
//#region src/generators/jsonGenerator.d.ts
|
|
5
|
-
declare const jsonGenerator: Generator<PluginOas>;
|
|
6
|
-
//#endregion
|
|
7
|
-
export { jsonGenerator };
|
|
8
|
-
//# sourceMappingURL=generators.d.ts.map
|
|
1
|
+
import { D as createReactGenerator, O as createGenerator, c as buildSchema, m as jsonGenerator, o as buildOperation, r as Generator, s as buildOperations } from "./OperationGenerator-BZPWkxw4.js";
|
|
2
|
+
import "./SchemaMapper-CqBW0VOy.js";
|
|
3
|
+
export { Generator, buildOperation, buildOperations, buildSchema, createGenerator, createReactGenerator, jsonGenerator };
|
package/dist/generators.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import
|
|
3
|
-
import "./
|
|
1
|
+
import { n as createReactGenerator, r as createGenerator, t as jsonGenerator } from "./generators-C61FxVIj.js";
|
|
2
|
+
import "./getFooter-D5MdeUVv.js";
|
|
3
|
+
import "./Oas-CIeHKOo0.js";
|
|
4
|
+
import { n as buildOperations, r as buildSchema, t as buildOperation } from "./utils-BnkB1ikY.js";
|
|
4
5
|
|
|
5
|
-
export { jsonGenerator };
|
|
6
|
+
export { buildOperation, buildOperations, buildSchema, createGenerator, createReactGenerator, jsonGenerator };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
|
-
let node_path = require("node:path");
|
|
3
|
-
node_path = require_chunk.__toESM(node_path);
|
|
4
2
|
let remeda = require("remeda");
|
|
5
3
|
remeda = require_chunk.__toESM(remeda);
|
|
4
|
+
let node_path = require("node:path");
|
|
5
|
+
node_path = require_chunk.__toESM(node_path);
|
|
6
6
|
|
|
7
7
|
//#region src/utils/getBanner.ts
|
|
8
8
|
/**
|
|
@@ -69,4 +69,4 @@ Object.defineProperty(exports, 'getFooter', {
|
|
|
69
69
|
return getFooter;
|
|
70
70
|
}
|
|
71
71
|
});
|
|
72
|
-
//# sourceMappingURL=getFooter-
|
|
72
|
+
//# sourceMappingURL=getFooter-CwjCW4h5.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getFooter-
|
|
1
|
+
{"version":3,"file":"getFooter-CwjCW4h5.cjs","names":["path"],"sources":["../src/utils/getBanner.ts","../src/utils/getFooter.ts"],"sourcesContent":["import type { Config, Output } from '@kubb/core'\nimport type { Oas } from '@kubb/oas'\nimport { isFunction } from 'remeda'\nimport path from 'node:path'\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":";;;;;;;;;;;AAeA,SAAS,iBAAiB,EAAE,OAAO,aAAa,SAAS,UAA8F;AACrJ,KAAI;EACF,IAAI,SAAS;AACb,MAAI,UAAU,OAAO,MACnB,UAASA,kBAAK,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,4BAAe,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,4BAAe,OAAO,OAAO,CAC3B,QAAO,OAAO,OAAO,IAAI;AAG3B,QAAO,OAAO"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
1
|
import { isFunction } from "remeda";
|
|
2
|
+
import path from "node:path";
|
|
3
3
|
|
|
4
4
|
//#region src/utils/getBanner.ts
|
|
5
5
|
/**
|
|
@@ -55,4 +55,4 @@ function getFooter({ output, oas }) {
|
|
|
55
55
|
|
|
56
56
|
//#endregion
|
|
57
57
|
export { getBanner as n, getFooter as t };
|
|
58
|
-
//# sourceMappingURL=getFooter-
|
|
58
|
+
//# sourceMappingURL=getFooter-D5MdeUVv.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getFooter-
|
|
1
|
+
{"version":3,"file":"getFooter-D5MdeUVv.js","names":[],"sources":["../src/utils/getBanner.ts","../src/utils/getFooter.ts"],"sourcesContent":["import type { Config, Output } from '@kubb/core'\nimport type { Oas } from '@kubb/oas'\nimport { isFunction } from 'remeda'\nimport path from 'node:path'\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":";;;;;;;;AAeA,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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getSchemas-
|
|
1
|
+
{"version":3,"file":"getSchemas-Bdg6n9Qk.js","names":["schemas: Record<string, OasTypes.SchemaObject>"],"sources":["../src/utils/getSchemaFactory.ts","../src/utils/getSchemas.ts"],"sourcesContent":["import { isOpenApiV3_1Document } from '@kubb/oas'\n\nimport type { Oas, OpenAPIV3, OpenAPIV3_1, SchemaObject } from '@kubb/oas'\n\n/**\n * Make it possible to narrow down the schema based on a specific version(3 or 3.1)\n */\ntype SchemaResult<TWithRef extends boolean = false> =\n | {\n schemaObject?: (TWithRef extends true ? OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject : OpenAPIV3.SchemaObject) & {\n nullable?: boolean\n 'x-nullable'?: boolean\n }\n version: '3.0'\n }\n | {\n schemaObject?: (TWithRef extends true ? OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ReferenceObject : OpenAPIV3_1.SchemaObject) & {\n nullable?: boolean\n 'x-nullable'?: boolean\n }\n version: '3.1'\n }\n\n/**\n * Creates a factory function that generates a versioned OpenAPI schema result.\n *\n * The returned function accepts an optional schema object and produces a {@link SchemaResult} containing the dereferenced schema and the OpenAPI version ('3.0' or '3.1').\n *\n * @returns A function that takes an optional schema and returns a versioned schema result.\n */\nexport function getSchemaFactory<TWithRef extends boolean = false>(oas: Oas): (schema?: SchemaObject) => SchemaResult<TWithRef> {\n return (schema?: SchemaObject) => {\n const version = isOpenApiV3_1Document(oas.api) ? '3.1' : '3.0'\n\n return {\n schemaObject: oas.dereferenceWithRef(schema),\n version,\n } as SchemaResult<TWithRef>\n }\n}\n","import type { Oas, OasTypes, contentType } from '@kubb/oas'\n\ntype Mode = 'schemas' | 'responses' | 'requestBodies'\n\ntype GetSchemasProps = {\n oas: Oas\n contentType?: contentType\n includes?: Mode[]\n}\n\nexport function getSchemas({ oas, contentType, includes = ['schemas', 'requestBodies', 'responses'] }: GetSchemasProps): Record<string, OasTypes.SchemaObject> {\n const components = oas.getDefinition().components\n\n let schemas: Record<string, OasTypes.SchemaObject> = {}\n\n if (includes.includes('schemas')) {\n schemas = {\n ...schemas,\n ...((components?.schemas as Record<string, OasTypes.SchemaObject>) || {}),\n }\n }\n\n const requestBodies = components?.requestBodies || {}\n if (includes.includes('responses')) {\n const responses = components?.responses || {}\n\n Object.entries(responses).forEach(([name, response]: [string, OasTypes.ResponseObject]) => {\n if (response.content && !schemas[name]) {\n const firstContentType = Object.keys(response.content)[0] || 'application/json'\n schemas[name] = response.content?.[contentType || firstContentType]?.schema as OasTypes.SchemaObject\n }\n })\n }\n\n if (includes.includes('requestBodies')) {\n Object.entries(requestBodies).forEach(([name, request]: [string, OasTypes.RequestBodyObject]) => {\n if (request.content && !schemas[name]) {\n const firstContentType = Object.keys(request.content)[0] || 'application/json'\n schemas[name] = request.content?.[contentType || firstContentType]?.schema as OasTypes.SchemaObject\n }\n })\n }\n\n return schemas\n}\n"],"mappings":";;;;;;;;;;AA8BA,SAAgB,iBAAmD,KAA6D;AAC9H,SAAQ,WAA0B;EAChC,MAAM,UAAU,sBAAsB,IAAI,IAAI,GAAG,QAAQ;AAEzD,SAAO;GACL,cAAc,IAAI,mBAAmB,OAAO;GAC5C;GACD;;;;;;AC3BL,SAAgB,WAAW,EAAE,KAAK,aAAa,WAAW;CAAC;CAAW;CAAiB;CAAY,IAA4D;CAC7J,MAAM,aAAa,IAAI,eAAe,CAAC;CAEvC,IAAIA,UAAiD,EAAE;AAEvD,KAAI,SAAS,SAAS,UAAU,CAC9B,WAAU;EACR,GAAG;EACH,GAAK,YAAY,WAAqD,EAAE;EACzE;CAGH,MAAM,gBAAgB,YAAY,iBAAiB,EAAE;AACrD,KAAI,SAAS,SAAS,YAAY,EAAE;EAClC,MAAM,YAAY,YAAY,aAAa,EAAE;AAE7C,SAAO,QAAQ,UAAU,CAAC,SAAS,CAAC,MAAM,cAAiD;AACzF,OAAI,SAAS,WAAW,CAAC,QAAQ,OAAO;IACtC,MAAM,mBAAmB,OAAO,KAAK,SAAS,QAAQ,CAAC,MAAM;AAC7D,YAAQ,QAAQ,SAAS,UAAU,eAAe,mBAAmB;;IAEvE;;AAGJ,KAAI,SAAS,SAAS,gBAAgB,CACpC,QAAO,QAAQ,cAAc,CAAC,SAAS,CAAC,MAAM,aAAmD;AAC/F,MAAI,QAAQ,WAAW,CAAC,QAAQ,OAAO;GACrC,MAAM,mBAAmB,OAAO,KAAK,QAAQ,QAAQ,CAAC,MAAM;AAC5D,WAAQ,QAAQ,QAAQ,UAAU,eAAe,mBAAmB;;GAEtE;AAGJ,QAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getSchemas-
|
|
1
|
+
{"version":3,"file":"getSchemas-DY8s2CSl.cjs","names":["schemas: Record<string, OasTypes.SchemaObject>"],"sources":["../src/utils/getSchemaFactory.ts","../src/utils/getSchemas.ts"],"sourcesContent":["import { isOpenApiV3_1Document } from '@kubb/oas'\n\nimport type { Oas, OpenAPIV3, OpenAPIV3_1, SchemaObject } from '@kubb/oas'\n\n/**\n * Make it possible to narrow down the schema based on a specific version(3 or 3.1)\n */\ntype SchemaResult<TWithRef extends boolean = false> =\n | {\n schemaObject?: (TWithRef extends true ? OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject : OpenAPIV3.SchemaObject) & {\n nullable?: boolean\n 'x-nullable'?: boolean\n }\n version: '3.0'\n }\n | {\n schemaObject?: (TWithRef extends true ? OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ReferenceObject : OpenAPIV3_1.SchemaObject) & {\n nullable?: boolean\n 'x-nullable'?: boolean\n }\n version: '3.1'\n }\n\n/**\n * Creates a factory function that generates a versioned OpenAPI schema result.\n *\n * The returned function accepts an optional schema object and produces a {@link SchemaResult} containing the dereferenced schema and the OpenAPI version ('3.0' or '3.1').\n *\n * @returns A function that takes an optional schema and returns a versioned schema result.\n */\nexport function getSchemaFactory<TWithRef extends boolean = false>(oas: Oas): (schema?: SchemaObject) => SchemaResult<TWithRef> {\n return (schema?: SchemaObject) => {\n const version = isOpenApiV3_1Document(oas.api) ? '3.1' : '3.0'\n\n return {\n schemaObject: oas.dereferenceWithRef(schema),\n version,\n } as SchemaResult<TWithRef>\n }\n}\n","import type { Oas, OasTypes, contentType } from '@kubb/oas'\n\ntype Mode = 'schemas' | 'responses' | 'requestBodies'\n\ntype GetSchemasProps = {\n oas: Oas\n contentType?: contentType\n includes?: Mode[]\n}\n\nexport function getSchemas({ oas, contentType, includes = ['schemas', 'requestBodies', 'responses'] }: GetSchemasProps): Record<string, OasTypes.SchemaObject> {\n const components = oas.getDefinition().components\n\n let schemas: Record<string, OasTypes.SchemaObject> = {}\n\n if (includes.includes('schemas')) {\n schemas = {\n ...schemas,\n ...((components?.schemas as Record<string, OasTypes.SchemaObject>) || {}),\n }\n }\n\n const requestBodies = components?.requestBodies || {}\n if (includes.includes('responses')) {\n const responses = components?.responses || {}\n\n Object.entries(responses).forEach(([name, response]: [string, OasTypes.ResponseObject]) => {\n if (response.content && !schemas[name]) {\n const firstContentType = Object.keys(response.content)[0] || 'application/json'\n schemas[name] = response.content?.[contentType || firstContentType]?.schema as OasTypes.SchemaObject\n }\n })\n }\n\n if (includes.includes('requestBodies')) {\n Object.entries(requestBodies).forEach(([name, request]: [string, OasTypes.RequestBodyObject]) => {\n if (request.content && !schemas[name]) {\n const firstContentType = Object.keys(request.content)[0] || 'application/json'\n schemas[name] = request.content?.[contentType || firstContentType]?.schema as OasTypes.SchemaObject\n }\n })\n }\n\n return schemas\n}\n"],"mappings":";;;;;;;;;;;;AA8BA,SAAgB,iBAAmD,KAA6D;AAC9H,SAAQ,WAA0B;EAChC,MAAM,gDAAgC,IAAI,IAAI,GAAG,QAAQ;AAEzD,SAAO;GACL,cAAc,IAAI,mBAAmB,OAAO;GAC5C;GACD;;;;;;AC3BL,SAAgB,WAAW,EAAE,KAAK,aAAa,WAAW;CAAC;CAAW;CAAiB;CAAY,IAA4D;CAC7J,MAAM,aAAa,IAAI,eAAe,CAAC;CAEvC,IAAIA,UAAiD,EAAE;AAEvD,KAAI,SAAS,SAAS,UAAU,CAC9B,WAAU;EACR,GAAG;EACH,GAAK,YAAY,WAAqD,EAAE;EACzE;CAGH,MAAM,gBAAgB,YAAY,iBAAiB,EAAE;AACrD,KAAI,SAAS,SAAS,YAAY,EAAE;EAClC,MAAM,YAAY,YAAY,aAAa,EAAE;AAE7C,SAAO,QAAQ,UAAU,CAAC,SAAS,CAAC,MAAM,cAAiD;AACzF,OAAI,SAAS,WAAW,CAAC,QAAQ,OAAO;IACtC,MAAM,mBAAmB,OAAO,KAAK,SAAS,QAAQ,CAAC,MAAM;AAC7D,YAAQ,QAAQ,SAAS,UAAU,eAAe,mBAAmB;;IAEvE;;AAGJ,KAAI,SAAS,SAAS,gBAAgB,CACpC,QAAO,QAAQ,cAAc,CAAC,SAAS,CAAC,MAAM,aAAmD;AAC/F,MAAI,QAAQ,WAAW,CAAC,QAAQ,OAAO;GACrC,MAAM,mBAAmB,OAAO,KAAK,QAAQ,QAAQ,CAAC,MAAM;AAC5D,WAAQ,QAAQ,QAAQ,UAAU,eAAe,mBAAmB;;GAEtE;AAGJ,QAAO"}
|
package/dist/hooks.cjs
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
require('./
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
const require_Oas = require('./Oas-BzrQ6RGC.cjs');
|
|
3
|
+
require('./utils-nzdccPlU.cjs');
|
|
4
|
+
const require_SchemaGenerator = require('./SchemaGenerator-DzVHk6OP.cjs');
|
|
5
|
+
const require_SchemaMapper = require('./SchemaMapper-DoL-a6qq.cjs');
|
|
6
|
+
require('./getSchemas-DY8s2CSl.cjs');
|
|
7
|
+
let __kubb_react_fabric = require("@kubb/react-fabric");
|
|
8
|
+
__kubb_react_fabric = require_chunk.__toESM(__kubb_react_fabric);
|
|
8
9
|
let __kubb_core_hooks = require("@kubb/core/hooks");
|
|
9
10
|
__kubb_core_hooks = require_chunk.__toESM(__kubb_core_hooks);
|
|
10
11
|
|
|
11
12
|
//#region src/hooks/useOas.ts
|
|
12
13
|
function useOas() {
|
|
13
|
-
const { oas } = (0,
|
|
14
|
+
const { oas } = (0, __kubb_react_fabric.useContext)(require_Oas.Oas.Context);
|
|
14
15
|
if (!oas) throw new Error("Oas is not defined");
|
|
15
16
|
return oas;
|
|
16
17
|
}
|
|
@@ -21,7 +22,7 @@ function useOas() {
|
|
|
21
22
|
* `useOperation` will return the current `Operation`
|
|
22
23
|
*/
|
|
23
24
|
function useOperation() {
|
|
24
|
-
const { operation } = (0,
|
|
25
|
+
const { operation } = (0, __kubb_react_fabric.useContext)(require_Oas.Operation.Context);
|
|
25
26
|
if (!operation) throw new Error("Operation is not defined");
|
|
26
27
|
return operation;
|
|
27
28
|
}
|
|
@@ -34,7 +35,7 @@ function useOperation() {
|
|
|
34
35
|
function useOperationManager() {
|
|
35
36
|
const plugin = (0, __kubb_core_hooks.usePlugin)();
|
|
36
37
|
const pluginManager = (0, __kubb_core_hooks.usePluginManager)();
|
|
37
|
-
const { generator } = (0,
|
|
38
|
+
const { generator } = (0, __kubb_react_fabric.useContext)(require_Oas.Oas.Context);
|
|
38
39
|
const getName = (operation, { prefix = "", suffix = "", pluginKey = plugin.key, type }) => {
|
|
39
40
|
return pluginManager.resolveName({
|
|
40
41
|
name: `${prefix} ${operation.getOperationId()} ${suffix}`,
|
|
@@ -155,7 +156,7 @@ function useOperationManager() {
|
|
|
155
156
|
* `useOperations` will return all the Operations
|
|
156
157
|
*/
|
|
157
158
|
function useOperations({ method, path } = {}) {
|
|
158
|
-
const { operations } = (0,
|
|
159
|
+
const { operations } = (0, __kubb_react_fabric.useContext)(require_Oas.Oas.Context);
|
|
159
160
|
if (!operations) throw new Error("Operations is not defined");
|
|
160
161
|
let items = operations;
|
|
161
162
|
if (path) items = items.filter((item) => item.path === path);
|
|
@@ -169,7 +170,7 @@ function useOperations({ method, path } = {}) {
|
|
|
169
170
|
* `useSchema` will return the current `schema properties`
|
|
170
171
|
*/
|
|
171
172
|
function useSchema() {
|
|
172
|
-
return (0,
|
|
173
|
+
return (0, __kubb_react_fabric.useContext)(require_Oas.Schema.Context);
|
|
173
174
|
}
|
|
174
175
|
|
|
175
176
|
//#endregion
|