@kubb/plugin-react-query 5.3.0-canary.20261012T072741 → 5.3.0-canary.20261012T181005
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 +53 -60
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +53 -60
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
package/dist/index.cjs
CHANGED
|
@@ -350,6 +350,9 @@ function createGroupConfig(group) {
|
|
|
350
350
|
};
|
|
351
351
|
}
|
|
352
352
|
//#endregion
|
|
353
|
+
//#region package.json
|
|
354
|
+
var version = "5.3.0-canary.20261012T181005";
|
|
355
|
+
//#endregion
|
|
353
356
|
//#region ../../internals/client/src/resolveClient.ts
|
|
354
357
|
/**
|
|
355
358
|
* Resolves which client plugin a consumer (react-query, vue-query, swr, mcp) should call for an
|
|
@@ -360,8 +363,8 @@ function createGroupConfig(group) {
|
|
|
360
363
|
*
|
|
361
364
|
* - `contract` — a registered contract client plugin owns the `<op>` functions and the consumer
|
|
362
365
|
* imports and calls them.
|
|
363
|
-
* - `error` — no client plugin is registered, several are registered without a selector,
|
|
364
|
-
* requested one is missing.
|
|
366
|
+
* - `error` — no client plugin is registered, several are registered without a selector, the
|
|
367
|
+
* requested one is missing, or `client` is not a known selector.
|
|
365
368
|
*
|
|
366
369
|
* The `client` string selects explicitly (`'fetch'` / `'axios'`); when it is unset a lone registered
|
|
367
370
|
* contract client plugin is picked up automatically.
|
|
@@ -402,6 +405,10 @@ function resolveClient(options) {
|
|
|
402
405
|
pluginName
|
|
403
406
|
};
|
|
404
407
|
}
|
|
408
|
+
if (client !== void 0) return {
|
|
409
|
+
kind: "error",
|
|
410
|
+
message: `Option \`client\` is ${typeof client === "string" ? `'${client}'` : String(client)}, but it must be one of 'fetch', 'axios'. Drop \`client\` to use the registered client plugin.`
|
|
411
|
+
};
|
|
405
412
|
const registered = contractPlugins.filter(has);
|
|
406
413
|
if (registered.length === 1) return {
|
|
407
414
|
kind: "contract",
|
|
@@ -1549,8 +1556,7 @@ const infiniteQueryGenerator = (0, kubb_kit.defineGenerator)({
|
|
|
1549
1556
|
if (!kubb_kit.ast.isHttpOperationNode(node)) return null;
|
|
1550
1557
|
const { config, driver, resolver, root } = ctx;
|
|
1551
1558
|
const { output, query, infinite, client, group, customOptions } = ctx.options;
|
|
1552
|
-
const pluginTs =
|
|
1553
|
-
if (!pluginTs) return null;
|
|
1559
|
+
const pluginTs = ctx.requirePlugin(_kubb_plugin_ts.pluginTsName);
|
|
1554
1560
|
const tsResolver = driver.getResolver(_kubb_plugin_ts.pluginTsName);
|
|
1555
1561
|
const infiniteOptions = infinite && typeof infinite === "object" ? infinite : null;
|
|
1556
1562
|
if (!infiniteOptions) return null;
|
|
@@ -1723,8 +1729,7 @@ const mutationGenerator = (0, kubb_kit.defineGenerator)({
|
|
|
1723
1729
|
if (!kubb_kit.ast.isHttpOperationNode(node)) return null;
|
|
1724
1730
|
const { config, driver, resolver, root } = ctx;
|
|
1725
1731
|
const { output, mutation, client, group, customOptions, hooks } = ctx.options;
|
|
1726
|
-
const pluginTs =
|
|
1727
|
-
if (!pluginTs) return null;
|
|
1732
|
+
const pluginTs = ctx.requirePlugin(_kubb_plugin_ts.pluginTsName);
|
|
1728
1733
|
const tsResolver = driver.getResolver(_kubb_plugin_ts.pluginTsName);
|
|
1729
1734
|
const importPath = mutation ? mutation.importPath : "@tanstack/react-query";
|
|
1730
1735
|
const contractOp = resolveClientOperation({
|
|
@@ -1872,8 +1877,7 @@ const queryGenerator = (0, kubb_kit.defineGenerator)({
|
|
|
1872
1877
|
if (!kubb_kit.ast.isHttpOperationNode(node)) return null;
|
|
1873
1878
|
const { config, driver, resolver, root } = ctx;
|
|
1874
1879
|
const { output, query, client, group, customOptions, hooks } = ctx.options;
|
|
1875
|
-
const pluginTs =
|
|
1876
|
-
if (!pluginTs) return null;
|
|
1880
|
+
const pluginTs = ctx.requirePlugin(_kubb_plugin_ts.pluginTsName);
|
|
1877
1881
|
const tsResolver = driver.getResolver(_kubb_plugin_ts.pluginTsName);
|
|
1878
1882
|
const importPath = query ? query.importPath : "@tanstack/react-query";
|
|
1879
1883
|
const contractOp = resolveClientOperation({
|
|
@@ -2030,8 +2034,7 @@ const suspenseInfiniteQueryGenerator = (0, kubb_kit.defineGenerator)({
|
|
|
2030
2034
|
if (!kubb_kit.ast.isHttpOperationNode(node)) return null;
|
|
2031
2035
|
const { config, driver, resolver, root } = ctx;
|
|
2032
2036
|
const { output, query, infinite, client, group, customOptions } = ctx.options;
|
|
2033
|
-
const pluginTs =
|
|
2034
|
-
if (!pluginTs) return null;
|
|
2037
|
+
const pluginTs = ctx.requirePlugin(_kubb_plugin_ts.pluginTsName);
|
|
2035
2038
|
const tsResolver = driver.getResolver(_kubb_plugin_ts.pluginTsName);
|
|
2036
2039
|
const infiniteOptions = infinite && typeof infinite === "object" ? infinite : null;
|
|
2037
2040
|
if (!infiniteOptions) return null;
|
|
@@ -2204,8 +2207,7 @@ const suspenseQueryGenerator = (0, kubb_kit.defineGenerator)({
|
|
|
2204
2207
|
if (!kubb_kit.ast.isHttpOperationNode(node)) return null;
|
|
2205
2208
|
const { config, driver, resolver, root } = ctx;
|
|
2206
2209
|
const { output, query, client, group, customOptions } = ctx.options;
|
|
2207
|
-
const pluginTs =
|
|
2208
|
-
if (!pluginTs) return null;
|
|
2210
|
+
const pluginTs = ctx.requirePlugin(_kubb_plugin_ts.pluginTsName);
|
|
2209
2211
|
const tsResolver = driver.getResolver(_kubb_plugin_ts.pluginTsName);
|
|
2210
2212
|
const importPath = query ? query.importPath : "@tanstack/react-query";
|
|
2211
2213
|
const contractOp = resolveClientOperation({
|
|
@@ -2410,55 +2412,46 @@ const pluginReactQueryName = "plugin-react-query";
|
|
|
2410
2412
|
* })
|
|
2411
2413
|
* ```
|
|
2412
2414
|
*/
|
|
2413
|
-
const pluginReactQuery = (0, kubb_kit.definePlugin)(
|
|
2414
|
-
|
|
2415
|
-
path: "hooks",
|
|
2416
|
-
barrel: { type: "named" }
|
|
2417
|
-
}, group, exclude = [], include, override = [], suspense = false, infinite = false, mutation = {}, query = {}, mutationKey = mutationKeyTransformer, queryKey = queryKeyTransformer, customOptions, hooks = false, client, resolver: userResolver, macros: userMacros } = options;
|
|
2418
|
-
const selectedGenerators = [
|
|
2419
|
-
queryGenerator,
|
|
2420
|
-
suspenseQueryGenerator,
|
|
2421
|
-
infiniteQueryGenerator,
|
|
2422
|
-
suspenseInfiniteQueryGenerator,
|
|
2423
|
-
mutationGenerator,
|
|
2424
|
-
hookOptionsGenerator,
|
|
2425
|
-
customHookOptionsFileGenerator
|
|
2426
|
-
];
|
|
2427
|
-
const groupConfig = createGroupConfig(group);
|
|
2428
|
-
return {
|
|
2415
|
+
const pluginReactQuery = (0, kubb_kit.definePlugin)({
|
|
2416
|
+
meta: {
|
|
2429
2417
|
name: pluginReactQueryName,
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2418
|
+
version,
|
|
2419
|
+
compatibility: { kubb: ">=5.7.0" }
|
|
2420
|
+
},
|
|
2421
|
+
dependencies: { [_kubb_plugin_ts.pluginTsName]: {} },
|
|
2422
|
+
setup(options, kubb) {
|
|
2423
|
+
const { output = {
|
|
2424
|
+
path: "hooks",
|
|
2425
|
+
barrel: { type: "named" }
|
|
2426
|
+
}, group, exclude = [], include, override = [], suspense = false, infinite = false, mutation = {}, query = {}, mutationKey = mutationKeyTransformer, queryKey = queryKeyTransformer, customOptions, hooks = false, client, resolver: userResolver, macros: userMacros } = options;
|
|
2427
|
+
const resolver = userResolver ? kubb_kit.Resolver.merge(resolverReactQuery, userResolver) : resolverReactQuery;
|
|
2428
|
+
kubb.setResolver(resolver);
|
|
2429
|
+
if (userMacros?.length) kubb.setMacros(userMacros);
|
|
2430
|
+
kubb.addGenerator(queryGenerator, suspenseQueryGenerator, infiniteQueryGenerator, suspenseInfiniteQueryGenerator, mutationGenerator, hookOptionsGenerator, customHookOptionsFileGenerator);
|
|
2431
|
+
return {
|
|
2432
|
+
output,
|
|
2433
|
+
client: resolveContractClient({
|
|
2434
|
+
client,
|
|
2435
|
+
plugins: kubb.config.plugins
|
|
2436
|
+
}),
|
|
2437
|
+
queryKey,
|
|
2438
|
+
query: resolveQueryConfig(query, { importPath: "@tanstack/react-query" }),
|
|
2439
|
+
mutationKey,
|
|
2440
|
+
mutation: resolveMutationConfig(mutation, { importPath: "@tanstack/react-query" }),
|
|
2441
|
+
infinite: resolveInfiniteConfig(infinite),
|
|
2442
|
+
suspense,
|
|
2443
|
+
customOptions: customOptions ? {
|
|
2444
|
+
name: "useCustomHookOptions",
|
|
2445
|
+
...customOptions
|
|
2446
|
+
} : null,
|
|
2447
|
+
hooks,
|
|
2448
|
+
group: createGroupConfig(group),
|
|
2449
|
+
exclude,
|
|
2450
|
+
include,
|
|
2451
|
+
override,
|
|
2452
|
+
resolver
|
|
2453
|
+
};
|
|
2454
|
+
}
|
|
2462
2455
|
});
|
|
2463
2456
|
//#endregion
|
|
2464
2457
|
exports.default = pluginReactQuery;
|