@kubb/kit 5.10.2 → 5.10.4

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.
@@ -0,0 +1,175 @@
1
+ import { SchemaNode, ast, ast as ast$1 } from "@kubb/ast";
2
+ import { Adapter, AdapterDefinition, AdapterFactory, AdapterFactoryOptions, AdapterSource, BannerMeta, Config, Diagnostic, Diagnostics, Exclude, ExtensionDependencies, ExtensionDependency, ExtensionDependencyRecord, ExtensionFactory, ExtensionKind, ExtensionManifest, ExtensionManifestOption, ExtensionMeta, Generator as Generator$1, GeneratorContext, Group, Hookable, Include, KubbHooks, KubbPluginEndContext, KubbPluginSetupContext, KubbPluginStartContext, NodeCache, NormalizedPlugin, Output, OutputOptions, Override, Parser, ParserDefinition, ParserFactory, Plugin, PluginDefinition, PluginFactory, PluginType, Renderer, RendererFactory, ResolveFileOptions, ResolveImportsOptions, ResolvePathOptions, Resolver, ResolverFile, ResolverFileParams, ResolverFilePathParams, ResolverPatch, Storage, addGenerator, addMacro, assertPluginOption, createAdapter, createRenderer, createResolver, createStorage, defineExtension, defineGenerator, defineParser, definePlugin, fsStorage, injectFile, isExtensionManifest, kubbContext, manifestProblems, memoryStorage, requirePlugin, setMacros, setOptions, setResolver, tryUseKubb, useConfig, useKubb, useOptions } from "@kubb/core";
3
+ //#region src/Url.d.ts
4
+ /**
5
+ * Helpers for OpenAPI/Swagger paths, plus a thin wrapper over the native `URL`.
6
+ */
7
+ export declare class Url {
8
+ /**
9
+ * Converts an OpenAPI/Swagger path to Express-style colon syntax.
10
+ *
11
+ * Distinct parameter names that normalize to the same identifier (e.g. `{group-id}` and
12
+ * `{group.id}` both becoming `groupId`) are deduplicated with an incrementing suffix so
13
+ * `path-to-regexp` never sees two identically named captures.
14
+ *
15
+ * @example
16
+ * Url.toPath('/pet/{petId}') // '/pet/:petId'
17
+ *
18
+ * @example
19
+ * Url.toPath('/point/{point-id}') // '/point/:pointId'
20
+ *
21
+ * @example
22
+ * Url.toPath('/groups/{group-id}/{group.id}.json') // '/groups/:groupId/:groupId2.json'
23
+ */
24
+ static toPath(path: string): string;
25
+ /**
26
+ * Converts an OpenAPI/Swagger path to a template literal that reads each parameter off a
27
+ * grouped `path` request option, e.g. `/pet/{petId}` becomes `` `/pet/${path.petId}` ``.
28
+ * Parameter names are kept exactly as they appear in the OpenAPI path; a name falls back to
29
+ * bracket access (`` path['pet-id'] ``) only when it isn't a valid JS identifier.
30
+ * `prefix` is prepended inside the literal. Shared by generators that pass a grouped `path` object.
31
+ *
32
+ * @example
33
+ * Url.toGroupedTemplateString('/pet/{petId}') // '`/pet/${path.petId}`'
34
+ *
35
+ * @example
36
+ * Url.toGroupedTemplateString('/user/{monetary-account-id}') // '`/user/${path["monetary-account-id"]}`'
37
+ */
38
+ static toGroupedTemplateString(path: string, { prefix }?: {
39
+ prefix?: string | null;
40
+ }): string;
41
+ }
42
+ //#endregion
43
+ //#region src/macros/macroDiscriminatorEnum.d.ts
44
+ type Props$2 = {
45
+ propertyName: string;
46
+ values: Array<string>;
47
+ enumName?: string;
48
+ };
49
+ /**
50
+ * Builds a macro that replaces a discriminator property's schema with a string enum of the given
51
+ * values. Object schemas that lack the property are returned unchanged.
52
+ *
53
+ * @example
54
+ * ```ts
55
+ * const macro = macroDiscriminatorEnum({ propertyName: 'type', values: ['dog', 'cat'] })
56
+ * const next = applyMacros(objectSchema, [macro], { depth: 'shallow' })
57
+ * ```
58
+ */
59
+ export declare function macroDiscriminatorEnum({ propertyName, values, enumName }: Props$2): ast$1.Macro;
60
+ //#endregion
61
+ //#region src/macros/macroEnumName.d.ts
62
+ type Props$1 = {
63
+ parentName: string | null | undefined;
64
+ propName: string;
65
+ enumSuffix: string;
66
+ };
67
+ /**
68
+ * Builds a macro that names an inline enum schema from its parent and property name. Boolean enums
69
+ * are left anonymous. Non-enum nodes are returned unchanged.
70
+ *
71
+ * @example
72
+ * ```ts
73
+ * const macro = macroEnumName({ parentName: 'Pet', propName: 'status', enumSuffix: 'enum' })
74
+ * const named = applyMacros(propSchema, [macro], { depth: 'shallow' })
75
+ * ```
76
+ */
77
+ export declare function macroEnumName({ parentName, propName, enumSuffix }: Props$1): ast$1.Macro;
78
+ //#endregion
79
+ //#region src/macros/macroRenameSchema.d.ts
80
+ type Props = {
81
+ from: string;
82
+ to: string;
83
+ };
84
+ /**
85
+ * Builds a macro that renames a schema consistently: the declaration (`name`) and every ref
86
+ * pointing at it (`targetName`) change together, so imports and printed references stay in
87
+ * sync. Renaming only one side by hand produces imports for files that are never generated.
88
+ *
89
+ * @example
90
+ * `const macro = macroRenameSchema({ from: 'Order', to: 'StoreOrder' })`
91
+ */
92
+ export declare function macroRenameSchema({ from, to }: Props): ast$1.Macro;
93
+ //#endregion
94
+ //#region src/macros/macroSimplifyUnion.d.ts
95
+ /**
96
+ * Removes union members a broader scalar primitive already covers, such as a multi-value string enum
97
+ * sitting next to a plain `string`. Single-value enums are kept.
98
+ *
99
+ * @example
100
+ * ```ts
101
+ * const next = applyMacros(unionSchema, [macroSimplifyUnion], { depth: 'shallow' })
102
+ * ```
103
+ */
104
+ export declare const macroSimplifyUnion: ast$1.Macro;
105
+ //#endregion
106
+ //#region src/utils/mergeAdjacentSchemas.d.ts
107
+ /**
108
+ * Merges a run of adjacent anonymous object members into one. Named or non-object members break the
109
+ * run and pass through unchanged. The merge follows member order, so callers control which members
110
+ * combine by where they place them in the sequence.
111
+ *
112
+ * @example
113
+ * ```ts
114
+ * const merged = [...mergeAdjacentObjectsLazy([objectA, objectB])]
115
+ * ```
116
+ */
117
+ export declare function mergeAdjacentObjectsLazy(members: Iterable<SchemaNode>): Generator<SchemaNode, void, undefined>;
118
+ //#endregion
119
+ //#region src/utils/refs.d.ts
120
+ /** Returns the last path segment of a reference string, for example `'Pet'` for `#/components/schemas/Pet`. */
121
+ export declare const extractRefName: typeof ast$1.refName;
122
+ /**
123
+ * Builds a PascalCase child schema name by joining a parent name and property name.
124
+ * Returns `null` when there is no parent to nest under.
125
+ *
126
+ * @example Nested under a parent
127
+ * `childName('Order', 'shipping_address') // 'OrderShippingAddress'`
128
+ *
129
+ * @example No parent
130
+ * `childName(undefined, 'params') // null`
131
+ */
132
+ export declare function childName(parentName: string | null | undefined, propName: string): string | null;
133
+ /**
134
+ * Builds a PascalCase enum name from the parent name, property name, and a suffix, skipping any
135
+ * empty parts.
136
+ *
137
+ * @example
138
+ * `enumPropName('Order', 'status', 'enum') // 'OrderStatusEnum'`
139
+ */
140
+ export declare function enumPropName(parentName: string | null | undefined, propName: string, enumSuffix: string): string;
141
+ /**
142
+ * Applies `ast.mergeRefWithSchema()` to a resolved ref and rebuilds the result through
143
+ * `ast.factory.createSchema()`. Non-ref nodes and unresolved refs are returned unchanged.
144
+ *
145
+ * @example
146
+ * ```ts
147
+ * const ref = ast.factory.createSchema({ type: 'ref', ref: '#/components/schemas/Pet', description: 'A cute pet' })
148
+ * const merged = syncSchemaRef(ref) // merges with resolved Pet schema
149
+ * ```
150
+ */
151
+ export declare function syncSchemaRef(node: SchemaNode): SchemaNode;
152
+ /**
153
+ * Returns `true` when a schema emits as a plain `string` type.
154
+ *
155
+ * Covers `string`, `uuid`, `email`, `url`, and `datetime` types. For `date` and `time`
156
+ * types, returns `true` only when `representation` is `'string'` rather than `'date'`.
157
+ */
158
+ export declare function isStringType(node: SchemaNode): boolean;
159
+ //#endregion
160
+ //#region src/utils/schemaGraph.d.ts
161
+ /**
162
+ * Returns `true` when a schema, or anything nested inside it, references a circular schema.
163
+ *
164
+ * Pass `excludeName` to skip refs to a specific schema, which helps when self-references are handled
165
+ * on their own. Pair it with `ast.findCircularSchemas()` to decide where lazy wrappers go.
166
+ *
167
+ * @note Reads the memoized `ast.collectSchemaRefs()` set, so a schema is scanned once across plugins.
168
+ */
169
+ export declare function containsCircularRef(node: SchemaNode | undefined, { circularSchemas, excludeName }: {
170
+ circularSchemas: ReadonlySet<string>;
171
+ excludeName?: string;
172
+ }): boolean;
173
+ //#endregion
174
+ export { type Adapter, type AdapterDefinition, type AdapterFactory, type AdapterFactoryOptions, type AdapterSource, type BannerMeta, type Config, type Diagnostic, Diagnostics, type Exclude, type ExtensionDependencies, type ExtensionDependency, type ExtensionDependencyRecord, type ExtensionFactory, type ExtensionKind, type ExtensionManifest, type ExtensionManifestOption, type ExtensionMeta, type Generator$1 as Generator, type GeneratorContext, type Group, Hookable, type Include, type KubbHooks, type KubbPluginEndContext, type KubbPluginSetupContext, type KubbPluginStartContext, type NodeCache, type NormalizedPlugin, type Output, type OutputOptions, type Override, type Parser, type ParserDefinition, type ParserFactory, type Plugin, type PluginDefinition, type PluginFactory, type PluginType, type Renderer, type RendererFactory, type ResolveFileOptions, type ResolveImportsOptions, type ResolvePathOptions, Resolver, type ResolverFile, type ResolverFileParams, type ResolverFilePathParams, type ResolverPatch, type Storage, addGenerator, addMacro, assertPluginOption, ast, createAdapter, createRenderer, createResolver, createStorage, defineExtension, defineGenerator, defineParser, definePlugin, fsStorage, injectFile, isExtensionManifest, kubbContext, manifestProblems, memoryStorage, requirePlugin, setMacros, setOptions, setResolver, tryUseKubb, useConfig, useKubb, useOptions };
175
+ //# sourceMappingURL=index.d.cts.map
package/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
2
1
  import { SchemaNode, ast, ast as ast$1 } from "@kubb/ast";
3
2
  import { Adapter, AdapterDefinition, AdapterFactory, AdapterFactoryOptions, AdapterSource, BannerMeta, Config, Diagnostic, Diagnostics, Exclude, ExtensionDependencies, ExtensionDependency, ExtensionDependencyRecord, ExtensionFactory, ExtensionKind, ExtensionManifest, ExtensionManifestOption, ExtensionMeta, Generator as Generator$1, GeneratorContext, Group, Hookable, Include, KubbHooks, KubbPluginEndContext, KubbPluginSetupContext, KubbPluginStartContext, NodeCache, NormalizedPlugin, Output, OutputOptions, Override, Parser, ParserDefinition, ParserFactory, Plugin, PluginDefinition, PluginFactory, PluginType, Renderer, RendererFactory, ResolveFileOptions, ResolveImportsOptions, ResolvePathOptions, Resolver, ResolverFile, ResolverFileParams, ResolverFilePathParams, ResolverPatch, Storage, addGenerator, addMacro, assertPluginOption, createAdapter, createRenderer, createResolver, createStorage, defineExtension, defineGenerator, defineParser, definePlugin, fsStorage, injectFile, isExtensionManifest, kubbContext, manifestProblems, memoryStorage, requirePlugin, setMacros, setOptions, setResolver, tryUseKubb, useConfig, useKubb, useOptions } from "@kubb/core";
4
3
  //#region src/Url.d.ts
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import "./rolldown-runtime-C0LytTxp.js";
2
1
  import { ast, ast as ast$1 } from "@kubb/ast";
3
2
  import { Diagnostics, Hookable, Resolver, addGenerator, addMacro, assertPluginOption, createAdapter, createRenderer, createResolver, createStorage, defineExtension, defineGenerator, defineParser, definePlugin, fsStorage, injectFile, isExtensionManifest, kubbContext, manifestProblems, memoryStorage, requirePlugin, setMacros, setOptions, setResolver, tryUseKubb, useConfig, useKubb, useOptions } from "@kubb/core";
3
+ //#endregion
4
4
  //#region src/Url.ts
5
5
  /**
6
6
  * Sanitizes a parameter name so it is safe to use as a `path-to-regexp` capture name, without
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/kit",
3
- "version": "5.10.2",
3
+ "version": "5.10.4",
4
4
  "description": "Authoring toolkit for Kubb plugins, generators, adapters, resolvers, and renderers.",
5
5
  "keywords": [
6
6
  "codegen",
@@ -45,16 +45,27 @@
45
45
  "main": "./dist/index.cjs",
46
46
  "module": "./dist/index.js",
47
47
  "types": "./dist/index.d.ts",
48
+ "typesVersions": {
49
+ "*": {
50
+ "testing": [
51
+ "./dist/testing.d.ts"
52
+ ]
53
+ }
54
+ },
48
55
  "exports": {
49
56
  ".": {
50
- "types": "./dist/index.d.ts",
51
- "import": "./dist/index.js",
52
- "require": "./dist/index.cjs"
57
+ "import": {
58
+ "types": "./dist/index.d.ts",
59
+ "default": "./dist/index.js"
60
+ },
61
+ "require": {
62
+ "types": "./dist/index.d.cts",
63
+ "default": "./dist/index.cjs"
64
+ }
53
65
  },
54
66
  "./testing": {
55
67
  "types": "./dist/testing.d.ts",
56
- "import": "./dist/testing.js",
57
- "require": "./dist/testing.cjs"
68
+ "default": "./dist/testing.js"
58
69
  },
59
70
  "./package.json": "./package.json"
60
71
  },
@@ -63,14 +74,22 @@
63
74
  "registry": "https://registry.npmjs.org/"
64
75
  },
65
76
  "dependencies": {
66
- "@kubb/ast": "5.10.2",
67
- "@kubb/core": "5.10.2"
77
+ "@kubb/ast": "5.10.4",
78
+ "@kubb/core": "5.10.4"
68
79
  },
69
80
  "devDependencies": {
70
81
  "@internals/utils": "0.0.1"
71
82
  },
83
+ "peerDependencies": {
84
+ "vitest": "^4.0.0 || ^5.0.0"
85
+ },
86
+ "peerDependenciesMeta": {
87
+ "vitest": {
88
+ "optional": true
89
+ }
90
+ },
72
91
  "engines": {
73
- "node": ">=22"
92
+ "node": ">=22.12"
74
93
  },
75
94
  "scripts": {
76
95
  "build": "tsdown",
@@ -1,8 +0,0 @@
1
- //#region \0rolldown/runtime.js
2
- var __defProp = Object.defineProperty;
3
- var __name = (target, value) => __defProp(target, "name", {
4
- value,
5
- configurable: true
6
- });
7
- //#endregion
8
- export { __name as t };
package/dist/testing.cjs DELETED
@@ -1,9 +0,0 @@
1
- var _kubb_core_mocks = require("@kubb/core/mocks");
2
- Object.keys(_kubb_core_mocks).forEach(function(k) {
3
- if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
4
- enumerable: true,
5
- get: function() {
6
- return _kubb_core_mocks[k];
7
- }
8
- });
9
- });