tanstack-cacher 1.4.2 → 1.4.4

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 +1 -1
  2. package/index.js +3 -3
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -10,7 +10,7 @@ interface PaginationConfig {
10
10
  pageSizePath?: string;
11
11
  }
12
12
  interface CacheConfig<TData, TItem> {
13
- queryClient?: QueryClient;
13
+ queryClient: QueryClient;
14
14
  queryKey: QueryKey;
15
15
  itemsPath?: string;
16
16
  pagination?: PaginationConfig;
package/index.js CHANGED
@@ -82,14 +82,13 @@ var DEFAULT_PAGINATION_PATHS = {
82
82
  };
83
83
 
84
84
  // src/managers/QueryCacheManager/QueryCache.manager.ts
85
- var defaultQueryClient = new reactQuery.QueryClient();
86
85
  var QueryCacheManager = class {
87
86
  constructor(config) {
88
87
  const isPaginated = Boolean(config.pagination);
89
88
  this.config = {
90
89
  ...config,
91
90
  itemsPath: config.itemsPath ?? "data.content",
92
- queryClient: config.queryClient ?? defaultQueryClient,
91
+ queryClient: config.queryClient,
93
92
  isPaginated,
94
93
  keyExtractor: config.keyExtractor || ((item) => item.id),
95
94
  pagination: isPaginated ? {
@@ -420,13 +419,14 @@ var useCustomMutation = (options) => {
420
419
  ...rest
421
420
  } = options;
422
421
  const cacherContext = useCacherContext();
422
+ const queryClient = reactQuery.useQueryClient();
423
423
  const shouldNotifyError = notify || notifyError;
424
424
  const shouldNotifySuccess = notify || notifySuccess;
425
425
  const cacheActionsToRun = Array.isArray(cacheActions) ? cacheActions : cacheActions ? [cacheActions] : [];
426
426
  const runCacheActions = (data) => {
427
427
  cacheActionsToRun.forEach((action) => {
428
428
  const { type, ...config } = action;
429
- const manager = cacheManagerFactory.create(config);
429
+ const manager = cacheManagerFactory.create({ ...config, queryClient });
430
430
  runCacheManagers(type, manager, data);
431
431
  });
432
432
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tanstack-cacher",
3
- "version": "1.4.2",
3
+ "version": "1.4.4",
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": {