@kubb/kit 5.0.0-beta.82 → 5.0.0-beta.85

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 CHANGED
@@ -1,12 +1,240 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#endregion
2
3
  let _kubb_ast = require("@kubb/ast");
3
4
  let _kubb_core = require("@kubb/core");
5
+ //#region ../../internals/utils/src/casing.ts
6
+ /**
7
+ * Shared implementation for camelCase and PascalCase conversion.
8
+ * Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)
9
+ * and capitalizes each word according to `pascal`.
10
+ *
11
+ * When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.
12
+ */
13
+ function toCamelOrPascal(text, pascal) {
14
+ return text.trim().replace(/([a-z\d])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").replace(/(\d)([a-z])/g, "$1 $2").split(/[\s\-_./\\:]+/).filter(Boolean).map((word, i) => {
15
+ if (word.length > 1 && word === word.toUpperCase()) return word;
16
+ return (i === 0 && !pascal ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()) + word.slice(1);
17
+ }).join("").replace(/[^a-zA-Z0-9]/g, "");
18
+ }
19
+ /**
20
+ * Converts `text` to camelCase.
21
+ *
22
+ * @example Word boundaries
23
+ * `camelCase('hello-world') // 'helloWorld'`
24
+ *
25
+ * @example With a prefix
26
+ * `camelCase('tag', { prefix: 'create' }) // 'createTag'`
27
+ */
28
+ function camelCase(text, { prefix = "", suffix = "" } = {}) {
29
+ return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false);
30
+ }
31
+ //#endregion
32
+ //#region ../../internals/utils/src/reserved.ts
33
+ /**
34
+ * JavaScript and Java reserved words.
35
+ * @link https://github.com/jonschlinkert/reserved/blob/master/index.js
36
+ */
37
+ const reservedWords = /* @__PURE__ */ new Set([
38
+ "abstract",
39
+ "arguments",
40
+ "boolean",
41
+ "break",
42
+ "byte",
43
+ "case",
44
+ "catch",
45
+ "char",
46
+ "class",
47
+ "const",
48
+ "continue",
49
+ "debugger",
50
+ "default",
51
+ "delete",
52
+ "do",
53
+ "double",
54
+ "else",
55
+ "enum",
56
+ "eval",
57
+ "export",
58
+ "extends",
59
+ "false",
60
+ "final",
61
+ "finally",
62
+ "float",
63
+ "for",
64
+ "function",
65
+ "goto",
66
+ "if",
67
+ "implements",
68
+ "import",
69
+ "in",
70
+ "instanceof",
71
+ "int",
72
+ "interface",
73
+ "let",
74
+ "long",
75
+ "native",
76
+ "new",
77
+ "null",
78
+ "package",
79
+ "private",
80
+ "protected",
81
+ "public",
82
+ "return",
83
+ "short",
84
+ "static",
85
+ "super",
86
+ "switch",
87
+ "synchronized",
88
+ "this",
89
+ "throw",
90
+ "throws",
91
+ "transient",
92
+ "true",
93
+ "try",
94
+ "typeof",
95
+ "var",
96
+ "void",
97
+ "volatile",
98
+ "while",
99
+ "with",
100
+ "yield",
101
+ "Array",
102
+ "Date",
103
+ "hasOwnProperty",
104
+ "Infinity",
105
+ "isFinite",
106
+ "isNaN",
107
+ "isPrototypeOf",
108
+ "length",
109
+ "Math",
110
+ "name",
111
+ "NaN",
112
+ "Number",
113
+ "Object",
114
+ "prototype",
115
+ "String",
116
+ "toString",
117
+ "undefined",
118
+ "valueOf"
119
+ ]);
120
+ /**
121
+ * Returns `true` when `name` is a syntactically valid JavaScript variable name.
122
+ *
123
+ * @example
124
+ * ```ts
125
+ * isValidVarName('status') // true
126
+ * isValidVarName('class') // false (reserved word)
127
+ * isValidVarName('42foo') // false (starts with digit)
128
+ * ```
129
+ */
130
+ function isValidVarName(name) {
131
+ if (!name || reservedWords.has(name)) return false;
132
+ return isIdentifier(name);
133
+ }
134
+ /**
135
+ * Returns `true` when `name` is syntactically a valid identifier, ignoring reserved words.
136
+ *
137
+ * Reserved words and globals (`class`, `name`, `Date`, …) are valid as bare object-literal keys
138
+ * even though they are not valid variable names, so use this (not {@link isValidVarName}) when
139
+ * deciding whether an object key needs quoting.
140
+ *
141
+ * @example
142
+ * ```ts
143
+ * isIdentifier('name') // true
144
+ * isIdentifier('x-total')// false
145
+ * ```
146
+ */
147
+ function isIdentifier(name) {
148
+ return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name);
149
+ }
150
+ //#endregion
151
+ //#region ../../internals/utils/src/Url.ts
152
+ function transformParam(raw, casing) {
153
+ const param = isValidVarName(raw) ? raw : camelCase(raw);
154
+ return casing === "camelcase" ? camelCase(param) : param;
155
+ }
156
+ function toParamsObject(path, { replacer, casing } = {}) {
157
+ const params = {};
158
+ for (const match of path.matchAll(/\{([^}]+)\}/g)) {
159
+ const param = transformParam(match[1], casing);
160
+ const key = replacer ? replacer(param) : param;
161
+ params[key] = key;
162
+ }
163
+ return Object.keys(params).length > 0 ? params : null;
164
+ }
165
+ /**
166
+ * Helpers for OpenAPI/Swagger paths, plus a thin wrapper over the native `URL`.
167
+ */
168
+ var Url = class Url {
169
+ /**
170
+ * Converts an OpenAPI/Swagger path to Express-style colon syntax.
171
+ *
172
+ * @example
173
+ * Url.toPath('/pet/{petId}') // '/pet/:petId'
174
+ */
175
+ static toPath(path) {
176
+ return path.replace(/\{([^}]+)\}/g, ":$1");
177
+ }
178
+ /**
179
+ * Converts an OpenAPI/Swagger path to a TypeScript template literal string.
180
+ * `prefix` is prepended inside the literal, `replacer` transforms each parameter name,
181
+ * and `casing` controls parameter identifier casing.
182
+ *
183
+ * @example
184
+ * Url.toTemplateString('/pet/{petId}') // '`/pet/${petId}`'
185
+ *
186
+ * @example
187
+ * Url.toTemplateString('/pet/{petId}', { prefix: 'https://api' }) // '`https://api/pet/${petId}`'
188
+ */
189
+ static toTemplateString(path, { prefix, replacer, casing } = {}) {
190
+ const result = path.split(/\{([^}]+)\}/).map((part, i) => {
191
+ if (i % 2 === 0) return part;
192
+ const param = transformParam(part, casing);
193
+ return `\${${replacer ? replacer(param) : param}}`;
194
+ }).join("");
195
+ return `\`${prefix ?? ""}${result}\``;
196
+ }
197
+ /**
198
+ * Returns the path and its extracted params as a structured `URLObject`, or as a stringified
199
+ * expression when `stringify` is set.
200
+ *
201
+ * @example
202
+ * Url.toObject('/pet/{petId}')
203
+ * // { url: '/pet/:petId', params: { petId: 'petId' } }
204
+ */
205
+ static toObject(path, { type = "path", replacer, stringify, casing } = {}) {
206
+ const object = {
207
+ url: type === "path" ? Url.toPath(path) : Url.toTemplateString(path, {
208
+ replacer,
209
+ casing
210
+ }),
211
+ params: toParamsObject(path, {
212
+ replacer,
213
+ casing
214
+ })
215
+ };
216
+ if (stringify) {
217
+ if (type === "template") return JSON.stringify(object).replaceAll("'", "").replaceAll(`"`, "");
218
+ if (object.params) return `{ url: '${object.url}', params: ${JSON.stringify(object.params).replaceAll("'", "").replaceAll(`"`, "")} }`;
219
+ return `{ url: '${object.url}' }`;
220
+ }
221
+ return object;
222
+ }
223
+ };
224
+ //#endregion
4
225
  Object.defineProperty(exports, "Diagnostics", {
5
226
  enumerable: true,
6
227
  get: function() {
7
228
  return _kubb_core.Diagnostics;
8
229
  }
9
230
  });
231
+ Object.defineProperty(exports, "Resolver", {
232
+ enumerable: true,
233
+ get: function() {
234
+ return _kubb_core.Resolver;
235
+ }
236
+ });
237
+ exports.Url = Url;
10
238
  Object.defineProperty(exports, "ast", {
11
239
  enumerable: true,
12
240
  get: function() {
@@ -25,6 +253,12 @@ Object.defineProperty(exports, "createRenderer", {
25
253
  return _kubb_core.createRenderer;
26
254
  }
27
255
  });
256
+ Object.defineProperty(exports, "createResolver", {
257
+ enumerable: true,
258
+ get: function() {
259
+ return _kubb_core.createResolver;
260
+ }
261
+ });
28
262
  Object.defineProperty(exports, "createStorage", {
29
263
  enumerable: true,
30
264
  get: function() {
@@ -49,18 +283,6 @@ Object.defineProperty(exports, "definePlugin", {
49
283
  return _kubb_core.definePlugin;
50
284
  }
51
285
  });
52
- Object.defineProperty(exports, "defineResolver", {
53
- enumerable: true,
54
- get: function() {
55
- return _kubb_core.defineResolver;
56
- }
57
- });
58
- Object.defineProperty(exports, "factory", {
59
- enumerable: true,
60
- get: function() {
61
- return _kubb_ast.factory;
62
- }
63
- });
64
286
  Object.defineProperty(exports, "fsStorage", {
65
287
  enumerable: true,
66
288
  get: function() {
@@ -73,3 +295,5 @@ Object.defineProperty(exports, "memoryStorage", {
73
295
  return _kubb_core.memoryStorage;
74
296
  }
75
297
  });
298
+
299
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","names":[],"sources":["../../../internals/utils/src/casing.ts","../../../internals/utils/src/reserved.ts","../../../internals/utils/src/Url.ts"],"sourcesContent":["type Options = {\n /**\n * Text prepended before casing is applied.\n */\n prefix?: string\n /**\n * Text appended before casing is applied.\n */\n suffix?: string\n}\n\n/**\n * Shared implementation for camelCase and PascalCase conversion.\n * Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)\n * and capitalizes each word according to `pascal`.\n *\n * When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.\n */\nfunction toCamelOrPascal(text: string, pascal: boolean): string {\n return text\n .trim()\n .replace(/([a-z\\d])([A-Z])/g, '$1 $2')\n .replace(/([A-Z]+)([A-Z][a-z])/g, '$1 $2')\n .replace(/(\\d)([a-z])/g, '$1 $2')\n .split(/[\\s\\-_./\\\\:]+/)\n .filter(Boolean)\n .map((word, i) => {\n if (word.length > 1 && word === word.toUpperCase()) return word\n const head = i === 0 && !pascal ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()\n return head + word.slice(1)\n })\n .join('')\n .replace(/[^a-zA-Z0-9]/g, '')\n}\n\n/**\n * Converts `text` to camelCase.\n *\n * @example Word boundaries\n * `camelCase('hello-world') // 'helloWorld'`\n *\n * @example With a prefix\n * `camelCase('tag', { prefix: 'create' }) // 'createTag'`\n */\nexport function camelCase(text: string, { prefix = '', suffix = '' }: Options = {}): string {\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false)\n}\n\n/**\n * Converts `text` to PascalCase.\n *\n * @example Word boundaries\n * `pascalCase('hello-world') // 'HelloWorld'`\n *\n * @example With a suffix\n * `pascalCase('tag', { suffix: 'schema' }) // 'TagSchema'`\n */\nexport function pascalCase(text: string, { prefix = '', suffix = '' }: Options = {}): string {\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true)\n}\n","/**\n * JavaScript and Java reserved words.\n * @link https://github.com/jonschlinkert/reserved/blob/master/index.js\n */\nconst reservedWords = new Set([\n 'abstract',\n 'arguments',\n 'boolean',\n 'break',\n 'byte',\n 'case',\n 'catch',\n 'char',\n 'class',\n 'const',\n 'continue',\n 'debugger',\n 'default',\n 'delete',\n 'do',\n 'double',\n 'else',\n 'enum',\n 'eval',\n 'export',\n 'extends',\n 'false',\n 'final',\n 'finally',\n 'float',\n 'for',\n 'function',\n 'goto',\n 'if',\n 'implements',\n 'import',\n 'in',\n 'instanceof',\n 'int',\n 'interface',\n 'let',\n 'long',\n 'native',\n 'new',\n 'null',\n 'package',\n 'private',\n 'protected',\n 'public',\n 'return',\n 'short',\n 'static',\n 'super',\n 'switch',\n 'synchronized',\n 'this',\n 'throw',\n 'throws',\n 'transient',\n 'true',\n 'try',\n 'typeof',\n 'var',\n 'void',\n 'volatile',\n 'while',\n 'with',\n 'yield',\n 'Array',\n 'Date',\n 'hasOwnProperty',\n 'Infinity',\n 'isFinite',\n 'isNaN',\n 'isPrototypeOf',\n 'length',\n 'Math',\n 'name',\n 'NaN',\n 'Number',\n 'Object',\n 'prototype',\n 'String',\n 'toString',\n 'undefined',\n 'valueOf',\n] as const)\n\n/**\n * Prefixes `word` with `_` when it is a reserved JavaScript/Java identifier or starts with a digit.\n *\n * @example\n * ```ts\n * transformReservedWord('class') // '_class'\n * transformReservedWord('42foo') // '_42foo'\n * transformReservedWord('status') // 'status'\n * ```\n */\nexport function transformReservedWord(word: string): string {\n const firstChar = word.charCodeAt(0)\n if (word && (reservedWords.has(word as 'valueOf') || (firstChar >= 48 && firstChar <= 57))) {\n return `_${word}`\n }\n return word\n}\n\n/**\n * Returns `true` when `name` is a syntactically valid JavaScript variable name.\n *\n * @example\n * ```ts\n * isValidVarName('status') // true\n * isValidVarName('class') // false (reserved word)\n * isValidVarName('42foo') // false (starts with digit)\n * ```\n */\nexport function isValidVarName(name: string): boolean {\n if (!name || reservedWords.has(name as 'valueOf')) {\n return false\n }\n return isIdentifier(name)\n}\n\n/**\n * Returns `true` when `name` is syntactically a valid identifier, ignoring reserved words.\n *\n * Reserved words and globals (`class`, `name`, `Date`, …) are valid as bare object-literal keys\n * even though they are not valid variable names, so use this (not {@link isValidVarName}) when\n * deciding whether an object key needs quoting.\n *\n * @example\n * ```ts\n * isIdentifier('name') // true\n * isIdentifier('x-total')// false\n * ```\n */\nexport function isIdentifier(name: string): boolean {\n return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name)\n}\n","import { camelCase } from './casing.ts'\nimport { isValidVarName } from './reserved.ts'\n\ntype URLObject = {\n /**\n * The resolved URL string (Express-style or template literal, depending on context).\n */\n url: string\n /**\n * Extracted path parameters as a key-value map, or `null` when the path has none.\n */\n params: Record<string, string> | null\n}\n\n/**\n * Supported identifier casing strategies for path parameters.\n */\ntype PathCasing = 'camelcase'\n\ntype TemplateOptions = {\n /**\n * Literal text prepended inside the template literal, e.g. a base URL.\n */\n prefix?: string | null\n /**\n * Transform applied to each extracted parameter name before interpolation.\n */\n replacer?: (pathParam: string) => string\n /**\n * Casing strategy applied to path parameter names.\n */\n casing?: PathCasing\n}\n\ntype ObjectOptions = {\n /**\n * Controls whether the `url` is rendered as an Express path or a template literal.\n * @default 'path'\n */\n type?: 'path' | 'template'\n /**\n * Transform applied to each extracted parameter name.\n */\n replacer?: (pathParam: string) => string\n /**\n * When `true`, the result is serialized to a string expression instead of a plain object.\n */\n stringify?: boolean\n /**\n * Casing strategy applied to path parameter names.\n */\n casing?: PathCasing\n}\n\nfunction transformParam(raw: string, casing?: PathCasing): string {\n const param = isValidVarName(raw) ? raw : camelCase(raw)\n return casing === 'camelcase' ? camelCase(param) : param\n}\n\nfunction toParamsObject(\n path: string,\n { replacer, casing }: { replacer?: (pathParam: string) => string; casing?: PathCasing } = {},\n): Record<string, string> | null {\n const params: Record<string, string> = {}\n\n for (const match of path.matchAll(/\\{([^}]+)\\}/g)) {\n const param = transformParam(match[1]!, casing)\n const key = replacer ? replacer(param) : param\n params[key] = key\n }\n\n return Object.keys(params).length > 0 ? params : null\n}\n\n/**\n * Helpers for OpenAPI/Swagger paths, plus a thin wrapper over the native `URL`.\n */\nexport class Url {\n /**\n * Converts an OpenAPI/Swagger path to Express-style colon syntax.\n *\n * @example\n * Url.toPath('/pet/{petId}') // '/pet/:petId'\n */\n static toPath(path: string): string {\n return path.replace(/\\{([^}]+)\\}/g, ':$1')\n }\n\n /**\n * Converts an OpenAPI/Swagger path to a TypeScript template literal string.\n * `prefix` is prepended inside the literal, `replacer` transforms each parameter name,\n * and `casing` controls parameter identifier casing.\n *\n * @example\n * Url.toTemplateString('/pet/{petId}') // '`/pet/${petId}`'\n *\n * @example\n * Url.toTemplateString('/pet/{petId}', { prefix: 'https://api' }) // '`https://api/pet/${petId}`'\n */\n static toTemplateString(path: string, { prefix, replacer, casing }: TemplateOptions = {}): string {\n const parts = path.split(/\\{([^}]+)\\}/)\n const result = parts\n .map((part, i) => {\n if (i % 2 === 0) return part\n const param = transformParam(part, casing)\n return `\\${${replacer ? replacer(param) : param}}`\n })\n .join('')\n\n return `\\`${prefix ?? ''}${result}\\``\n }\n\n /**\n * Returns the path and its extracted params as a structured `URLObject`, or as a stringified\n * expression when `stringify` is set.\n *\n * @example\n * Url.toObject('/pet/{petId}')\n * // { url: '/pet/:petId', params: { petId: 'petId' } }\n */\n static toObject(path: string, { type = 'path', replacer, stringify, casing }: ObjectOptions = {}): URLObject | string {\n const object: URLObject = {\n url: type === 'path' ? Url.toPath(path) : Url.toTemplateString(path, { replacer, casing }),\n params: toParamsObject(path, { replacer, casing }),\n }\n\n if (stringify) {\n if (type === 'template') {\n return JSON.stringify(object).replaceAll(\"'\", '').replaceAll(`\"`, '')\n }\n\n if (object.params) {\n return `{ url: '${object.url}', params: ${JSON.stringify(object.params).replaceAll(\"'\", '').replaceAll(`\"`, '')} }`\n }\n\n return `{ url: '${object.url}' }`\n }\n\n return object\n }\n}\n"],"mappings":";;;;;;;;;;;;AAkBA,SAAS,gBAAgB,MAAc,QAAyB;CAC9D,OAAO,KACJ,KAAK,CAAC,CACN,QAAQ,qBAAqB,OAAO,CAAC,CACrC,QAAQ,yBAAyB,OAAO,CAAC,CACzC,QAAQ,gBAAgB,OAAO,CAAC,CAChC,MAAM,eAAe,CAAC,CACtB,OAAO,OAAO,CAAC,CACf,KAAK,MAAM,MAAM;EAChB,IAAI,KAAK,SAAS,KAAK,SAAS,KAAK,YAAY,GAAG,OAAO;EAE3D,QADa,MAAM,KAAK,CAAC,SAAS,KAAK,OAAO,CAAC,CAAC,CAAC,YAAY,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,YAAY,KAC9E,KAAK,MAAM,CAAC;CAC5B,CAAC,CAAC,CACD,KAAK,EAAE,CAAC,CACR,QAAQ,iBAAiB,EAAE;AAChC;;;;;;;;;;AAWA,SAAgB,UAAU,MAAc,EAAE,SAAS,IAAI,SAAS,OAAgB,CAAC,GAAW;CAC1F,OAAO,gBAAgB,GAAG,OAAO,GAAG,KAAK,GAAG,UAAU,KAAK;AAC7D;;;;;;;AC1CA,MAAM,gCAAgB,IAAI,IAAI;CAC5B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;C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;;CAUA,OAAO,SAAS,MAAc,EAAE,OAAO,QAAQ,UAAU,WAAW,WAA0B,CAAC,GAAuB;EACpH,MAAM,SAAoB;GACxB,KAAK,SAAS,SAAS,IAAI,OAAO,IAAI,IAAI,IAAI,iBAAiB,MAAM;IAAE;IAAU;GAAO,CAAC;GACzF,QAAQ,eAAe,MAAM;IAAE;IAAU;GAAO,CAAC;EACnD;EAEA,IAAI,WAAW;GACb,IAAI,SAAS,YACX,OAAO,KAAK,UAAU,MAAM,CAAC,CAAC,WAAW,KAAK,EAAE,CAAC,CAAC,WAAW,KAAK,EAAE;GAGtE,IAAI,OAAO,QACT,OAAO,WAAW,OAAO,IAAI,aAAa,KAAK,UAAU,OAAO,MAAM,CAAC,CAAC,WAAW,KAAK,EAAE,CAAC,CAAC,WAAW,KAAK,EAAE,EAAE;GAGlH,OAAO,WAAW,OAAO,IAAI;EAC/B;EAEA,OAAO;CACT;AACF"}
package/dist/index.d.ts CHANGED
@@ -1,3 +1,97 @@
1
- import { ast, factory } from "@kubb/ast";
2
- import { Adapter, AdapterFactoryOptions, AdapterSource, BannerMeta, Config, Diagnostics, Exclude, Generator, GeneratorContext, Group, Include, KubbHooks, KubbPluginEndContext, KubbPluginSetupContext, KubbPluginStartContext, Output, OutputMode, OutputOptions, Override, Parser, Plugin, PluginFactoryOptions, Renderer, RendererFactory, ResolveBannerContext, ResolveBannerFile, ResolveOptionsContext, Resolver, ResolverContext, ResolverFileParams, ResolverPathParams, Storage, UserConfig, createAdapter, createRenderer, createStorage, defineGenerator, defineParser, definePlugin, defineResolver, fsStorage, memoryStorage } from "@kubb/core";
3
- export { type Adapter, type AdapterFactoryOptions, type AdapterSource, type BannerMeta, type Config, Diagnostics, type Exclude, type Generator, type GeneratorContext, type Group, type Include, type KubbHooks, type KubbPluginEndContext, type KubbPluginSetupContext, type KubbPluginStartContext, type Output, type OutputMode, type OutputOptions, type Override, type Parser, type Plugin, type PluginFactoryOptions, type Renderer, type RendererFactory, type ResolveBannerContext, type ResolveBannerFile, type ResolveOptionsContext, type Resolver, type ResolverContext, type ResolverFileParams, type ResolverPathParams, type Storage, type UserConfig, ast, createAdapter, createRenderer, createStorage, defineGenerator, defineParser, definePlugin, defineResolver, factory, fsStorage, memoryStorage };
1
+ import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
2
+ import { ast } from "@kubb/ast";
3
+ import { Adapter, AdapterFactoryOptions, AdapterSource, BannerMeta, Config, Diagnostics, Exclude, Generator, GeneratorContext, Group, Include, KubbHooks, KubbPluginEndContext, KubbPluginSetupContext, KubbPluginStartContext, Output, OutputMode, OutputOptions, Override, Parser, Plugin, PluginFactoryOptions, Renderer, RendererFactory, ResolveBannerContext, ResolveBannerFile, ResolveOptionsContext, Resolver, ResolverContext, ResolverDefault, ResolverFileParams, ResolverOverride, ResolverPathParams, Storage, UserConfig, createAdapter, createRenderer, createResolver, createStorage, defineGenerator, defineParser, definePlugin, fsStorage, memoryStorage } from "@kubb/core";
4
+
5
+ //#region ../../internals/utils/src/Url.d.ts
6
+ type URLObject = {
7
+ /**
8
+ * The resolved URL string (Express-style or template literal, depending on context).
9
+ */
10
+ url: string;
11
+ /**
12
+ * Extracted path parameters as a key-value map, or `null` when the path has none.
13
+ */
14
+ params: Record<string, string> | null;
15
+ };
16
+ /**
17
+ * Supported identifier casing strategies for path parameters.
18
+ */
19
+ type PathCasing = 'camelcase';
20
+ type TemplateOptions = {
21
+ /**
22
+ * Literal text prepended inside the template literal, e.g. a base URL.
23
+ */
24
+ prefix?: string | null;
25
+ /**
26
+ * Transform applied to each extracted parameter name before interpolation.
27
+ */
28
+ replacer?: (pathParam: string) => string;
29
+ /**
30
+ * Casing strategy applied to path parameter names.
31
+ */
32
+ casing?: PathCasing;
33
+ };
34
+ type ObjectOptions = {
35
+ /**
36
+ * Controls whether the `url` is rendered as an Express path or a template literal.
37
+ * @default 'path'
38
+ */
39
+ type?: 'path' | 'template';
40
+ /**
41
+ * Transform applied to each extracted parameter name.
42
+ */
43
+ replacer?: (pathParam: string) => string;
44
+ /**
45
+ * When `true`, the result is serialized to a string expression instead of a plain object.
46
+ */
47
+ stringify?: boolean;
48
+ /**
49
+ * Casing strategy applied to path parameter names.
50
+ */
51
+ casing?: PathCasing;
52
+ };
53
+ /**
54
+ * Helpers for OpenAPI/Swagger paths, plus a thin wrapper over the native `URL`.
55
+ */
56
+ declare class Url {
57
+ /**
58
+ * Converts an OpenAPI/Swagger path to Express-style colon syntax.
59
+ *
60
+ * @example
61
+ * Url.toPath('/pet/{petId}') // '/pet/:petId'
62
+ */
63
+ static toPath(path: string): string;
64
+ /**
65
+ * Converts an OpenAPI/Swagger path to a TypeScript template literal string.
66
+ * `prefix` is prepended inside the literal, `replacer` transforms each parameter name,
67
+ * and `casing` controls parameter identifier casing.
68
+ *
69
+ * @example
70
+ * Url.toTemplateString('/pet/{petId}') // '`/pet/${petId}`'
71
+ *
72
+ * @example
73
+ * Url.toTemplateString('/pet/{petId}', { prefix: 'https://api' }) // '`https://api/pet/${petId}`'
74
+ */
75
+ static toTemplateString(path: string, {
76
+ prefix,
77
+ replacer,
78
+ casing
79
+ }?: TemplateOptions): string;
80
+ /**
81
+ * Returns the path and its extracted params as a structured `URLObject`, or as a stringified
82
+ * expression when `stringify` is set.
83
+ *
84
+ * @example
85
+ * Url.toObject('/pet/{petId}')
86
+ * // { url: '/pet/:petId', params: { petId: 'petId' } }
87
+ */
88
+ static toObject(path: string, {
89
+ type,
90
+ replacer,
91
+ stringify,
92
+ casing
93
+ }?: ObjectOptions): URLObject | string;
94
+ }
95
+ //#endregion
96
+ export { type Adapter, type AdapterFactoryOptions, type AdapterSource, type BannerMeta, type Config, Diagnostics, type Exclude, type Generator, type GeneratorContext, type Group, type Include, type KubbHooks, type KubbPluginEndContext, type KubbPluginSetupContext, type KubbPluginStartContext, type Output, type OutputMode, type OutputOptions, type Override, type Parser, type Plugin, type PluginFactoryOptions, type Renderer, type RendererFactory, type ResolveBannerContext, type ResolveBannerFile, type ResolveOptionsContext, Resolver, type ResolverContext, type ResolverDefault, type ResolverFileParams, type ResolverOverride, type ResolverPathParams, type Storage, Url, type UserConfig, ast, createAdapter, createRenderer, createResolver, createStorage, defineGenerator, defineParser, definePlugin, fsStorage, memoryStorage };
97
+ //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,3 +1,226 @@
1
- import { ast, factory } from "@kubb/ast";
2
- import { Diagnostics, createAdapter, createRenderer, createStorage, defineGenerator, defineParser, definePlugin, defineResolver, fsStorage, memoryStorage } from "@kubb/core";
3
- export { Diagnostics, ast, createAdapter, createRenderer, createStorage, defineGenerator, defineParser, definePlugin, defineResolver, factory, fsStorage, memoryStorage };
1
+ import "./rolldown-runtime-C0LytTxp.js";
2
+ import { ast } from "@kubb/ast";
3
+ import { Diagnostics, Resolver, createAdapter, createRenderer, createResolver, createStorage, defineGenerator, defineParser, definePlugin, fsStorage, memoryStorage } from "@kubb/core";
4
+ //#region ../../internals/utils/src/casing.ts
5
+ /**
6
+ * Shared implementation for camelCase and PascalCase conversion.
7
+ * Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)
8
+ * and capitalizes each word according to `pascal`.
9
+ *
10
+ * When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.
11
+ */
12
+ function toCamelOrPascal(text, pascal) {
13
+ return text.trim().replace(/([a-z\d])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").replace(/(\d)([a-z])/g, "$1 $2").split(/[\s\-_./\\:]+/).filter(Boolean).map((word, i) => {
14
+ if (word.length > 1 && word === word.toUpperCase()) return word;
15
+ return (i === 0 && !pascal ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()) + word.slice(1);
16
+ }).join("").replace(/[^a-zA-Z0-9]/g, "");
17
+ }
18
+ /**
19
+ * Converts `text` to camelCase.
20
+ *
21
+ * @example Word boundaries
22
+ * `camelCase('hello-world') // 'helloWorld'`
23
+ *
24
+ * @example With a prefix
25
+ * `camelCase('tag', { prefix: 'create' }) // 'createTag'`
26
+ */
27
+ function camelCase(text, { prefix = "", suffix = "" } = {}) {
28
+ return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false);
29
+ }
30
+ //#endregion
31
+ //#region ../../internals/utils/src/reserved.ts
32
+ /**
33
+ * JavaScript and Java reserved words.
34
+ * @link https://github.com/jonschlinkert/reserved/blob/master/index.js
35
+ */
36
+ const reservedWords = /* @__PURE__ */ new Set([
37
+ "abstract",
38
+ "arguments",
39
+ "boolean",
40
+ "break",
41
+ "byte",
42
+ "case",
43
+ "catch",
44
+ "char",
45
+ "class",
46
+ "const",
47
+ "continue",
48
+ "debugger",
49
+ "default",
50
+ "delete",
51
+ "do",
52
+ "double",
53
+ "else",
54
+ "enum",
55
+ "eval",
56
+ "export",
57
+ "extends",
58
+ "false",
59
+ "final",
60
+ "finally",
61
+ "float",
62
+ "for",
63
+ "function",
64
+ "goto",
65
+ "if",
66
+ "implements",
67
+ "import",
68
+ "in",
69
+ "instanceof",
70
+ "int",
71
+ "interface",
72
+ "let",
73
+ "long",
74
+ "native",
75
+ "new",
76
+ "null",
77
+ "package",
78
+ "private",
79
+ "protected",
80
+ "public",
81
+ "return",
82
+ "short",
83
+ "static",
84
+ "super",
85
+ "switch",
86
+ "synchronized",
87
+ "this",
88
+ "throw",
89
+ "throws",
90
+ "transient",
91
+ "true",
92
+ "try",
93
+ "typeof",
94
+ "var",
95
+ "void",
96
+ "volatile",
97
+ "while",
98
+ "with",
99
+ "yield",
100
+ "Array",
101
+ "Date",
102
+ "hasOwnProperty",
103
+ "Infinity",
104
+ "isFinite",
105
+ "isNaN",
106
+ "isPrototypeOf",
107
+ "length",
108
+ "Math",
109
+ "name",
110
+ "NaN",
111
+ "Number",
112
+ "Object",
113
+ "prototype",
114
+ "String",
115
+ "toString",
116
+ "undefined",
117
+ "valueOf"
118
+ ]);
119
+ /**
120
+ * Returns `true` when `name` is a syntactically valid JavaScript variable name.
121
+ *
122
+ * @example
123
+ * ```ts
124
+ * isValidVarName('status') // true
125
+ * isValidVarName('class') // false (reserved word)
126
+ * isValidVarName('42foo') // false (starts with digit)
127
+ * ```
128
+ */
129
+ function isValidVarName(name) {
130
+ if (!name || reservedWords.has(name)) return false;
131
+ return isIdentifier(name);
132
+ }
133
+ /**
134
+ * Returns `true` when `name` is syntactically a valid identifier, ignoring reserved words.
135
+ *
136
+ * Reserved words and globals (`class`, `name`, `Date`, …) are valid as bare object-literal keys
137
+ * even though they are not valid variable names, so use this (not {@link isValidVarName}) when
138
+ * deciding whether an object key needs quoting.
139
+ *
140
+ * @example
141
+ * ```ts
142
+ * isIdentifier('name') // true
143
+ * isIdentifier('x-total')// false
144
+ * ```
145
+ */
146
+ function isIdentifier(name) {
147
+ return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name);
148
+ }
149
+ //#endregion
150
+ //#region ../../internals/utils/src/Url.ts
151
+ function transformParam(raw, casing) {
152
+ const param = isValidVarName(raw) ? raw : camelCase(raw);
153
+ return casing === "camelcase" ? camelCase(param) : param;
154
+ }
155
+ function toParamsObject(path, { replacer, casing } = {}) {
156
+ const params = {};
157
+ for (const match of path.matchAll(/\{([^}]+)\}/g)) {
158
+ const param = transformParam(match[1], casing);
159
+ const key = replacer ? replacer(param) : param;
160
+ params[key] = key;
161
+ }
162
+ return Object.keys(params).length > 0 ? params : null;
163
+ }
164
+ /**
165
+ * Helpers for OpenAPI/Swagger paths, plus a thin wrapper over the native `URL`.
166
+ */
167
+ var Url = class Url {
168
+ /**
169
+ * Converts an OpenAPI/Swagger path to Express-style colon syntax.
170
+ *
171
+ * @example
172
+ * Url.toPath('/pet/{petId}') // '/pet/:petId'
173
+ */
174
+ static toPath(path) {
175
+ return path.replace(/\{([^}]+)\}/g, ":$1");
176
+ }
177
+ /**
178
+ * Converts an OpenAPI/Swagger path to a TypeScript template literal string.
179
+ * `prefix` is prepended inside the literal, `replacer` transforms each parameter name,
180
+ * and `casing` controls parameter identifier casing.
181
+ *
182
+ * @example
183
+ * Url.toTemplateString('/pet/{petId}') // '`/pet/${petId}`'
184
+ *
185
+ * @example
186
+ * Url.toTemplateString('/pet/{petId}', { prefix: 'https://api' }) // '`https://api/pet/${petId}`'
187
+ */
188
+ static toTemplateString(path, { prefix, replacer, casing } = {}) {
189
+ const result = path.split(/\{([^}]+)\}/).map((part, i) => {
190
+ if (i % 2 === 0) return part;
191
+ const param = transformParam(part, casing);
192
+ return `\${${replacer ? replacer(param) : param}}`;
193
+ }).join("");
194
+ return `\`${prefix ?? ""}${result}\``;
195
+ }
196
+ /**
197
+ * Returns the path and its extracted params as a structured `URLObject`, or as a stringified
198
+ * expression when `stringify` is set.
199
+ *
200
+ * @example
201
+ * Url.toObject('/pet/{petId}')
202
+ * // { url: '/pet/:petId', params: { petId: 'petId' } }
203
+ */
204
+ static toObject(path, { type = "path", replacer, stringify, casing } = {}) {
205
+ const object = {
206
+ url: type === "path" ? Url.toPath(path) : Url.toTemplateString(path, {
207
+ replacer,
208
+ casing
209
+ }),
210
+ params: toParamsObject(path, {
211
+ replacer,
212
+ casing
213
+ })
214
+ };
215
+ if (stringify) {
216
+ if (type === "template") return JSON.stringify(object).replaceAll("'", "").replaceAll(`"`, "");
217
+ if (object.params) return `{ url: '${object.url}', params: ${JSON.stringify(object.params).replaceAll("'", "").replaceAll(`"`, "")} }`;
218
+ return `{ url: '${object.url}' }`;
219
+ }
220
+ return object;
221
+ }
222
+ };
223
+ //#endregion
224
+ export { Diagnostics, Resolver, Url, ast, createAdapter, createRenderer, createResolver, createStorage, defineGenerator, defineParser, definePlugin, fsStorage, memoryStorage };
225
+
226
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../internals/utils/src/casing.ts","../../../internals/utils/src/reserved.ts","../../../internals/utils/src/Url.ts"],"sourcesContent":["type Options = {\n /**\n * Text prepended before casing is applied.\n */\n prefix?: string\n /**\n * Text appended before casing is applied.\n */\n suffix?: string\n}\n\n/**\n * Shared implementation for camelCase and PascalCase conversion.\n * Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)\n * and capitalizes each word according to `pascal`.\n *\n * When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.\n */\nfunction toCamelOrPascal(text: string, pascal: boolean): string {\n return text\n .trim()\n .replace(/([a-z\\d])([A-Z])/g, '$1 $2')\n .replace(/([A-Z]+)([A-Z][a-z])/g, '$1 $2')\n .replace(/(\\d)([a-z])/g, '$1 $2')\n .split(/[\\s\\-_./\\\\:]+/)\n .filter(Boolean)\n .map((word, i) => {\n if (word.length > 1 && word === word.toUpperCase()) return word\n const head = i === 0 && !pascal ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()\n return head + word.slice(1)\n })\n .join('')\n .replace(/[^a-zA-Z0-9]/g, '')\n}\n\n/**\n * Converts `text` to camelCase.\n *\n * @example Word boundaries\n * `camelCase('hello-world') // 'helloWorld'`\n *\n * @example With a prefix\n * `camelCase('tag', { prefix: 'create' }) // 'createTag'`\n */\nexport function camelCase(text: string, { prefix = '', suffix = '' }: Options = {}): string {\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false)\n}\n\n/**\n * Converts `text` to PascalCase.\n *\n * @example Word boundaries\n * `pascalCase('hello-world') // 'HelloWorld'`\n *\n * @example With a suffix\n * `pascalCase('tag', { suffix: 'schema' }) // 'TagSchema'`\n */\nexport function pascalCase(text: string, { prefix = '', suffix = '' }: Options = {}): string {\n return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true)\n}\n","/**\n * JavaScript and Java reserved words.\n * @link https://github.com/jonschlinkert/reserved/blob/master/index.js\n */\nconst reservedWords = new Set([\n 'abstract',\n 'arguments',\n 'boolean',\n 'break',\n 'byte',\n 'case',\n 'catch',\n 'char',\n 'class',\n 'const',\n 'continue',\n 'debugger',\n 'default',\n 'delete',\n 'do',\n 'double',\n 'else',\n 'enum',\n 'eval',\n 'export',\n 'extends',\n 'false',\n 'final',\n 'finally',\n 'float',\n 'for',\n 'function',\n 'goto',\n 'if',\n 'implements',\n 'import',\n 'in',\n 'instanceof',\n 'int',\n 'interface',\n 'let',\n 'long',\n 'native',\n 'new',\n 'null',\n 'package',\n 'private',\n 'protected',\n 'public',\n 'return',\n 'short',\n 'static',\n 'super',\n 'switch',\n 'synchronized',\n 'this',\n 'throw',\n 'throws',\n 'transient',\n 'true',\n 'try',\n 'typeof',\n 'var',\n 'void',\n 'volatile',\n 'while',\n 'with',\n 'yield',\n 'Array',\n 'Date',\n 'hasOwnProperty',\n 'Infinity',\n 'isFinite',\n 'isNaN',\n 'isPrototypeOf',\n 'length',\n 'Math',\n 'name',\n 'NaN',\n 'Number',\n 'Object',\n 'prototype',\n 'String',\n 'toString',\n 'undefined',\n 'valueOf',\n] as const)\n\n/**\n * Prefixes `word` with `_` when it is a reserved JavaScript/Java identifier or starts with a digit.\n *\n * @example\n * ```ts\n * transformReservedWord('class') // '_class'\n * transformReservedWord('42foo') // '_42foo'\n * transformReservedWord('status') // 'status'\n * ```\n */\nexport function transformReservedWord(word: string): string {\n const firstChar = word.charCodeAt(0)\n if (word && (reservedWords.has(word as 'valueOf') || (firstChar >= 48 && firstChar <= 57))) {\n return `_${word}`\n }\n return word\n}\n\n/**\n * Returns `true` when `name` is a syntactically valid JavaScript variable name.\n *\n * @example\n * ```ts\n * isValidVarName('status') // true\n * isValidVarName('class') // false (reserved word)\n * isValidVarName('42foo') // false (starts with digit)\n * ```\n */\nexport function isValidVarName(name: string): boolean {\n if (!name || reservedWords.has(name as 'valueOf')) {\n return false\n }\n return isIdentifier(name)\n}\n\n/**\n * Returns `true` when `name` is syntactically a valid identifier, ignoring reserved words.\n *\n * Reserved words and globals (`class`, `name`, `Date`, …) are valid as bare object-literal keys\n * even though they are not valid variable names, so use this (not {@link isValidVarName}) when\n * deciding whether an object key needs quoting.\n *\n * @example\n * ```ts\n * isIdentifier('name') // true\n * isIdentifier('x-total')// false\n * ```\n */\nexport function isIdentifier(name: string): boolean {\n return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name)\n}\n","import { camelCase } from './casing.ts'\nimport { isValidVarName } from './reserved.ts'\n\ntype URLObject = {\n /**\n * The resolved URL string (Express-style or template literal, depending on context).\n */\n url: string\n /**\n * Extracted path parameters as a key-value map, or `null` when the path has none.\n */\n params: Record<string, string> | null\n}\n\n/**\n * Supported identifier casing strategies for path parameters.\n */\ntype PathCasing = 'camelcase'\n\ntype TemplateOptions = {\n /**\n * Literal text prepended inside the template literal, e.g. a base URL.\n */\n prefix?: string | null\n /**\n * Transform applied to each extracted parameter name before interpolation.\n */\n replacer?: (pathParam: string) => string\n /**\n * Casing strategy applied to path parameter names.\n */\n casing?: PathCasing\n}\n\ntype ObjectOptions = {\n /**\n * Controls whether the `url` is rendered as an Express path or a template literal.\n * @default 'path'\n */\n type?: 'path' | 'template'\n /**\n * Transform applied to each extracted parameter name.\n */\n replacer?: (pathParam: string) => string\n /**\n * When `true`, the result is serialized to a string expression instead of a plain object.\n */\n stringify?: boolean\n /**\n * Casing strategy applied to path parameter names.\n */\n casing?: PathCasing\n}\n\nfunction transformParam(raw: string, casing?: PathCasing): string {\n const param = isValidVarName(raw) ? raw : camelCase(raw)\n return casing === 'camelcase' ? camelCase(param) : param\n}\n\nfunction toParamsObject(\n path: string,\n { replacer, casing }: { replacer?: (pathParam: string) => string; casing?: PathCasing } = {},\n): Record<string, string> | null {\n const params: Record<string, string> = {}\n\n for (const match of path.matchAll(/\\{([^}]+)\\}/g)) {\n const param = transformParam(match[1]!, casing)\n const key = replacer ? replacer(param) : param\n params[key] = key\n }\n\n return Object.keys(params).length > 0 ? params : null\n}\n\n/**\n * Helpers for OpenAPI/Swagger paths, plus a thin wrapper over the native `URL`.\n */\nexport class Url {\n /**\n * Converts an OpenAPI/Swagger path to Express-style colon syntax.\n *\n * @example\n * Url.toPath('/pet/{petId}') // '/pet/:petId'\n */\n static toPath(path: string): string {\n return path.replace(/\\{([^}]+)\\}/g, ':$1')\n }\n\n /**\n * Converts an OpenAPI/Swagger path to a TypeScript template literal string.\n * `prefix` is prepended inside the literal, `replacer` transforms each parameter name,\n * and `casing` controls parameter identifier casing.\n *\n * @example\n * Url.toTemplateString('/pet/{petId}') // '`/pet/${petId}`'\n *\n * @example\n * Url.toTemplateString('/pet/{petId}', { prefix: 'https://api' }) // '`https://api/pet/${petId}`'\n */\n static toTemplateString(path: string, { prefix, replacer, casing }: TemplateOptions = {}): string {\n const parts = path.split(/\\{([^}]+)\\}/)\n const result = parts\n .map((part, i) => {\n if (i % 2 === 0) return part\n const param = transformParam(part, casing)\n return `\\${${replacer ? replacer(param) : param}}`\n })\n .join('')\n\n return `\\`${prefix ?? ''}${result}\\``\n }\n\n /**\n * Returns the path and its extracted params as a structured `URLObject`, or as a stringified\n * expression when `stringify` is set.\n *\n * @example\n * Url.toObject('/pet/{petId}')\n * // { url: '/pet/:petId', params: { petId: 'petId' } }\n */\n static toObject(path: string, { type = 'path', replacer, stringify, casing }: ObjectOptions = {}): URLObject | string {\n const object: URLObject = {\n url: type === 'path' ? Url.toPath(path) : Url.toTemplateString(path, { replacer, casing }),\n params: toParamsObject(path, { replacer, casing }),\n }\n\n if (stringify) {\n if (type === 'template') {\n return JSON.stringify(object).replaceAll(\"'\", '').replaceAll(`\"`, '')\n }\n\n if (object.params) {\n return `{ url: '${object.url}', params: ${JSON.stringify(object.params).replaceAll(\"'\", '').replaceAll(`\"`, '')} }`\n }\n\n return `{ url: '${object.url}' }`\n }\n\n return object\n }\n}\n"],"mappings":";;;;;;;;;;;AAkBA,SAAS,gBAAgB,MAAc,QAAyB;CAC9D,OAAO,KACJ,KAAK,CAAC,CACN,QAAQ,qBAAqB,OAAO,CAAC,CACrC,QAAQ,yBAAyB,OAAO,CAAC,CACzC,QAAQ,gBAAgB,OAAO,CAAC,CAChC,MAAM,eAAe,CAAC,CACtB,OAAO,OAAO,CAAC,CACf,KAAK,MAAM,MAAM;EAChB,IAAI,KAAK,SAAS,KAAK,SAAS,KAAK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,OAAO,WAAW,OAAO,IAAI;EAC/B;EAEA,OAAO;CACT;AACF"}
@@ -0,0 +1,8 @@
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/kit",
3
- "version": "5.0.0-beta.82",
3
+ "version": "5.0.0-beta.85",
4
4
  "description": "Authoring toolkit for Kubb plugins, generators, adapters, resolvers, and renderers.",
5
5
  "keywords": [
6
6
  "codegen",
@@ -46,15 +46,12 @@
46
46
  "registry": "https://registry.npmjs.org/"
47
47
  },
48
48
  "dependencies": {
49
- "@kubb/ast": "5.0.0-beta.82",
50
- "@kubb/core": "5.0.0-beta.82"
49
+ "@kubb/ast": "5.0.0-beta.85",
50
+ "@kubb/core": "5.0.0-beta.85"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@internals/utils": "0.0.0"
54
54
  },
55
- "peerDependencies": {
56
- "@kubb/core": "5.0.0-beta.82"
57
- },
58
55
  "engines": {
59
56
  "node": ">=22"
60
57
  },