tanstack-cacher 1.3.3 → 1.4.0

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.
Files changed (3) hide show
  1. package/index.d.ts +2 -0
  2. package/index.js +16 -2
  3. package/package.json +3 -4
package/index.d.ts CHANGED
@@ -41,6 +41,8 @@ declare class QueryCacheManager<TData, TItem> {
41
41
  getDataFromCache(): TData | undefined;
42
42
  invalidate(): void;
43
43
  refetch(key?: string | string[]): void;
44
+ hasQuery(key?: string): boolean;
45
+ removeQuery(key?: string): void;
44
46
  createHandlers(): CacheHandlers<TItem>;
45
47
  }
46
48
 
package/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  var reactQuery = require('@tanstack/react-query');
4
4
  var react = require('react');
5
5
 
6
- // src/index.ts
6
+ // src/hooks/useCustomMutation.ts
7
7
 
8
8
  // src/managers/QueryCacheManager/QueryCache.utils.ts
9
9
  function getAtPath(obj, path, defaultValue) {
@@ -226,7 +226,7 @@ var QueryCacheManager = class {
226
226
  /**
227
227
  * Remove item from cache
228
228
  *
229
- * @param itemOrId - Item object or ID to remove
229
+ * @param itemOrId - Item object or ID to removex
230
230
  * @param matcher - Optional custom matcher function. Defaults to matching by key
231
231
  */
232
232
  delete(itemOrId, matcher) {
@@ -338,6 +338,20 @@ var QueryCacheManager = class {
338
338
  console.error("[QueryCacheManager] Refetch failed:", error);
339
339
  }
340
340
  }
341
+ /**
342
+ * Check if query exists in cache
343
+ */
344
+ hasQuery(key) {
345
+ const queryKey = key ?? this.config.queryKey;
346
+ return !!this.config.queryClient.getQueryCache().find({ queryKey: [queryKey] });
347
+ }
348
+ /**
349
+ * Remove query from cache
350
+ */
351
+ removeQuery(key) {
352
+ const queryKey = key ?? this.config.queryKey;
353
+ this.config.queryClient.removeQueries({ queryKey: [queryKey] });
354
+ }
341
355
  /**
342
356
  * Get handlers for use with mutations
343
357
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tanstack-cacher",
3
- "version": "1.3.3",
3
+ "version": "1.4.0",
4
4
  "description": "A lightweight cache management utility for TanStack Query that simplifies adding, updating, deleting, and synchronizing cached data",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -59,13 +59,12 @@
59
59
  "lint:fix": "eslint src --ext .ts,.tsx --fix",
60
60
  "copy-dist": "cp dist/index.js index.js && cp dist/index.d.ts index.d.ts"
61
61
  },
62
- "dependencies": {
63
- "@tanstack/react-query": "^5.62.11"
64
- },
65
62
  "peerDependencies": {
63
+ "@tanstack/react-query": "^5.0.0",
66
64
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
67
65
  },
68
66
  "devDependencies": {
67
+ "@tanstack/react-query": "^5.62.11",
69
68
  "@types/react": "^18.3.12",
70
69
  "@typescript-eslint/eslint-plugin": "^7.18.0",
71
70
  "@typescript-eslint/parser": "^7.18.0",