@kubb/plugin-zod 5.7.3 → 5.7.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.
- package/dist/index.cjs +11 -60
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +6 -55
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Diagnostics, Resolver, addGenerator, ast, containsCircularRef, createResolver, defineExtension, defineGenerator, extractRefName, setMacros, setResolver, syncSchemaRef } from "kubb/kit";
|
|
1
|
+
import { Diagnostics, Resolver, addGenerator, ast, camelCase, containsCircularRef, createResolver, defineExtension, defineGenerator, extractRefName, pascalCase, setMacros, setResolver, syncSchemaRef } from "kubb/kit";
|
|
2
2
|
import { Const, File, Function, Type, jsxRenderer } from "kubb/jsx";
|
|
3
3
|
import { Fragment, jsx, jsxs } from "kubb/jsx/jsx-runtime";
|
|
4
4
|
// ../../internals/shared/src/operation.ts
|
|
@@ -255,55 +255,6 @@ function getOasAdapter(adapter) {
|
|
|
255
255
|
});
|
|
256
256
|
return adapter;
|
|
257
257
|
}
|
|
258
|
-
// ../../internals/utils/src/casing.ts
|
|
259
|
-
/**
|
|
260
|
-
* Shared implementation for camelCase and PascalCase conversion.
|
|
261
|
-
* Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)
|
|
262
|
-
* and capitalizes each word according to `pascal`.
|
|
263
|
-
*
|
|
264
|
-
* When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.
|
|
265
|
-
*/
|
|
266
|
-
function convert(text, pascal) {
|
|
267
|
-
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) => {
|
|
268
|
-
if (word.length > 1 && word === word.toUpperCase()) return word;
|
|
269
|
-
return (i === 0 && !pascal ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()) + word.slice(1);
|
|
270
|
-
}).join("").replace(/[^a-zA-Z0-9]/g, "");
|
|
271
|
-
}
|
|
272
|
-
const cache = /* @__PURE__ */ new Map();
|
|
273
|
-
const cacheLimit = 1e4;
|
|
274
|
-
function toCamelOrPascal(text, pascal) {
|
|
275
|
-
const key = `${pascal ? "P" : "c"}${text}`;
|
|
276
|
-
const cached = cache.get(key);
|
|
277
|
-
if (cached !== void 0) return cached;
|
|
278
|
-
const result = convert(text, pascal);
|
|
279
|
-
if (cache.size >= cacheLimit) cache.clear();
|
|
280
|
-
cache.set(key, result);
|
|
281
|
-
return result;
|
|
282
|
-
}
|
|
283
|
-
/**
|
|
284
|
-
* Converts `text` to camelCase.
|
|
285
|
-
*
|
|
286
|
-
* @example Word boundaries
|
|
287
|
-
* `camelCase('hello-world') // 'helloWorld'`
|
|
288
|
-
*
|
|
289
|
-
* @example With a prefix
|
|
290
|
-
* `camelCase('tag', { prefix: 'create' }) // 'createTag'`
|
|
291
|
-
*/
|
|
292
|
-
function camelCase(text, { prefix = "", suffix = "" } = {}) {
|
|
293
|
-
return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false);
|
|
294
|
-
}
|
|
295
|
-
/**
|
|
296
|
-
* Converts `text` to PascalCase.
|
|
297
|
-
*
|
|
298
|
-
* @example Word boundaries
|
|
299
|
-
* `pascalCase('hello-world') // 'HelloWorld'`
|
|
300
|
-
*
|
|
301
|
-
* @example With a suffix
|
|
302
|
-
* `pascalCase('tag', { suffix: 'schema' }) // 'TagSchema'`
|
|
303
|
-
*/
|
|
304
|
-
function pascalCase(text, { prefix = "", suffix = "" } = {}) {
|
|
305
|
-
return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true);
|
|
306
|
-
}
|
|
307
258
|
// ../../internals/utils/src/reserved.ts
|
|
308
259
|
/**
|
|
309
260
|
* JavaScript and Java reserved words.
|
|
@@ -746,7 +697,7 @@ function createOperationResponseResolver() {
|
|
|
746
697
|
*/
|
|
747
698
|
function createCasedFile(caseLast) {
|
|
748
699
|
return { baseName({ name, extname }) {
|
|
749
|
-
return `${toFilePath(name, caseLast)}${extname}
|
|
700
|
+
return this.memo(`file:${name}\0${extname}`, () => `${toFilePath(name, caseLast)}${extname}`);
|
|
750
701
|
} };
|
|
751
702
|
}
|
|
752
703
|
// ../../internals/shared/src/group.ts
|
|
@@ -2380,7 +2331,7 @@ var compatibility = {
|
|
|
2380
2331
|
"node": ">=22.22"
|
|
2381
2332
|
};
|
|
2382
2333
|
// package.json
|
|
2383
|
-
var version = "5.7.
|
|
2334
|
+
var version = "5.7.4";
|
|
2384
2335
|
// src/resolvers/resolverZod.ts
|
|
2385
2336
|
/**
|
|
2386
2337
|
* Default resolver used by `@kubb/plugin-zod`. Decides the names and file
|
|
@@ -2400,15 +2351,15 @@ var version = "5.7.3";
|
|
|
2400
2351
|
const resolverZod = createResolver({
|
|
2401
2352
|
pluginName: "plugin-zod",
|
|
2402
2353
|
name(name) {
|
|
2403
|
-
return ensureValidVarName(camelCase(name, { suffix: "schema" }));
|
|
2354
|
+
return this.memo(`name:${name}`, () => ensureValidVarName(camelCase(name, { suffix: "schema" })));
|
|
2404
2355
|
},
|
|
2405
2356
|
file: createCasedFile((part) => camelCase(part, { suffix: "schema" })),
|
|
2406
2357
|
schema: {
|
|
2407
2358
|
typeName(name) {
|
|
2408
|
-
return ensureValidVarName(pascalCase(name, { suffix: "schema type" }));
|
|
2359
|
+
return this.memo(`typeName:${name}`, () => ensureValidVarName(pascalCase(name, { suffix: "schema type" })));
|
|
2409
2360
|
},
|
|
2410
2361
|
type(name) {
|
|
2411
|
-
return ensureValidVarName(pascalCase(name, { suffix: "type" }));
|
|
2362
|
+
return this.memo(`type:${name}`, () => ensureValidVarName(pascalCase(name, { suffix: "type" })));
|
|
2412
2363
|
},
|
|
2413
2364
|
inputName(name) {
|
|
2414
2365
|
return this.name(`${name} input`);
|