@kubb/plugin-ts 4.5.1 → 4.5.2
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.d.cts +1 -1
- package/dist/components.d.ts +1 -1
- package/dist/generators.cjs +1 -1
- package/dist/generators.d.cts +1 -1
- package/dist/generators.d.ts +1 -1
- package/dist/generators.js +1 -1
- 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-BKcG9C_Y.cjs → plugin-CE_zX-yD.cjs} +7 -10
- package/dist/plugin-CE_zX-yD.cjs.map +1 -0
- package/dist/{plugin-CfDmQVWY.js → plugin-G3YVWEvI.js} +8 -11
- package/dist/plugin-G3YVWEvI.js.map +1 -0
- package/dist/{types-BXlkWRNi.d.ts → types-HJWH9NtA.d.ts} +47 -42
- package/dist/{types-BdHzvKY0.d.cts → types-SviN821p.d.cts} +47 -42
- package/package.json +8 -8
- package/src/plugin.ts +6 -13
- package/src/types.ts +1 -1
- package/dist/plugin-BKcG9C_Y.cjs.map +0 -1
- package/dist/plugin-CfDmQVWY.js.map +0 -1
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-SviN821p.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-HJWH9NtA.js";
|
|
2
2
|
import { KubbNode } from "@kubb/react-fabric/types";
|
|
3
3
|
|
|
4
4
|
//#region src/components/OasType.d.ts
|
package/dist/generators.cjs
CHANGED
package/dist/generators.d.cts
CHANGED
package/dist/generators.d.ts
CHANGED
package/dist/generators.js
CHANGED
package/dist/index.cjs
CHANGED
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -274,7 +274,7 @@ const typeGenerator = (0, __kubb_plugin_oas_generators.createReactGenerator)({
|
|
|
274
274
|
//#endregion
|
|
275
275
|
//#region src/plugin.ts
|
|
276
276
|
const pluginTsName = "plugin-ts";
|
|
277
|
-
const pluginTs = (0, __kubb_core.
|
|
277
|
+
const pluginTs = (0, __kubb_core.definePlugin)((options) => {
|
|
278
278
|
const { output = {
|
|
279
279
|
path: "types",
|
|
280
280
|
barrelType: "named"
|
|
@@ -294,10 +294,8 @@ const pluginTs = (0, __kubb_core.createPlugin)((options) => {
|
|
|
294
294
|
syntaxType,
|
|
295
295
|
group,
|
|
296
296
|
override,
|
|
297
|
-
mapper
|
|
298
|
-
|
|
299
|
-
context() {
|
|
300
|
-
return { usedEnumNames: {} };
|
|
297
|
+
mapper,
|
|
298
|
+
usedEnumNames: {}
|
|
301
299
|
},
|
|
302
300
|
pre: [__kubb_plugin_oas.pluginOasName],
|
|
303
301
|
resolvePath(baseName, pathMode, options$1) {
|
|
@@ -322,11 +320,10 @@ const pluginTs = (0, __kubb_core.createPlugin)((options) => {
|
|
|
322
320
|
if (type) return transformers$1?.name?.(resolvedName, type) || resolvedName;
|
|
323
321
|
return resolvedName;
|
|
324
322
|
},
|
|
325
|
-
async
|
|
326
|
-
const [swaggerPlugin] = __kubb_core.PluginManager.getDependedPlugins(this.plugins, [__kubb_plugin_oas.pluginOasName]);
|
|
327
|
-
const oas = await swaggerPlugin.context.getOas();
|
|
323
|
+
async install() {
|
|
328
324
|
const root = node_path.default.resolve(this.config.root, this.config.output.path);
|
|
329
325
|
const mode = (0, __kubb_core.getMode)(node_path.default.resolve(root, output.path));
|
|
326
|
+
const oas = await this.getOas();
|
|
330
327
|
const schemaFiles = await new __kubb_plugin_oas.SchemaGenerator(this.plugin.options, {
|
|
331
328
|
fabric: this.fabric,
|
|
332
329
|
oas,
|
|
@@ -351,7 +348,7 @@ const pluginTs = (0, __kubb_core.createPlugin)((options) => {
|
|
|
351
348
|
mode
|
|
352
349
|
}).build(...generators);
|
|
353
350
|
await this.addFile(...operationFiles);
|
|
354
|
-
const barrelFiles = await (0, __kubb_core.getBarrelFiles)(this.
|
|
351
|
+
const barrelFiles = await (0, __kubb_core.getBarrelFiles)(this.fabric.files, {
|
|
355
352
|
type: output.barrelType ?? "named",
|
|
356
353
|
root,
|
|
357
354
|
output,
|
|
@@ -388,4 +385,4 @@ Object.defineProperty(exports, 'typeGenerator', {
|
|
|
388
385
|
return typeGenerator;
|
|
389
386
|
}
|
|
390
387
|
});
|
|
391
|
-
//# sourceMappingURL=plugin-
|
|
388
|
+
//# sourceMappingURL=plugin-CE_zX-yD.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-CE_zX-yD.cjs","names":["File","OasType","properties: Record<string, ts.TypeNode>","transformers","SchemaGenerator","options","type","File","Type","schemaKeywords","pluginOasName","path","options","groupName: Group['name']","transformers","SchemaGenerator","OperationGenerator"],"sources":["../src/generators/oasGenerator.tsx","../src/generators/typeGenerator.tsx","../src/plugin.ts"],"sourcesContent":["import { usePluginManager } from '@kubb/core/hooks'\nimport { createReactGenerator } from '@kubb/plugin-oas/generators'\nimport { useOas } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { File } from '@kubb/react-fabric'\nimport { OasType } from '../components'\nimport type { PluginTs } from '../types.ts'\n\nexport const oasGenerator = createReactGenerator<PluginTs>({\n name: 'oas',\n Operations({ plugin }) {\n const {\n options: { output },\n key: pluginKey,\n } = plugin\n const pluginManager = usePluginManager()\n const oas = useOas()\n\n const file = pluginManager.getFile({ name: 'oas', extname: '.ts', pluginKey })\n\n return (\n <File\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n <File.Import name={['Infer']} path=\"@kubb/oas\" isTypeOnly />\n\n <OasType name={'oas'} typeName={'Oas'} api={oas.api} />\n </File>\n )\n },\n})\n","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 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: schemaObject, description, keysToOmit, ...options }: OperationSchemaType) => {\n const tree = schemaGenerator.parse({ schemaObject, name })\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={schemaObject}\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 if (enumType === 'asPascalConst') {\n console.warn(`enumType '${enumType}' is deprecated`)\n }\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 { oasGenerator, 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 oasType = false,\n mapper = {},\n generators = [typeGenerator, oasType === 'infer' ? oasGenerator : undefined].filter(Boolean),\n contentType,\n } = options\n\n return {\n name: pluginTsName,\n options: {\n output,\n transformers,\n dateType,\n optionalType,\n oasType,\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 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.addFile(...schemaFiles)\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\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.addFile(...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 logger: this.logger,\n })\n\n await this.addFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAQA,MAAa,sEAA8C;CACzD,MAAM;CACN,WAAW,EAAE,UAAU;EACrB,MAAM,EACJ,SAAS,EAAE,UACX,KAAK,cACH;EACJ,MAAM,yDAAkC;EACxC,MAAM,2CA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AAU;GACd,MAAM,OAAOH,kBAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,KAAK;GACpE,MAAM,gCAAeA,kBAAK,QAAQ,MAAM,OAAO,KAAK,CAAC;GACrD,MAAM,MAAM,MAAM,KAAK,QAAQ;GAc/B,MAAM,cAAc,MAZI,IAAII,kCAAgB,KAAK,OAAO,SAAS;IAC/D,QAAQ,KAAK;IACb;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb;IACA,SAAS;IACT;IACA;IACA,QAAQ,OAAO;IAChB,CAAC,CAEwC,MAAM,GAAG,WAAW;AAC9D,SAAM,KAAK,QAAQ,GAAG,YAAY;GAclC,MAAM,iBAAiB,MAZI,IAAIC,qCAAmB,KAAK,OAAO,SAAS;IACrE,QAAQ,KAAK;IACb;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb;IACA;IACA;IACA;IACA;IACD,CAAC,CAE8C,MAAM,GAAG,WAAW;AACpE,SAAM,KAAK,QAAQ,GAAG,eAAe;GAErC,MAAM,cAAc,sCAAqB,KAAK,OAAO,OAAO;IAC1D,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,WAAW,KAAK,OAAO,KACxB;IACD,QAAQ,KAAK;IACd,CAAC;AAEF,SAAM,KAAK,QAAQ,GAAG,YAAY;;EAErC;EACD"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as createTypeLiteralNode, c as modifiers, i as createTypeAliasDeclaration, l as OasType, n as createIdentifier, o as createTypeReferenceNode, r as createPropertySignature, s as createUnionDeclaration, t as Type$1 } from "./components-pUMLFnXb.js";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import {
|
|
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";
|
|
@@ -263,7 +263,7 @@ const typeGenerator = createReactGenerator({
|
|
|
263
263
|
//#endregion
|
|
264
264
|
//#region src/plugin.ts
|
|
265
265
|
const pluginTsName = "plugin-ts";
|
|
266
|
-
const pluginTs =
|
|
266
|
+
const pluginTs = definePlugin((options) => {
|
|
267
267
|
const { output = {
|
|
268
268
|
path: "types",
|
|
269
269
|
barrelType: "named"
|
|
@@ -283,10 +283,8 @@ const pluginTs = createPlugin((options) => {
|
|
|
283
283
|
syntaxType,
|
|
284
284
|
group,
|
|
285
285
|
override,
|
|
286
|
-
mapper
|
|
287
|
-
|
|
288
|
-
context() {
|
|
289
|
-
return { usedEnumNames: {} };
|
|
286
|
+
mapper,
|
|
287
|
+
usedEnumNames: {}
|
|
290
288
|
},
|
|
291
289
|
pre: [pluginOasName],
|
|
292
290
|
resolvePath(baseName, pathMode, options$1) {
|
|
@@ -311,11 +309,10 @@ const pluginTs = createPlugin((options) => {
|
|
|
311
309
|
if (type) return transformers$1?.name?.(resolvedName, type) || resolvedName;
|
|
312
310
|
return resolvedName;
|
|
313
311
|
},
|
|
314
|
-
async
|
|
315
|
-
const [swaggerPlugin] = PluginManager.getDependedPlugins(this.plugins, [pluginOasName]);
|
|
316
|
-
const oas = await swaggerPlugin.context.getOas();
|
|
312
|
+
async install() {
|
|
317
313
|
const root = path.resolve(this.config.root, this.config.output.path);
|
|
318
314
|
const mode = getMode(path.resolve(root, output.path));
|
|
315
|
+
const oas = await this.getOas();
|
|
319
316
|
const schemaFiles = await new SchemaGenerator(this.plugin.options, {
|
|
320
317
|
fabric: this.fabric,
|
|
321
318
|
oas,
|
|
@@ -340,7 +337,7 @@ const pluginTs = createPlugin((options) => {
|
|
|
340
337
|
mode
|
|
341
338
|
}).build(...generators);
|
|
342
339
|
await this.addFile(...operationFiles);
|
|
343
|
-
const barrelFiles = await getBarrelFiles(this.
|
|
340
|
+
const barrelFiles = await getBarrelFiles(this.fabric.files, {
|
|
344
341
|
type: output.barrelType ?? "named",
|
|
345
342
|
root,
|
|
346
343
|
output,
|
|
@@ -354,4 +351,4 @@ const pluginTs = createPlugin((options) => {
|
|
|
354
351
|
|
|
355
352
|
//#endregion
|
|
356
353
|
export { oasGenerator as i, pluginTsName as n, typeGenerator as r, pluginTs as t };
|
|
357
|
-
//# sourceMappingURL=plugin-
|
|
354
|
+
//# sourceMappingURL=plugin-G3YVWEvI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-G3YVWEvI.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/oasGenerator.tsx","../src/generators/typeGenerator.tsx","../src/plugin.ts"],"sourcesContent":["import { usePluginManager } from '@kubb/core/hooks'\nimport { createReactGenerator } from '@kubb/plugin-oas/generators'\nimport { useOas } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { File } from '@kubb/react-fabric'\nimport { OasType } from '../components'\nimport type { PluginTs } from '../types.ts'\n\nexport const oasGenerator = createReactGenerator<PluginTs>({\n name: 'oas',\n Operations({ plugin }) {\n const {\n options: { output },\n key: pluginKey,\n } = plugin\n const pluginManager = usePluginManager()\n const oas = useOas()\n\n const file = pluginManager.getFile({ name: 'oas', extname: '.ts', pluginKey })\n\n return (\n <File\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n <File.Import name={['Infer']} path=\"@kubb/oas\" isTypeOnly />\n\n <OasType name={'oas'} typeName={'Oas'} api={oas.api} />\n </File>\n )\n },\n})\n","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 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: schemaObject, description, keysToOmit, ...options }: OperationSchemaType) => {\n const tree = schemaGenerator.parse({ schemaObject, name })\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={schemaObject}\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 if (enumType === 'asPascalConst') {\n console.warn(`enumType '${enumType}' is deprecated`)\n }\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 { oasGenerator, 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 oasType = false,\n mapper = {},\n generators = [typeGenerator, oasType === 'infer' ? oasGenerator : undefined].filter(Boolean),\n contentType,\n } = options\n\n return {\n name: pluginTsName,\n options: {\n output,\n transformers,\n dateType,\n optionalType,\n oasType,\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 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.addFile(...schemaFiles)\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\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.addFile(...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 logger: this.logger,\n })\n\n await this.addFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;;;AAQA,MAAa,eAAe,qBAA+B;CACzD,MAAM;CACN,WAAW,EAAE,UAAU;EACrB,MAAM,EACJ,SAAS,EAAE,UACX,KAAK,cACH;EACJ,MAAM,gBAAgB,kBAAkB;EACxC,MAAM,MAAM,QAAQ;EAEpB,MAAM,OAAO,cAAc,QAAQ;GAAE,MAAM;GAAO,SAAS;GAAO;GAAW,CAAC;AAE9E,SACE,qBAAC;GACC,UAAU,KAAK;GACf,MAAM,KAAK;GACX,MAAM,KAAK;GACX,QAAQ,UAAU;IAAE;IAAK;IAAQ,QAAQ,cAAc;IAAQ,CAAC;GAChE,QAAQ,UAAU;IAAE;IAAK;IAAQ,CAAC;cAElC,oBAAC,KAAK;IAAO,MAA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O,MAAM,KAAK,OAAO,OAAO,KAAK;GACpE,MAAM,OAAO,QAAQ,KAAK,QAAQ,MAAM,OAAO,KAAK,CAAC;GACrD,MAAM,MAAM,MAAM,KAAK,QAAQ;GAc/B,MAAM,cAAc,MAZI,IAAI,gBAAgB,KAAK,OAAO,SAAS;IAC/D,QAAQ,KAAK;IACb;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb;IACA,SAAS;IACT;IACA;IACA,QAAQ,OAAO;IAChB,CAAC,CAEwC,MAAM,GAAG,WAAW;AAC9D,SAAM,KAAK,QAAQ,GAAG,YAAY;GAclC,MAAM,iBAAiB,MAZI,IAAI,mBAAmB,KAAK,OAAO,SAAS;IACrE,QAAQ,KAAK;IACb;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb;IACA;IACA;IACA;IACA;IACD,CAAC,CAE8C,MAAM,GAAG,WAAW;AACpE,SAAM,KAAK,QAAQ,GAAG,eAAe;GAErC,MAAM,cAAc,MAAM,eAAe,KAAK,OAAO,OAAO;IAC1D,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,WAAW,KAAK,OAAO,KACxB;IACD,QAAQ,KAAK;IACd,CAAC;AAEF,SAAM,KAAK,QAAQ,GAAG,YAAY;;EAErC;EACD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Fabric
|
|
1
|
+
import { Fabric } from "@kubb/react-fabric";
|
|
2
2
|
import ts from "typescript";
|
|
3
3
|
import * as OasTypes from "oas/types";
|
|
4
4
|
import { HttpMethods as HttpMethod, OASDocument, SchemaObject, User } from "oas/types";
|
|
@@ -6,9 +6,9 @@ import { Operation, Operation as Operation$1 } from "oas/operation";
|
|
|
6
6
|
import { OpenAPIV3 } from "openapi-types";
|
|
7
7
|
import * as oas_normalize_lib_types0 from "oas-normalize/lib/types";
|
|
8
8
|
import BaseOas from "oas";
|
|
9
|
-
import { KubbNode } from "@kubb/react-fabric/types";
|
|
10
9
|
import { KubbFile } from "@kubb/fabric-core/types";
|
|
11
10
|
import { ConsolaInstance, LogLevel } from "consola";
|
|
11
|
+
import { KubbNode } from "@kubb/react-fabric/types";
|
|
12
12
|
|
|
13
13
|
//#region ../oas/src/types.d.ts
|
|
14
14
|
type contentType = 'application/json' | (string & {});
|
|
@@ -111,6 +111,21 @@ type Logger = {
|
|
|
111
111
|
type PossiblePromise<T> = Promise<T> | T;
|
|
112
112
|
//#endregion
|
|
113
113
|
//#region ../core/src/types.d.ts
|
|
114
|
+
declare global {
|
|
115
|
+
namespace Kubb {
|
|
116
|
+
interface PluginContext {}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Config used in `kubb.config.ts`
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* import { defineConfig } from '@kubb/core'
|
|
124
|
+
* export default defineConfig({
|
|
125
|
+
* ...
|
|
126
|
+
* })
|
|
127
|
+
*/
|
|
128
|
+
|
|
114
129
|
type InputPath = {
|
|
115
130
|
/**
|
|
116
131
|
* Specify your Swagger/OpenAPI file, either as an absolute path or a path relative to the root.
|
|
@@ -265,11 +280,8 @@ type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> =
|
|
|
265
280
|
* Specifies the succeeding plugins for the current plugin. You can pass an array of succeeding plugin names, and the current plugin will be executed before these plugins.
|
|
266
281
|
*/
|
|
267
282
|
post?: Array<string>;
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
} : {
|
|
271
|
-
context: (this: TOptions['name'] extends 'core' ? null : Omit<PluginContext<TOptions>, 'addFile'>) => TOptions['context'];
|
|
272
|
-
});
|
|
283
|
+
inject?: (this: PluginContext<TOptions>, context: PluginContext<TOptions>) => TOptions['context'];
|
|
284
|
+
};
|
|
273
285
|
type UserPluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = UserPlugin<TOptions> & PluginLifecycle<TOptions>;
|
|
274
286
|
type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
275
287
|
/**
|
|
@@ -295,25 +307,26 @@ type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
|
295
307
|
* Options set for a specific plugin(see kubb.config.js), passthrough of options.
|
|
296
308
|
*/
|
|
297
309
|
options: TOptions['resolvedOptions'];
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
310
|
+
install: (this: PluginContext<TOptions>, context: PluginContext<TOptions>) => PossiblePromise<void>;
|
|
311
|
+
/**
|
|
312
|
+
* Define a context that can be used by other plugins, see `PluginManager' where we convert from `UserPlugin` to `Plugin`(used when calling `definePlugin`).
|
|
313
|
+
*/
|
|
314
|
+
inject: (this: PluginContext<TOptions>, context: PluginContext<TOptions>) => TOptions['context'];
|
|
315
|
+
};
|
|
303
316
|
type PluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions> & PluginLifecycle<TOptions>;
|
|
304
317
|
type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
305
318
|
/**
|
|
306
319
|
* Start of the lifecycle of a plugin.
|
|
307
320
|
* @type hookParallel
|
|
308
321
|
*/
|
|
309
|
-
|
|
322
|
+
install?: (this: PluginContext<TOptions>, context: PluginContext<TOptions>) => PossiblePromise<void>;
|
|
310
323
|
/**
|
|
311
324
|
* Resolve to a Path based on a baseName(example: `./Pet.ts`) and directory(example: `./models`).
|
|
312
325
|
* Options can als be included.
|
|
313
326
|
* @type hookFirst
|
|
314
327
|
* @example ('./Pet.ts', './src/gen/') => '/src/gen/Pet.ts'
|
|
315
328
|
*/
|
|
316
|
-
resolvePath?: (this: PluginContext<TOptions>, baseName: KubbFile.BaseName, mode?: KubbFile.Mode, options?: TOptions['resolvePathOptions']) => KubbFile.
|
|
329
|
+
resolvePath?: (this: PluginContext<TOptions>, baseName: KubbFile.BaseName, mode?: KubbFile.Mode, options?: TOptions['resolvePathOptions']) => KubbFile.Path;
|
|
317
330
|
/**
|
|
318
331
|
* Resolve to a name based on a string.
|
|
319
332
|
* Useful when converting to PascalCase or camelCase.
|
|
@@ -321,11 +334,6 @@ type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOption
|
|
|
321
334
|
* @example ('pet') => 'Pet'
|
|
322
335
|
*/
|
|
323
336
|
resolveName?: (this: PluginContext<TOptions>, name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
324
|
-
/**
|
|
325
|
-
* End of the plugin lifecycle.
|
|
326
|
-
* @type hookParallel
|
|
327
|
-
*/
|
|
328
|
-
buildEnd?: (this: PluginContext<TOptions>) => PossiblePromise<void>;
|
|
329
337
|
};
|
|
330
338
|
type PluginLifecycleHooks = keyof PluginLifecycle;
|
|
331
339
|
type PluginParameter<H extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H]>;
|
|
@@ -352,24 +360,15 @@ type ResolveNameParams = {
|
|
|
352
360
|
type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
353
361
|
fabric: Fabric;
|
|
354
362
|
config: Config;
|
|
355
|
-
/**
|
|
356
|
-
* @deprecated
|
|
357
|
-
*/
|
|
358
|
-
fileManager: FileManager;
|
|
359
363
|
pluginManager: PluginManager;
|
|
360
|
-
addFile: (...file: Array<KubbFile.File>) => Promise<
|
|
361
|
-
resolvePath: (params: ResolvePathParams<TOptions['resolvePathOptions']>) => KubbFile.OptionalPath;
|
|
362
|
-
resolveName: (params: ResolveNameParams) => string;
|
|
364
|
+
addFile: (...file: Array<KubbFile.File>) => Promise<void>;
|
|
363
365
|
logger: Logger;
|
|
364
|
-
|
|
365
|
-
* All plugins
|
|
366
|
-
*/
|
|
367
|
-
plugins: Plugin[];
|
|
366
|
+
mode: KubbFile.Mode;
|
|
368
367
|
/**
|
|
369
368
|
* Current plugin
|
|
370
369
|
*/
|
|
371
370
|
plugin: Plugin<TOptions>;
|
|
372
|
-
};
|
|
371
|
+
} & Kubb.PluginContext;
|
|
373
372
|
/**
|
|
374
373
|
* Specify the export location for the files and define the behavior of the output
|
|
375
374
|
*/
|
|
@@ -444,13 +443,14 @@ type GetFileProps<TOptions = object> = {
|
|
|
444
443
|
};
|
|
445
444
|
declare class PluginManager {
|
|
446
445
|
#private;
|
|
447
|
-
readonly plugins: Set<Plugin<PluginFactoryOptions<string, object, object, any, object>>>;
|
|
448
446
|
readonly events: EventEmitter<Events>;
|
|
449
447
|
readonly config: Config;
|
|
450
448
|
readonly executed: Array<Executer>;
|
|
451
449
|
readonly logger: Logger;
|
|
452
450
|
readonly options: Options$2;
|
|
453
451
|
constructor(config: Config, options: Options$2);
|
|
452
|
+
getContext<TOptions extends PluginFactoryOptions>(plugin: Plugin<TOptions>): PluginContext<TOptions> & Record<string, any>;
|
|
453
|
+
get plugins(): Array<Plugin>;
|
|
454
454
|
getFile<TOptions = object>({
|
|
455
455
|
name,
|
|
456
456
|
mode,
|
|
@@ -460,7 +460,7 @@ declare class PluginManager {
|
|
|
460
460
|
}: GetFileProps<TOptions>): KubbFile.File<{
|
|
461
461
|
pluginKey: Plugin['key'];
|
|
462
462
|
}>;
|
|
463
|
-
resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => KubbFile.
|
|
463
|
+
resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => KubbFile.Path;
|
|
464
464
|
resolveName: (params: ResolveNameParams) => string;
|
|
465
465
|
/**
|
|
466
466
|
* Instead of calling `pluginManager.events.on` you can use `pluginManager.on`. This one also has better types.
|
|
@@ -548,11 +548,9 @@ declare class PluginManager {
|
|
|
548
548
|
}): Promise<void>;
|
|
549
549
|
getPluginByKey(pluginKey: Plugin['key']): Plugin | undefined;
|
|
550
550
|
getPluginsByKey(hookName: keyof PluginWithLifeCycle, pluginKey: Plugin['key']): Plugin[];
|
|
551
|
-
static getDependedPlugins<T1 extends PluginFactoryOptions, T2 extends PluginFactoryOptions = never, T3 extends PluginFactoryOptions = never, TOutput = (T3 extends never ? (T2 extends never ? [T1: Plugin<T1>] : [T1: Plugin<T1>, T2: Plugin<T2>]) : [T1: Plugin<T1>, T2: Plugin<T2>, T3: Plugin<T3>])>(plugins: Array<Plugin>, dependedPluginNames: string | string[]): TOutput;
|
|
552
|
-
static get hooks(): readonly ["buildStart", "resolvePath", "resolveName", "buildEnd"];
|
|
553
551
|
}
|
|
554
552
|
//#endregion
|
|
555
|
-
//#region ../core/src/
|
|
553
|
+
//#region ../core/src/utils/getBarrelFiles.d.ts
|
|
556
554
|
type FileMetaBase = {
|
|
557
555
|
pluginKey?: Plugin['key'];
|
|
558
556
|
};
|
|
@@ -670,7 +668,7 @@ type SchemaKeywordMapper = {
|
|
|
670
668
|
/**
|
|
671
669
|
* Full qualified path.
|
|
672
670
|
*/
|
|
673
|
-
path: KubbFile.
|
|
671
|
+
path: KubbFile.Path;
|
|
674
672
|
/**
|
|
675
673
|
* When true `File.Import` will be used.
|
|
676
674
|
* When false a reference will be used inside the current file.
|
|
@@ -775,6 +773,15 @@ type Schema = {
|
|
|
775
773
|
} | SchemaKeywordMapper[keyof SchemaKeywordMapper];
|
|
776
774
|
//#endregion
|
|
777
775
|
//#region ../plugin-oas/src/types.d.ts
|
|
776
|
+
type Context$2 = {
|
|
777
|
+
getOas(): Promise<Oas>;
|
|
778
|
+
getBaseURL(): Promise<string | undefined>;
|
|
779
|
+
};
|
|
780
|
+
declare global {
|
|
781
|
+
namespace Kubb {
|
|
782
|
+
interface PluginContext extends Context$2 {}
|
|
783
|
+
}
|
|
784
|
+
}
|
|
778
785
|
type ResolvePathOptions = {
|
|
779
786
|
pluginKey?: Plugin['key'];
|
|
780
787
|
group?: {
|
|
@@ -795,7 +802,7 @@ type ResolvePathOptions = {
|
|
|
795
802
|
type Ref = {
|
|
796
803
|
propertyName: string;
|
|
797
804
|
originalName: string;
|
|
798
|
-
path: KubbFile.
|
|
805
|
+
path: KubbFile.Path;
|
|
799
806
|
pluginKey?: Plugin['key'];
|
|
800
807
|
};
|
|
801
808
|
type Refs = Record<string, Ref>;
|
|
@@ -1100,9 +1107,7 @@ type ResolvedOptions = {
|
|
|
1100
1107
|
syntaxType: NonNullable<Options$1['syntaxType']>;
|
|
1101
1108
|
mapper: Record<string, any>;
|
|
1102
1109
|
};
|
|
1103
|
-
type PluginTs = PluginFactoryOptions<'plugin-ts', Options$1, ResolvedOptions,
|
|
1104
|
-
usedEnumNames: Record<string, number>;
|
|
1105
|
-
}, ResolvePathOptions>;
|
|
1110
|
+
type PluginTs = PluginFactoryOptions<'plugin-ts', Options$1, ResolvedOptions, never, ResolvePathOptions>;
|
|
1106
1111
|
//#endregion
|
|
1107
1112
|
export { UserPluginWithLifeCycle as a, Schema as i, PluginTs as n, OasTypes as o, ReactGenerator as r, SchemaObject$1 as s, Options$1 as t };
|
|
1108
|
-
//# sourceMappingURL=types-
|
|
1113
|
+
//# sourceMappingURL=types-HJWH9NtA.d.ts.map
|
|
@@ -4,10 +4,10 @@ import { Operation, Operation as Operation$1 } from "oas/operation";
|
|
|
4
4
|
import { OpenAPIV3 } from "openapi-types";
|
|
5
5
|
import * as oas_normalize_lib_types0 from "oas-normalize/lib/types";
|
|
6
6
|
import BaseOas from "oas";
|
|
7
|
-
import { KubbNode } from "@kubb/react-fabric/types";
|
|
8
7
|
import { KubbFile } from "@kubb/fabric-core/types";
|
|
9
|
-
import { Fabric
|
|
8
|
+
import { Fabric } from "@kubb/react-fabric";
|
|
10
9
|
import { ConsolaInstance, LogLevel } from "consola";
|
|
10
|
+
import { KubbNode } from "@kubb/react-fabric/types";
|
|
11
11
|
import ts from "typescript";
|
|
12
12
|
|
|
13
13
|
//#region ../oas/src/types.d.ts
|
|
@@ -111,6 +111,21 @@ type Logger = {
|
|
|
111
111
|
type PossiblePromise<T> = Promise<T> | T;
|
|
112
112
|
//#endregion
|
|
113
113
|
//#region ../core/src/types.d.ts
|
|
114
|
+
declare global {
|
|
115
|
+
namespace Kubb {
|
|
116
|
+
interface PluginContext {}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Config used in `kubb.config.ts`
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* import { defineConfig } from '@kubb/core'
|
|
124
|
+
* export default defineConfig({
|
|
125
|
+
* ...
|
|
126
|
+
* })
|
|
127
|
+
*/
|
|
128
|
+
|
|
114
129
|
type InputPath = {
|
|
115
130
|
/**
|
|
116
131
|
* Specify your Swagger/OpenAPI file, either as an absolute path or a path relative to the root.
|
|
@@ -265,11 +280,8 @@ type UserPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> =
|
|
|
265
280
|
* Specifies the succeeding plugins for the current plugin. You can pass an array of succeeding plugin names, and the current plugin will be executed before these plugins.
|
|
266
281
|
*/
|
|
267
282
|
post?: Array<string>;
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
} : {
|
|
271
|
-
context: (this: TOptions['name'] extends 'core' ? null : Omit<PluginContext<TOptions>, 'addFile'>) => TOptions['context'];
|
|
272
|
-
});
|
|
283
|
+
inject?: (this: PluginContext<TOptions>, context: PluginContext<TOptions>) => TOptions['context'];
|
|
284
|
+
};
|
|
273
285
|
type UserPluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = UserPlugin<TOptions> & PluginLifecycle<TOptions>;
|
|
274
286
|
type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
275
287
|
/**
|
|
@@ -295,25 +307,26 @@ type Plugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
|
295
307
|
* Options set for a specific plugin(see kubb.config.js), passthrough of options.
|
|
296
308
|
*/
|
|
297
309
|
options: TOptions['resolvedOptions'];
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
310
|
+
install: (this: PluginContext<TOptions>, context: PluginContext<TOptions>) => PossiblePromise<void>;
|
|
311
|
+
/**
|
|
312
|
+
* Define a context that can be used by other plugins, see `PluginManager' where we convert from `UserPlugin` to `Plugin`(used when calling `definePlugin`).
|
|
313
|
+
*/
|
|
314
|
+
inject: (this: PluginContext<TOptions>, context: PluginContext<TOptions>) => TOptions['context'];
|
|
315
|
+
};
|
|
303
316
|
type PluginWithLifeCycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = Plugin<TOptions> & PluginLifecycle<TOptions>;
|
|
304
317
|
type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
305
318
|
/**
|
|
306
319
|
* Start of the lifecycle of a plugin.
|
|
307
320
|
* @type hookParallel
|
|
308
321
|
*/
|
|
309
|
-
|
|
322
|
+
install?: (this: PluginContext<TOptions>, context: PluginContext<TOptions>) => PossiblePromise<void>;
|
|
310
323
|
/**
|
|
311
324
|
* Resolve to a Path based on a baseName(example: `./Pet.ts`) and directory(example: `./models`).
|
|
312
325
|
* Options can als be included.
|
|
313
326
|
* @type hookFirst
|
|
314
327
|
* @example ('./Pet.ts', './src/gen/') => '/src/gen/Pet.ts'
|
|
315
328
|
*/
|
|
316
|
-
resolvePath?: (this: PluginContext<TOptions>, baseName: KubbFile.BaseName, mode?: KubbFile.Mode, options?: TOptions['resolvePathOptions']) => KubbFile.
|
|
329
|
+
resolvePath?: (this: PluginContext<TOptions>, baseName: KubbFile.BaseName, mode?: KubbFile.Mode, options?: TOptions['resolvePathOptions']) => KubbFile.Path;
|
|
317
330
|
/**
|
|
318
331
|
* Resolve to a name based on a string.
|
|
319
332
|
* Useful when converting to PascalCase or camelCase.
|
|
@@ -321,11 +334,6 @@ type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOption
|
|
|
321
334
|
* @example ('pet') => 'Pet'
|
|
322
335
|
*/
|
|
323
336
|
resolveName?: (this: PluginContext<TOptions>, name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
324
|
-
/**
|
|
325
|
-
* End of the plugin lifecycle.
|
|
326
|
-
* @type hookParallel
|
|
327
|
-
*/
|
|
328
|
-
buildEnd?: (this: PluginContext<TOptions>) => PossiblePromise<void>;
|
|
329
337
|
};
|
|
330
338
|
type PluginLifecycleHooks = keyof PluginLifecycle;
|
|
331
339
|
type PluginParameter<H extends PluginLifecycleHooks> = Parameters<Required<PluginLifecycle>[H]>;
|
|
@@ -352,24 +360,15 @@ type ResolveNameParams = {
|
|
|
352
360
|
type PluginContext<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
|
|
353
361
|
fabric: Fabric;
|
|
354
362
|
config: Config;
|
|
355
|
-
/**
|
|
356
|
-
* @deprecated
|
|
357
|
-
*/
|
|
358
|
-
fileManager: FileManager;
|
|
359
363
|
pluginManager: PluginManager;
|
|
360
|
-
addFile: (...file: Array<KubbFile.File>) => Promise<
|
|
361
|
-
resolvePath: (params: ResolvePathParams<TOptions['resolvePathOptions']>) => KubbFile.OptionalPath;
|
|
362
|
-
resolveName: (params: ResolveNameParams) => string;
|
|
364
|
+
addFile: (...file: Array<KubbFile.File>) => Promise<void>;
|
|
363
365
|
logger: Logger;
|
|
364
|
-
|
|
365
|
-
* All plugins
|
|
366
|
-
*/
|
|
367
|
-
plugins: Plugin[];
|
|
366
|
+
mode: KubbFile.Mode;
|
|
368
367
|
/**
|
|
369
368
|
* Current plugin
|
|
370
369
|
*/
|
|
371
370
|
plugin: Plugin<TOptions>;
|
|
372
|
-
};
|
|
371
|
+
} & Kubb.PluginContext;
|
|
373
372
|
/**
|
|
374
373
|
* Specify the export location for the files and define the behavior of the output
|
|
375
374
|
*/
|
|
@@ -444,13 +443,14 @@ type GetFileProps<TOptions = object> = {
|
|
|
444
443
|
};
|
|
445
444
|
declare class PluginManager {
|
|
446
445
|
#private;
|
|
447
|
-
readonly plugins: Set<Plugin<PluginFactoryOptions<string, object, object, any, object>>>;
|
|
448
446
|
readonly events: EventEmitter<Events>;
|
|
449
447
|
readonly config: Config;
|
|
450
448
|
readonly executed: Array<Executer>;
|
|
451
449
|
readonly logger: Logger;
|
|
452
450
|
readonly options: Options$2;
|
|
453
451
|
constructor(config: Config, options: Options$2);
|
|
452
|
+
getContext<TOptions extends PluginFactoryOptions>(plugin: Plugin<TOptions>): PluginContext<TOptions> & Record<string, any>;
|
|
453
|
+
get plugins(): Array<Plugin>;
|
|
454
454
|
getFile<TOptions = object>({
|
|
455
455
|
name,
|
|
456
456
|
mode,
|
|
@@ -460,7 +460,7 @@ declare class PluginManager {
|
|
|
460
460
|
}: GetFileProps<TOptions>): KubbFile.File<{
|
|
461
461
|
pluginKey: Plugin['key'];
|
|
462
462
|
}>;
|
|
463
|
-
resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => KubbFile.
|
|
463
|
+
resolvePath: <TOptions = object>(params: ResolvePathParams<TOptions>) => KubbFile.Path;
|
|
464
464
|
resolveName: (params: ResolveNameParams) => string;
|
|
465
465
|
/**
|
|
466
466
|
* Instead of calling `pluginManager.events.on` you can use `pluginManager.on`. This one also has better types.
|
|
@@ -548,11 +548,9 @@ declare class PluginManager {
|
|
|
548
548
|
}): Promise<void>;
|
|
549
549
|
getPluginByKey(pluginKey: Plugin['key']): Plugin | undefined;
|
|
550
550
|
getPluginsByKey(hookName: keyof PluginWithLifeCycle, pluginKey: Plugin['key']): Plugin[];
|
|
551
|
-
static getDependedPlugins<T1 extends PluginFactoryOptions, T2 extends PluginFactoryOptions = never, T3 extends PluginFactoryOptions = never, TOutput = (T3 extends never ? (T2 extends never ? [T1: Plugin<T1>] : [T1: Plugin<T1>, T2: Plugin<T2>]) : [T1: Plugin<T1>, T2: Plugin<T2>, T3: Plugin<T3>])>(plugins: Array<Plugin>, dependedPluginNames: string | string[]): TOutput;
|
|
552
|
-
static get hooks(): readonly ["buildStart", "resolvePath", "resolveName", "buildEnd"];
|
|
553
551
|
}
|
|
554
552
|
//#endregion
|
|
555
|
-
//#region ../core/src/
|
|
553
|
+
//#region ../core/src/utils/getBarrelFiles.d.ts
|
|
556
554
|
type FileMetaBase = {
|
|
557
555
|
pluginKey?: Plugin['key'];
|
|
558
556
|
};
|
|
@@ -670,7 +668,7 @@ type SchemaKeywordMapper = {
|
|
|
670
668
|
/**
|
|
671
669
|
* Full qualified path.
|
|
672
670
|
*/
|
|
673
|
-
path: KubbFile.
|
|
671
|
+
path: KubbFile.Path;
|
|
674
672
|
/**
|
|
675
673
|
* When true `File.Import` will be used.
|
|
676
674
|
* When false a reference will be used inside the current file.
|
|
@@ -775,6 +773,15 @@ type Schema = {
|
|
|
775
773
|
} | SchemaKeywordMapper[keyof SchemaKeywordMapper];
|
|
776
774
|
//#endregion
|
|
777
775
|
//#region ../plugin-oas/src/types.d.ts
|
|
776
|
+
type Context$2 = {
|
|
777
|
+
getOas(): Promise<Oas>;
|
|
778
|
+
getBaseURL(): Promise<string | undefined>;
|
|
779
|
+
};
|
|
780
|
+
declare global {
|
|
781
|
+
namespace Kubb {
|
|
782
|
+
interface PluginContext extends Context$2 {}
|
|
783
|
+
}
|
|
784
|
+
}
|
|
778
785
|
type ResolvePathOptions = {
|
|
779
786
|
pluginKey?: Plugin['key'];
|
|
780
787
|
group?: {
|
|
@@ -795,7 +802,7 @@ type ResolvePathOptions = {
|
|
|
795
802
|
type Ref = {
|
|
796
803
|
propertyName: string;
|
|
797
804
|
originalName: string;
|
|
798
|
-
path: KubbFile.
|
|
805
|
+
path: KubbFile.Path;
|
|
799
806
|
pluginKey?: Plugin['key'];
|
|
800
807
|
};
|
|
801
808
|
type Refs = Record<string, Ref>;
|
|
@@ -1100,9 +1107,7 @@ type ResolvedOptions = {
|
|
|
1100
1107
|
syntaxType: NonNullable<Options$1['syntaxType']>;
|
|
1101
1108
|
mapper: Record<string, any>;
|
|
1102
1109
|
};
|
|
1103
|
-
type PluginTs = PluginFactoryOptions<'plugin-ts', Options$1, ResolvedOptions,
|
|
1104
|
-
usedEnumNames: Record<string, number>;
|
|
1105
|
-
}, ResolvePathOptions>;
|
|
1110
|
+
type PluginTs = PluginFactoryOptions<'plugin-ts', Options$1, ResolvedOptions, never, ResolvePathOptions>;
|
|
1106
1111
|
//#endregion
|
|
1107
1112
|
export { UserPluginWithLifeCycle as a, Schema as i, PluginTs as n, OasTypes as o, ReactGenerator as r, SchemaObject$1 as s, Options$1 as t };
|
|
1108
|
-
//# sourceMappingURL=types-
|
|
1113
|
+
//# sourceMappingURL=types-SviN821p.d.cts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-ts",
|
|
3
|
-
"version": "4.5.
|
|
3
|
+
"version": "4.5.2",
|
|
4
4
|
"description": "TypeScript code generation plugin for Kubb, transforming OpenAPI schemas into TypeScript interfaces, types, and utility functions.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -64,19 +64,19 @@
|
|
|
64
64
|
}
|
|
65
65
|
],
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@kubb/fabric-core": "0.2.
|
|
68
|
-
"@kubb/react-fabric": "0.2.
|
|
67
|
+
"@kubb/fabric-core": "0.2.19",
|
|
68
|
+
"@kubb/react-fabric": "0.2.19",
|
|
69
69
|
"remeda": "^2.32.0",
|
|
70
70
|
"typescript": "5.9.3",
|
|
71
|
-
"@kubb/core": "4.5.
|
|
72
|
-
"@kubb/oas": "4.5.
|
|
73
|
-
"@kubb/plugin-oas": "4.5.
|
|
71
|
+
"@kubb/core": "4.5.2",
|
|
72
|
+
"@kubb/oas": "4.5.2",
|
|
73
|
+
"@kubb/plugin-oas": "4.5.2"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
|
-
"@kubb/plugin-oas": "4.5.
|
|
76
|
+
"@kubb/plugin-oas": "4.5.2"
|
|
77
77
|
},
|
|
78
78
|
"peerDependencies": {
|
|
79
|
-
"@kubb/react-fabric": "0.2.
|
|
79
|
+
"@kubb/react-fabric": "0.2.19"
|
|
80
80
|
},
|
|
81
81
|
"engines": {
|
|
82
82
|
"node": ">=20"
|
package/src/plugin.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import path from 'node:path'
|
|
2
|
-
import {
|
|
2
|
+
import { definePlugin, type Group, getBarrelFiles, getMode } from '@kubb/core'
|
|
3
3
|
import { camelCase, pascalCase } from '@kubb/core/transformers'
|
|
4
|
-
import type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'
|
|
5
4
|
import { OperationGenerator, pluginOasName, SchemaGenerator } from '@kubb/plugin-oas'
|
|
6
5
|
import { oasGenerator, typeGenerator } from './generators'
|
|
7
6
|
import type { PluginTs } from './types.ts'
|
|
8
7
|
|
|
9
8
|
export const pluginTsName = 'plugin-ts' satisfies PluginTs['name']
|
|
10
9
|
|
|
11
|
-
export const pluginTs =
|
|
10
|
+
export const pluginTs = definePlugin<PluginTs>((options) => {
|
|
12
11
|
const {
|
|
13
12
|
output = { path: 'types', barrelType: 'named' },
|
|
14
13
|
group,
|
|
@@ -45,11 +44,7 @@ export const pluginTs = createPlugin<PluginTs>((options) => {
|
|
|
45
44
|
group,
|
|
46
45
|
override,
|
|
47
46
|
mapper,
|
|
48
|
-
|
|
49
|
-
context() {
|
|
50
|
-
return {
|
|
51
|
-
usedEnumNames: {} as Record<string, number>,
|
|
52
|
-
}
|
|
47
|
+
usedEnumNames: {},
|
|
53
48
|
},
|
|
54
49
|
pre: [pluginOasName],
|
|
55
50
|
resolvePath(baseName, pathMode, options) {
|
|
@@ -95,12 +90,10 @@ export const pluginTs = createPlugin<PluginTs>((options) => {
|
|
|
95
90
|
|
|
96
91
|
return resolvedName
|
|
97
92
|
},
|
|
98
|
-
async
|
|
99
|
-
const [swaggerPlugin]: [Plugin<SwaggerPluginOptions>] = PluginManager.getDependedPlugins<SwaggerPluginOptions>(this.plugins, [pluginOasName])
|
|
100
|
-
|
|
101
|
-
const oas = await swaggerPlugin.context.getOas()
|
|
93
|
+
async install() {
|
|
102
94
|
const root = path.resolve(this.config.root, this.config.output.path)
|
|
103
95
|
const mode = getMode(path.resolve(root, output.path))
|
|
96
|
+
const oas = await this.getOas()
|
|
104
97
|
|
|
105
98
|
const schemaGenerator = new SchemaGenerator(this.plugin.options, {
|
|
106
99
|
fabric: this.fabric,
|
|
@@ -132,7 +125,7 @@ export const pluginTs = createPlugin<PluginTs>((options) => {
|
|
|
132
125
|
const operationFiles = await operationGenerator.build(...generators)
|
|
133
126
|
await this.addFile(...operationFiles)
|
|
134
127
|
|
|
135
|
-
const barrelFiles = await getBarrelFiles(this.
|
|
128
|
+
const barrelFiles = await getBarrelFiles(this.fabric.files, {
|
|
136
129
|
type: output.barrelType ?? 'named',
|
|
137
130
|
root,
|
|
138
131
|
output,
|
package/src/types.ts
CHANGED
|
@@ -113,4 +113,4 @@ type ResolvedOptions = {
|
|
|
113
113
|
mapper: Record<string, any>
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
export type PluginTs = PluginFactoryOptions<'plugin-ts', Options, ResolvedOptions,
|
|
116
|
+
export type PluginTs = PluginFactoryOptions<'plugin-ts', Options, ResolvedOptions, never, ResolvePathOptions>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-BKcG9C_Y.cjs","names":["File","OasType","properties: Record<string, ts.TypeNode>","transformers","SchemaGenerator","options","type","File","Type","schemaKeywords","pluginOasName","path","options","groupName: Group['name']","transformers","PluginManager","SchemaGenerator","OperationGenerator"],"sources":["../src/generators/oasGenerator.tsx","../src/generators/typeGenerator.tsx","../src/plugin.ts"],"sourcesContent":["import { usePluginManager } from '@kubb/core/hooks'\nimport { createReactGenerator } from '@kubb/plugin-oas/generators'\nimport { useOas } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { File } from '@kubb/react-fabric'\nimport { OasType } from '../components'\nimport type { PluginTs } from '../types.ts'\n\nexport const oasGenerator = createReactGenerator<PluginTs>({\n name: 'oas',\n Operations({ plugin }) {\n const {\n options: { output },\n key: pluginKey,\n } = plugin\n const pluginManager = usePluginManager()\n const oas = useOas()\n\n const file = pluginManager.getFile({ name: 'oas', extname: '.ts', pluginKey })\n\n return (\n <File\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n <File.Import name={['Infer']} path=\"@kubb/oas\" isTypeOnly />\n\n <OasType name={'oas'} typeName={'Oas'} api={oas.api} />\n </File>\n )\n },\n})\n","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 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: schemaObject, description, keysToOmit, ...options }: OperationSchemaType) => {\n const tree = schemaGenerator.parse({ schemaObject, name })\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={schemaObject}\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 if (enumType === 'asPascalConst') {\n console.warn(`enumType '${enumType}' is deprecated`)\n }\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 { createPlugin, type Group, getBarrelFiles, getMode, type Plugin, PluginManager } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'\nimport { OperationGenerator, pluginOasName, SchemaGenerator } from '@kubb/plugin-oas'\nimport { oasGenerator, typeGenerator } from './generators'\nimport type { PluginTs } from './types.ts'\n\nexport const pluginTsName = 'plugin-ts' satisfies PluginTs['name']\n\nexport const pluginTs = createPlugin<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 oasType = false,\n mapper = {},\n generators = [typeGenerator, oasType === 'infer' ? oasGenerator : undefined].filter(Boolean),\n contentType,\n } = options\n\n return {\n name: pluginTsName,\n options: {\n output,\n transformers,\n dateType,\n optionalType,\n oasType,\n enumType,\n enumSuffix,\n unknownType,\n emptySchemaType,\n syntaxType,\n group,\n override,\n mapper,\n },\n context() {\n return {\n usedEnumNames: {} as Record<string, number>,\n }\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 buildStart() {\n const [swaggerPlugin]: [Plugin<SwaggerPluginOptions>] = PluginManager.getDependedPlugins<SwaggerPluginOptions>(this.plugins, [pluginOasName])\n\n const oas = await swaggerPlugin.context.getOas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = getMode(path.resolve(root, output.path))\n\n const schemaGenerator = new SchemaGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\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.addFile(...schemaFiles)\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\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.addFile(...operationFiles)\n\n const barrelFiles = await getBarrelFiles(this.fileManager.files, {\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginKey: this.plugin.key,\n },\n logger: this.logger,\n })\n\n await this.addFile(...barrelFiles)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.createUnionDeclaration","factory.createTypeReferenceNode","factory.createIdentifier","factory.createTypeAliasDeclaration","factory.createTypeLiteralNode","factory.createPropertySignature","options","type","Type","options","groupName: Group['name']","transformers"],"sources":["../src/generators/oasGenerator.tsx","../src/generators/typeGenerator.tsx","../src/plugin.ts"],"sourcesContent":["import { usePluginManager } from '@kubb/core/hooks'\nimport { createReactGenerator } from '@kubb/plugin-oas/generators'\nimport { useOas } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { File } from '@kubb/react-fabric'\nimport { OasType } from '../components'\nimport type { PluginTs } from '../types.ts'\n\nexport const oasGenerator = createReactGenerator<PluginTs>({\n name: 'oas',\n Operations({ plugin }) {\n const {\n options: { output },\n key: pluginKey,\n } = plugin\n const pluginManager = usePluginManager()\n const oas = useOas()\n\n const file = pluginManager.getFile({ name: 'oas', extname: '.ts', pluginKey })\n\n return (\n <File\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n <File.Import name={['Infer']} path=\"@kubb/oas\" isTypeOnly />\n\n <OasType name={'oas'} typeName={'Oas'} api={oas.api} />\n </File>\n )\n },\n})\n","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 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: schemaObject, description, keysToOmit, ...options }: OperationSchemaType) => {\n const tree = schemaGenerator.parse({ schemaObject, name })\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={schemaObject}\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 if (enumType === 'asPascalConst') {\n console.warn(`enumType '${enumType}' is deprecated`)\n }\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 { createPlugin, type Group, getBarrelFiles, getMode, type Plugin, PluginManager } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'\nimport { OperationGenerator, pluginOasName, SchemaGenerator } from '@kubb/plugin-oas'\nimport { oasGenerator, typeGenerator } from './generators'\nimport type { PluginTs } from './types.ts'\n\nexport const pluginTsName = 'plugin-ts' satisfies PluginTs['name']\n\nexport const pluginTs = createPlugin<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 oasType = false,\n mapper = {},\n generators = [typeGenerator, oasType === 'infer' ? oasGenerator : undefined].filter(Boolean),\n contentType,\n } = options\n\n return {\n name: pluginTsName,\n options: {\n output,\n transformers,\n dateType,\n optionalType,\n oasType,\n enumType,\n enumSuffix,\n unknownType,\n emptySchemaType,\n syntaxType,\n group,\n override,\n mapper,\n },\n context() {\n return {\n usedEnumNames: {} as Record<string, number>,\n }\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 buildStart() {\n const [swaggerPlugin]: [Plugin<SwaggerPluginOptions>] = PluginManager.getDependedPlugins<SwaggerPluginOptions>(this.plugins, [pluginOasName])\n\n const oas = await swaggerPlugin.context.getOas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = getMode(path.resolve(root, output.path))\n\n const schemaGenerator = new SchemaGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\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.addFile(...schemaFiles)\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\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.addFile(...operationFiles)\n\n const barrelFiles = await getBarrelFiles(this.fileManager.files, {\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginKey: this.plugin.key,\n },\n logger: this.logger,\n })\n\n await this.addFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;;;AAQA,MAAa,eAAe,qBAA+B;CACzD,MAAM;CACN,WAAW,EAAE,UAAU;EACrB,MAAM,EACJ,SAAS,EAAE,UACX,KAAK,cACH;EACJ,MAAM,gBAAgB,kBAAkB;EACxC,MAAM,MAAM,QAAQ;EAEpB,MAAM,OAAO,cAAc,QAAQ;GAAE,MAAM;GAAO,SAAS;GAAO;GAAW,CAAC;AAE9E,SACE,qBAAC;GACC,UAAU,KAAK;GACf,MAAM,KAAK;GACX,MAAM,KAAK;GACX,QAAQ,UAAU;IAAE;IAAK;IAAQ,QAAQ,cAAc;IAAQ,CAAC;GAChE,QAAQ,UAAU;IAAE;IAAK;IAAQ,CAAC;cAElC,oBAAC,KAAK;IAAO,MAAM,CAAC,QAAQ;IAAE,MAAK;IAAY;KAAa,EAE5D,oBAAC;IAAQ,MAAM;IAAO,UAAU;IAAO,KAAK,IAAI;KAAO;IAClD;;CAGZ,CAAC;;;;ACnBF,SAAS,oBAAoB,EAAE,MAAM,SAAS,iBAAoG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