@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.cjs
CHANGED
|
@@ -259,55 +259,6 @@ function getOasAdapter(adapter) {
|
|
|
259
259
|
});
|
|
260
260
|
return adapter;
|
|
261
261
|
}
|
|
262
|
-
// ../../internals/utils/src/casing.ts
|
|
263
|
-
/**
|
|
264
|
-
* Shared implementation for camelCase and PascalCase conversion.
|
|
265
|
-
* Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)
|
|
266
|
-
* and capitalizes each word according to `pascal`.
|
|
267
|
-
*
|
|
268
|
-
* When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.
|
|
269
|
-
*/
|
|
270
|
-
function convert(text, pascal) {
|
|
271
|
-
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) => {
|
|
272
|
-
if (word.length > 1 && word === word.toUpperCase()) return word;
|
|
273
|
-
return (i === 0 && !pascal ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()) + word.slice(1);
|
|
274
|
-
}).join("").replace(/[^a-zA-Z0-9]/g, "");
|
|
275
|
-
}
|
|
276
|
-
const cache = /* @__PURE__ */ new Map();
|
|
277
|
-
const cacheLimit = 1e4;
|
|
278
|
-
function toCamelOrPascal(text, pascal) {
|
|
279
|
-
const key = `${pascal ? "P" : "c"}${text}`;
|
|
280
|
-
const cached = cache.get(key);
|
|
281
|
-
if (cached !== void 0) return cached;
|
|
282
|
-
const result = convert(text, pascal);
|
|
283
|
-
if (cache.size >= cacheLimit) cache.clear();
|
|
284
|
-
cache.set(key, result);
|
|
285
|
-
return result;
|
|
286
|
-
}
|
|
287
|
-
/**
|
|
288
|
-
* Converts `text` to camelCase.
|
|
289
|
-
*
|
|
290
|
-
* @example Word boundaries
|
|
291
|
-
* `camelCase('hello-world') // 'helloWorld'`
|
|
292
|
-
*
|
|
293
|
-
* @example With a prefix
|
|
294
|
-
* `camelCase('tag', { prefix: 'create' }) // 'createTag'`
|
|
295
|
-
*/
|
|
296
|
-
function camelCase(text, { prefix = "", suffix = "" } = {}) {
|
|
297
|
-
return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false);
|
|
298
|
-
}
|
|
299
|
-
/**
|
|
300
|
-
* Converts `text` to PascalCase.
|
|
301
|
-
*
|
|
302
|
-
* @example Word boundaries
|
|
303
|
-
* `pascalCase('hello-world') // 'HelloWorld'`
|
|
304
|
-
*
|
|
305
|
-
* @example With a suffix
|
|
306
|
-
* `pascalCase('tag', { suffix: 'schema' }) // 'TagSchema'`
|
|
307
|
-
*/
|
|
308
|
-
function pascalCase(text, { prefix = "", suffix = "" } = {}) {
|
|
309
|
-
return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true);
|
|
310
|
-
}
|
|
311
262
|
// ../../internals/utils/src/reserved.ts
|
|
312
263
|
/**
|
|
313
264
|
* JavaScript and Java reserved words.
|
|
@@ -633,9 +584,9 @@ function lazyGetter({ name, body }) {
|
|
|
633
584
|
* @example Suffix applied to the final segment only
|
|
634
585
|
* `toFilePath('tag.tag', (part) => camelCase(part, { suffix: 'schema' })) // 'tag/tagSchema'`
|
|
635
586
|
*/
|
|
636
|
-
function toFilePath(name, caseLast = camelCase) {
|
|
587
|
+
function toFilePath(name, caseLast = kubb_kit.camelCase) {
|
|
637
588
|
const parts = name.split(/\.(?=[a-zA-Z])/);
|
|
638
|
-
return parts.map((part, i) => i === parts.length - 1 ? caseLast(part) : camelCase(part)).filter(Boolean).join("/");
|
|
589
|
+
return parts.map((part, i) => i === parts.length - 1 ? caseLast(part) : (0, kubb_kit.camelCase)(part)).filter(Boolean).join("/");
|
|
639
590
|
}
|
|
640
591
|
// ../../internals/shared/src/resolver.ts
|
|
641
592
|
/**
|
|
@@ -750,7 +701,7 @@ function createOperationResponseResolver() {
|
|
|
750
701
|
*/
|
|
751
702
|
function createCasedFile(caseLast) {
|
|
752
703
|
return { baseName({ name, extname }) {
|
|
753
|
-
return `${toFilePath(name, caseLast)}${extname}
|
|
704
|
+
return this.memo(`file:${name}\0${extname}`, () => `${toFilePath(name, caseLast)}${extname}`);
|
|
754
705
|
} };
|
|
755
706
|
}
|
|
756
707
|
// ../../internals/shared/src/group.ts
|
|
@@ -776,7 +727,7 @@ function createGroupConfig(group) {
|
|
|
776
727
|
if (!group) return null;
|
|
777
728
|
const defaultName = (ctx) => {
|
|
778
729
|
if (group.type === "path") return `${ctx.group.split("/")[1]}`;
|
|
779
|
-
return camelCase(ctx.group);
|
|
730
|
+
return (0, kubb_kit.camelCase)(ctx.group);
|
|
780
731
|
};
|
|
781
732
|
return {
|
|
782
733
|
...group,
|
|
@@ -2384,7 +2335,7 @@ var compatibility = {
|
|
|
2384
2335
|
"node": ">=22.22"
|
|
2385
2336
|
};
|
|
2386
2337
|
// package.json
|
|
2387
|
-
var version = "5.7.
|
|
2338
|
+
var version = "5.7.4";
|
|
2388
2339
|
// src/resolvers/resolverZod.ts
|
|
2389
2340
|
/**
|
|
2390
2341
|
* Default resolver used by `@kubb/plugin-zod`. Decides the names and file
|
|
@@ -2404,15 +2355,15 @@ var version = "5.7.3";
|
|
|
2404
2355
|
const resolverZod = (0, kubb_kit.createResolver)({
|
|
2405
2356
|
pluginName: "plugin-zod",
|
|
2406
2357
|
name(name) {
|
|
2407
|
-
return ensureValidVarName(camelCase(name, { suffix: "schema" }));
|
|
2358
|
+
return this.memo(`name:${name}`, () => ensureValidVarName((0, kubb_kit.camelCase)(name, { suffix: "schema" })));
|
|
2408
2359
|
},
|
|
2409
|
-
file: createCasedFile((part) => camelCase(part, { suffix: "schema" })),
|
|
2360
|
+
file: createCasedFile((part) => (0, kubb_kit.camelCase)(part, { suffix: "schema" })),
|
|
2410
2361
|
schema: {
|
|
2411
2362
|
typeName(name) {
|
|
2412
|
-
return ensureValidVarName(pascalCase(name, { suffix: "schema type" }));
|
|
2363
|
+
return this.memo(`typeName:${name}`, () => ensureValidVarName((0, kubb_kit.pascalCase)(name, { suffix: "schema type" })));
|
|
2413
2364
|
},
|
|
2414
2365
|
type(name) {
|
|
2415
|
-
return ensureValidVarName(pascalCase(name, { suffix: "type" }));
|
|
2366
|
+
return this.memo(`type:${name}`, () => ensureValidVarName((0, kubb_kit.pascalCase)(name, { suffix: "type" })));
|
|
2416
2367
|
},
|
|
2417
2368
|
inputName(name) {
|
|
2418
2369
|
return this.name(`${name} input`);
|
|
@@ -2421,10 +2372,10 @@ const resolverZod = (0, kubb_kit.createResolver)({
|
|
|
2421
2372
|
return this.schema.typeName(`${name} input`);
|
|
2422
2373
|
},
|
|
2423
2374
|
isName(name) {
|
|
2424
|
-
return ensureValidVarName(camelCase(name, { prefix: "is" }));
|
|
2375
|
+
return ensureValidVarName((0, kubb_kit.camelCase)(name, { prefix: "is" }));
|
|
2425
2376
|
},
|
|
2426
2377
|
assertName(name) {
|
|
2427
|
-
return ensureValidVarName(camelCase(name, { prefix: "assert" }));
|
|
2378
|
+
return ensureValidVarName((0, kubb_kit.camelCase)(name, { prefix: "assert" }));
|
|
2428
2379
|
}
|
|
2429
2380
|
},
|
|
2430
2381
|
param: createOperationParamResolver(),
|