@braine/quantum-query 1.2.8 → 1.2.9

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
@@ -591,7 +591,7 @@ function isDeepEqual(a, b) {
591
591
  var QueryStorage = class {
592
592
  // Tracks access order (least to most recent)
593
593
  // Default configuration
594
- constructor(defaultStaleTime = 0, defaultCacheTime = 5 * 60 * 1e3, maxSize = 100) {
594
+ constructor(defaultStaleTime = 5 * 60 * 1e3, defaultCacheTime = 5 * 60 * 1e3, maxSize = 100) {
595
595
  this.defaultStaleTime = defaultStaleTime;
596
596
  this.defaultCacheTime = defaultCacheTime;
597
597
  this.maxSize = maxSize;
@@ -944,7 +944,7 @@ var QueryClient = class {
944
944
  defaultCacheTime;
945
945
  defaultSchema;
946
946
  constructor(config) {
947
- this.defaultStaleTime = config?.defaultStaleTime ?? 0;
947
+ this.defaultStaleTime = config?.defaultStaleTime ?? 5 * 60 * 1e3;
948
948
  this.defaultCacheTime = config?.defaultCacheTime ?? 5 * 60 * 1e3;
949
949
  this.defaultSchema = config?.defaultSchema;
950
950
  this.storage = new QueryStorage(
@@ -1126,6 +1126,14 @@ var QueryClient = class {
1126
1126
  return Date.now() - entry.timestamp > entry.staleTime;
1127
1127
  };
1128
1128
  getAll = () => this.storage.getAll();
1129
+ /**
1130
+ * Check if a query key exists in the cache
1131
+ */
1132
+ has = (queryKey) => {
1133
+ const key = this.storage.generateKey(queryKey);
1134
+ const signal2 = this.storage.get(key, false);
1135
+ return signal2 !== void 0 && signal2.get() !== void 0;
1136
+ };
1129
1137
  snapshot = () => this.storage.getSnapshot();
1130
1138
  clear = () => this.storage.clear();
1131
1139
  remove = (key) => this.storage.delete(this.storage.generateKey(key));
package/dist/index.d.cts CHANGED
@@ -244,6 +244,10 @@ declare class QueryClient {
244
244
  use: (plugin: QueryPlugin) => this;
245
245
  isStale: (queryKey: QueryKeyInput) => boolean;
246
246
  getAll: () => Map<string, CacheEntry<unknown>>;
247
+ /**
248
+ * Check if a query key exists in the cache
249
+ */
250
+ has: (queryKey: QueryKeyInput) => boolean;
247
251
  snapshot: () => Map<string, CacheEntry<unknown>>;
248
252
  clear: () => void;
249
253
  remove: (key: QueryKeyInput) => void;
package/dist/index.d.ts CHANGED
@@ -244,6 +244,10 @@ declare class QueryClient {
244
244
  use: (plugin: QueryPlugin) => this;
245
245
  isStale: (queryKey: QueryKeyInput) => boolean;
246
246
  getAll: () => Map<string, CacheEntry<unknown>>;
247
+ /**
248
+ * Check if a query key exists in the cache
249
+ */
250
+ has: (queryKey: QueryKeyInput) => boolean;
247
251
  snapshot: () => Map<string, CacheEntry<unknown>>;
248
252
  clear: () => void;
249
253
  remove: (key: QueryKeyInput) => void;
package/dist/index.js CHANGED
@@ -550,7 +550,7 @@ function isDeepEqual(a, b) {
550
550
  var QueryStorage = class {
551
551
  // Tracks access order (least to most recent)
552
552
  // Default configuration
553
- constructor(defaultStaleTime = 0, defaultCacheTime = 5 * 60 * 1e3, maxSize = 100) {
553
+ constructor(defaultStaleTime = 5 * 60 * 1e3, defaultCacheTime = 5 * 60 * 1e3, maxSize = 100) {
554
554
  this.defaultStaleTime = defaultStaleTime;
555
555
  this.defaultCacheTime = defaultCacheTime;
556
556
  this.maxSize = maxSize;
@@ -903,7 +903,7 @@ var QueryClient = class {
903
903
  defaultCacheTime;
904
904
  defaultSchema;
905
905
  constructor(config) {
906
- this.defaultStaleTime = config?.defaultStaleTime ?? 0;
906
+ this.defaultStaleTime = config?.defaultStaleTime ?? 5 * 60 * 1e3;
907
907
  this.defaultCacheTime = config?.defaultCacheTime ?? 5 * 60 * 1e3;
908
908
  this.defaultSchema = config?.defaultSchema;
909
909
  this.storage = new QueryStorage(
@@ -1085,6 +1085,14 @@ var QueryClient = class {
1085
1085
  return Date.now() - entry.timestamp > entry.staleTime;
1086
1086
  };
1087
1087
  getAll = () => this.storage.getAll();
1088
+ /**
1089
+ * Check if a query key exists in the cache
1090
+ */
1091
+ has = (queryKey) => {
1092
+ const key = this.storage.generateKey(queryKey);
1093
+ const signal2 = this.storage.get(key, false);
1094
+ return signal2 !== void 0 && signal2.get() !== void 0;
1095
+ };
1088
1096
  snapshot = () => this.storage.getSnapshot();
1089
1097
  clear = () => this.storage.clear();
1090
1098
  remove = (key) => this.storage.delete(this.storage.generateKey(key));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@braine/quantum-query",
3
- "version": "1.2.8",
3
+ "version": "1.2.9",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "scripts": {