@kubb/plugin-react-query 5.7.0 → 5.7.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.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Diagnostics, Resolver, Url, addGenerator, ast, createResolver, defineExtension, defineGenerator, setMacros, setResolver, useConfig } from "kubb/kit";
|
|
1
|
+
import { Diagnostics, Resolver, Url, addGenerator, ast, camelCase, createResolver, defineExtension, defineGenerator, setMacros, setResolver, useConfig } from "kubb/kit";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { pluginZodName } from "@kubb/plugin-zod";
|
|
4
4
|
import { File, Function, Type, jsxRenderer } from "kubb/jsx";
|
|
@@ -229,78 +229,37 @@ function resolveSuccessNames(node, resolver) {
|
|
|
229
229
|
function resolveStatusCodeNames(node, resolver) {
|
|
230
230
|
return node.responses.map((response) => resolver.response.status(node, response.statusCode));
|
|
231
231
|
}
|
|
232
|
-
const typeNamesByResolver = /* @__PURE__ */ new WeakMap();
|
|
233
|
-
function resolveOperationTypeNames(node, resolver, options = {}) {
|
|
234
|
-
const cacheKey = `${node.operationId}\0${options.order ?? ""}\0${options.responseStatusNames ?? ""}\0${options.includeParams === false ? "noparams" : ""}\0${(options.exclude ?? []).join(",")}`;
|
|
235
|
-
let byResolver = typeNamesByResolver.get(resolver);
|
|
236
|
-
if (byResolver) {
|
|
237
|
-
const cached = byResolver.get(cacheKey);
|
|
238
|
-
if (cached) return cached;
|
|
239
|
-
} else {
|
|
240
|
-
byResolver = /* @__PURE__ */ new Map();
|
|
241
|
-
typeNamesByResolver.set(resolver, byResolver);
|
|
242
|
-
}
|
|
243
|
-
const { path, query, header } = getOperationParameters(node);
|
|
244
|
-
const responseStatusNames = options.responseStatusNames === "error" ? resolveErrorNames(node, resolver) : options.responseStatusNames === false ? [] : resolveStatusCodeNames(node, resolver);
|
|
245
|
-
const exclude = new Set(options.exclude ?? []);
|
|
246
|
-
const paramNames = options.includeParams === false ? [] : [
|
|
247
|
-
...path.map((param) => resolver.param.path(node, param)),
|
|
248
|
-
...query.map((param) => resolver.param.query(node, param)),
|
|
249
|
-
...header.map((param) => resolver.param.headers(node, param))
|
|
250
|
-
];
|
|
251
|
-
const bodyAndResponseNames = [node.requestBody?.content?.[0]?.schema ? resolver.response.body(node) : null, resolver.response.response(node)];
|
|
252
|
-
const result = (options.order === "body-response-first" ? [
|
|
253
|
-
...bodyAndResponseNames,
|
|
254
|
-
...paramNames,
|
|
255
|
-
...responseStatusNames
|
|
256
|
-
] : [
|
|
257
|
-
...paramNames,
|
|
258
|
-
...bodyAndResponseNames,
|
|
259
|
-
...responseStatusNames
|
|
260
|
-
]).filter((name) => Boolean(name) && !exclude.has(name));
|
|
261
|
-
byResolver.set(cacheKey, result);
|
|
262
|
-
return result;
|
|
263
|
-
}
|
|
264
|
-
// ../../internals/utils/src/casing.ts
|
|
265
|
-
/**
|
|
266
|
-
* Shared implementation for camelCase and PascalCase conversion.
|
|
267
|
-
* Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)
|
|
268
|
-
* and capitalizes each word according to `pascal`.
|
|
269
|
-
*
|
|
270
|
-
* When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.
|
|
271
|
-
*/
|
|
272
|
-
function convert(text, pascal) {
|
|
273
|
-
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) => {
|
|
274
|
-
if (word.length > 1 && word === word.toUpperCase()) return word;
|
|
275
|
-
return (i === 0 && !pascal ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()) + word.slice(1);
|
|
276
|
-
}).join("").replace(/[^a-zA-Z0-9]/g, "");
|
|
277
|
-
}
|
|
278
|
-
const cache = /* @__PURE__ */ new Map();
|
|
279
|
-
const cacheLimit = 1e4;
|
|
280
|
-
function toCamelOrPascal(text, pascal) {
|
|
281
|
-
const key = `${pascal ? "P" : "c"}${text}`;
|
|
282
|
-
const cached = cache.get(key);
|
|
283
|
-
if (cached !== void 0) return cached;
|
|
284
|
-
const result = convert(text, pascal);
|
|
285
|
-
if (cache.size >= cacheLimit) cache.clear();
|
|
286
|
-
cache.set(key, result);
|
|
287
|
-
return result;
|
|
288
|
-
}
|
|
289
232
|
/**
|
|
290
|
-
*
|
|
291
|
-
*
|
|
292
|
-
* @example Word boundaries
|
|
293
|
-
* `camelCase('hello-world') // 'helloWorld'`
|
|
294
|
-
*
|
|
295
|
-
* @example With a prefix
|
|
296
|
-
* `camelCase('tag', { prefix: 'create' }) // 'createTag'`
|
|
233
|
+
* Lists the type names an operation's types file declares, computed once per resolver and `options` so every
|
|
234
|
+
* dependent reads the same list.
|
|
297
235
|
*/
|
|
298
|
-
function
|
|
299
|
-
|
|
236
|
+
function resolveOperationTypeNames(node, resolver, options = {}) {
|
|
237
|
+
const key = `${node.operationId}\0${options.order ?? ""}\0${options.responseStatusNames ?? ""}\0${options.includeParams === false ? "noparams" : ""}\0${(options.exclude ?? []).join(",")}`;
|
|
238
|
+
return resolver.memo(`operationTypeNames:${key}`, () => {
|
|
239
|
+
const { path, query, header } = getOperationParameters(node);
|
|
240
|
+
const responseStatusNames = options.responseStatusNames === "error" ? resolveErrorNames(node, resolver) : options.responseStatusNames === false ? [] : resolveStatusCodeNames(node, resolver);
|
|
241
|
+
const exclude = new Set(options.exclude ?? []);
|
|
242
|
+
const paramNames = options.includeParams === false ? [] : [
|
|
243
|
+
...path.map((param) => resolver.param.path(node, param)),
|
|
244
|
+
...query.map((param) => resolver.param.query(node, param)),
|
|
245
|
+
...header.map((param) => resolver.param.headers(node, param))
|
|
246
|
+
];
|
|
247
|
+
const bodyAndResponseNames = [node.requestBody?.content?.[0]?.schema ? resolver.response.body(node) : null, resolver.response.response(node)];
|
|
248
|
+
return (options.order === "body-response-first" ? [
|
|
249
|
+
...bodyAndResponseNames,
|
|
250
|
+
...paramNames,
|
|
251
|
+
...responseStatusNames
|
|
252
|
+
] : [
|
|
253
|
+
...paramNames,
|
|
254
|
+
...bodyAndResponseNames,
|
|
255
|
+
...responseStatusNames
|
|
256
|
+
]).filter((name) => Boolean(name) && !exclude.has(name));
|
|
257
|
+
});
|
|
300
258
|
}
|
|
259
|
+
// ../../internals/utils/src/casing.ts
|
|
301
260
|
/**
|
|
302
261
|
* Uppercases only the first character of `text`, leaving the rest untouched.
|
|
303
|
-
* Unlike
|
|
262
|
+
* Unlike `pascalCase` it never re-splits word boundaries or strips characters.
|
|
304
263
|
*
|
|
305
264
|
* @example
|
|
306
265
|
* `capitalize('getPetById') // 'GetPetById'`
|
|
@@ -464,8 +423,11 @@ function getNestedAccessor(param, accessor) {
|
|
|
464
423
|
return `${accessor}?.['${`${parts.join("']?.['")}']`}`;
|
|
465
424
|
}
|
|
466
425
|
// ../../internals/shared/src/resolver.ts
|
|
426
|
+
/**
|
|
427
|
+
* The shared top-level `name` of the operation plugins, computed once per operation name and build.
|
|
428
|
+
*/
|
|
467
429
|
function resolveOperationName(name) {
|
|
468
|
-
return ensureValidVarName(camelCase(name));
|
|
430
|
+
return this.memo(`operation:${name}`, () => ensureValidVarName(camelCase(name)));
|
|
469
431
|
}
|
|
470
432
|
/**
|
|
471
433
|
* Builds the allocation key for a declaration an operation owns. `scope` names which declaration
|
|
@@ -521,7 +483,7 @@ var compatibility = {
|
|
|
521
483
|
"node": ">=22.22"
|
|
522
484
|
};
|
|
523
485
|
// package.json
|
|
524
|
-
var version = "5.7.
|
|
486
|
+
var version = "5.7.1";
|
|
525
487
|
// ../../internals/client/src/resolveOperationTypes.ts
|
|
526
488
|
/**
|
|
527
489
|
* A `plugin-ts` shaped resolver whose operation type names point at the types `pluginZod({ inferred })`
|
|
@@ -532,6 +494,7 @@ function toZodTypeResolver(resolver) {
|
|
|
532
494
|
return {
|
|
533
495
|
...resolver,
|
|
534
496
|
file: resolver.file.bind(resolver),
|
|
497
|
+
memo: (key, compute) => resolver.memo(`zodTypes:${key}`, compute),
|
|
535
498
|
param: {
|
|
536
499
|
name: (node, p) => type(resolver.param.name(node, p)),
|
|
537
500
|
path: (node, p) => type(resolver.param.path(node, p)),
|