@kubb/plugin-react-query 5.5.3 → 5.5.5
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 +40 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +27 -1
- package/dist/index.d.ts +27 -1
- package/dist/index.js +39 -3
- package/dist/index.js.map +1 -1
- package/docs/options.md +20 -4
- package/kubb-extension.json +28 -0
- package/package.json +5 -5
package/dist/index.d.cts
CHANGED
|
@@ -138,6 +138,32 @@ type Infinite = {
|
|
|
138
138
|
};
|
|
139
139
|
type PageParamFn<TPage = any, TParam = any> = (page: TPage, allPages: Array<TPage>, pageParam: TParam, allPageParams: Array<TParam>) => TParam | undefined | null;
|
|
140
140
|
//#endregion
|
|
141
|
+
//#region ../../internals/tanstack-query/src/components/MutationKey.d.ts
|
|
142
|
+
/**
|
|
143
|
+
* Default `mutationKey` builder. Call it from a custom builder to extend the default key.
|
|
144
|
+
*
|
|
145
|
+
* @remarks The returned segments may change between releases. Spread them instead of reading single entries.
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* ```ts
|
|
149
|
+
* mutationKey: (props) => [JSON.stringify(props.node.operationId), ...mutationKeyTransformer(props)]
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
export declare const mutationKeyTransformer: Transformer;
|
|
153
|
+
//#endregion
|
|
154
|
+
//#region ../../internals/tanstack-query/src/components/QueryKey.d.ts
|
|
155
|
+
/**
|
|
156
|
+
* Default `queryKey` builder. Call it from a custom builder to extend the default key.
|
|
157
|
+
*
|
|
158
|
+
* @remarks The returned segments may change between releases. Spread them instead of reading single entries.
|
|
159
|
+
*
|
|
160
|
+
* @example
|
|
161
|
+
* ```ts
|
|
162
|
+
* queryKey: (props) => [JSON.stringify(props.node.operationId), ...queryKeyTransformer(props)]
|
|
163
|
+
* ```
|
|
164
|
+
*/
|
|
165
|
+
export declare const queryKeyTransformer: Transformer;
|
|
166
|
+
//#endregion
|
|
141
167
|
//#region ../../internals/tanstack-query/src/utils.d.ts
|
|
142
168
|
/**
|
|
143
169
|
* Helper to define a typed page param function for `infinite.getNextPageParam` or
|
|
@@ -534,5 +560,5 @@ export declare const pluginReactQuery: import("kubb/kit").PluginFactory<PluginRe
|
|
|
534
560
|
*/
|
|
535
561
|
export declare const resolverReactQuery: ResolverReactQuery;
|
|
536
562
|
//#endregion
|
|
537
|
-
export { type PageParamFn, type PluginReactQuery, type ResolverReactQuery, pluginReactQuery as default };
|
|
563
|
+
export { type PageParamFn, type PluginReactQuery, type ResolverReactQuery, type Transformer, pluginReactQuery as default };
|
|
538
564
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -138,6 +138,32 @@ type Infinite = {
|
|
|
138
138
|
};
|
|
139
139
|
type PageParamFn<TPage = any, TParam = any> = (page: TPage, allPages: Array<TPage>, pageParam: TParam, allPageParams: Array<TParam>) => TParam | undefined | null;
|
|
140
140
|
//#endregion
|
|
141
|
+
//#region ../../internals/tanstack-query/src/components/MutationKey.d.ts
|
|
142
|
+
/**
|
|
143
|
+
* Default `mutationKey` builder. Call it from a custom builder to extend the default key.
|
|
144
|
+
*
|
|
145
|
+
* @remarks The returned segments may change between releases. Spread them instead of reading single entries.
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* ```ts
|
|
149
|
+
* mutationKey: (props) => [JSON.stringify(props.node.operationId), ...mutationKeyTransformer(props)]
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
export declare const mutationKeyTransformer: Transformer;
|
|
153
|
+
//#endregion
|
|
154
|
+
//#region ../../internals/tanstack-query/src/components/QueryKey.d.ts
|
|
155
|
+
/**
|
|
156
|
+
* Default `queryKey` builder. Call it from a custom builder to extend the default key.
|
|
157
|
+
*
|
|
158
|
+
* @remarks The returned segments may change between releases. Spread them instead of reading single entries.
|
|
159
|
+
*
|
|
160
|
+
* @example
|
|
161
|
+
* ```ts
|
|
162
|
+
* queryKey: (props) => [JSON.stringify(props.node.operationId), ...queryKeyTransformer(props)]
|
|
163
|
+
* ```
|
|
164
|
+
*/
|
|
165
|
+
export declare const queryKeyTransformer: Transformer;
|
|
166
|
+
//#endregion
|
|
141
167
|
//#region ../../internals/tanstack-query/src/utils.d.ts
|
|
142
168
|
/**
|
|
143
169
|
* Helper to define a typed page param function for `infinite.getNextPageParam` or
|
|
@@ -534,5 +560,5 @@ export declare const pluginReactQuery: import("kubb/kit").PluginFactory<PluginRe
|
|
|
534
560
|
*/
|
|
535
561
|
export declare const resolverReactQuery: ResolverReactQuery;
|
|
536
562
|
//#endregion
|
|
537
|
-
export { type PageParamFn, type PluginReactQuery, type ResolverReactQuery, pluginReactQuery as default };
|
|
563
|
+
export { type PageParamFn, type PluginReactQuery, type ResolverReactQuery, type Transformer, pluginReactQuery as default };
|
|
538
564
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -236,12 +236,23 @@ function resolveOperationTypeNames(node, resolver, options = {}) {
|
|
|
236
236
|
*
|
|
237
237
|
* When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.
|
|
238
238
|
*/
|
|
239
|
-
function
|
|
239
|
+
function convert(text, pascal) {
|
|
240
240
|
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) => {
|
|
241
241
|
if (word.length > 1 && word === word.toUpperCase()) return word;
|
|
242
242
|
return (i === 0 && !pascal ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()) + word.slice(1);
|
|
243
243
|
}).join("").replace(/[^a-zA-Z0-9]/g, "");
|
|
244
244
|
}
|
|
245
|
+
const cache = /* @__PURE__ */ new Map();
|
|
246
|
+
const cacheLimit = 1e4;
|
|
247
|
+
function toCamelOrPascal(text, pascal) {
|
|
248
|
+
const key = `${pascal ? "P" : "c"}${text}`;
|
|
249
|
+
const cached = cache.get(key);
|
|
250
|
+
if (cached !== void 0) return cached;
|
|
251
|
+
const result = convert(text, pascal);
|
|
252
|
+
if (cache.size >= cacheLimit) cache.clear();
|
|
253
|
+
cache.set(key, result);
|
|
254
|
+
return result;
|
|
255
|
+
}
|
|
245
256
|
/**
|
|
246
257
|
* Converts `text` to camelCase.
|
|
247
258
|
*
|
|
@@ -320,7 +331,7 @@ var compatibility = {
|
|
|
320
331
|
};
|
|
321
332
|
//#endregion
|
|
322
333
|
//#region package.json
|
|
323
|
-
var version = "5.5.
|
|
334
|
+
var version = "5.5.5";
|
|
324
335
|
//#endregion
|
|
325
336
|
//#region ../../internals/client/src/resolveClient.ts
|
|
326
337
|
/**
|
|
@@ -846,6 +857,11 @@ function getDefaultPageParamsWarning(node, infinite) {
|
|
|
846
857
|
return `${node.operationId}: the default infinite page params expect an array response and never end for this one. Set \`infinite.getNextPageParam\` (or \`nextParam\`) to read the next page from the response.`;
|
|
847
858
|
}
|
|
848
859
|
function matchesPattern(node, ov) {
|
|
860
|
+
if ("key" in ov) {
|
|
861
|
+
const extensions = node.extensions;
|
|
862
|
+
if (!extensions || !(ov.key in extensions)) return false;
|
|
863
|
+
return ov.value === void 0 || extensions[ov.key] === ov.value;
|
|
864
|
+
}
|
|
849
865
|
const { type, pattern } = ov;
|
|
850
866
|
const matches = (value) => typeof pattern === "string" ? value === pattern : pattern.test(value);
|
|
851
867
|
if (type === "operationId") return matches(node.operationId);
|
|
@@ -1010,6 +1026,16 @@ return infiniteQueryOptions<${queryFnDataType}, ${errorType}, InfiniteData<${que
|
|
|
1010
1026
|
//#endregion
|
|
1011
1027
|
//#region ../../internals/tanstack-query/src/components/MutationKey.tsx
|
|
1012
1028
|
const declarationPrinter$5 = functionPrinter({ mode: "declaration" });
|
|
1029
|
+
/**
|
|
1030
|
+
* Default `mutationKey` builder. Call it from a custom builder to extend the default key.
|
|
1031
|
+
*
|
|
1032
|
+
* @remarks The returned segments may change between releases. Spread them instead of reading single entries.
|
|
1033
|
+
*
|
|
1034
|
+
* @example
|
|
1035
|
+
* ```ts
|
|
1036
|
+
* mutationKey: (props) => [JSON.stringify(props.node.operationId), ...mutationKeyTransformer(props)]
|
|
1037
|
+
* ```
|
|
1038
|
+
*/
|
|
1013
1039
|
const mutationKeyTransformer = ({ node }) => {
|
|
1014
1040
|
if (!node.path) return [];
|
|
1015
1041
|
return [`{ url: '${Url.toPath(node.path)}' }`];
|
|
@@ -1101,6 +1127,16 @@ function createMutationResolver() {
|
|
|
1101
1127
|
//#endregion
|
|
1102
1128
|
//#region ../../internals/tanstack-query/src/components/QueryKey.tsx
|
|
1103
1129
|
const declarationPrinter$4 = functionPrinter({ mode: "declaration" });
|
|
1130
|
+
/**
|
|
1131
|
+
* Default `queryKey` builder. Call it from a custom builder to extend the default key.
|
|
1132
|
+
*
|
|
1133
|
+
* @remarks The returned segments may change between releases. Spread them instead of reading single entries.
|
|
1134
|
+
*
|
|
1135
|
+
* @example
|
|
1136
|
+
* ```ts
|
|
1137
|
+
* queryKey: (props) => [JSON.stringify(props.node.operationId), ...queryKeyTransformer(props)]
|
|
1138
|
+
* ```
|
|
1139
|
+
*/
|
|
1104
1140
|
const queryKeyTransformer = ({ node, variant }) => {
|
|
1105
1141
|
if (!node.path) return [];
|
|
1106
1142
|
const { path, query } = getOperationParameters(node);
|
|
@@ -2079,6 +2115,6 @@ const pluginReactQuery = defineExtension({
|
|
|
2079
2115
|
}
|
|
2080
2116
|
});
|
|
2081
2117
|
//#endregion
|
|
2082
|
-
export { pluginReactQuery as default, pluginReactQuery, definePageParam, pluginReactQueryName, resolverReactQuery };
|
|
2118
|
+
export { pluginReactQuery as default, pluginReactQuery, definePageParam, mutationKeyTransformer, pluginReactQueryName, queryKeyTransformer, resolverReactQuery };
|
|
2083
2119
|
|
|
2084
2120
|
//# sourceMappingURL=index.js.map
|