@kubb/plugin-ts 5.0.6 → 5.0.7

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.d.ts CHANGED
@@ -511,7 +511,7 @@ export declare const pluginTsName = "plugin-ts";
511
511
  * })
512
512
  * ```
513
513
  */
514
- export declare const pluginTs: (options?: Options | undefined) => import("kubb/kit").Plugin<PluginTs>;
514
+ export declare const pluginTs: import("kubb/kit").PluginFactory<PluginTs>;
515
515
  //#endregion
516
516
  //#region src/printers/functionParams.d.ts
517
517
  /**
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import { n as __name, t as __exportAll } from "./rolldown-runtime-CthDji9g.js";
2
2
  import { createRequire } from "node:module";
3
3
  import { parserTs } from "@kubb/parser-ts";
4
4
  import { File, jsxRenderer } from "kubb/jsx";
5
- import { Resolver, assertPluginOption, ast, createResolver, defineGenerator, definePlugin, isStringType, syncSchemaRef } from "kubb/kit";
5
+ import { Resolver, addGenerator, assertPluginOption, ast, createResolver, defineGenerator, definePlugin, isStringType, setMacros, setResolver, syncSchemaRef } from "kubb/kit";
6
6
  import { Fragment, jsx, jsxs } from "kubb/jsx/jsx-runtime";
7
7
  //#region ../../internals/utils/src/casing.ts
8
8
  /**
@@ -1831,6 +1831,9 @@ const typeGenerator = defineGenerator({
1831
1831
  }
1832
1832
  });
1833
1833
  //#endregion
1834
+ //#region package.json
1835
+ var version = "5.0.7";
1836
+ //#endregion
1834
1837
  //#region src/resolvers/resolverTs.ts
1835
1838
  /**
1836
1839
  * Default resolver used by `@kubb/plugin-ts`. Decides the names and file paths
@@ -1946,52 +1949,52 @@ function assertEnumLikeOptions({ prefix, options }) {
1946
1949
  * })
1947
1950
  * ```
1948
1951
  */
1949
- const pluginTs = definePlugin((options) => {
1950
- const { output = {
1951
- path: "types",
1952
- barrel: { type: "named" }
1953
- }, group, exclude = [], include, override = [], enum: enumOptions = {}, optionalType = "questionToken", arrayType = "array", syntaxType = "type", printer, resolver: userResolver, macros: userMacros } = options;
1954
- const groupConfig = createGroupConfig(group);
1955
- const resolvedEnum = {
1956
- type: enumOptions.type ?? "asConst",
1957
- constCasing: enumOptions.constCasing ?? "camelCase",
1958
- typeSuffix: enumOptions.typeSuffix ?? "Key",
1959
- keyCasing: enumOptions.keyCasing ?? "none"
1960
- };
1961
- return {
1952
+ const pluginTs = definePlugin({
1953
+ meta: {
1962
1954
  name: pluginTsName,
1963
- options,
1964
- hooks: { "kubb:plugin:setup"(ctx) {
1965
- assertEnumLikeOptions({
1966
- prefix: "",
1967
- options: {
1968
- enum: resolvedEnum,
1969
- syntaxType,
1970
- arrayType,
1971
- optionalType
1972
- }
1973
- });
1974
- for (const [index, entry] of override.entries()) assertEnumLikeOptions({
1975
- prefix: `override[${index}].options.`,
1976
- options: entry.options
1977
- });
1978
- ctx.setOptions({
1979
- output,
1980
- exclude,
1981
- include,
1982
- override,
1983
- optionalType,
1984
- group: groupConfig,
1985
- arrayType,
1955
+ version,
1956
+ compatibility: { kubb: ">=5.8.0" }
1957
+ },
1958
+ setup(options) {
1959
+ const { output = {
1960
+ path: "types",
1961
+ barrel: { type: "named" }
1962
+ }, group, exclude = [], include, override = [], enum: enumOptions = {}, optionalType = "questionToken", arrayType = "array", syntaxType = "type", printer, resolver: userResolver, macros: userMacros } = options;
1963
+ const resolvedEnum = {
1964
+ type: enumOptions.type ?? "asConst",
1965
+ constCasing: enumOptions.constCasing ?? "camelCase",
1966
+ typeSuffix: enumOptions.typeSuffix ?? "Key",
1967
+ keyCasing: enumOptions.keyCasing ?? "none"
1968
+ };
1969
+ assertEnumLikeOptions({
1970
+ prefix: "",
1971
+ options: {
1986
1972
  enum: resolvedEnum,
1987
1973
  syntaxType,
1988
- printer
1989
- });
1990
- ctx.setResolver(userResolver ? Resolver.merge(resolverTs, userResolver) : resolverTs);
1991
- if (userMacros?.length) ctx.setMacros(userMacros);
1992
- ctx.addGenerator(typeGenerator);
1993
- } }
1994
- };
1974
+ arrayType,
1975
+ optionalType
1976
+ }
1977
+ });
1978
+ for (const [index, entry] of override.entries()) assertEnumLikeOptions({
1979
+ prefix: `override[${index}].options.`,
1980
+ options: entry.options
1981
+ });
1982
+ setResolver(userResolver ? Resolver.merge(resolverTs, userResolver) : resolverTs);
1983
+ if (userMacros?.length) setMacros(userMacros);
1984
+ addGenerator(typeGenerator);
1985
+ return {
1986
+ output,
1987
+ exclude,
1988
+ include,
1989
+ override,
1990
+ optionalType,
1991
+ group: createGroupConfig(group),
1992
+ arrayType,
1993
+ enum: resolvedEnum,
1994
+ syntaxType,
1995
+ printer
1996
+ };
1997
+ }
1995
1998
  });
1996
1999
  //#endregion
1997
2000
  //#region src/printers/functionParams.ts