@kubb/kit 5.0.0-beta.100

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,230 @@
1
+ import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
2
+ import { SchemaNode, ast, ast as ast$1 } from "@kubb/ast";
3
+ import { Adapter, AdapterFactoryOptions, AdapterSource, BannerMeta, Config, Diagnostics, Exclude, Generator as Generator$1, GeneratorContext, Group, Hookable, Include, KubbHooks, KubbPluginEndContext, KubbPluginSetupContext, KubbPluginStartContext, Output, OutputOptions, Override, Parser, Plugin, PluginFactoryOptions, Renderer, RendererFactory, ResolveFileOptions, ResolveImportsOptions, ResolvePathOptions, Resolver, ResolverFile, ResolverFileParams, ResolverFilePathParams, ResolverPatch, Storage, createAdapter, createRenderer, createResolver, createStorage, defineGenerator, defineParser, definePlugin, fsStorage, memoryStorage } from "@kubb/core";
4
+ //#region ../../internals/utils/src/Url.d.ts
5
+ type URLObject = {
6
+ /**
7
+ * The resolved URL string (Express-style or template literal, depending on context).
8
+ */
9
+ url: string;
10
+ /**
11
+ * Extracted path parameters as a key-value map, or `null` when the path has none.
12
+ */
13
+ params: Record<string, string> | null;
14
+ };
15
+ type TemplateOptions = {
16
+ /**
17
+ * Literal text prepended inside the template literal, e.g. a base URL.
18
+ */
19
+ prefix?: string | null;
20
+ /**
21
+ * Transform applied to each extracted parameter name before interpolation.
22
+ */
23
+ replacer?: (pathParam: string) => string;
24
+ };
25
+ type ObjectOptions = {
26
+ /**
27
+ * Controls whether the `url` is rendered as an Express path or a template literal.
28
+ * @default 'path'
29
+ */
30
+ type?: 'path' | 'template';
31
+ /**
32
+ * Transform applied to each extracted parameter name.
33
+ */
34
+ replacer?: (pathParam: string) => string;
35
+ /**
36
+ * When `true`, the result is serialized to a string expression instead of a plain object.
37
+ */
38
+ stringify?: boolean;
39
+ };
40
+ /**
41
+ * Helpers for OpenAPI/Swagger paths, plus a thin wrapper over the native `URL`.
42
+ */
43
+ declare class Url {
44
+ /**
45
+ * Converts an OpenAPI/Swagger path to Express-style colon syntax.
46
+ *
47
+ * @example
48
+ * Url.toPath('/pet/{petId}') // '/pet/:petId'
49
+ */
50
+ static toPath(path: string): string;
51
+ /**
52
+ * Converts an OpenAPI/Swagger path to a TypeScript template literal string.
53
+ * `prefix` is prepended inside the literal, and `replacer` transforms each parameter name.
54
+ *
55
+ * @example
56
+ * Url.toTemplateString('/pet/{petId}') // '`/pet/${petId}`'
57
+ *
58
+ * @example
59
+ * Url.toTemplateString('/pet/{petId}', { prefix: 'https://api' }) // '`https://api/pet/${petId}`'
60
+ */
61
+ static toTemplateString(path: string, { prefix, replacer }?: TemplateOptions): string;
62
+ /**
63
+ * Converts an OpenAPI/Swagger path to a template literal that reads each parameter off a
64
+ * grouped `path` request option, e.g. `/pet/{petId}` becomes `` `/pet/${path.petId}` ``.
65
+ * Parameter names are kept exactly as they appear in the OpenAPI path; a name falls back to
66
+ * bracket access (`` path['pet-id'] ``) only when it isn't a valid JS identifier.
67
+ * `prefix` is prepended inside the literal. Shared by generators that pass a grouped `path` object.
68
+ *
69
+ * @example
70
+ * Url.toGroupedTemplateString('/pet/{petId}') // '`/pet/${path.petId}`'
71
+ *
72
+ * @example
73
+ * Url.toGroupedTemplateString('/user/{monetary-account-id}') // '`/user/${path["monetary-account-id"]}`'
74
+ */
75
+ static toGroupedTemplateString(path: string, { prefix }?: {
76
+ prefix?: string | null;
77
+ }): string;
78
+ /**
79
+ * Returns the path and its extracted params as a structured `URLObject`, or as a stringified
80
+ * expression when `stringify` is set.
81
+ *
82
+ * @example
83
+ * Url.toObject('/pet/{petId}')
84
+ * // { url: '/pet/:petId', params: { petId: 'petId' } }
85
+ */
86
+ static toObject(path: string, { type, replacer, stringify }?: ObjectOptions): URLObject | string;
87
+ }
88
+ //#endregion
89
+ //#region src/macros/macroDiscriminatorEnum.d.ts
90
+ type Props$2 = {
91
+ propertyName: string;
92
+ values: Array<string>;
93
+ enumName?: string;
94
+ };
95
+ /**
96
+ * Builds a macro that replaces a discriminator property's schema with a string enum of the given
97
+ * values. Object schemas that lack the property are returned unchanged.
98
+ *
99
+ * @example
100
+ * ```ts
101
+ * const macro = macroDiscriminatorEnum({ propertyName: 'type', values: ['dog', 'cat'] })
102
+ * const next = applyMacros(objectSchema, [macro], { depth: 'shallow' })
103
+ * ```
104
+ */
105
+ declare function macroDiscriminatorEnum({ propertyName, values, enumName }: Props$2): ast$1.Macro;
106
+ //#endregion
107
+ //#region src/macros/macroEnumName.d.ts
108
+ type Props$1 = {
109
+ parentName: string | null | undefined;
110
+ propName: string;
111
+ enumSuffix: string;
112
+ };
113
+ /**
114
+ * Builds a macro that names an inline enum schema from its parent and property name. Boolean enums
115
+ * are left anonymous. Non-enum nodes are returned unchanged.
116
+ *
117
+ * @example
118
+ * ```ts
119
+ * const macro = macroEnumName({ parentName: 'Pet', propName: 'status', enumSuffix: 'enum' })
120
+ * const named = applyMacros(propSchema, [macro], { depth: 'shallow' })
121
+ * ```
122
+ */
123
+ declare function macroEnumName({ parentName, propName, enumSuffix }: Props$1): ast$1.Macro;
124
+ //#endregion
125
+ //#region src/macros/macroRenameSchema.d.ts
126
+ type Props = {
127
+ from: string;
128
+ to: string;
129
+ };
130
+ /**
131
+ * Builds a macro that renames a schema consistently: the declaration (`name`) and every ref
132
+ * pointing at it (`targetName`) change together, so imports and printed references stay in
133
+ * sync. Renaming only one side by hand produces imports for files that are never generated.
134
+ *
135
+ * @example
136
+ * `const macro = macroRenameSchema({ from: 'Order', to: 'StoreOrder' })`
137
+ */
138
+ declare function macroRenameSchema({ from, to }: Props): ast$1.Macro;
139
+ //#endregion
140
+ //#region src/macros/macroSimplifyUnion.d.ts
141
+ /**
142
+ * Removes union members a broader scalar primitive already covers, such as a multi-value string enum
143
+ * sitting next to a plain `string`. Single-value enums are kept.
144
+ *
145
+ * @example
146
+ * ```ts
147
+ * const next = applyMacros(unionSchema, [macroSimplifyUnion], { depth: 'shallow' })
148
+ * ```
149
+ */
150
+ declare const macroSimplifyUnion: ast$1.Macro;
151
+ //#endregion
152
+ //#region src/utils/mergeAdjacentSchemas.d.ts
153
+ /**
154
+ * Merges a run of adjacent anonymous object members into one. Named or non-object members break the
155
+ * run and pass through unchanged. The merge follows member order, so callers control which members
156
+ * combine by where they place them in the sequence.
157
+ *
158
+ * @example
159
+ * ```ts
160
+ * const merged = [...mergeAdjacentObjectsLazy([objectA, objectB])]
161
+ * ```
162
+ */
163
+ declare function mergeAdjacentObjectsLazy(members: Iterable<SchemaNode>): Generator<SchemaNode, void, undefined>;
164
+ //#endregion
165
+ //#region src/utils/refs.d.ts
166
+ /**
167
+ * Returns the last path segment of a reference string.
168
+ *
169
+ * @example
170
+ * `extractRefName('#/components/schemas/Pet') // 'Pet'`
171
+ */
172
+ declare function extractRefName(ref: string): string;
173
+ /**
174
+ * Builds a PascalCase child schema name by joining a parent name and property name.
175
+ * Returns `null` when there is no parent to nest under.
176
+ *
177
+ * @example Nested under a parent
178
+ * `childName('Order', 'shipping_address') // 'OrderShippingAddress'`
179
+ *
180
+ * @example No parent
181
+ * `childName(undefined, 'params') // null`
182
+ */
183
+ declare function childName(parentName: string | null | undefined, propName: string): string | null;
184
+ /**
185
+ * Builds a PascalCase enum name from the parent name, property name, and a suffix, skipping any
186
+ * empty parts.
187
+ *
188
+ * @example
189
+ * `enumPropName('Order', 'status', 'enum') // 'OrderStatusEnum'`
190
+ */
191
+ declare function enumPropName(parentName: string | null | undefined, propName: string, enumSuffix: string): string;
192
+ /**
193
+ * Merges a ref node with its resolved schema, giving usage-site fields precedence.
194
+ *
195
+ * Every field set on the ref node except `kind`, `type`, `name`, `ref`, and `schema` overrides the
196
+ * same field in the resolved `node.schema` (for example `description`, `nullable`, `readOnly`,
197
+ * `deprecated`). Fields left `undefined` on the ref do not shadow the resolved schema. Non-ref
198
+ * nodes and refs without a resolved `schema` are returned unchanged.
199
+ *
200
+ * @example
201
+ * ```ts
202
+ * const ref = ast.factory.createSchema({ type: 'ref', ref: '#/components/schemas/Pet', description: 'A cute pet' })
203
+ * const merged = syncSchemaRef(ref) // merges with resolved Pet schema
204
+ * ```
205
+ */
206
+ declare function syncSchemaRef(node: SchemaNode): SchemaNode;
207
+ /**
208
+ * Returns `true` when a schema emits as a plain `string` type.
209
+ *
210
+ * Covers `string`, `uuid`, `email`, `url`, and `datetime` types. For `date` and `time`
211
+ * types, returns `true` only when `representation` is `'string'` rather than `'date'`.
212
+ */
213
+ declare function isStringType(node: SchemaNode): boolean;
214
+ //#endregion
215
+ //#region src/utils/schemaGraph.d.ts
216
+ /**
217
+ * Returns `true` when a schema, or anything nested inside it, references a circular schema.
218
+ *
219
+ * Pass `excludeName` to skip refs to a specific schema, which helps when self-references are handled
220
+ * on their own. Pair it with `ast.findCircularSchemas()` to decide where lazy wrappers go.
221
+ *
222
+ * @note Stops at the first matching circular ref.
223
+ */
224
+ declare function containsCircularRef(node: SchemaNode | undefined, { circularSchemas, excludeName }: {
225
+ circularSchemas: ReadonlySet<string>;
226
+ excludeName?: string;
227
+ }): boolean;
228
+ //#endregion
229
+ export { type Adapter, type AdapterFactoryOptions, type AdapterSource, type BannerMeta, type Config, Diagnostics, type Exclude, type Generator$1 as Generator, type GeneratorContext, type Group, Hookable, type Include, type KubbHooks, type KubbPluginEndContext, type KubbPluginSetupContext, type KubbPluginStartContext, type Output, type OutputOptions, type Override, type Parser, type Plugin, type PluginFactoryOptions, type Renderer, type RendererFactory, type ResolveFileOptions, type ResolveImportsOptions, type ResolvePathOptions, Resolver, type ResolverFile, type ResolverFileParams, type ResolverFilePathParams, type ResolverPatch, type Storage, Url, ast, childName, containsCircularRef, createAdapter, createRenderer, createResolver, createStorage, defineGenerator, defineParser, definePlugin, enumPropName, extractRefName, fsStorage, isStringType, macroDiscriminatorEnum, macroEnumName, macroRenameSchema, macroSimplifyUnion, memoryStorage, mergeAdjacentObjectsLazy, syncSchemaRef };
230
+ //# sourceMappingURL=index.d.ts.map