@kubb/plugin-react-query 5.8.0-canary.20261027T202821 → 5.8.0-canary.20261029T082701
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 +65 -106
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +57 -1
- package/dist/index.d.ts +57 -1
- package/dist/index.js +65 -106
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
package/dist/index.cjs
CHANGED
|
@@ -256,86 +256,37 @@ function resolveSuccessNames(node, resolver) {
|
|
|
256
256
|
function resolveStatusCodeNames(node, resolver) {
|
|
257
257
|
return node.responses.map((response) => resolver.response.status(node, response.statusCode));
|
|
258
258
|
}
|
|
259
|
-
const typeNamesByResolver = /* @__PURE__ */ new WeakMap();
|
|
260
|
-
function resolveOperationTypeNames(node, resolver, options = {}) {
|
|
261
|
-
const cacheKey = `${node.operationId}\0${options.order ?? ""}\0${options.responseStatusNames ?? ""}\0${options.includeParams === false ? "noparams" : ""}\0${(options.exclude ?? []).join(",")}`;
|
|
262
|
-
let byResolver = typeNamesByResolver.get(resolver);
|
|
263
|
-
if (byResolver) {
|
|
264
|
-
const cached = byResolver.get(cacheKey);
|
|
265
|
-
if (cached) return cached;
|
|
266
|
-
} else {
|
|
267
|
-
byResolver = /* @__PURE__ */ new Map();
|
|
268
|
-
typeNamesByResolver.set(resolver, byResolver);
|
|
269
|
-
}
|
|
270
|
-
const { path, query, header } = getOperationParameters(node);
|
|
271
|
-
const responseStatusNames = options.responseStatusNames === "error" ? resolveErrorNames(node, resolver) : options.responseStatusNames === false ? [] : resolveStatusCodeNames(node, resolver);
|
|
272
|
-
const exclude = new Set(options.exclude ?? []);
|
|
273
|
-
const paramNames = options.includeParams === false ? [] : [
|
|
274
|
-
...path.map((param) => resolver.param.path(node, param)),
|
|
275
|
-
...query.map((param) => resolver.param.query(node, param)),
|
|
276
|
-
...header.map((param) => resolver.param.headers(node, param))
|
|
277
|
-
];
|
|
278
|
-
const bodyAndResponseNames = [node.requestBody?.content?.[0]?.schema ? resolver.response.body(node) : null, resolver.response.response(node)];
|
|
279
|
-
const result = (options.order === "body-response-first" ? [
|
|
280
|
-
...bodyAndResponseNames,
|
|
281
|
-
...paramNames,
|
|
282
|
-
...responseStatusNames
|
|
283
|
-
] : [
|
|
284
|
-
...paramNames,
|
|
285
|
-
...bodyAndResponseNames,
|
|
286
|
-
...responseStatusNames
|
|
287
|
-
]).filter((name) => Boolean(name) && !exclude.has(name));
|
|
288
|
-
byResolver.set(cacheKey, result);
|
|
289
|
-
return result;
|
|
290
|
-
}
|
|
291
|
-
// ../../internals/utils/src/casing.ts
|
|
292
|
-
const wordStart = /(?<=[a-z\d])(?=[A-Z])|(?<=[A-Z]{2})(?=[A-Z][a-z]{2})/;
|
|
293
259
|
/**
|
|
294
|
-
*
|
|
295
|
-
*
|
|
296
|
-
* so snake case leaves a name that is already in it unchanged.
|
|
260
|
+
* Lists the type names an operation's types file declares, computed once per resolver and `options` so every
|
|
261
|
+
* dependent reads the same list.
|
|
297
262
|
*/
|
|
298
|
-
function
|
|
299
|
-
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
return (
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
if (cache.size >= cacheLimit) cache.clear();
|
|
321
|
-
cache.set(key, result);
|
|
322
|
-
return result;
|
|
323
|
-
}
|
|
324
|
-
/**
|
|
325
|
-
* Converts `text` to camelCase.
|
|
326
|
-
*
|
|
327
|
-
* @example Word boundaries
|
|
328
|
-
* `camelCase('hello-world') // 'helloWorld'`
|
|
329
|
-
*
|
|
330
|
-
* @example With a prefix
|
|
331
|
-
* `camelCase('tag', { prefix: 'create' }) // 'createTag'`
|
|
332
|
-
*/
|
|
333
|
-
function camelCase(text, { prefix = "", suffix = "" } = {}) {
|
|
334
|
-
return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false);
|
|
263
|
+
function resolveOperationTypeNames(node, resolver, options = {}) {
|
|
264
|
+
const key = `${node.operationId}\0${options.order ?? ""}\0${options.responseStatusNames ?? ""}\0${options.includeParams === false ? "noparams" : ""}\0${(options.exclude ?? []).join(",")}`;
|
|
265
|
+
return resolver.memo(`operationTypeNames:${key}`, () => {
|
|
266
|
+
const { path, query, header } = getOperationParameters(node);
|
|
267
|
+
const responseStatusNames = options.responseStatusNames === "error" ? resolveErrorNames(node, resolver) : options.responseStatusNames === false ? [] : resolveStatusCodeNames(node, resolver);
|
|
268
|
+
const exclude = new Set(options.exclude ?? []);
|
|
269
|
+
const paramNames = options.includeParams === false ? [] : [
|
|
270
|
+
...path.map((param) => resolver.param.path(node, param)),
|
|
271
|
+
...query.map((param) => resolver.param.query(node, param)),
|
|
272
|
+
...header.map((param) => resolver.param.headers(node, param))
|
|
273
|
+
];
|
|
274
|
+
const bodyAndResponseNames = [node.requestBody?.content?.[0]?.schema ? resolver.response.body(node) : null, resolver.response.response(node)];
|
|
275
|
+
return (options.order === "body-response-first" ? [
|
|
276
|
+
...bodyAndResponseNames,
|
|
277
|
+
...paramNames,
|
|
278
|
+
...responseStatusNames
|
|
279
|
+
] : [
|
|
280
|
+
...paramNames,
|
|
281
|
+
...bodyAndResponseNames,
|
|
282
|
+
...responseStatusNames
|
|
283
|
+
]).filter((name) => Boolean(name) && !exclude.has(name));
|
|
284
|
+
});
|
|
335
285
|
}
|
|
286
|
+
// ../../internals/utils/src/casing.ts
|
|
336
287
|
/**
|
|
337
288
|
* Uppercases only the first character of `text`, leaving the rest untouched.
|
|
338
|
-
* Unlike
|
|
289
|
+
* Unlike `pascalCase` it never re-splits word boundaries or strips characters.
|
|
339
290
|
*
|
|
340
291
|
* @example
|
|
341
292
|
* `capitalize('getPetById') // 'GetPetById'`
|
|
@@ -499,8 +450,11 @@ function getNestedAccessor(param, accessor) {
|
|
|
499
450
|
return `${accessor}?.['${`${parts.join("']?.['")}']`}`;
|
|
500
451
|
}
|
|
501
452
|
// ../../internals/shared/src/resolver.ts
|
|
453
|
+
/**
|
|
454
|
+
* The shared top-level `name` of the operation plugins, computed once per operation name and build.
|
|
455
|
+
*/
|
|
502
456
|
function resolveOperationName(name) {
|
|
503
|
-
return ensureValidVarName(camelCase(name));
|
|
457
|
+
return this.memo(`operation:${name}`, () => ensureValidVarName((0, kubb_kit.camelCase)(name)));
|
|
504
458
|
}
|
|
505
459
|
/**
|
|
506
460
|
* Builds the allocation key for a declaration an operation owns. `scope` names which declaration
|
|
@@ -543,7 +497,7 @@ function createGroupConfig(group) {
|
|
|
543
497
|
if (!group) return null;
|
|
544
498
|
const defaultName = (ctx) => {
|
|
545
499
|
if (group.type === "path") return `${ctx.group.split("/")[1]}`;
|
|
546
|
-
return camelCase(ctx.group);
|
|
500
|
+
return (0, kubb_kit.camelCase)(ctx.group);
|
|
547
501
|
};
|
|
548
502
|
return {
|
|
549
503
|
...group,
|
|
@@ -556,7 +510,7 @@ var compatibility = {
|
|
|
556
510
|
"node": ">=22.22"
|
|
557
511
|
};
|
|
558
512
|
// package.json
|
|
559
|
-
var version = "5.8.0-canary.
|
|
513
|
+
var version = "5.8.0-canary.20261029T082701";
|
|
560
514
|
// ../../internals/client/src/resolveOperationTypes.ts
|
|
561
515
|
/**
|
|
562
516
|
* A `plugin-ts` shaped resolver whose operation type names point at the types `pluginZod({ inferred })`
|
|
@@ -567,6 +521,7 @@ function toZodTypeResolver(resolver) {
|
|
|
567
521
|
return {
|
|
568
522
|
...resolver,
|
|
569
523
|
file: resolver.file.bind(resolver),
|
|
524
|
+
memo: (key, compute) => resolver.memo(`zodTypes:${key}`, compute),
|
|
570
525
|
param: {
|
|
571
526
|
name: (node, p) => type(resolver.param.name(node, p)),
|
|
572
527
|
path: (node, p) => type(resolver.param.path(node, p)),
|
|
@@ -596,32 +551,34 @@ function toZodTypeResolver(resolver) {
|
|
|
596
551
|
* ```
|
|
597
552
|
*/
|
|
598
553
|
function resolveOperationTypes(driver, pluginName) {
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
554
|
+
return driver.memo(`operationTypes:${pluginName}`, () => {
|
|
555
|
+
const pluginTs = driver.getPlugin(_kubb_plugin_ts.pluginTsName);
|
|
556
|
+
const pluginZod = driver.getPlugin(_kubb_plugin_zod.pluginZodName);
|
|
557
|
+
if (pluginTs && pluginZod?.options?.inferred !== "codec") {
|
|
558
|
+
const resolver = driver.getResolver(_kubb_plugin_ts.pluginTsName);
|
|
559
|
+
return {
|
|
560
|
+
response: resolver.response,
|
|
561
|
+
resolver,
|
|
562
|
+
output: pluginTs.options?.output,
|
|
563
|
+
group: pluginTs.options?.group ?? void 0
|
|
564
|
+
};
|
|
565
|
+
}
|
|
566
|
+
if (!pluginZod?.options?.inferred) throw new kubb_kit.Diagnostics.Error({
|
|
567
|
+
code: kubb_kit.Diagnostics.code.missingDependency,
|
|
568
|
+
severity: "error",
|
|
569
|
+
message: `Plugin "${pluginName}" has no source for operation types.`,
|
|
570
|
+
help: `Add \`pluginTs()\` before "${pluginName}", or add \`pluginZod({ inferred: true })\`.`,
|
|
571
|
+
location: { kind: "config" },
|
|
572
|
+
plugin: pluginName
|
|
573
|
+
});
|
|
574
|
+
const resolver = toZodTypeResolver(driver.getResolver(_kubb_plugin_zod.pluginZodName));
|
|
603
575
|
return {
|
|
604
576
|
response: resolver.response,
|
|
605
577
|
resolver,
|
|
606
|
-
output:
|
|
607
|
-
group:
|
|
578
|
+
output: pluginZod.options.output,
|
|
579
|
+
group: pluginZod.options.group ?? void 0
|
|
608
580
|
};
|
|
609
|
-
}
|
|
610
|
-
if (!pluginZod?.options?.inferred) throw new kubb_kit.Diagnostics.Error({
|
|
611
|
-
code: kubb_kit.Diagnostics.code.missingDependency,
|
|
612
|
-
severity: "error",
|
|
613
|
-
message: `Plugin "${pluginName}" has no source for operation types.`,
|
|
614
|
-
help: `Add \`pluginTs()\` before "${pluginName}", or add \`pluginZod({ inferred: true })\`.`,
|
|
615
|
-
location: { kind: "config" },
|
|
616
|
-
plugin: pluginName
|
|
617
581
|
});
|
|
618
|
-
const resolver = toZodTypeResolver(driver.getResolver(_kubb_plugin_zod.pluginZodName));
|
|
619
|
-
return {
|
|
620
|
-
response: resolver.response,
|
|
621
|
-
resolver,
|
|
622
|
-
output: pluginZod.options.output,
|
|
623
|
-
group: pluginZod.options.group ?? void 0
|
|
624
|
-
};
|
|
625
582
|
}
|
|
626
583
|
// ../../internals/client/src/resolveClient.ts
|
|
627
584
|
/**
|
|
@@ -1022,13 +979,15 @@ function buildCallResultBody(call, options = {}) {
|
|
|
1022
979
|
* success responses into `TData` and wrapping the error responses in `ResponseErrorConfig<...>`.
|
|
1023
980
|
*/
|
|
1024
981
|
function buildResponseTypes(node, resolver) {
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
982
|
+
return resolver.memo(`responseTypes:${node.method}\0${node.path}`, () => {
|
|
983
|
+
const successNames = resolveSuccessNames(node, resolver);
|
|
984
|
+
const responseName = successNames.length > 0 ? successNames.join(" | ") : resolver.response.response(node);
|
|
985
|
+
const errorNames = resolveErrorNames(node, resolver);
|
|
986
|
+
return {
|
|
987
|
+
TData: responseName,
|
|
988
|
+
TError: `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`
|
|
989
|
+
};
|
|
990
|
+
});
|
|
1032
991
|
}
|
|
1033
992
|
function resolveFallbackPageParamType(initialPageParam) {
|
|
1034
993
|
if (typeof initialPageParam === "number") return "number";
|