@kubb/plugin-ts 4.12.10 → 4.12.12
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/{components-ZUH5lh79.cjs → components-DCfalUek.cjs} +2 -2
- package/dist/{components-ZUH5lh79.cjs.map → components-DCfalUek.cjs.map} +1 -1
- package/dist/{components-CR15X8lO.js → components-Daoap7CS.js} +2 -2
- package/dist/{components-CR15X8lO.js.map → components-Daoap7CS.js.map} +1 -1
- package/dist/components.cjs +1 -1
- package/dist/components.d.cts +1 -1
- package/dist/components.d.ts +1 -1
- package/dist/components.js +1 -1
- package/dist/generators.cjs +1 -2
- package/dist/generators.d.cts +2 -5
- package/dist/generators.d.ts +2 -5
- package/dist/generators.js +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/{plugin-CyGtLdqW.js → plugin-DTEjK1nR.js} +10 -49
- package/dist/plugin-DTEjK1nR.js.map +1 -0
- package/dist/{plugin-BHBQPt9a.cjs → plugin-N8vqlDtu.cjs} +9 -54
- package/dist/plugin-N8vqlDtu.cjs.map +1 -0
- package/dist/{types-BrFvnqzT.d.ts → types-Ccxn5EsU.d.ts} +23 -31
- package/dist/{types-DqDeNp1Z.d.cts → types-CwXJHtHd.d.cts} +23 -31
- package/package.json +4 -4
- package/src/generators/index.ts +0 -1
- package/src/generators/typeGenerator.tsx +3 -3
- package/src/plugin.ts +2 -4
- package/src/types.ts +0 -5
- package/dist/plugin-BHBQPt9a.cjs.map +0 -1
- package/dist/plugin-CyGtLdqW.js.map +0 -1
- package/src/generators/oasGenerator.tsx +0 -35
package/dist/components.cjs
CHANGED
package/dist/components.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as Schema, n as PluginTs, o as OasTypes, s as SchemaObject } from "./types-
|
|
1
|
+
import { i as Schema, n as PluginTs, o as OasTypes, s as SchemaObject } from "./types-CwXJHtHd.cjs";
|
|
2
2
|
import { KubbNode } from "@kubb/react-fabric/types";
|
|
3
3
|
|
|
4
4
|
//#region src/components/OasType.d.ts
|
package/dist/components.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as Schema, n as PluginTs, o as OasTypes, s as SchemaObject } from "./types-
|
|
1
|
+
import { i as Schema, n as PluginTs, o as OasTypes, s as SchemaObject } from "./types-Ccxn5EsU.js";
|
|
2
2
|
import { KubbNode } from "@kubb/react-fabric/types";
|
|
3
3
|
|
|
4
4
|
//#region src/components/OasType.d.ts
|
package/dist/components.js
CHANGED
package/dist/generators.cjs
CHANGED
package/dist/generators.d.cts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import { n as PluginTs, r as ReactGenerator } from "./types-
|
|
1
|
+
import { n as PluginTs, r as ReactGenerator } from "./types-CwXJHtHd.cjs";
|
|
2
2
|
|
|
3
|
-
//#region src/generators/oasGenerator.d.ts
|
|
4
|
-
declare const oasGenerator: ReactGenerator<PluginTs>;
|
|
5
|
-
//#endregion
|
|
6
3
|
//#region src/generators/typeGenerator.d.ts
|
|
7
4
|
declare const typeGenerator: ReactGenerator<PluginTs>;
|
|
8
5
|
//#endregion
|
|
9
|
-
export {
|
|
6
|
+
export { typeGenerator };
|
|
10
7
|
//# sourceMappingURL=generators.d.cts.map
|
package/dist/generators.d.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import { n as PluginTs, r as ReactGenerator } from "./types-
|
|
1
|
+
import { n as PluginTs, r as ReactGenerator } from "./types-Ccxn5EsU.js";
|
|
2
2
|
|
|
3
|
-
//#region src/generators/oasGenerator.d.ts
|
|
4
|
-
declare const oasGenerator: ReactGenerator<PluginTs>;
|
|
5
|
-
//#endregion
|
|
6
3
|
//#region src/generators/typeGenerator.d.ts
|
|
7
4
|
declare const typeGenerator: ReactGenerator<PluginTs>;
|
|
8
5
|
//#endregion
|
|
9
|
-
export {
|
|
6
|
+
export { typeGenerator };
|
|
10
7
|
//# sourceMappingURL=generators.d.ts.map
|
package/dist/generators.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { r as typeGenerator } from "./plugin-DTEjK1nR.js";
|
|
2
2
|
|
|
3
|
-
export {
|
|
3
|
+
export { typeGenerator };
|
package/dist/index.cjs
CHANGED
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,55 +1,16 @@
|
|
|
1
|
-
import { a as createTypeLiteralNode, c as modifiers, i as createTypeAliasDeclaration,
|
|
1
|
+
import { a as createTypeLiteralNode, c as modifiers, i as createTypeAliasDeclaration, n as createIdentifier, o as createTypeReferenceNode, r as createPropertySignature, s as createUnionDeclaration, t as Type$1 } from "./components-Daoap7CS.js";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { definePlugin, getBarrelFiles, getMode } from "@kubb/core";
|
|
4
4
|
import transformers, { camelCase, pascalCase } from "@kubb/core/transformers";
|
|
5
5
|
import { OperationGenerator, SchemaGenerator, isKeyword, pluginOasName, schemaKeywords } from "@kubb/plugin-oas";
|
|
6
6
|
import { useMode, usePluginManager } from "@kubb/core/hooks";
|
|
7
|
+
import { print } from "@kubb/fabric-core/parsers/typescript";
|
|
7
8
|
import { createReactGenerator } from "@kubb/plugin-oas/generators";
|
|
8
9
|
import { useOas, useOperationManager, useSchemaManager } from "@kubb/plugin-oas/hooks";
|
|
9
10
|
import { getBanner, getFooter } from "@kubb/plugin-oas/utils";
|
|
10
11
|
import { File } from "@kubb/react-fabric";
|
|
11
12
|
import { Fragment, jsx, jsxs } from "@kubb/react-fabric/jsx-runtime";
|
|
12
|
-
import { print } from "@kubb/fabric-core/parsers/typescript";
|
|
13
|
-
|
|
14
|
-
//#region src/generators/oasGenerator.tsx
|
|
15
|
-
const oasGenerator = createReactGenerator({
|
|
16
|
-
name: "oas",
|
|
17
|
-
Operations({ plugin }) {
|
|
18
|
-
const { options: { output }, key: pluginKey } = plugin;
|
|
19
|
-
const pluginManager = usePluginManager();
|
|
20
|
-
const oas = useOas();
|
|
21
|
-
const file = pluginManager.getFile({
|
|
22
|
-
name: "oas",
|
|
23
|
-
extname: ".ts",
|
|
24
|
-
pluginKey
|
|
25
|
-
});
|
|
26
|
-
return /* @__PURE__ */ jsxs(File, {
|
|
27
|
-
baseName: file.baseName,
|
|
28
|
-
path: file.path,
|
|
29
|
-
meta: file.meta,
|
|
30
|
-
banner: getBanner({
|
|
31
|
-
oas,
|
|
32
|
-
output,
|
|
33
|
-
config: pluginManager.config
|
|
34
|
-
}),
|
|
35
|
-
footer: getFooter({
|
|
36
|
-
oas,
|
|
37
|
-
output
|
|
38
|
-
}),
|
|
39
|
-
children: [/* @__PURE__ */ jsx(File.Import, {
|
|
40
|
-
name: ["Infer"],
|
|
41
|
-
path: "@kubb/oas",
|
|
42
|
-
isTypeOnly: true
|
|
43
|
-
}), /* @__PURE__ */ jsx(OasType, {
|
|
44
|
-
name: "oas",
|
|
45
|
-
typeName: "Oas",
|
|
46
|
-
api: oas.api
|
|
47
|
-
})]
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
13
|
|
|
52
|
-
//#endregion
|
|
53
14
|
//#region src/generators/typeGenerator.tsx
|
|
54
15
|
function printCombinedSchema({ name, schemas, pluginManager }) {
|
|
55
16
|
const properties = {};
|
|
@@ -147,10 +108,11 @@ const typeGenerator = createReactGenerator({
|
|
|
147
108
|
schemas.request,
|
|
148
109
|
schemas.response
|
|
149
110
|
].flat().filter(Boolean);
|
|
150
|
-
const mapOperationSchema = ({ name, schema
|
|
111
|
+
const mapOperationSchema = ({ name, schema, description, keysToOmit, ...options$1 }) => {
|
|
151
112
|
const tree = schemaGenerator.parse({
|
|
152
|
-
|
|
153
|
-
name
|
|
113
|
+
schema,
|
|
114
|
+
name,
|
|
115
|
+
parentName: null
|
|
154
116
|
});
|
|
155
117
|
const imports = schemaManager.getImports(tree);
|
|
156
118
|
const group = options$1.operation ? getGroup(options$1.operation) : void 0;
|
|
@@ -174,7 +136,7 @@ const typeGenerator = createReactGenerator({
|
|
|
174
136
|
typedName: type$1.typedName,
|
|
175
137
|
description,
|
|
176
138
|
tree,
|
|
177
|
-
schema
|
|
139
|
+
schema,
|
|
178
140
|
mapper,
|
|
179
141
|
enumType,
|
|
180
142
|
optionalType,
|
|
@@ -267,7 +229,7 @@ const pluginTs = definePlugin((options) => {
|
|
|
267
229
|
const { output = {
|
|
268
230
|
path: "types",
|
|
269
231
|
barrelType: "named"
|
|
270
|
-
}, group, exclude = [], include, override = [], enumType = "asConst", enumSuffix = "enum", dateType = "string", unknownType = "any", optionalType = "questionToken", emptySchemaType = unknownType, syntaxType = "type", transformers: transformers$1 = {},
|
|
232
|
+
}, group, exclude = [], include, override = [], enumType = "asConst", enumSuffix = "enum", dateType = "string", unknownType = "any", optionalType = "questionToken", emptySchemaType = unknownType, syntaxType = "type", transformers: transformers$1 = {}, mapper = {}, generators = [typeGenerator].filter(Boolean), contentType } = options;
|
|
271
233
|
return {
|
|
272
234
|
name: pluginTsName,
|
|
273
235
|
options: {
|
|
@@ -275,7 +237,6 @@ const pluginTs = definePlugin((options) => {
|
|
|
275
237
|
transformers: transformers$1,
|
|
276
238
|
dateType,
|
|
277
239
|
optionalType,
|
|
278
|
-
oasType,
|
|
279
240
|
enumType,
|
|
280
241
|
enumSuffix,
|
|
281
242
|
unknownType,
|
|
@@ -351,5 +312,5 @@ const pluginTs = definePlugin((options) => {
|
|
|
351
312
|
});
|
|
352
313
|
|
|
353
314
|
//#endregion
|
|
354
|
-
export {
|
|
355
|
-
//# sourceMappingURL=plugin-
|
|
315
|
+
export { pluginTsName as n, typeGenerator as r, pluginTs as t };
|
|
316
|
+
//# sourceMappingURL=plugin-DTEjK1nR.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-DTEjK1nR.js","names":["properties: Record<string, ts.TypeNode>","factory.createUnionDeclaration","factory.createTypeReferenceNode","factory.createIdentifier","factory.createTypeAliasDeclaration","factory.createTypeLiteralNode","factory.createPropertySignature","options","type","Type","options","groupName: Group['name']","transformers"],"sources":["../src/generators/typeGenerator.tsx","../src/plugin.ts"],"sourcesContent":["import type { PluginManager } from '@kubb/core'\nimport { useMode, usePluginManager } from '@kubb/core/hooks'\nimport transformers from '@kubb/core/transformers'\nimport { print } from '@kubb/fabric-core/parsers/typescript'\nimport { isKeyword, type OperationSchemas, type OperationSchema as OperationSchemaType, SchemaGenerator, schemaKeywords } from '@kubb/plugin-oas'\nimport { createReactGenerator } from '@kubb/plugin-oas/generators'\nimport { useOas, useOperationManager, useSchemaManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { File } from '@kubb/react-fabric'\nimport type ts from 'typescript'\nimport { Type } from '../components'\nimport * as factory from '../factory.ts'\nimport { pluginTsName } from '../plugin.ts'\nimport type { PluginTs } from '../types'\n\nfunction printCombinedSchema({ name, schemas, pluginManager }: { name: string; schemas: OperationSchemas; pluginManager: PluginManager }): string {\n const properties: Record<string, ts.TypeNode> = {}\n\n if (schemas.response) {\n properties['response'] = factory.createUnionDeclaration({\n nodes: schemas.responses.map((res) => {\n const identifier = pluginManager.resolveName({\n name: res.name,\n pluginKey: [pluginTsName],\n type: 'function',\n })\n\n return factory.createTypeReferenceNode(factory.createIdentifier(identifier), undefined)\n }),\n })!\n }\n\n if (schemas.request) {\n const identifier = pluginManager.resolveName({\n name: schemas.request.name,\n pluginKey: [pluginTsName],\n type: 'function',\n })\n properties['request'] = factory.createTypeReferenceNode(factory.createIdentifier(identifier), undefined)\n }\n\n if (schemas.pathParams) {\n const identifier = pluginManager.resolveName({\n name: schemas.pathParams.name,\n pluginKey: [pluginTsName],\n type: 'function',\n })\n properties['pathParams'] = factory.createTypeReferenceNode(factory.createIdentifier(identifier), undefined)\n }\n\n if (schemas.queryParams) {\n const identifier = pluginManager.resolveName({\n name: schemas.queryParams.name,\n pluginKey: [pluginTsName],\n type: 'function',\n })\n properties['queryParams'] = factory.createTypeReferenceNode(factory.createIdentifier(identifier), undefined)\n }\n\n if (schemas.headerParams) {\n const identifier = pluginManager.resolveName({\n name: schemas.headerParams.name,\n pluginKey: [pluginTsName],\n type: 'function',\n })\n properties['headerParams'] = factory.createTypeReferenceNode(factory.createIdentifier(identifier), undefined)\n }\n\n if (schemas.errors) {\n properties['errors'] = factory.createUnionDeclaration({\n nodes: schemas.errors.map((error) => {\n const identifier = pluginManager.resolveName({\n name: error.name,\n pluginKey: [pluginTsName],\n type: 'function',\n })\n\n return factory.createTypeReferenceNode(factory.createIdentifier(identifier), undefined)\n }),\n })!\n }\n\n const namespaceNode = factory.createTypeAliasDeclaration({\n name,\n type: factory.createTypeLiteralNode(\n Object.keys(properties)\n .map((key) => {\n const type = properties[key]\n if (!type) {\n return undefined\n }\n\n return factory.createPropertySignature({\n name: transformers.pascalCase(key),\n type,\n })\n })\n .filter(Boolean),\n ),\n modifiers: [factory.modifiers.export],\n })\n\n return print(namespaceNode)\n}\n\nexport const typeGenerator = createReactGenerator<PluginTs>({\n name: 'typescript',\n Operation({ operation, generator, plugin }) {\n const {\n options,\n options: { mapper, enumType, syntaxType, optionalType },\n } = plugin\n\n const mode = useMode()\n const pluginManager = usePluginManager()\n\n const oas = useOas()\n const { getSchemas, getFile, getName, getGroup } = useOperationManager(generator)\n const schemaManager = useSchemaManager()\n\n const file = getFile(operation)\n const schemas = getSchemas(operation)\n const type = getName(operation, { type: 'function', pluginKey: [pluginTsName] })\n const combinedSchemaName = operation.method === 'get' ? `${type}Query` : `${type}Mutation`\n const schemaGenerator = new SchemaGenerator(options, {\n fabric: generator.context.fabric,\n oas,\n events: generator.context.events,\n plugin,\n pluginManager,\n mode,\n override: options.override,\n })\n\n const operationSchemas = [schemas.pathParams, schemas.queryParams, schemas.headerParams, schemas.statusCodes, schemas.request, schemas.response]\n .flat()\n .filter(Boolean)\n\n const mapOperationSchema = ({ name, schema, description, keysToOmit, ...options }: OperationSchemaType) => {\n const tree = schemaGenerator.parse({ schema, name, parentName: null })\n const imports = schemaManager.getImports(tree)\n const group = options.operation ? getGroup(options.operation) : undefined\n\n const type = {\n name: schemaManager.getName(name, { type: 'type' }),\n typedName: schemaManager.getName(name, { type: 'type' }),\n file: schemaManager.getFile(options.operationName || name, { group }),\n }\n\n return (\n <>\n {mode === 'split' &&\n imports.map((imp) => (\n <File.Import key={[name, imp.name, imp.path, imp.isTypeOnly].join('-')} root={file.path} path={imp.path} name={imp.name} isTypeOnly />\n ))}\n <Type\n name={type.name}\n typedName={type.typedName}\n description={description}\n tree={tree}\n schema={schema}\n mapper={mapper}\n enumType={enumType}\n optionalType={optionalType}\n keysToOmit={keysToOmit}\n syntaxType={syntaxType}\n />\n </>\n )\n }\n\n return (\n <File\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={getBanner({ oas, output: plugin.options.output, config: pluginManager.config })}\n footer={getFooter({ oas, output: plugin.options.output })}\n >\n {operationSchemas.map(mapOperationSchema)}\n\n <File.Source name={combinedSchemaName} isExportable isIndexable isTypeOnly>\n {printCombinedSchema({ name: combinedSchemaName, schemas, pluginManager })}\n </File.Source>\n </File>\n )\n },\n Schema({ schema, plugin }) {\n const {\n options: { mapper, enumType, syntaxType, optionalType, output },\n } = plugin\n const mode = useMode()\n\n const oas = useOas()\n const pluginManager = usePluginManager()\n\n const { getName, getImports, getFile } = useSchemaManager()\n const imports = getImports(schema.tree)\n const schemaFromTree = schema.tree.find((item) => item.keyword === schemaKeywords.schema)\n\n let typedName = getName(schema.name, { type: 'type' })\n\n if (enumType === 'asConst' && schemaFromTree && isKeyword(schemaFromTree, schemaKeywords.enum)) {\n typedName = typedName += 'Key' //Suffix for avoiding collisions (https://github.com/kubb-labs/kubb/issues/1873)\n }\n\n const type = {\n name: getName(schema.name, { type: 'function' }),\n typedName,\n file: getFile(schema.name),\n }\n\n return (\n <File\n baseName={type.file.baseName}\n path={type.file.path}\n meta={type.file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n {mode === 'split' &&\n imports.map((imp) => (\n <File.Import key={[schema.name, imp.path, imp.isTypeOnly].join('-')} root={type.file.path} path={imp.path} name={imp.name} isTypeOnly />\n ))}\n <Type\n name={type.name}\n typedName={type.typedName}\n description={schema.value.description}\n tree={schema.tree}\n schema={schema.value}\n mapper={mapper}\n enumType={enumType}\n optionalType={optionalType}\n syntaxType={syntaxType}\n />\n </File>\n )\n },\n})\n","import path from 'node:path'\nimport { definePlugin, type Group, getBarrelFiles, getMode } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport { OperationGenerator, pluginOasName, SchemaGenerator } from '@kubb/plugin-oas'\nimport { typeGenerator } from './generators'\nimport type { PluginTs } from './types.ts'\n\nexport const pluginTsName = 'plugin-ts' satisfies PluginTs['name']\n\nexport const pluginTs = definePlugin<PluginTs>((options) => {\n const {\n output = { path: 'types', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n enumType = 'asConst',\n enumSuffix = 'enum',\n dateType = 'string',\n unknownType = 'any',\n optionalType = 'questionToken',\n emptySchemaType = unknownType,\n syntaxType = 'type',\n transformers = {},\n mapper = {},\n generators = [typeGenerator].filter(Boolean),\n contentType,\n } = options\n\n const usedEnumNames = {}\n\n return {\n name: pluginTsName,\n options: {\n output,\n transformers,\n dateType,\n optionalType,\n enumType,\n enumSuffix,\n unknownType,\n emptySchemaType,\n syntaxType,\n group,\n override,\n mapper,\n usedEnumNames,\n },\n pre: [pluginOasName],\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Controller`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n const resolvedName = pascalCase(name, { isFile: type === 'file' })\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async install() {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = getMode(path.resolve(root, output.path))\n const oas = await this.getOas()\n\n const schemaGenerator = new SchemaGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\n events: this.events,\n plugin: this.plugin,\n contentType,\n include: undefined,\n override,\n mode,\n output: output.path,\n })\n\n const schemaFiles = await schemaGenerator.build(...generators)\n await this.upsertFile(...schemaFiles)\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\n events: this.events,\n plugin: this.plugin,\n contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const operationFiles = await operationGenerator.build(...generators)\n await this.upsertFile(...operationFiles)\n\n const barrelFiles = await getBarrelFiles(this.fabric.files, {\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginKey: this.plugin.key,\n },\n })\n\n await this.upsertFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;;;AAeA,SAAS,oBAAoB,EAAE,MAAM,SAAS,iBAAoG;CAChJ,MAAMA,aAA0C,EAAE;AAElD,KAAI,QAAQ,SACV,YAAW,cAAcC,uBAA+B,EACtD,OAAO,QAAQ,UAAU,KAAK,QAAQ;EACpC,MAAM,aAAa,cAAc,YAAY;GAC3C,MAAM,IAAI;GACV,WAAW,CAAC,aAAa;GACzB,MAAM;GACP,CAAC;AAEF,SAAOC,w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AAe,KAAK;IACpB,QAAQ,KAAK;IACb,QAAQ,KAAK;IACb;IACA;IACA;IACA;IACA;IACD,CAAC,CAE8C,MAAM,GAAG,WAAW;AACpE,SAAM,KAAK,WAAW,GAAG,eAAe;GAExC,MAAM,cAAc,MAAM,eAAe,KAAK,OAAO,OAAO;IAC1D,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,WAAW,KAAK,OAAO,KACxB;IACF,CAAC;AAEF,SAAM,KAAK,WAAW,GAAG,YAAY;;EAExC;EACD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_components = require('./components-
|
|
1
|
+
const require_components = require('./components-DCfalUek.cjs');
|
|
2
2
|
let node_path = require("node:path");
|
|
3
3
|
node_path = require_components.__toESM(node_path);
|
|
4
4
|
let _kubb_core = require("@kubb/core");
|
|
@@ -6,52 +6,13 @@ let _kubb_core_transformers = require("@kubb/core/transformers");
|
|
|
6
6
|
_kubb_core_transformers = require_components.__toESM(_kubb_core_transformers);
|
|
7
7
|
let _kubb_plugin_oas = require("@kubb/plugin-oas");
|
|
8
8
|
let _kubb_core_hooks = require("@kubb/core/hooks");
|
|
9
|
+
let _kubb_fabric_core_parsers_typescript = require("@kubb/fabric-core/parsers/typescript");
|
|
9
10
|
let _kubb_plugin_oas_generators = require("@kubb/plugin-oas/generators");
|
|
10
11
|
let _kubb_plugin_oas_hooks = require("@kubb/plugin-oas/hooks");
|
|
11
12
|
let _kubb_plugin_oas_utils = require("@kubb/plugin-oas/utils");
|
|
12
13
|
let _kubb_react_fabric = require("@kubb/react-fabric");
|
|
13
14
|
let _kubb_react_fabric_jsx_runtime = require("@kubb/react-fabric/jsx-runtime");
|
|
14
|
-
let _kubb_fabric_core_parsers_typescript = require("@kubb/fabric-core/parsers/typescript");
|
|
15
|
-
|
|
16
|
-
//#region src/generators/oasGenerator.tsx
|
|
17
|
-
const oasGenerator = (0, _kubb_plugin_oas_generators.createReactGenerator)({
|
|
18
|
-
name: "oas",
|
|
19
|
-
Operations({ plugin }) {
|
|
20
|
-
const { options: { output }, key: pluginKey } = plugin;
|
|
21
|
-
const pluginManager = (0, _kubb_core_hooks.usePluginManager)();
|
|
22
|
-
const oas = (0, _kubb_plugin_oas_hooks.useOas)();
|
|
23
|
-
const file = pluginManager.getFile({
|
|
24
|
-
name: "oas",
|
|
25
|
-
extname: ".ts",
|
|
26
|
-
pluginKey
|
|
27
|
-
});
|
|
28
|
-
return /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsxs)(_kubb_react_fabric.File, {
|
|
29
|
-
baseName: file.baseName,
|
|
30
|
-
path: file.path,
|
|
31
|
-
meta: file.meta,
|
|
32
|
-
banner: (0, _kubb_plugin_oas_utils.getBanner)({
|
|
33
|
-
oas,
|
|
34
|
-
output,
|
|
35
|
-
config: pluginManager.config
|
|
36
|
-
}),
|
|
37
|
-
footer: (0, _kubb_plugin_oas_utils.getFooter)({
|
|
38
|
-
oas,
|
|
39
|
-
output
|
|
40
|
-
}),
|
|
41
|
-
children: [/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
42
|
-
name: ["Infer"],
|
|
43
|
-
path: "@kubb/oas",
|
|
44
|
-
isTypeOnly: true
|
|
45
|
-
}), /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(require_components.OasType, {
|
|
46
|
-
name: "oas",
|
|
47
|
-
typeName: "Oas",
|
|
48
|
-
api: oas.api
|
|
49
|
-
})]
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
15
|
|
|
54
|
-
//#endregion
|
|
55
16
|
//#region src/generators/typeGenerator.tsx
|
|
56
17
|
function printCombinedSchema({ name, schemas, pluginManager }) {
|
|
57
18
|
const properties = {};
|
|
@@ -149,10 +110,11 @@ const typeGenerator = (0, _kubb_plugin_oas_generators.createReactGenerator)({
|
|
|
149
110
|
schemas.request,
|
|
150
111
|
schemas.response
|
|
151
112
|
].flat().filter(Boolean);
|
|
152
|
-
const mapOperationSchema = ({ name, schema
|
|
113
|
+
const mapOperationSchema = ({ name, schema, description, keysToOmit, ...options$1 }) => {
|
|
153
114
|
const tree = schemaGenerator.parse({
|
|
154
|
-
|
|
155
|
-
name
|
|
115
|
+
schema,
|
|
116
|
+
name,
|
|
117
|
+
parentName: null
|
|
156
118
|
});
|
|
157
119
|
const imports = schemaManager.getImports(tree);
|
|
158
120
|
const group = options$1.operation ? getGroup(options$1.operation) : void 0;
|
|
@@ -176,7 +138,7 @@ const typeGenerator = (0, _kubb_plugin_oas_generators.createReactGenerator)({
|
|
|
176
138
|
typedName: type$1.typedName,
|
|
177
139
|
description,
|
|
178
140
|
tree,
|
|
179
|
-
schema
|
|
141
|
+
schema,
|
|
180
142
|
mapper,
|
|
181
143
|
enumType,
|
|
182
144
|
optionalType,
|
|
@@ -269,7 +231,7 @@ const pluginTs = (0, _kubb_core.definePlugin)((options) => {
|
|
|
269
231
|
const { output = {
|
|
270
232
|
path: "types",
|
|
271
233
|
barrelType: "named"
|
|
272
|
-
}, group, exclude = [], include, override = [], enumType = "asConst", enumSuffix = "enum", dateType = "string", unknownType = "any", optionalType = "questionToken", emptySchemaType = unknownType, syntaxType = "type", transformers: transformers$1 = {},
|
|
234
|
+
}, group, exclude = [], include, override = [], enumType = "asConst", enumSuffix = "enum", dateType = "string", unknownType = "any", optionalType = "questionToken", emptySchemaType = unknownType, syntaxType = "type", transformers: transformers$1 = {}, mapper = {}, generators = [typeGenerator].filter(Boolean), contentType } = options;
|
|
273
235
|
return {
|
|
274
236
|
name: pluginTsName,
|
|
275
237
|
options: {
|
|
@@ -277,7 +239,6 @@ const pluginTs = (0, _kubb_core.definePlugin)((options) => {
|
|
|
277
239
|
transformers: transformers$1,
|
|
278
240
|
dateType,
|
|
279
241
|
optionalType,
|
|
280
|
-
oasType,
|
|
281
242
|
enumType,
|
|
282
243
|
enumSuffix,
|
|
283
244
|
unknownType,
|
|
@@ -353,12 +314,6 @@ const pluginTs = (0, _kubb_core.definePlugin)((options) => {
|
|
|
353
314
|
});
|
|
354
315
|
|
|
355
316
|
//#endregion
|
|
356
|
-
Object.defineProperty(exports, 'oasGenerator', {
|
|
357
|
-
enumerable: true,
|
|
358
|
-
get: function () {
|
|
359
|
-
return oasGenerator;
|
|
360
|
-
}
|
|
361
|
-
});
|
|
362
317
|
Object.defineProperty(exports, 'pluginTs', {
|
|
363
318
|
enumerable: true,
|
|
364
319
|
get: function () {
|
|
@@ -377,4 +332,4 @@ Object.defineProperty(exports, 'typeGenerator', {
|
|
|
377
332
|
return typeGenerator;
|
|
378
333
|
}
|
|
379
334
|
});
|
|
380
|
-
//# sourceMappingURL=plugin-
|
|
335
|
+
//# sourceMappingURL=plugin-N8vqlDtu.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-N8vqlDtu.cjs","names":["properties: Record<string, ts.TypeNode>","transformers","SchemaGenerator","options","type","File","Type","schemaKeywords","pluginOasName","path","options","groupName: Group['name']","transformers","SchemaGenerator","OperationGenerator"],"sources":["../src/generators/typeGenerator.tsx","../src/plugin.ts"],"sourcesContent":["import type { PluginManager } from '@kubb/core'\nimport { useMode, usePluginManager } from '@kubb/core/hooks'\nimport transformers from '@kubb/core/transformers'\nimport { print } from '@kubb/fabric-core/parsers/typescript'\nimport { isKeyword, type OperationSchemas, type OperationSchema as OperationSchemaType, SchemaGenerator, schemaKeywords } from '@kubb/plugin-oas'\nimport { createReactGenerator } from '@kubb/plugin-oas/generators'\nimport { useOas, useOperationManager, useSchemaManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { File } from '@kubb/react-fabric'\nimport type ts from 'typescript'\nimport { Type } from '../components'\nimport * as factory from '../factory.ts'\nimport { pluginTsName } from '../plugin.ts'\nimport type { PluginTs } from '../types'\n\nfunction printCombinedSchema({ name, schemas, pluginManager }: { name: string; schemas: OperationSchemas; pluginManager: PluginManager }): string {\n const properties: Record<string, ts.TypeNode> = {}\n\n if (schemas.response) {\n properties['response'] = factory.createUnionDeclaration({\n nodes: schemas.responses.map((res) => {\n const identifier = pluginManager.resolveName({\n name: res.name,\n pluginKey: [pluginTsName],\n type: 'function',\n })\n\n return factory.createTypeReferenceNode(factory.createIdentifier(identifier), undefined)\n }),\n })!\n }\n\n if (schemas.request) {\n const identifier = pluginManager.resolveName({\n name: schemas.request.name,\n pluginKey: [pluginTsName],\n type: 'function',\n })\n properties['request'] = factory.createTypeReferenceNode(factory.createIdentifier(identifier), undefined)\n }\n\n if (schemas.pathParams) {\n const identifier = pluginManager.resolveName({\n name: schemas.pathParams.name,\n pluginKey: [pluginTsName],\n type: 'function',\n })\n properties['pathParams'] = factory.createTypeReferenceNode(factory.createIdentifier(identifier), undefined)\n }\n\n if (schemas.queryParams) {\n const identifier = pluginManager.resolveName({\n name: schemas.queryParams.name,\n pluginKey: [pluginTsName],\n type: 'function',\n })\n properties['queryParams'] = factory.createTypeReferenceNode(factory.createIdentifier(identifier), undefined)\n }\n\n if (schemas.headerParams) {\n const identifier = pluginManager.resolveName({\n name: schemas.headerParams.name,\n pluginKey: [pluginTsName],\n type: 'function',\n })\n properties['headerParams'] = factory.createTypeReferenceNode(factory.createIdentifier(identifier), undefined)\n }\n\n if (schemas.errors) {\n properties['errors'] = factory.createUnionDeclaration({\n nodes: schemas.errors.map((error) => {\n const identifier = pluginManager.resolveName({\n name: error.name,\n pluginKey: [pluginTsName],\n type: 'function',\n })\n\n return factory.createTypeReferenceNode(factory.createIdentifier(identifier), undefined)\n }),\n })!\n }\n\n const namespaceNode = factory.createTypeAliasDeclaration({\n name,\n type: factory.createTypeLiteralNode(\n Object.keys(properties)\n .map((key) => {\n const type = properties[key]\n if (!type) {\n return undefined\n }\n\n return factory.createPropertySignature({\n name: transformers.pascalCase(key),\n type,\n })\n })\n .filter(Boolean),\n ),\n modifiers: [factory.modifiers.export],\n })\n\n return print(namespaceNode)\n}\n\nexport const typeGenerator = createReactGenerator<PluginTs>({\n name: 'typescript',\n Operation({ operation, generator, plugin }) {\n const {\n options,\n options: { mapper, enumType, syntaxType, optionalType },\n } = plugin\n\n const mode = useMode()\n const pluginManager = usePluginManager()\n\n const oas = useOas()\n const { getSchemas, getFile, getName, getGroup } = useOperationManager(generator)\n const schemaManager = useSchemaManager()\n\n const file = getFile(operation)\n const schemas = getSchemas(operation)\n const type = getName(operation, { type: 'function', pluginKey: [pluginTsName] })\n const combinedSchemaName = operation.method === 'get' ? `${type}Query` : `${type}Mutation`\n const schemaGenerator = new SchemaGenerator(options, {\n fabric: generator.context.fabric,\n oas,\n events: generator.context.events,\n plugin,\n pluginManager,\n mode,\n override: options.override,\n })\n\n const operationSchemas = [schemas.pathParams, schemas.queryParams, schemas.headerParams, schemas.statusCodes, schemas.request, schemas.response]\n .flat()\n .filter(Boolean)\n\n const mapOperationSchema = ({ name, schema, description, keysToOmit, ...options }: OperationSchemaType) => {\n const tree = schemaGenerator.parse({ schema, name, parentName: null })\n const imports = schemaManager.getImports(tree)\n const group = options.operation ? getGroup(options.operation) : undefined\n\n const type = {\n name: schemaManager.getName(name, { type: 'type' }),\n typedName: schemaManager.getName(name, { type: 'type' }),\n file: schemaManager.getFile(options.operationName || name, { group }),\n }\n\n return (\n <>\n {mode === 'split' &&\n imports.map((imp) => (\n <File.Import key={[name, imp.name, imp.path, imp.isTypeOnly].join('-')} root={file.path} path={imp.path} name={imp.name} isTypeOnly />\n ))}\n <Type\n name={type.name}\n typedName={type.typedName}\n description={description}\n tree={tree}\n schema={schema}\n mapper={mapper}\n enumType={enumType}\n optionalType={optionalType}\n keysToOmit={keysToOmit}\n syntaxType={syntaxType}\n />\n </>\n )\n }\n\n return (\n <File\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={getBanner({ oas, output: plugin.options.output, config: pluginManager.config })}\n footer={getFooter({ oas, output: plugin.options.output })}\n >\n {operationSchemas.map(mapOperationSchema)}\n\n <File.Source name={combinedSchemaName} isExportable isIndexable isTypeOnly>\n {printCombinedSchema({ name: combinedSchemaName, schemas, pluginManager })}\n </File.Source>\n </File>\n )\n },\n Schema({ schema, plugin }) {\n const {\n options: { mapper, enumType, syntaxType, optionalType, output },\n } = plugin\n const mode = useMode()\n\n const oas = useOas()\n const pluginManager = usePluginManager()\n\n const { getName, getImports, getFile } = useSchemaManager()\n const imports = getImports(schema.tree)\n const schemaFromTree = schema.tree.find((item) => item.keyword === schemaKeywords.schema)\n\n let typedName = getName(schema.name, { type: 'type' })\n\n if (enumType === 'asConst' && schemaFromTree && isKeyword(schemaFromTree, schemaKeywords.enum)) {\n typedName = typedName += 'Key' //Suffix for avoiding collisions (https://github.com/kubb-labs/kubb/issues/1873)\n }\n\n const type = {\n name: getName(schema.name, { type: 'function' }),\n typedName,\n file: getFile(schema.name),\n }\n\n return (\n <File\n baseName={type.file.baseName}\n path={type.file.path}\n meta={type.file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n {mode === 'split' &&\n imports.map((imp) => (\n <File.Import key={[schema.name, imp.path, imp.isTypeOnly].join('-')} root={type.file.path} path={imp.path} name={imp.name} isTypeOnly />\n ))}\n <Type\n name={type.name}\n typedName={type.typedName}\n description={schema.value.description}\n tree={schema.tree}\n schema={schema.value}\n mapper={mapper}\n enumType={enumType}\n optionalType={optionalType}\n syntaxType={syntaxType}\n />\n </File>\n )\n },\n})\n","import path from 'node:path'\nimport { definePlugin, type Group, getBarrelFiles, getMode } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport { OperationGenerator, pluginOasName, SchemaGenerator } from '@kubb/plugin-oas'\nimport { typeGenerator } from './generators'\nimport type { PluginTs } from './types.ts'\n\nexport const pluginTsName = 'plugin-ts' satisfies PluginTs['name']\n\nexport const pluginTs = definePlugin<PluginTs>((options) => {\n const {\n output = { path: 'types', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n enumType = 'asConst',\n enumSuffix = 'enum',\n dateType = 'string',\n unknownType = 'any',\n optionalType = 'questionToken',\n emptySchemaType = unknownType,\n syntaxType = 'type',\n transformers = {},\n mapper = {},\n generators = [typeGenerator].filter(Boolean),\n contentType,\n } = options\n\n const usedEnumNames = {}\n\n return {\n name: pluginTsName,\n options: {\n output,\n transformers,\n dateType,\n optionalType,\n enumType,\n enumSuffix,\n unknownType,\n emptySchemaType,\n syntaxType,\n group,\n override,\n mapper,\n usedEnumNames,\n },\n pre: [pluginOasName],\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Controller`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n const resolvedName = pascalCase(name, { isFile: type === 'file' })\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async install() {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = getMode(path.resolve(root, output.path))\n const oas = await this.getOas()\n\n const schemaGenerator = new SchemaGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\n events: this.events,\n plugin: this.plugin,\n contentType,\n include: undefined,\n override,\n mode,\n output: output.path,\n })\n\n const schemaFiles = await schemaGenerator.build(...generators)\n await this.upsertFile(...schemaFiles)\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\n events: this.events,\n plugin: this.plugin,\n contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const operationFiles = await operationGenerator.build(...generators)\n await this.upsertFile(...operationFiles)\n\n const barrelFiles = await getBarrelFiles(this.fabric.files, {\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginKey: this.plugin.key,\n },\n })\n\n await this.upsertFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;;;;;AAeA,SAAS,oBAAoB,EAAE,MAAM,SAAS,iBAAoG;CAChJ,MAAMA,aAA0C,EAAE;AAElD,KAAI,QAAQ,SACV,YAAW,wDAA6C,EACtD,OAAO,QAAQ,UAAU,KAAK,QAAQ;EACpC,MAAM,aAAa,cAAc,YAAY;GAC3C,MAAM,IAAI;GACV,WAAW,CAAC,aAAa;GACzB,MAAM;GACP,CAAC;AAEF,wFAAgE,WAAW,EAAE,OAAU;GACvF,EACH,CAAC;AAGJ,KAAI,QAAQ,SAAS;EACnB,MAAM,aAAa,cAAc,YAAY;GAC3C,MAAM,QAAQ,QAAQ;GACtB,WAAW,CAAC,aAAa;GACzB,MAAM;GACP,CAAC;AACF,aAAW,4FAAsE,WAAW,EAAE,OAAU;;AAG1G,KAAI,QAAQ,YAAY;EACtB,MAAM,aAAa,cAAc,YAAY;GAC3C,MAAM,QAAQ,WAAW;GACzB,WAAW,CAAC,aAAa;GACzB,MAAM;GACP,CAAC;AACF,aAAW,+FAAyE,WAAW,EAAE,OAAU;;AAG7G,KAAI,QAAQ,aAAa;EACvB,MAAM,aAAa,cAAc,YAAY;GAC3C,MAAM,QAAQ,YAAY;GAC1B,WAAW,CAAC,aAAa;GACzB,MAAM;GACP,CAAC;AACF,aAAW,gGAA0E,WAAW,EAAE,OAAU;;AAG9G,KAAI,QAAQ,cAAc;EACxB,MAAM,aAAa,cAAc,YAAY;GAC3C,MAAM,QAAQ,aAAa;GAC3B,WAAW,CAAC,aAAa;GACzB,MAAM;GACP,CAAC;AACF,aAAW,iGAA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,iCAAgB,KAAK,OAAO,SAAS;IAC/D,QAAQ,KAAK;IACb;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb,QAAQ,KAAK;IACb;IACA,SAAS;IACT;IACA;IACA,QAAQ,OAAO;IAChB,CAAC,CAEwC,MAAM,GAAG,WAAW;AAC9D,SAAM,KAAK,WAAW,GAAG,YAAY;GAerC,MAAM,iBAAiB,MAbI,IAAIC,oCAAmB,KAAK,OAAO,SAAS;IACrE,QAAQ,KAAK;IACb;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb,QAAQ,KAAK;IACb;IACA;IACA;IACA;IACA;IACD,CAAC,CAE8C,MAAM,GAAG,WAAW;AACpE,SAAM,KAAK,WAAW,GAAG,eAAe;GAExC,MAAM,cAAc,qCAAqB,KAAK,OAAO,OAAO;IAC1D,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,WAAW,KAAK,OAAO,KACxB;IACF,CAAC;AAEF,SAAM,KAAK,WAAW,GAAG,YAAY;;EAExC;EACD"}
|
|
@@ -1,48 +1,45 @@
|
|
|
1
1
|
import { Fabric } from "@kubb/react-fabric";
|
|
2
2
|
import ts from "typescript";
|
|
3
|
-
import * as OasTypes from "oas/types";
|
|
4
|
-
import { HttpMethods as HttpMethod, OASDocument, SchemaObject, User } from "oas/types";
|
|
5
|
-
import { Operation, Operation as Operation$1 } from "oas/operation";
|
|
6
|
-
import { OpenAPIV3 } from "openapi-types";
|
|
7
3
|
import * as oas_normalize_lib_types0 from "oas-normalize/lib/types";
|
|
8
4
|
import BaseOas from "oas";
|
|
5
|
+
import { Operation } from "oas/operation";
|
|
6
|
+
import * as OasTypes from "oas/types";
|
|
7
|
+
import { DiscriminatorObject, HttpMethods, OASDocument, SchemaObject } from "oas/types";
|
|
9
8
|
import { KubbFile } from "@kubb/fabric-core/types";
|
|
10
9
|
import { KubbNode } from "@kubb/react-fabric/types";
|
|
11
10
|
|
|
12
11
|
//#region ../oas/src/types.d.ts
|
|
13
12
|
type contentType = 'application/json' | (string & {});
|
|
14
|
-
type SchemaObject$1 =
|
|
13
|
+
type SchemaObject$1 = SchemaObject & {
|
|
15
14
|
'x-nullable'?: boolean;
|
|
16
15
|
$ref?: string;
|
|
17
16
|
};
|
|
17
|
+
type HttpMethod = HttpMethods;
|
|
18
|
+
type Document = OASDocument;
|
|
19
|
+
type Operation$1 = Operation;
|
|
20
|
+
type DiscriminatorObject$1 = DiscriminatorObject;
|
|
18
21
|
//#endregion
|
|
19
22
|
//#region ../oas/src/Oas.d.ts
|
|
20
23
|
type Options$2 = {
|
|
21
24
|
contentType?: contentType;
|
|
22
25
|
discriminator?: 'strict' | 'inherit';
|
|
23
26
|
};
|
|
24
|
-
declare class Oas
|
|
27
|
+
declare class Oas extends BaseOas {
|
|
25
28
|
#private;
|
|
26
|
-
document:
|
|
27
|
-
constructor(
|
|
28
|
-
oas,
|
|
29
|
-
user
|
|
30
|
-
}: {
|
|
31
|
-
oas: TOAS | OASDocument | string;
|
|
32
|
-
user?: User;
|
|
33
|
-
});
|
|
29
|
+
document: Document;
|
|
30
|
+
constructor(document: Document);
|
|
34
31
|
setOptions(options: Options$2): void;
|
|
35
32
|
get options(): Options$2;
|
|
36
|
-
get($ref: string):
|
|
33
|
+
get<T = unknown>($ref: string): T | null;
|
|
37
34
|
getKey($ref: string): string | undefined;
|
|
38
35
|
set($ref: string, value: unknown): false | undefined;
|
|
39
|
-
getDiscriminator(schema:
|
|
40
|
-
dereferenceWithRef(schema?:
|
|
41
|
-
getResponseSchema(operation: Operation, statusCode: string | number): SchemaObject;
|
|
42
|
-
getRequestSchema(operation: Operation): SchemaObject | undefined;
|
|
43
|
-
getParametersSchema(operation: Operation, inKey: 'path' | 'query' | 'header'): SchemaObject | null;
|
|
36
|
+
getDiscriminator(schema: SchemaObject$1 | null): DiscriminatorObject$1 | null;
|
|
37
|
+
dereferenceWithRef<T = unknown>(schema?: T): T;
|
|
38
|
+
getResponseSchema(operation: Operation$1, statusCode: string | number): SchemaObject$1;
|
|
39
|
+
getRequestSchema(operation: Operation$1): SchemaObject$1 | undefined;
|
|
40
|
+
getParametersSchema(operation: Operation$1, inKey: 'path' | 'query' | 'header'): SchemaObject$1 | null;
|
|
44
41
|
valdiate(): Promise<oas_normalize_lib_types0.ValidationResult>;
|
|
45
|
-
flattenSchema(schema
|
|
42
|
+
flattenSchema(schema: SchemaObject$1 | null): SchemaObject$1 | null;
|
|
46
43
|
}
|
|
47
44
|
//#endregion
|
|
48
45
|
//#region ../core/src/BaseGenerator.d.ts
|
|
@@ -1096,13 +1093,13 @@ type SchemaGeneratorOptions = {
|
|
|
1096
1093
|
* TODO TODO add docs
|
|
1097
1094
|
* @beta
|
|
1098
1095
|
*/
|
|
1099
|
-
schema?: (schemaProps: SchemaProps$1, defaultSchemas: Schema[]) => Schema
|
|
1096
|
+
schema?: (schemaProps: SchemaProps$1, defaultSchemas: Schema[]) => Array<Schema> | undefined;
|
|
1100
1097
|
};
|
|
1101
1098
|
};
|
|
1102
1099
|
type SchemaProps$1 = {
|
|
1103
|
-
|
|
1104
|
-
name
|
|
1105
|
-
parentName
|
|
1100
|
+
schema: SchemaObject$1 | null;
|
|
1101
|
+
name: string | null;
|
|
1102
|
+
parentName: string | null;
|
|
1106
1103
|
};
|
|
1107
1104
|
declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions, Context<TOptions, TPluginOptions>> {
|
|
1108
1105
|
#private;
|
|
@@ -1239,10 +1236,6 @@ type Options = {
|
|
|
1239
1236
|
*/
|
|
1240
1237
|
name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
1241
1238
|
};
|
|
1242
|
-
/**
|
|
1243
|
-
* Export an Oas object as Oas type with `import type { Infer } from '@kubb/oas'`
|
|
1244
|
-
*/
|
|
1245
|
-
oasType?: 'infer' | false;
|
|
1246
1239
|
/**
|
|
1247
1240
|
* @example
|
|
1248
1241
|
* Use https://ts-ast-viewer.com to generate factory code(see createPropertySignature)
|
|
@@ -1270,11 +1263,10 @@ type ResolvedOptions = {
|
|
|
1270
1263
|
emptySchemaType: NonNullable<Options['emptySchemaType']>;
|
|
1271
1264
|
optionalType: NonNullable<Options['optionalType']>;
|
|
1272
1265
|
transformers: NonNullable<Options['transformers']>;
|
|
1273
|
-
oasType: NonNullable<Options['oasType']>;
|
|
1274
1266
|
syntaxType: NonNullable<Options['syntaxType']>;
|
|
1275
1267
|
mapper: Record<string, any>;
|
|
1276
1268
|
};
|
|
1277
1269
|
type PluginTs = PluginFactoryOptions<'plugin-ts', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
1278
1270
|
//#endregion
|
|
1279
1271
|
export { UserPluginWithLifeCycle as a, Schema as i, PluginTs as n, OasTypes as o, ReactGenerator as r, SchemaObject$1 as s, Options as t };
|
|
1280
|
-
//# sourceMappingURL=types-
|
|
1272
|
+
//# sourceMappingURL=types-Ccxn5EsU.d.ts.map
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import * as OasTypes from "oas/types";
|
|
2
|
-
import { HttpMethods as HttpMethod, OASDocument, SchemaObject, User } from "oas/types";
|
|
3
|
-
import { Operation, Operation as Operation$1 } from "oas/operation";
|
|
4
|
-
import { OpenAPIV3 } from "openapi-types";
|
|
5
1
|
import * as oas_normalize_lib_types0 from "oas-normalize/lib/types";
|
|
6
2
|
import BaseOas from "oas";
|
|
3
|
+
import { Operation } from "oas/operation";
|
|
4
|
+
import * as OasTypes from "oas/types";
|
|
5
|
+
import { DiscriminatorObject, HttpMethods, OASDocument, SchemaObject } from "oas/types";
|
|
7
6
|
import { KubbFile } from "@kubb/fabric-core/types";
|
|
8
7
|
import { Fabric } from "@kubb/react-fabric";
|
|
9
8
|
import { KubbNode } from "@kubb/react-fabric/types";
|
|
@@ -11,38 +10,36 @@ import ts from "typescript";
|
|
|
11
10
|
|
|
12
11
|
//#region ../oas/src/types.d.ts
|
|
13
12
|
type contentType = 'application/json' | (string & {});
|
|
14
|
-
type SchemaObject$1 =
|
|
13
|
+
type SchemaObject$1 = SchemaObject & {
|
|
15
14
|
'x-nullable'?: boolean;
|
|
16
15
|
$ref?: string;
|
|
17
16
|
};
|
|
17
|
+
type HttpMethod = HttpMethods;
|
|
18
|
+
type Document = OASDocument;
|
|
19
|
+
type Operation$1 = Operation;
|
|
20
|
+
type DiscriminatorObject$1 = DiscriminatorObject;
|
|
18
21
|
//#endregion
|
|
19
22
|
//#region ../oas/src/Oas.d.ts
|
|
20
23
|
type Options$2 = {
|
|
21
24
|
contentType?: contentType;
|
|
22
25
|
discriminator?: 'strict' | 'inherit';
|
|
23
26
|
};
|
|
24
|
-
declare class Oas
|
|
27
|
+
declare class Oas extends BaseOas {
|
|
25
28
|
#private;
|
|
26
|
-
document:
|
|
27
|
-
constructor(
|
|
28
|
-
oas,
|
|
29
|
-
user
|
|
30
|
-
}: {
|
|
31
|
-
oas: TOAS | OASDocument | string;
|
|
32
|
-
user?: User;
|
|
33
|
-
});
|
|
29
|
+
document: Document;
|
|
30
|
+
constructor(document: Document);
|
|
34
31
|
setOptions(options: Options$2): void;
|
|
35
32
|
get options(): Options$2;
|
|
36
|
-
get($ref: string):
|
|
33
|
+
get<T = unknown>($ref: string): T | null;
|
|
37
34
|
getKey($ref: string): string | undefined;
|
|
38
35
|
set($ref: string, value: unknown): false | undefined;
|
|
39
|
-
getDiscriminator(schema:
|
|
40
|
-
dereferenceWithRef(schema?:
|
|
41
|
-
getResponseSchema(operation: Operation, statusCode: string | number): SchemaObject;
|
|
42
|
-
getRequestSchema(operation: Operation): SchemaObject | undefined;
|
|
43
|
-
getParametersSchema(operation: Operation, inKey: 'path' | 'query' | 'header'): SchemaObject | null;
|
|
36
|
+
getDiscriminator(schema: SchemaObject$1 | null): DiscriminatorObject$1 | null;
|
|
37
|
+
dereferenceWithRef<T = unknown>(schema?: T): T;
|
|
38
|
+
getResponseSchema(operation: Operation$1, statusCode: string | number): SchemaObject$1;
|
|
39
|
+
getRequestSchema(operation: Operation$1): SchemaObject$1 | undefined;
|
|
40
|
+
getParametersSchema(operation: Operation$1, inKey: 'path' | 'query' | 'header'): SchemaObject$1 | null;
|
|
44
41
|
valdiate(): Promise<oas_normalize_lib_types0.ValidationResult>;
|
|
45
|
-
flattenSchema(schema
|
|
42
|
+
flattenSchema(schema: SchemaObject$1 | null): SchemaObject$1 | null;
|
|
46
43
|
}
|
|
47
44
|
//#endregion
|
|
48
45
|
//#region ../core/src/BaseGenerator.d.ts
|
|
@@ -1096,13 +1093,13 @@ type SchemaGeneratorOptions = {
|
|
|
1096
1093
|
* TODO TODO add docs
|
|
1097
1094
|
* @beta
|
|
1098
1095
|
*/
|
|
1099
|
-
schema?: (schemaProps: SchemaProps$1, defaultSchemas: Schema[]) => Schema
|
|
1096
|
+
schema?: (schemaProps: SchemaProps$1, defaultSchemas: Schema[]) => Array<Schema> | undefined;
|
|
1100
1097
|
};
|
|
1101
1098
|
};
|
|
1102
1099
|
type SchemaProps$1 = {
|
|
1103
|
-
|
|
1104
|
-
name
|
|
1105
|
-
parentName
|
|
1100
|
+
schema: SchemaObject$1 | null;
|
|
1101
|
+
name: string | null;
|
|
1102
|
+
parentName: string | null;
|
|
1106
1103
|
};
|
|
1107
1104
|
declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions, Context<TOptions, TPluginOptions>> {
|
|
1108
1105
|
#private;
|
|
@@ -1239,10 +1236,6 @@ type Options = {
|
|
|
1239
1236
|
*/
|
|
1240
1237
|
name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
1241
1238
|
};
|
|
1242
|
-
/**
|
|
1243
|
-
* Export an Oas object as Oas type with `import type { Infer } from '@kubb/oas'`
|
|
1244
|
-
*/
|
|
1245
|
-
oasType?: 'infer' | false;
|
|
1246
1239
|
/**
|
|
1247
1240
|
* @example
|
|
1248
1241
|
* Use https://ts-ast-viewer.com to generate factory code(see createPropertySignature)
|
|
@@ -1270,11 +1263,10 @@ type ResolvedOptions = {
|
|
|
1270
1263
|
emptySchemaType: NonNullable<Options['emptySchemaType']>;
|
|
1271
1264
|
optionalType: NonNullable<Options['optionalType']>;
|
|
1272
1265
|
transformers: NonNullable<Options['transformers']>;
|
|
1273
|
-
oasType: NonNullable<Options['oasType']>;
|
|
1274
1266
|
syntaxType: NonNullable<Options['syntaxType']>;
|
|
1275
1267
|
mapper: Record<string, any>;
|
|
1276
1268
|
};
|
|
1277
1269
|
type PluginTs = PluginFactoryOptions<'plugin-ts', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
1278
1270
|
//#endregion
|
|
1279
1271
|
export { UserPluginWithLifeCycle as a, Schema as i, PluginTs as n, OasTypes as o, ReactGenerator as r, SchemaObject$1 as s, Options as t };
|
|
1280
|
-
//# sourceMappingURL=types-
|
|
1272
|
+
//# sourceMappingURL=types-CwXJHtHd.d.cts.map
|