@kubb/plugin-ts 5.0.15 → 5.0.16
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/index.cjs +1 -61
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2 -62
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
2
|
import { parserTs } from "@kubb/parser-ts";
|
|
3
3
|
import { File, jsxRenderer } from "kubb/jsx";
|
|
4
|
-
import { Resolver, addGenerator,
|
|
4
|
+
import { Resolver, addGenerator, ast, createResolver, defineExtension, defineGenerator, isStringType, setMacros, setResolver, syncSchemaRef } from "kubb/kit";
|
|
5
5
|
import { Fragment, jsx, jsxs } from "kubb/jsx/jsx-runtime";
|
|
6
6
|
//#region \0rolldown/runtime.js
|
|
7
7
|
var __defProp = Object.defineProperty;
|
|
@@ -1638,7 +1638,7 @@ var compatibility = {
|
|
|
1638
1638
|
};
|
|
1639
1639
|
//#endregion
|
|
1640
1640
|
//#region package.json
|
|
1641
|
-
var version = "5.0.
|
|
1641
|
+
var version = "5.0.16";
|
|
1642
1642
|
//#endregion
|
|
1643
1643
|
//#region src/resolvers/resolverTs.ts
|
|
1644
1644
|
/**
|
|
@@ -1684,53 +1684,6 @@ const resolverTs = createResolver({
|
|
|
1684
1684
|
* cross-plugin dependency references.
|
|
1685
1685
|
*/
|
|
1686
1686
|
const pluginTsName = "plugin-ts";
|
|
1687
|
-
const allowedEnumTypes = [
|
|
1688
|
-
"asConst",
|
|
1689
|
-
"enum",
|
|
1690
|
-
"constEnum",
|
|
1691
|
-
"literal",
|
|
1692
|
-
"inlineLiteral"
|
|
1693
|
-
];
|
|
1694
|
-
const allowedSyntaxTypes = ["type", "interface"];
|
|
1695
|
-
const allowedArrayTypes = ["array", "generic"];
|
|
1696
|
-
const allowedOptionalTypes = [
|
|
1697
|
-
"questionToken",
|
|
1698
|
-
"undefined",
|
|
1699
|
-
"questionTokenAndUndefined"
|
|
1700
|
-
];
|
|
1701
|
-
/**
|
|
1702
|
-
* Throws when an enum-like option holds a value outside its allowed set. Options left out are skipped.
|
|
1703
|
-
*/
|
|
1704
|
-
function assertEnumLikeOptions({ prefix, options }) {
|
|
1705
|
-
const checks = [
|
|
1706
|
-
{
|
|
1707
|
-
option: "enum.type",
|
|
1708
|
-
value: options.enum?.type,
|
|
1709
|
-
allowed: allowedEnumTypes
|
|
1710
|
-
},
|
|
1711
|
-
{
|
|
1712
|
-
option: "syntaxType",
|
|
1713
|
-
value: options.syntaxType,
|
|
1714
|
-
allowed: allowedSyntaxTypes
|
|
1715
|
-
},
|
|
1716
|
-
{
|
|
1717
|
-
option: "arrayType",
|
|
1718
|
-
value: options.arrayType,
|
|
1719
|
-
allowed: allowedArrayTypes
|
|
1720
|
-
},
|
|
1721
|
-
{
|
|
1722
|
-
option: "optionalType",
|
|
1723
|
-
value: options.optionalType,
|
|
1724
|
-
allowed: allowedOptionalTypes
|
|
1725
|
-
}
|
|
1726
|
-
];
|
|
1727
|
-
for (const { option, value, allowed } of checks) if (value !== void 0) assertPluginOption({
|
|
1728
|
-
plugin: pluginTsName,
|
|
1729
|
-
option: `${prefix}${option}`,
|
|
1730
|
-
value,
|
|
1731
|
-
allowed
|
|
1732
|
-
});
|
|
1733
|
-
}
|
|
1734
1687
|
/**
|
|
1735
1688
|
* Generates TypeScript `type` aliases and `interface` declarations from an
|
|
1736
1689
|
* OpenAPI spec. The foundation that every other Kubb plugin builds on:
|
|
@@ -1773,19 +1726,6 @@ const pluginTs = defineExtension({
|
|
|
1773
1726
|
typeSuffix: enumOptions.typeSuffix ?? "Key",
|
|
1774
1727
|
keyCasing: enumOptions.keyCasing ?? "none"
|
|
1775
1728
|
};
|
|
1776
|
-
assertEnumLikeOptions({
|
|
1777
|
-
prefix: "",
|
|
1778
|
-
options: {
|
|
1779
|
-
enum: resolvedEnum,
|
|
1780
|
-
syntaxType,
|
|
1781
|
-
arrayType,
|
|
1782
|
-
optionalType
|
|
1783
|
-
}
|
|
1784
|
-
});
|
|
1785
|
-
for (const [index, entry] of override.entries()) assertEnumLikeOptions({
|
|
1786
|
-
prefix: `override[${index}].options.`,
|
|
1787
|
-
options: entry.options
|
|
1788
|
-
});
|
|
1789
1729
|
setResolver(userResolver ? Resolver.merge(resolverTs, userResolver) : resolverTs);
|
|
1790
1730
|
if (userMacros?.length) setMacros(userMacros);
|
|
1791
1731
|
addGenerator(typeGenerator);
|