@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.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 { createFunctionParameter, createFunctionParameters, createObjectBindingPattern, createTypeLiteral, functionPrinter, pluginTsName } from "@kubb/plugin-ts";
|
|
4
4
|
import { pluginZodName } from "@kubb/plugin-zod";
|
|
@@ -228,78 +228,37 @@ function resolveSuccessNames(node, resolver) {
|
|
|
228
228
|
function resolveStatusCodeNames(node, resolver) {
|
|
229
229
|
return node.responses.map((response) => resolver.response.status(node, response.statusCode));
|
|
230
230
|
}
|
|
231
|
-
const typeNamesByResolver = /* @__PURE__ */ new WeakMap();
|
|
232
|
-
function resolveOperationTypeNames(node, resolver, options = {}) {
|
|
233
|
-
const cacheKey = `${node.operationId}\0${options.order ?? ""}\0${options.responseStatusNames ?? ""}\0${options.includeParams === false ? "noparams" : ""}\0${(options.exclude ?? []).join(",")}`;
|
|
234
|
-
let byResolver = typeNamesByResolver.get(resolver);
|
|
235
|
-
if (byResolver) {
|
|
236
|
-
const cached = byResolver.get(cacheKey);
|
|
237
|
-
if (cached) return cached;
|
|
238
|
-
} else {
|
|
239
|
-
byResolver = /* @__PURE__ */ new Map();
|
|
240
|
-
typeNamesByResolver.set(resolver, byResolver);
|
|
241
|
-
}
|
|
242
|
-
const { path, query, header } = getOperationParameters(node);
|
|
243
|
-
const responseStatusNames = options.responseStatusNames === "error" ? resolveErrorNames(node, resolver) : options.responseStatusNames === false ? [] : resolveStatusCodeNames(node, resolver);
|
|
244
|
-
const exclude = new Set(options.exclude ?? []);
|
|
245
|
-
const paramNames = options.includeParams === false ? [] : [
|
|
246
|
-
...path.map((param) => resolver.param.path(node, param)),
|
|
247
|
-
...query.map((param) => resolver.param.query(node, param)),
|
|
248
|
-
...header.map((param) => resolver.param.headers(node, param))
|
|
249
|
-
];
|
|
250
|
-
const bodyAndResponseNames = [node.requestBody?.content?.[0]?.schema ? resolver.response.body(node) : null, resolver.response.response(node)];
|
|
251
|
-
const result = (options.order === "body-response-first" ? [
|
|
252
|
-
...bodyAndResponseNames,
|
|
253
|
-
...paramNames,
|
|
254
|
-
...responseStatusNames
|
|
255
|
-
] : [
|
|
256
|
-
...paramNames,
|
|
257
|
-
...bodyAndResponseNames,
|
|
258
|
-
...responseStatusNames
|
|
259
|
-
]).filter((name) => Boolean(name) && !exclude.has(name));
|
|
260
|
-
byResolver.set(cacheKey, result);
|
|
261
|
-
return result;
|
|
262
|
-
}
|
|
263
|
-
// ../../internals/utils/src/casing.ts
|
|
264
231
|
/**
|
|
265
|
-
*
|
|
266
|
-
*
|
|
267
|
-
* and capitalizes each word according to `pascal`.
|
|
268
|
-
*
|
|
269
|
-
* When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.
|
|
232
|
+
* Lists the type names an operation's types file declares, computed once per resolver and `options` so every
|
|
233
|
+
* dependent reads the same list.
|
|
270
234
|
*/
|
|
271
|
-
function
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
const
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
*
|
|
294
|
-
* @example With a prefix
|
|
295
|
-
* `camelCase('tag', { prefix: 'create' }) // 'createTag'`
|
|
296
|
-
*/
|
|
297
|
-
function camelCase(text, { prefix = "", suffix = "" } = {}) {
|
|
298
|
-
return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false);
|
|
235
|
+
function resolveOperationTypeNames(node, resolver, options = {}) {
|
|
236
|
+
const key = `${node.operationId}\0${options.order ?? ""}\0${options.responseStatusNames ?? ""}\0${options.includeParams === false ? "noparams" : ""}\0${(options.exclude ?? []).join(",")}`;
|
|
237
|
+
return resolver.memo(`operationTypeNames:${key}`, () => {
|
|
238
|
+
const { path, query, header } = getOperationParameters(node);
|
|
239
|
+
const responseStatusNames = options.responseStatusNames === "error" ? resolveErrorNames(node, resolver) : options.responseStatusNames === false ? [] : resolveStatusCodeNames(node, resolver);
|
|
240
|
+
const exclude = new Set(options.exclude ?? []);
|
|
241
|
+
const paramNames = options.includeParams === false ? [] : [
|
|
242
|
+
...path.map((param) => resolver.param.path(node, param)),
|
|
243
|
+
...query.map((param) => resolver.param.query(node, param)),
|
|
244
|
+
...header.map((param) => resolver.param.headers(node, param))
|
|
245
|
+
];
|
|
246
|
+
const bodyAndResponseNames = [node.requestBody?.content?.[0]?.schema ? resolver.response.body(node) : null, resolver.response.response(node)];
|
|
247
|
+
return (options.order === "body-response-first" ? [
|
|
248
|
+
...bodyAndResponseNames,
|
|
249
|
+
...paramNames,
|
|
250
|
+
...responseStatusNames
|
|
251
|
+
] : [
|
|
252
|
+
...paramNames,
|
|
253
|
+
...bodyAndResponseNames,
|
|
254
|
+
...responseStatusNames
|
|
255
|
+
]).filter((name) => Boolean(name) && !exclude.has(name));
|
|
256
|
+
});
|
|
299
257
|
}
|
|
258
|
+
// ../../internals/utils/src/casing.ts
|
|
300
259
|
/**
|
|
301
260
|
* Uppercases only the first character of `text`, leaving the rest untouched.
|
|
302
|
-
* Unlike
|
|
261
|
+
* Unlike `pascalCase` it never re-splits word boundaries or strips characters.
|
|
303
262
|
*
|
|
304
263
|
* @example
|
|
305
264
|
* `capitalize('getPetById') // 'GetPetById'`
|
|
@@ -447,8 +406,11 @@ function isIdentifier(name) {
|
|
|
447
406
|
return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name);
|
|
448
407
|
}
|
|
449
408
|
// ../../internals/shared/src/resolver.ts
|
|
409
|
+
/**
|
|
410
|
+
* The shared top-level `name` of the operation plugins, computed once per operation name and build.
|
|
411
|
+
*/
|
|
450
412
|
function resolveOperationName(name) {
|
|
451
|
-
return ensureValidVarName(camelCase(name));
|
|
413
|
+
return this.memo(`operation:${name}`, () => ensureValidVarName(camelCase(name)));
|
|
452
414
|
}
|
|
453
415
|
/**
|
|
454
416
|
* Builds the allocation key for a declaration an operation owns. `scope` names which declaration
|
|
@@ -504,7 +466,7 @@ var compatibility = {
|
|
|
504
466
|
"node": ">=22.22"
|
|
505
467
|
};
|
|
506
468
|
// package.json
|
|
507
|
-
var version = "5.6.
|
|
469
|
+
var version = "5.6.1";
|
|
508
470
|
// ../../internals/client/src/resolveOperationTypes.ts
|
|
509
471
|
/**
|
|
510
472
|
* A `plugin-ts` shaped resolver whose operation type names point at the types `pluginZod({ inferred })`
|
|
@@ -515,6 +477,7 @@ function toZodTypeResolver(resolver) {
|
|
|
515
477
|
return {
|
|
516
478
|
...resolver,
|
|
517
479
|
file: resolver.file.bind(resolver),
|
|
480
|
+
memo: (key, compute) => resolver.memo(`zodTypes:${key}`, compute),
|
|
518
481
|
param: {
|
|
519
482
|
name: (node, p) => type(resolver.param.name(node, p)),
|
|
520
483
|
path: (node, p) => type(resolver.param.path(node, p)),
|