@kubb/plugin-vue-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 CHANGED
@@ -261,12 +261,23 @@ function resolveOperationTypeNames(node, resolver, options = {}) {
261
261
  *
262
262
  * When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.
263
263
  */
264
- function toCamelOrPascal(text, pascal) {
264
+ function convert(text, pascal) {
265
265
  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) => {
266
266
  if (word.length > 1 && word === word.toUpperCase()) return word;
267
267
  return (i === 0 && !pascal ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()) + word.slice(1);
268
268
  }).join("").replace(/[^a-zA-Z0-9]/g, "");
269
269
  }
270
+ const cache = /* @__PURE__ */ new Map();
271
+ const cacheLimit = 1e4;
272
+ function toCamelOrPascal(text, pascal) {
273
+ const key = `${pascal ? "P" : "c"}${text}`;
274
+ const cached = cache.get(key);
275
+ if (cached !== void 0) return cached;
276
+ const result = convert(text, pascal);
277
+ if (cache.size >= cacheLimit) cache.clear();
278
+ cache.set(key, result);
279
+ return result;
280
+ }
270
281
  /**
271
282
  * Converts `text` to camelCase.
272
283
  *
@@ -345,7 +356,7 @@ var compatibility = {
345
356
  };
346
357
  //#endregion
347
358
  //#region package.json
348
- var version = "5.5.3";
359
+ var version = "5.5.5";
349
360
  //#endregion
350
361
  //#region ../../internals/tanstack-query/src/components/HookFile.tsx
351
362
  /**
@@ -835,6 +846,16 @@ return infiniteQueryOptions<${queryFnDataType}, ${errorType}, InfiniteData<${que
835
846
  //#endregion
836
847
  //#region ../../internals/tanstack-query/src/components/MutationKey.tsx
837
848
  const declarationPrinter$4 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "declaration" });
849
+ /**
850
+ * Default `mutationKey` builder. Call it from a custom builder to extend the default key.
851
+ *
852
+ * @remarks The returned segments may change between releases. Spread them instead of reading single entries.
853
+ *
854
+ * @example
855
+ * ```ts
856
+ * mutationKey: (props) => [JSON.stringify(props.node.operationId), ...mutationKeyTransformer(props)]
857
+ * ```
858
+ */
838
859
  const mutationKeyTransformer = ({ node }) => {
839
860
  if (!node.path) return [];
840
861
  return [`{ url: '${kubb_kit.Url.toPath(node.path)}' }`];
@@ -926,6 +947,16 @@ function createMutationResolver() {
926
947
  //#endregion
927
948
  //#region ../../internals/tanstack-query/src/components/QueryKey.tsx
928
949
  const declarationPrinter$3 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "declaration" });
950
+ /**
951
+ * Default `queryKey` builder. Call it from a custom builder to extend the default key.
952
+ *
953
+ * @remarks The returned segments may change between releases. Spread them instead of reading single entries.
954
+ *
955
+ * @example
956
+ * ```ts
957
+ * queryKey: (props) => [JSON.stringify(props.node.operationId), ...queryKeyTransformer(props)]
958
+ * ```
959
+ */
929
960
  const queryKeyTransformer = ({ node, variant }) => {
930
961
  if (!node.path) return [];
931
962
  const { path, query } = getOperationParameters(node);
@@ -1752,8 +1783,10 @@ const pluginVueQuery = (0, kubb_kit.defineExtension)({
1752
1783
  //#endregion
1753
1784
  exports.default = pluginVueQuery;
1754
1785
  exports.definePageParam = definePageParam;
1786
+ exports.mutationKeyTransformer = mutationKeyTransformer;
1755
1787
  exports.pluginVueQuery = pluginVueQuery;
1756
1788
  exports.pluginVueQueryName = pluginVueQueryName;
1789
+ exports.queryKeyTransformer = queryKeyTransformer;
1757
1790
  exports.resolverVueQuery = resolverVueQuery;
1758
1791
 
1759
1792
  //# sourceMappingURL=index.cjs.map