@kubb/plugin-ts 5.0.6 → 5.0.8

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/OVERVIEW.md ADDED
@@ -0,0 +1,17 @@
1
+ # TypeScript
2
+
3
+ Generates TypeScript types and interfaces from your OpenAPI spec. You get a type for every schema, plus the request, response, and parameter types of each operation.
4
+
5
+ Most other Kubb plugins build on these types. The client, query, mock, and test plugins import them, so add this plugin first.
6
+
7
+ ## Setup
8
+
9
+ No other plugins or packages are needed.
10
+
11
+ ## Options worth knowing
12
+
13
+ - `enum.type` sets how enums are written: `asConst` (default), `enum`, `constEnum`, `literal`, or `inlineLiteral`. `enum.constCasing`, `enum.typeSuffix`, and `enum.keyCasing` tune the names.
14
+ - `syntaxType` writes object schemas as `type` aliases (default) or `interface` declarations.
15
+ - `optionalType` sets how optional properties are written: `questionToken` (default), `undefined`, or `questionTokenAndUndefined`.
16
+ - `arrayType` writes arrays as `T[]` (default) or `Array<T>`.
17
+ - `group` splits the output into folders by tag or path. It does not work with `output.mode: 'file'`.
package/dist/index.cjs CHANGED
@@ -1850,6 +1850,15 @@ const typeGenerator = (0, kubb_kit.defineGenerator)({
1850
1850
  }
1851
1851
  });
1852
1852
  //#endregion
1853
+ //#region kubb-extension.json
1854
+ var compatibility = {
1855
+ "kubb": ">=5.8.0",
1856
+ "node": ">=22"
1857
+ };
1858
+ //#endregion
1859
+ //#region package.json
1860
+ var version = "5.0.8";
1861
+ //#endregion
1853
1862
  //#region src/resolvers/resolverTs.ts
1854
1863
  /**
1855
1864
  * Default resolver used by `@kubb/plugin-ts`. Decides the names and file paths
@@ -1965,52 +1974,52 @@ function assertEnumLikeOptions({ prefix, options }) {
1965
1974
  * })
1966
1975
  * ```
1967
1976
  */
1968
- const pluginTs = (0, kubb_kit.definePlugin)((options) => {
1969
- const { output = {
1970
- path: "types",
1971
- barrel: { type: "named" }
1972
- }, group, exclude = [], include, override = [], enum: enumOptions = {}, optionalType = "questionToken", arrayType = "array", syntaxType = "type", printer, resolver: userResolver, macros: userMacros } = options;
1973
- const groupConfig = createGroupConfig(group);
1974
- const resolvedEnum = {
1975
- type: enumOptions.type ?? "asConst",
1976
- constCasing: enumOptions.constCasing ?? "camelCase",
1977
- typeSuffix: enumOptions.typeSuffix ?? "Key",
1978
- keyCasing: enumOptions.keyCasing ?? "none"
1979
- };
1980
- return {
1977
+ const pluginTs = (0, kubb_kit.definePlugin)({
1978
+ meta: {
1981
1979
  name: pluginTsName,
1982
- options,
1983
- hooks: { "kubb:plugin:setup"(ctx) {
1984
- assertEnumLikeOptions({
1985
- prefix: "",
1986
- options: {
1987
- enum: resolvedEnum,
1988
- syntaxType,
1989
- arrayType,
1990
- optionalType
1991
- }
1992
- });
1993
- for (const [index, entry] of override.entries()) assertEnumLikeOptions({
1994
- prefix: `override[${index}].options.`,
1995
- options: entry.options
1996
- });
1997
- ctx.setOptions({
1998
- output,
1999
- exclude,
2000
- include,
2001
- override,
2002
- optionalType,
2003
- group: groupConfig,
2004
- arrayType,
1980
+ version,
1981
+ compatibility
1982
+ },
1983
+ setup(options) {
1984
+ const { output = {
1985
+ path: "types",
1986
+ barrel: { type: "named" }
1987
+ }, group, exclude = [], include, override = [], enum: enumOptions = {}, optionalType = "questionToken", arrayType = "array", syntaxType = "type", printer, resolver: userResolver, macros: userMacros } = options;
1988
+ const resolvedEnum = {
1989
+ type: enumOptions.type ?? "asConst",
1990
+ constCasing: enumOptions.constCasing ?? "camelCase",
1991
+ typeSuffix: enumOptions.typeSuffix ?? "Key",
1992
+ keyCasing: enumOptions.keyCasing ?? "none"
1993
+ };
1994
+ assertEnumLikeOptions({
1995
+ prefix: "",
1996
+ options: {
2005
1997
  enum: resolvedEnum,
2006
1998
  syntaxType,
2007
- printer
2008
- });
2009
- ctx.setResolver(userResolver ? kubb_kit.Resolver.merge(resolverTs, userResolver) : resolverTs);
2010
- if (userMacros?.length) ctx.setMacros(userMacros);
2011
- ctx.addGenerator(typeGenerator);
2012
- } }
2013
- };
1999
+ arrayType,
2000
+ optionalType
2001
+ }
2002
+ });
2003
+ for (const [index, entry] of override.entries()) assertEnumLikeOptions({
2004
+ prefix: `override[${index}].options.`,
2005
+ options: entry.options
2006
+ });
2007
+ (0, kubb_kit.setResolver)(userResolver ? kubb_kit.Resolver.merge(resolverTs, userResolver) : resolverTs);
2008
+ if (userMacros?.length) (0, kubb_kit.setMacros)(userMacros);
2009
+ (0, kubb_kit.addGenerator)(typeGenerator);
2010
+ return {
2011
+ output,
2012
+ exclude,
2013
+ include,
2014
+ override,
2015
+ optionalType,
2016
+ group: createGroupConfig(group),
2017
+ arrayType,
2018
+ enum: resolvedEnum,
2019
+ syntaxType,
2020
+ printer
2021
+ };
2022
+ }
2014
2023
  });
2015
2024
  //#endregion
2016
2025
  //#region src/printers/functionParams.ts