@kubb/plugin-swr 5.6.0 → 5.6.1
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 +33 -70
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +33 -70
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -254,78 +254,37 @@ function resolveSuccessNames(node, resolver) {
|
|
|
254
254
|
function resolveStatusCodeNames(node, resolver) {
|
|
255
255
|
return node.responses.map((response) => resolver.response.status(node, response.statusCode));
|
|
256
256
|
}
|
|
257
|
-
const typeNamesByResolver = /* @__PURE__ */ new WeakMap();
|
|
258
|
-
function resolveOperationTypeNames(node, resolver, options = {}) {
|
|
259
|
-
const cacheKey = `${node.operationId}\0${options.order ?? ""}\0${options.responseStatusNames ?? ""}\0${options.includeParams === false ? "noparams" : ""}\0${(options.exclude ?? []).join(",")}`;
|
|
260
|
-
let byResolver = typeNamesByResolver.get(resolver);
|
|
261
|
-
if (byResolver) {
|
|
262
|
-
const cached = byResolver.get(cacheKey);
|
|
263
|
-
if (cached) return cached;
|
|
264
|
-
} else {
|
|
265
|
-
byResolver = /* @__PURE__ */ new Map();
|
|
266
|
-
typeNamesByResolver.set(resolver, byResolver);
|
|
267
|
-
}
|
|
268
|
-
const { path, query, header } = getOperationParameters(node);
|
|
269
|
-
const responseStatusNames = options.responseStatusNames === "error" ? resolveErrorNames(node, resolver) : options.responseStatusNames === false ? [] : resolveStatusCodeNames(node, resolver);
|
|
270
|
-
const exclude = new Set(options.exclude ?? []);
|
|
271
|
-
const paramNames = options.includeParams === false ? [] : [
|
|
272
|
-
...path.map((param) => resolver.param.path(node, param)),
|
|
273
|
-
...query.map((param) => resolver.param.query(node, param)),
|
|
274
|
-
...header.map((param) => resolver.param.headers(node, param))
|
|
275
|
-
];
|
|
276
|
-
const bodyAndResponseNames = [node.requestBody?.content?.[0]?.schema ? resolver.response.body(node) : null, resolver.response.response(node)];
|
|
277
|
-
const result = (options.order === "body-response-first" ? [
|
|
278
|
-
...bodyAndResponseNames,
|
|
279
|
-
...paramNames,
|
|
280
|
-
...responseStatusNames
|
|
281
|
-
] : [
|
|
282
|
-
...paramNames,
|
|
283
|
-
...bodyAndResponseNames,
|
|
284
|
-
...responseStatusNames
|
|
285
|
-
]).filter((name) => Boolean(name) && !exclude.has(name));
|
|
286
|
-
byResolver.set(cacheKey, result);
|
|
287
|
-
return result;
|
|
288
|
-
}
|
|
289
|
-
// ../../internals/utils/src/casing.ts
|
|
290
257
|
/**
|
|
291
|
-
*
|
|
292
|
-
*
|
|
293
|
-
* and capitalizes each word according to `pascal`.
|
|
294
|
-
*
|
|
295
|
-
* When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.
|
|
258
|
+
* Lists the type names an operation's types file declares, computed once per resolver and `options` so every
|
|
259
|
+
* dependent reads the same list.
|
|
296
260
|
*/
|
|
297
|
-
function
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
const
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
*
|
|
320
|
-
* @example With a prefix
|
|
321
|
-
* `camelCase('tag', { prefix: 'create' }) // 'createTag'`
|
|
322
|
-
*/
|
|
323
|
-
function camelCase(text, { prefix = "", suffix = "" } = {}) {
|
|
324
|
-
return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false);
|
|
261
|
+
function resolveOperationTypeNames(node, resolver, options = {}) {
|
|
262
|
+
const key = `${node.operationId}\0${options.order ?? ""}\0${options.responseStatusNames ?? ""}\0${options.includeParams === false ? "noparams" : ""}\0${(options.exclude ?? []).join(",")}`;
|
|
263
|
+
return resolver.memo(`operationTypeNames:${key}`, () => {
|
|
264
|
+
const { path, query, header } = getOperationParameters(node);
|
|
265
|
+
const responseStatusNames = options.responseStatusNames === "error" ? resolveErrorNames(node, resolver) : options.responseStatusNames === false ? [] : resolveStatusCodeNames(node, resolver);
|
|
266
|
+
const exclude = new Set(options.exclude ?? []);
|
|
267
|
+
const paramNames = options.includeParams === false ? [] : [
|
|
268
|
+
...path.map((param) => resolver.param.path(node, param)),
|
|
269
|
+
...query.map((param) => resolver.param.query(node, param)),
|
|
270
|
+
...header.map((param) => resolver.param.headers(node, param))
|
|
271
|
+
];
|
|
272
|
+
const bodyAndResponseNames = [node.requestBody?.content?.[0]?.schema ? resolver.response.body(node) : null, resolver.response.response(node)];
|
|
273
|
+
return (options.order === "body-response-first" ? [
|
|
274
|
+
...bodyAndResponseNames,
|
|
275
|
+
...paramNames,
|
|
276
|
+
...responseStatusNames
|
|
277
|
+
] : [
|
|
278
|
+
...paramNames,
|
|
279
|
+
...bodyAndResponseNames,
|
|
280
|
+
...responseStatusNames
|
|
281
|
+
]).filter((name) => Boolean(name) && !exclude.has(name));
|
|
282
|
+
});
|
|
325
283
|
}
|
|
284
|
+
// ../../internals/utils/src/casing.ts
|
|
326
285
|
/**
|
|
327
286
|
* Uppercases only the first character of `text`, leaving the rest untouched.
|
|
328
|
-
* Unlike
|
|
287
|
+
* Unlike `pascalCase` it never re-splits word boundaries or strips characters.
|
|
329
288
|
*
|
|
330
289
|
* @example
|
|
331
290
|
* `capitalize('getPetById') // 'GetPetById'`
|
|
@@ -473,8 +432,11 @@ function isIdentifier(name) {
|
|
|
473
432
|
return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name);
|
|
474
433
|
}
|
|
475
434
|
// ../../internals/shared/src/resolver.ts
|
|
435
|
+
/**
|
|
436
|
+
* The shared top-level `name` of the operation plugins, computed once per operation name and build.
|
|
437
|
+
*/
|
|
476
438
|
function resolveOperationName(name) {
|
|
477
|
-
return ensureValidVarName(camelCase(name));
|
|
439
|
+
return this.memo(`operation:${name}`, () => ensureValidVarName((0, kubb_kit.camelCase)(name)));
|
|
478
440
|
}
|
|
479
441
|
/**
|
|
480
442
|
* Builds the allocation key for a declaration an operation owns. `scope` names which declaration
|
|
@@ -517,7 +479,7 @@ function createGroupConfig(group) {
|
|
|
517
479
|
if (!group) return null;
|
|
518
480
|
const defaultName = (ctx) => {
|
|
519
481
|
if (group.type === "path") return `${ctx.group.split("/")[1]}`;
|
|
520
|
-
return camelCase(ctx.group);
|
|
482
|
+
return (0, kubb_kit.camelCase)(ctx.group);
|
|
521
483
|
};
|
|
522
484
|
return {
|
|
523
485
|
...group,
|
|
@@ -530,7 +492,7 @@ var compatibility = {
|
|
|
530
492
|
"node": ">=22.22"
|
|
531
493
|
};
|
|
532
494
|
// package.json
|
|
533
|
-
var version = "5.6.
|
|
495
|
+
var version = "5.6.1";
|
|
534
496
|
// ../../internals/client/src/resolveOperationTypes.ts
|
|
535
497
|
/**
|
|
536
498
|
* A `plugin-ts` shaped resolver whose operation type names point at the types `pluginZod({ inferred })`
|
|
@@ -541,6 +503,7 @@ function toZodTypeResolver(resolver) {
|
|
|
541
503
|
return {
|
|
542
504
|
...resolver,
|
|
543
505
|
file: resolver.file.bind(resolver),
|
|
506
|
+
memo: (key, compute) => resolver.memo(`zodTypes:${key}`, compute),
|
|
544
507
|
param: {
|
|
545
508
|
name: (node, p) => type(resolver.param.name(node, p)),
|
|
546
509
|
path: (node, p) => type(resolver.param.path(node, p)),
|