@kubb/plugin-ts 4.12.9 → 4.12.11
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-YKTwNDfu.cjs → components-DCfalUek.cjs} +22 -3
- package/dist/components-DCfalUek.cjs.map +1 -0
- package/dist/{components-CbJlTYEP.js → components-Daoap7CS.js} +22 -3
- package/dist/components-Daoap7CS.js.map +1 -0
- 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-DEnfu1Si.js → plugin-DTEjK1nR.js} +10 -49
- package/dist/plugin-DTEjK1nR.js.map +1 -0
- package/dist/{plugin-Bgktd6zB.cjs → plugin-N8vqlDtu.cjs} +9 -54
- package/dist/plugin-N8vqlDtu.cjs.map +1 -0
- package/dist/{types-D6lr3k_H.d.ts → types-Ccxn5EsU.d.ts} +24 -31
- package/dist/{types-Cd_tEnfY.d.cts → types-CwXJHtHd.d.cts} +24 -31
- package/package.json +4 -4
- package/src/generators/__snapshots__/petDict.ts +13 -0
- package/src/generators/index.ts +0 -1
- package/src/generators/typeGenerator.tsx +3 -3
- package/src/parser.ts +23 -1
- package/src/plugin.ts +2 -4
- package/src/types.ts +0 -5
- package/dist/components-CbJlTYEP.js.map +0 -1
- package/dist/components-YKTwNDfu.cjs.map +0 -1
- package/dist/plugin-Bgktd6zB.cjs.map +0 -1
- package/dist/plugin-DEnfu1Si.js.map +0 -1
- package/src/generators/oasGenerator.tsx +0 -35
|
@@ -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,wB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Ae,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,iGAA2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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
|
|
@@ -852,6 +849,7 @@ type SchemaKeywordMapper = {
|
|
|
852
849
|
[x: string]: Schema[];
|
|
853
850
|
};
|
|
854
851
|
additionalProperties: Schema[];
|
|
852
|
+
patternProperties?: Record<string, Schema[]>;
|
|
855
853
|
strict?: boolean;
|
|
856
854
|
};
|
|
857
855
|
};
|
|
@@ -1095,13 +1093,13 @@ type SchemaGeneratorOptions = {
|
|
|
1095
1093
|
* TODO TODO add docs
|
|
1096
1094
|
* @beta
|
|
1097
1095
|
*/
|
|
1098
|
-
schema?: (schemaProps: SchemaProps$1, defaultSchemas: Schema[]) => Schema
|
|
1096
|
+
schema?: (schemaProps: SchemaProps$1, defaultSchemas: Schema[]) => Array<Schema> | undefined;
|
|
1099
1097
|
};
|
|
1100
1098
|
};
|
|
1101
1099
|
type SchemaProps$1 = {
|
|
1102
|
-
|
|
1103
|
-
name
|
|
1104
|
-
parentName
|
|
1100
|
+
schema: SchemaObject$1 | null;
|
|
1101
|
+
name: string | null;
|
|
1102
|
+
parentName: string | null;
|
|
1105
1103
|
};
|
|
1106
1104
|
declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions, Context<TOptions, TPluginOptions>> {
|
|
1107
1105
|
#private;
|
|
@@ -1238,10 +1236,6 @@ type Options = {
|
|
|
1238
1236
|
*/
|
|
1239
1237
|
name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
1240
1238
|
};
|
|
1241
|
-
/**
|
|
1242
|
-
* Export an Oas object as Oas type with `import type { Infer } from '@kubb/oas'`
|
|
1243
|
-
*/
|
|
1244
|
-
oasType?: 'infer' | false;
|
|
1245
1239
|
/**
|
|
1246
1240
|
* @example
|
|
1247
1241
|
* Use https://ts-ast-viewer.com to generate factory code(see createPropertySignature)
|
|
@@ -1269,11 +1263,10 @@ type ResolvedOptions = {
|
|
|
1269
1263
|
emptySchemaType: NonNullable<Options['emptySchemaType']>;
|
|
1270
1264
|
optionalType: NonNullable<Options['optionalType']>;
|
|
1271
1265
|
transformers: NonNullable<Options['transformers']>;
|
|
1272
|
-
oasType: NonNullable<Options['oasType']>;
|
|
1273
1266
|
syntaxType: NonNullable<Options['syntaxType']>;
|
|
1274
1267
|
mapper: Record<string, any>;
|
|
1275
1268
|
};
|
|
1276
1269
|
type PluginTs = PluginFactoryOptions<'plugin-ts', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
1277
1270
|
//#endregion
|
|
1278
1271
|
export { UserPluginWithLifeCycle as a, Schema as i, PluginTs as n, OasTypes as o, ReactGenerator as r, SchemaObject$1 as s, Options as t };
|
|
1279
|
-
//# 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
|
|
@@ -852,6 +849,7 @@ type SchemaKeywordMapper = {
|
|
|
852
849
|
[x: string]: Schema[];
|
|
853
850
|
};
|
|
854
851
|
additionalProperties: Schema[];
|
|
852
|
+
patternProperties?: Record<string, Schema[]>;
|
|
855
853
|
strict?: boolean;
|
|
856
854
|
};
|
|
857
855
|
};
|
|
@@ -1095,13 +1093,13 @@ type SchemaGeneratorOptions = {
|
|
|
1095
1093
|
* TODO TODO add docs
|
|
1096
1094
|
* @beta
|
|
1097
1095
|
*/
|
|
1098
|
-
schema?: (schemaProps: SchemaProps$1, defaultSchemas: Schema[]) => Schema
|
|
1096
|
+
schema?: (schemaProps: SchemaProps$1, defaultSchemas: Schema[]) => Array<Schema> | undefined;
|
|
1099
1097
|
};
|
|
1100
1098
|
};
|
|
1101
1099
|
type SchemaProps$1 = {
|
|
1102
|
-
|
|
1103
|
-
name
|
|
1104
|
-
parentName
|
|
1100
|
+
schema: SchemaObject$1 | null;
|
|
1101
|
+
name: string | null;
|
|
1102
|
+
parentName: string | null;
|
|
1105
1103
|
};
|
|
1106
1104
|
declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGeneratorOptions, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends BaseGenerator<TOptions, Context<TOptions, TPluginOptions>> {
|
|
1107
1105
|
#private;
|
|
@@ -1238,10 +1236,6 @@ type Options = {
|
|
|
1238
1236
|
*/
|
|
1239
1237
|
name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
1240
1238
|
};
|
|
1241
|
-
/**
|
|
1242
|
-
* Export an Oas object as Oas type with `import type { Infer } from '@kubb/oas'`
|
|
1243
|
-
*/
|
|
1244
|
-
oasType?: 'infer' | false;
|
|
1245
1239
|
/**
|
|
1246
1240
|
* @example
|
|
1247
1241
|
* Use https://ts-ast-viewer.com to generate factory code(see createPropertySignature)
|
|
@@ -1269,11 +1263,10 @@ type ResolvedOptions = {
|
|
|
1269
1263
|
emptySchemaType: NonNullable<Options['emptySchemaType']>;
|
|
1270
1264
|
optionalType: NonNullable<Options['optionalType']>;
|
|
1271
1265
|
transformers: NonNullable<Options['transformers']>;
|
|
1272
|
-
oasType: NonNullable<Options['oasType']>;
|
|
1273
1266
|
syntaxType: NonNullable<Options['syntaxType']>;
|
|
1274
1267
|
mapper: Record<string, any>;
|
|
1275
1268
|
};
|
|
1276
1269
|
type PluginTs = PluginFactoryOptions<'plugin-ts', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
1277
1270
|
//#endregion
|
|
1278
1271
|
export { UserPluginWithLifeCycle as a, Schema as i, PluginTs as n, OasTypes as o, ReactGenerator as r, SchemaObject$1 as s, Options as t };
|
|
1279
|
-
//# sourceMappingURL=types-
|
|
1272
|
+
//# sourceMappingURL=types-CwXJHtHd.d.cts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-ts",
|
|
3
|
-
"version": "4.12.
|
|
3
|
+
"version": "4.12.11",
|
|
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",
|
|
@@ -69,9 +69,9 @@
|
|
|
69
69
|
"natural-orderby": "^5.0.0",
|
|
70
70
|
"remeda": "^2.32.0",
|
|
71
71
|
"typescript": "5.9.3",
|
|
72
|
-
"@kubb/core": "4.12.
|
|
73
|
-
"@kubb/oas": "4.12.
|
|
74
|
-
"@kubb/plugin-oas": "4.12.
|
|
72
|
+
"@kubb/core": "4.12.11",
|
|
73
|
+
"@kubb/oas": "4.12.11",
|
|
74
|
+
"@kubb/plugin-oas": "4.12.11"
|
|
75
75
|
},
|
|
76
76
|
"peerDependencies": {
|
|
77
77
|
"@kubb/react-fabric": "0.7.4",
|
package/src/generators/index.ts
CHANGED
|
@@ -136,8 +136,8 @@ export const typeGenerator = createReactGenerator<PluginTs>({
|
|
|
136
136
|
.flat()
|
|
137
137
|
.filter(Boolean)
|
|
138
138
|
|
|
139
|
-
const mapOperationSchema = ({ name, schema
|
|
140
|
-
const tree = schemaGenerator.parse({
|
|
139
|
+
const mapOperationSchema = ({ name, schema, description, keysToOmit, ...options }: OperationSchemaType) => {
|
|
140
|
+
const tree = schemaGenerator.parse({ schema, name, parentName: null })
|
|
141
141
|
const imports = schemaManager.getImports(tree)
|
|
142
142
|
const group = options.operation ? getGroup(options.operation) : undefined
|
|
143
143
|
|
|
@@ -158,7 +158,7 @@ export const typeGenerator = createReactGenerator<PluginTs>({
|
|
|
158
158
|
typedName={type.typedName}
|
|
159
159
|
description={description}
|
|
160
160
|
tree={tree}
|
|
161
|
-
schema={
|
|
161
|
+
schema={schema}
|
|
162
162
|
mapper={mapper}
|
|
163
163
|
enumType={enumType}
|
|
164
164
|
optionalType={optionalType}
|
package/src/parser.ts
CHANGED
|
@@ -336,7 +336,29 @@ export const parse = createParser<ts.Node | null, ParserOptions>({
|
|
|
336
336
|
additionalProperties = factory.createIndexSignature(additionalProperties)
|
|
337
337
|
}
|
|
338
338
|
|
|
339
|
-
|
|
339
|
+
let patternProperties: ts.TypeNode | ts.IndexSignatureDeclaration | undefined
|
|
340
|
+
|
|
341
|
+
if (current.args?.patternProperties) {
|
|
342
|
+
const allPatternSchemas = Object.values(current.args.patternProperties).flat()
|
|
343
|
+
|
|
344
|
+
if (allPatternSchemas.length > 0) {
|
|
345
|
+
patternProperties = allPatternSchemas
|
|
346
|
+
.map((it) => this.parse({ schema, parent: current, name, current: it, siblings: [] }, options))
|
|
347
|
+
.filter(Boolean)
|
|
348
|
+
.at(0) as ts.TypeNode
|
|
349
|
+
|
|
350
|
+
const isNullable = allPatternSchemas.some((schema) => isKeyword(schema, schemaKeywords.nullable))
|
|
351
|
+
if (isNullable) {
|
|
352
|
+
patternProperties = factory.createUnionDeclaration({
|
|
353
|
+
nodes: [patternProperties, factory.keywordTypeNodes.null],
|
|
354
|
+
}) as ts.TypeNode
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
patternProperties = factory.createIndexSignature(patternProperties)
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
return typeKeywordMapper.object([...properties, additionalProperties, patternProperties].filter(Boolean))
|
|
340
362
|
},
|
|
341
363
|
datetime(tree) {
|
|
342
364
|
const { current } = tree
|
package/src/plugin.ts
CHANGED
|
@@ -2,7 +2,7 @@ import path from 'node:path'
|
|
|
2
2
|
import { definePlugin, type Group, getBarrelFiles, getMode } from '@kubb/core'
|
|
3
3
|
import { camelCase, pascalCase } from '@kubb/core/transformers'
|
|
4
4
|
import { OperationGenerator, pluginOasName, SchemaGenerator } from '@kubb/plugin-oas'
|
|
5
|
-
import {
|
|
5
|
+
import { typeGenerator } from './generators'
|
|
6
6
|
import type { PluginTs } from './types.ts'
|
|
7
7
|
|
|
8
8
|
export const pluginTsName = 'plugin-ts' satisfies PluginTs['name']
|
|
@@ -22,9 +22,8 @@ export const pluginTs = definePlugin<PluginTs>((options) => {
|
|
|
22
22
|
emptySchemaType = unknownType,
|
|
23
23
|
syntaxType = 'type',
|
|
24
24
|
transformers = {},
|
|
25
|
-
oasType = false,
|
|
26
25
|
mapper = {},
|
|
27
|
-
generators = [typeGenerator
|
|
26
|
+
generators = [typeGenerator].filter(Boolean),
|
|
28
27
|
contentType,
|
|
29
28
|
} = options
|
|
30
29
|
|
|
@@ -37,7 +36,6 @@ export const pluginTs = definePlugin<PluginTs>((options) => {
|
|
|
37
36
|
transformers,
|
|
38
37
|
dateType,
|
|
39
38
|
optionalType,
|
|
40
|
-
oasType,
|
|
41
39
|
enumType,
|
|
42
40
|
enumSuffix,
|
|
43
41
|
unknownType,
|
package/src/types.ts
CHANGED
|
@@ -80,10 +80,6 @@ export type Options = {
|
|
|
80
80
|
*/
|
|
81
81
|
name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string
|
|
82
82
|
}
|
|
83
|
-
/**
|
|
84
|
-
* Export an Oas object as Oas type with `import type { Infer } from '@kubb/oas'`
|
|
85
|
-
*/
|
|
86
|
-
oasType?: 'infer' | false
|
|
87
83
|
/**
|
|
88
84
|
* @example
|
|
89
85
|
* Use https://ts-ast-viewer.com to generate factory code(see createPropertySignature)
|
|
@@ -112,7 +108,6 @@ type ResolvedOptions = {
|
|
|
112
108
|
emptySchemaType: NonNullable<Options['emptySchemaType']>
|
|
113
109
|
optionalType: NonNullable<Options['optionalType']>
|
|
114
110
|
transformers: NonNullable<Options['transformers']>
|
|
115
|
-
oasType: NonNullable<Options['oasType']>
|
|
116
111
|
syntaxType: NonNullable<Options['syntaxType']>
|
|
117
112
|
mapper: Record<string, any>
|
|
118
113
|
}
|