@asaidimu/utils-remote-store 1.3.10 → 1.3.12

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/index.d.cts ADDED
@@ -0,0 +1,549 @@
1
+ //#region src/persistence/types.d.ts
2
+ interface SimplePersistence<T> {
3
+ /**
4
+ * Persists data to storage.
5
+ *
6
+ * @param id The **unique identifier of the *consumer instance*** making the change. This is NOT the ID of the data (`T`) itself.
7
+ * Think of it as the ID of the specific browser tab, component, or module that's currently interacting with the persistence layer.
8
+ * It should typically be a **UUID** generated once at the consumer instance's instantiation.
9
+ * This `id` is crucial for the `subscribe` method, helping to differentiate updates originating from the current instance versus other instances/tabs, thereby preventing self-triggered notification loops.
10
+ * @param state The state (of type T) to persist. This state is generally considered the **global or shared state** that all instances interact with.
11
+ * @returns `true` if the operation was successful, `false` if an error occurred. For asynchronous implementations (like `IndexedDBPersistence`), this returns a `Promise<boolean>`.
12
+ */
13
+ set(id: string, state: T): boolean | Promise<boolean>;
14
+ /**
15
+ * Retrieves the global persisted data from storage.
16
+ *
17
+ * @returns The retrieved state of type `T`, or `null` if no data is found or if an error occurs during retrieval/parsing.
18
+ * For asynchronous implementations, this returns a `Promise<T | null>`.
19
+ */
20
+ get(): (T | null) | Promise<T | null>;
21
+ /**
22
+ * Subscribes to changes in the global persisted data that originate from *other* instances of your application (e.g., other tabs or independent components using the same persistence layer).
23
+ *
24
+ * @param id The **unique identifier of the *consumer instance* subscribing**. This allows the persistence implementation to filter out notifications that were initiated by the subscribing instance itself.
25
+ * @param callback The function to call when the global persisted data changes from *another* source. The new state (`T`) is passed as an argument to this callback.
26
+ * @returns A function that, when called, will unsubscribe the provided callback from future updates. Call this when your component or instance is no longer active to prevent memory leaks.
27
+ */
28
+ subscribe(id: string, callback: (state: T) => void): () => void;
29
+ /**
30
+ * Clears (removes) the entire global persisted data from storage.
31
+ *
32
+ * @returns `true` if the operation was successful, `false` if an error occurred. For asynchronous implementations, this returns a `Promise<boolean>`.
33
+ */
34
+ clear(): boolean | Promise<boolean>;
35
+ /**
36
+ * Returns metadata about the persistence layer.
37
+ *
38
+ * This is useful for distinguishing between multiple apps running on the same host
39
+ * (e.g., several apps served at `localhost:3000` that share the same storage key).
40
+ *
41
+ * @returns An object containing:
42
+ * - `version`: The semantic version string of the persistence schema or application.
43
+ * - `id`: A unique identifier for the application using this persistence instance.
44
+ */
45
+ stats(): {
46
+ version: string;
47
+ id: string;
48
+ };
49
+ }
50
+ //#endregion
51
+ //#region src/cache/types.d.ts
52
+ interface CacheOptions {
53
+ staleTime?: number;
54
+ cacheTime?: number;
55
+ retryAttempts?: number;
56
+ retryDelay?: number;
57
+ maxSize?: number;
58
+ enableMetrics?: boolean;
59
+ persistence?: SimplePersistence<SerializableCacheState>;
60
+ persistenceId?: string;
61
+ serializeValue?: (value: any) => any;
62
+ deserializeValue?: (value: any) => any;
63
+ persistenceDebounceTime?: number;
64
+ }
65
+ interface CacheMetrics {
66
+ hits: number;
67
+ misses: number;
68
+ fetches: number;
69
+ errors: number;
70
+ evictions: number;
71
+ staleHits: number;
72
+ }
73
+ interface SerializableCacheEntry {
74
+ data: any;
75
+ lastUpdated: number;
76
+ lastAccessed: number;
77
+ accessCount: number;
78
+ error?: {
79
+ name: string;
80
+ message: string;
81
+ stack?: string;
82
+ };
83
+ }
84
+ type SerializableCacheState = Array<[string, SerializableCacheEntry]>;
85
+ type CacheEventBase<Type extends string, Payload = {}> = {
86
+ type: Type;
87
+ key: string;
88
+ timestamp: number;
89
+ } & Payload;
90
+ type CacheReadHitEvent<T = any> = CacheEventBase<"cache:read:hit", {
91
+ data: T;
92
+ isStale: boolean;
93
+ }>;
94
+ type CacheReadMissEvent = CacheEventBase<"cache:read:miss">;
95
+ type CacheFetchStartEvent = CacheEventBase<"cache:fetch:start", {
96
+ attempt: number;
97
+ }>;
98
+ type CacheFetchSuccessEvent<T = any> = CacheEventBase<"cache:fetch:success", {
99
+ data: T;
100
+ }>;
101
+ type CacheFetchErrorEvent = CacheEventBase<"cache:fetch:error", {
102
+ error: Error;
103
+ attempt: number;
104
+ }>;
105
+ type CacheDataEvictEvent = CacheEventBase<"cache:data:evict", {
106
+ reason?: string;
107
+ }>;
108
+ type CacheDataInvalidateEvent = CacheEventBase<"cache:data:invalidate">;
109
+ type CacheDataSetEvent<T = any> = CacheEventBase<"cache:data:set", {
110
+ newData: T;
111
+ oldData?: T;
112
+ }>;
113
+ type CachePersistenceLoadSuccessEvent = CacheEventBase<"cache:persistence:load:success", {
114
+ message?: string;
115
+ }>;
116
+ type CachePersistenceLoadErrorEvent = CacheEventBase<"cache:persistence:load:error", {
117
+ message?: string;
118
+ error?: any;
119
+ }>;
120
+ type CachePersistenceSaveSuccessEvent = CacheEventBase<"cache:persistence:save:success">;
121
+ type CachePersistenceSaveErrorEvent = CacheEventBase<"cache:persistence:save:error", {
122
+ message?: string;
123
+ error?: any;
124
+ }>;
125
+ type CachePersistenceClearSuccessEvent = CacheEventBase<"cache:persistence:clear:success">;
126
+ type CachePersistenceClearErrorEvent = CacheEventBase<"cache:persistence:clear:error", {
127
+ message?: string;
128
+ error?: any;
129
+ }>;
130
+ type CachePersistenceSyncEvent = CacheEventBase<"cache:persistence:sync", {
131
+ message?: string;
132
+ }>;
133
+ type CacheEvent = CacheReadHitEvent | CacheReadMissEvent | CacheFetchStartEvent | CacheFetchSuccessEvent | CacheFetchErrorEvent | CacheDataEvictEvent | CacheDataInvalidateEvent | CacheDataSetEvent | CachePersistenceLoadSuccessEvent | CachePersistenceLoadErrorEvent | CachePersistenceSaveSuccessEvent | CachePersistenceSaveErrorEvent | CachePersistenceClearSuccessEvent | CachePersistenceClearErrorEvent | CachePersistenceSyncEvent;
134
+ type CacheEventType = CacheEvent["type"];
135
+ //#endregion
136
+ //#region src/cache/cache.d.ts
137
+ declare class QueryCache {
138
+ private cache;
139
+ private queries;
140
+ private fetching;
141
+ private readonly defaultOptions;
142
+ private metrics;
143
+ private eventBus;
144
+ private gcTimer?;
145
+ private readonly persistenceId;
146
+ private persistenceUnsubscribe?;
147
+ private persistenceDebounceTimer?;
148
+ private isHandlingRemoteUpdate;
149
+ constructor(defaultOptions?: CacheOptions);
150
+ private initializePersistence;
151
+ private serializeCache;
152
+ private deserializeAndLoadCache;
153
+ private schedulePersistState;
154
+ private handleRemoteStateChange;
155
+ registerQuery<T>(key: string, fetchFunction: () => Promise<T>, options?: CacheOptions): void;
156
+ get<T>(key: string, options?: {
157
+ waitForFresh?: boolean;
158
+ throwOnError?: boolean;
159
+ }): Promise<T | undefined>;
160
+ peek<T>(key: string): T | undefined;
161
+ has(key: string): boolean;
162
+ private fetch;
163
+ private fetchAndWait;
164
+ private performFetchWithRetry;
165
+ private isStale;
166
+ invalidate(key: string, refetch?: boolean): Promise<void>;
167
+ invalidatePattern(pattern: RegExp, refetch?: boolean): Promise<void>;
168
+ prefetch(key: string): Promise<void>;
169
+ refresh<T>(key: string): Promise<T | undefined>;
170
+ setData<T>(key: string, data: T): void;
171
+ remove(key: string): boolean;
172
+ private enforceSizeLimit;
173
+ private startGarbageCollection;
174
+ garbageCollect(): number;
175
+ getStats(): {
176
+ size: number;
177
+ metrics: CacheMetrics;
178
+ hitRate: number;
179
+ staleHitRate: number;
180
+ entries: Array<{
181
+ key: string;
182
+ lastAccessed: number;
183
+ lastUpdated: number;
184
+ accessCount: number;
185
+ isStale: boolean;
186
+ isLoading?: boolean;
187
+ error?: boolean;
188
+ }>;
189
+ };
190
+ on<EType extends CacheEventType>(event: EType, listener: (ev: Extract<CacheEvent, {
191
+ type: EType;
192
+ }>) => void): () => void;
193
+ private emitEvent;
194
+ private updateMetrics;
195
+ private delay;
196
+ clear(): Promise<void>;
197
+ destroy(): void;
198
+ }
199
+ //#endregion
200
+ //#region src/remote-store/error.d.ts
201
+ interface StoreErrorDetails {
202
+ code: string;
203
+ message: string;
204
+ status?: number;
205
+ data?: unknown;
206
+ isRetryable: boolean;
207
+ }
208
+ declare class StoreError extends Error {
209
+ readonly code: string;
210
+ readonly status?: number;
211
+ readonly data?: unknown;
212
+ readonly isRetryable: boolean;
213
+ readonly originalError?: Error;
214
+ constructor(details: StoreErrorDetails, originalError?: Error);
215
+ static fromError(error: any, operation: string): StoreError;
216
+ }
217
+ //#endregion
218
+ //#region src/remote-store/types.d.ts
219
+ /**
220
+ * Represents a paginated response containing a list of records and pagination details.
221
+ * @template T The type of the records in the page.
222
+ */
223
+ interface Page<T> {
224
+ /** The array of records for the current page. */
225
+ data: T[];
226
+ /** Pagination metadata. */
227
+ page: PaginationInfo;
228
+ }
229
+ /**
230
+ * Represents an event emitted by the store, typically for notifications or state changes.
231
+ */
232
+ interface StoreEvent {
233
+ /** The scope of the event, indicating its type and context. Custom scopes are allowed. */
234
+ scope: string;
235
+ /** Optional payload carrying data related to the event. */
236
+ payload?: any;
237
+ }
238
+ /**
239
+ * Defines the types of mutation operations that can occur.
240
+ */
241
+ type MutationOperation = "create" | "update" | "delete" | "upload";
242
+ /**
243
+ * A correlator function that determines which active queries should be invalidated
244
+ * based on a mutation operation.
245
+ * @param mutation An object describing the mutation operation and its parameters.
246
+ * @param activeQueries An array of currently active queries.
247
+ * @returns An array of query keys to be invalidated.
248
+ */
249
+ type Correlator = (mutation: {
250
+ operation: MutationOperation;
251
+ params: any;
252
+ }, activeQueries: ActiveQuery[]) => string[];
253
+ /**
254
+ * A correlator function that determines which active queries should be invalidated
255
+ * based on a store event.
256
+ * @param event The StoreEvent that occurred.
257
+ * @param activeQueries An array of currently active queries.
258
+ * @returns An array of query keys to be invalidated.
259
+ */
260
+ type StoreEventCorrelator = (event: StoreEvent, activeQueries: ActiveQuery[]) => string[];
261
+ /**
262
+ * Defines the core interface for interacting with a remote data store.
263
+ * @template T The type of the records managed by the store, extending Record.
264
+ * @template TFindOptions Options for the find operation.
265
+ * @template TReadOptions Options for the read operation.
266
+ * @template TListOptions Options for the list operation.
267
+ * @template TDeleteOptions Options for the delete operation.
268
+ * @template TUpdateOptions Options for the update operation.
269
+ * @template TCreateOptions Options for the create operation.
270
+ * @template TUploadOptions Options for the upload operation.
271
+ * @template TStreamOptions Options for the stream operation.
272
+ */
273
+ interface BaseStore<T extends StoreRecord, TFindOptions = Record<string, unknown>, TReadOptions = Record<string, unknown>, TListOptions = Record<string, unknown>, TDeleteOptions = Record<string, unknown>, TUpdateOptions = Record<string, unknown>, TCreateOptions = Record<string, unknown>, TUploadOptions = Record<string, unknown>, TStreamOptions = Record<string, unknown>> {
274
+ /**
275
+ * Finds records based on provided options, returning a paginated result.
276
+ * @param options The options for the find operation.
277
+ * @returns A promise that resolves to a Page of records.
278
+ */
279
+ find: (options: TFindOptions) => Promise<Page<T>>;
280
+ /**
281
+ * Reads a single record by its identifier or other read options.
282
+ * @param options The options for the read operation, typically including an ID.
283
+ * @returns A promise that resolves to the record or undefined if not found.
284
+ */
285
+ read: (options: TReadOptions) => Promise<T | undefined>;
286
+ /**
287
+ * Lists records based on provided options, returning a paginated result.
288
+ * @param options The options for the list operation.
289
+ * @returns A promise that resolves to a Page of records.
290
+ */
291
+ list: (options: TListOptions) => Promise<Page<T>>;
292
+ /**
293
+ * Deletes a record based on provided options, typically including an ID.
294
+ * @param options The options for the delete operation.
295
+ * @returns A promise that resolves when the deletion is complete.
296
+ */
297
+ delete: (options: TDeleteOptions) => Promise<void>;
298
+ /**
299
+ * Updates an existing record.
300
+ * @param props An object containing the ID of the record to update, the partial data, and optional update options.
301
+ * @returns A promise that resolves to the updated record or undefined if not found.
302
+ */
303
+ update: (props: {
304
+ data: Partial<T>;
305
+ options?: TUpdateOptions;
306
+ }) => Promise<T | undefined>;
307
+ /**
308
+ * Creates a new record.
309
+ * @param props An object containing the data for the new record and optional create options.
310
+ * @returns A promise that resolves to the newly created record or undefined if creation failed.
311
+ */
312
+ create: (props: {
313
+ data: Partial<T>;
314
+ options?: TCreateOptions;
315
+ }) => Promise<T | undefined>;
316
+ /**
317
+ * Uploads a file associated with a record. Optionally updates the record with upload details.
318
+ * @param props An object containing the file to upload and optional upload options.
319
+ * @returns A promise that resolves to the updated record after upload or undefined if upload failed.
320
+ */
321
+ upload: (props: {
322
+ file: File;
323
+ options?: TUploadOptions;
324
+ }) => Promise<T | undefined>;
325
+ /**
326
+ * Subscribes to store events for a given scope.
327
+ * @param scope The event scope to subscribe to (e.g., 'todos:created:success', '*').
328
+ * @param callback The function to call when an event matching the scope is received.
329
+ * @returns A promise that resolves to an unsubscribe function. Call this function to stop receiving events.
330
+ */
331
+ subscribe(scope: string, callback: (event: StoreEvent) => void): Promise<() => void>;
332
+ /**
333
+ * Notifies the store of an event, which can then be broadcast to subscribers.
334
+ * @param event The StoreEvent to notify.
335
+ * @returns A promise that resolves when the notification has been processed.
336
+ */
337
+ notify: (event: StoreEvent) => Promise<void>;
338
+ /**
339
+ * Establishes a stream of records based on provided options.
340
+ * @param options Options for configuring the stream (e.g., batch size, delay, filters).
341
+ * @param onStreamChange A callback function that is called when the stream's status changes.
342
+ * @returns An object containing the async iterable stream, a cancel function, and a status getter.
343
+ */
344
+ stream: (options: TStreamOptions, onStreamChange: () => void) => {
345
+ /** An async iterable that yields records as they become available in the stream. */stream: () => AsyncIterable<T>; /** A function to call to cancel the ongoing stream. */
346
+ cancel: () => void; /** A getter function that returns the current status of the stream ('active', 'cancelled', or 'completed'). */
347
+ status: () => "active" | "cancelled" | "completed";
348
+ };
349
+ }
350
+ /**
351
+ * Represents an active query in the cache, used for invalidation correlation.
352
+ */
353
+ interface ActiveQuery {
354
+ /** The unique key identifying the query in the cache. */
355
+ queryKey: string;
356
+ /** The type of operation this query represents (e.g., 'read', 'list', 'find'). */
357
+ operation: string;
358
+ /** The parameters used to make this query. */
359
+ params: any;
360
+ }
361
+ /**
362
+ * Represents the result of a single record query.
363
+ * @template T The type of the data being queried.
364
+ */
365
+ interface QueryResult<T> {
366
+ /** The data returned by the query, or undefined if not found or still loading. */
367
+ data: T | undefined;
368
+ /** Indicates if the query is currently loading data. */
369
+ loading: boolean;
370
+ /** An error object if the query failed, otherwise undefined. */
371
+ error: Error | undefined;
372
+ /** Indicates if the cached data is stale and a refetch is needed. */
373
+ stale: boolean;
374
+ /** Timestamp of the last update to the data. */
375
+ updated: number;
376
+ }
377
+ /**
378
+ * Represents the result of a paginated query (list or find).
379
+ * @template T The type of the records in the page.
380
+ */
381
+ interface PagedQueryResult<T> {
382
+ /** The paginated data, or undefined if not found or still loading. */
383
+ page: Page<T> | undefined;
384
+ /** Indicates if the query is currently loading data. */
385
+ loading: boolean;
386
+ /** An error object if the query failed, otherwise undefined. */
387
+ error: StoreError | undefined;
388
+ /** Indicates if the cached data is stale and a refetch is needed. */
389
+ stale: boolean;
390
+ /** Timestamp of the last update to the data. */
391
+ updated: number;
392
+ /** True if there is a next page, false otherwise. */
393
+ hasNext: boolean;
394
+ /** True if there is a previous page, false otherwise. */
395
+ hasPrevious: boolean;
396
+ /** Function to fetch the next page of data. */
397
+ next: () => Promise<void>;
398
+ /** Function to fetch the previous page of data. */
399
+ previous: () => Promise<void>;
400
+ /** Function to fetch a specific page of data.
401
+ * @param page The page number to fetch.
402
+ */
403
+ navigate: (page: number) => Promise<void>;
404
+ refresh: (delay?: number) => Promise<void>;
405
+ changeParams: (setter: (params: any) => any) => Promise<void>;
406
+ }
407
+ /**
408
+ * Represents a basic record in the remote store.
409
+ * All records must have a unique `id` of type string.
410
+ * Other properties can be of any type.
411
+ */
412
+ type StoreRecord<BaseProps extends Record<string, unknown> = Record<string, unknown>> = BaseProps;
413
+ /**
414
+ * Provides pagination information for a collection of records.
415
+ */
416
+ type PaginationInfo = {
417
+ /** The current page number (1-based). */number: number; /** The number of items per page. */
418
+ size: number; /** The total count of items across all pages. */
419
+ count: number; /** The total number of available pages. */
420
+ pages: number;
421
+ };
422
+ /**
423
+ * Represents the name of a resource in the store, e.g., 'todos', 'users'.
424
+ */
425
+ type ResourceName = string;
426
+ /**
427
+ * Internal interface representing an active subscription to a query.
428
+ * @template T The type of the data being queried.
429
+ */
430
+ interface QuerySubscription<T> {
431
+ /** Callbacks to unsubscribe from cache events. */
432
+ unsubscribeCallbacks: (() => void)[];
433
+ /** Set of functions to notify when the query data changes. */
434
+ subscribers: Set<() => void>;
435
+ /** A cached function to subscribe to changes for this query. */
436
+ cachedSubscribe: (callback: () => void) => () => void;
437
+ /** A cached selector function to get the current query result. */
438
+ cachedSelector: () => QueryResult<T> | PagedQueryResult<T>;
439
+ /** The operation type of the query (e.g., 'read', 'list'). */
440
+ operation: string;
441
+ /** The parameters for the query. */
442
+ params: any;
443
+ /** A stable reference to the operations results. */
444
+ result: QueryResult<T> | PagedQueryResult<T>;
445
+ }
446
+ //#endregion
447
+ //#region src/remote-store/store.d.ts
448
+ /**
449
+ * Represents the result of a store query with stable React integration.
450
+ * @template T The type of the result data.
451
+ */
452
+ interface StoreResult<T extends Record<string, any> = Record<string, any>, V = QueryResult<T> | PagedQueryResult<T>> {
453
+ /** Function that returns the current query state */
454
+ value: () => V;
455
+ /** Function to subscribe to state changes */
456
+ onValueChange: (callback: () => void) => () => void;
457
+ }
458
+ /**
459
+ * A reactive remote store that provides cached and observable access to data
460
+ * from a `BaseStore`. It handles caching, invalidation, and real-time updates
461
+ * via server-sent events (SSE).
462
+ */
463
+ declare class ReactiveRemoteStore<T extends StoreRecord, TFindOptions = Record<string, unknown>, TReadOptions = Record<string, unknown>, TListOptions = Record<string, unknown>, TDeleteOptions = Record<string, unknown>, TUpdateOptions = Record<string, unknown>, TCreateOptions = Record<string, unknown>, TUploadOptions = Record<string, unknown>, TStreamOptions = Record<string, unknown>> {
464
+ private cache;
465
+ private baseStore;
466
+ private correlator?;
467
+ private storeEventCorrelator?;
468
+ private queryStates;
469
+ private stableResults;
470
+ private stablePaginationMethods;
471
+ private errorCache;
472
+ private keyCache;
473
+ private unsubscribeFromBaseStore;
474
+ private cacheEventCleanups;
475
+ constructor(cache: QueryCache, baseStore: BaseStore<T, TFindOptions, TReadOptions, TListOptions, TDeleteOptions, TUpdateOptions, TCreateOptions, TUploadOptions, TStreamOptions>, correlator?: Correlator | undefined, storeEventCorrelator?: StoreEventCorrelator | undefined);
476
+ private setupCacheEventListeners;
477
+ private handleCacheEvent;
478
+ private buildKey;
479
+ private getOrCreateError;
480
+ private getOrCreateStoreError;
481
+ private computeResult;
482
+ private scheduleBackgroundFetch;
483
+ private getCurrentPageForQuery;
484
+ private getOrCreatePaginationMethods;
485
+ private computeResultForParams;
486
+ hasActiveQuery(operation: string, params: any): boolean;
487
+ getActiveQuery<TResult extends Record<string, unknown> = T>(operation: string, params: any): StoreResult<TResult> | undefined;
488
+ read(params: TReadOptions): StoreResult<T, QueryResult<T>>;
489
+ list(params: TListOptions): StoreResult<T, PagedQueryResult<T>>;
490
+ find(params: TFindOptions): StoreResult<T, PagedQueryResult<T>>;
491
+ private setupPagedQuery;
492
+ private invalidateQueries;
493
+ private handleStoreEvent;
494
+ create(params: {
495
+ data: Partial<T>;
496
+ options?: TCreateOptions;
497
+ }): Promise<T | undefined>;
498
+ update(params: {
499
+ data: Partial<T>;
500
+ options?: TUpdateOptions;
501
+ }): Promise<T | undefined>;
502
+ delete(params: TDeleteOptions): Promise<void>;
503
+ notify(event: StoreEvent): Promise<void>;
504
+ stream(options: TStreamOptions, onStreamChange: () => void): {
505
+ stream: () => AsyncIterable<T>;
506
+ cancel: () => void;
507
+ status: () => "active" | "cancelled" | "completed";
508
+ };
509
+ subscribe(scope: string, callback: (event: StoreEvent) => void): Promise<() => void>;
510
+ upload(params: {
511
+ file: File;
512
+ options?: TUploadOptions;
513
+ }): Promise<T | undefined>;
514
+ refresh(operation: "read", params: TReadOptions): Promise<T | undefined>;
515
+ refresh(operation: "list", params: TListOptions): Promise<Page<T> | undefined>;
516
+ refresh(operation: "find", query: TFindOptions): Promise<Page<T> | undefined>;
517
+ prefetch(operation: "read", params: TReadOptions): void;
518
+ prefetch(operation: "list", params: TListOptions): void;
519
+ prefetch(operation: "find", params: TFindOptions): void;
520
+ invalidate(operation: string, params: any): Promise<void>;
521
+ invalidateAll(): Promise<void>;
522
+ getStats(): {
523
+ activeSubscriptions: number;
524
+ size: number;
525
+ metrics: CacheMetrics;
526
+ hitRate: number;
527
+ staleHitRate: number;
528
+ entries: Array<{
529
+ key: string;
530
+ lastAccessed: number;
531
+ lastUpdated: number;
532
+ accessCount: number;
533
+ isStale: boolean;
534
+ isLoading?: boolean;
535
+ error?: boolean;
536
+ }>;
537
+ };
538
+ destroy(): void;
539
+ }
540
+ //#endregion
541
+ //#region src/remote-store/hash.d.ts
542
+ /**
543
+ * Computes the FNV-1a 64-bit hash of the given data.
544
+ * @param {any} data - The data to hash. Can be any type that can be serialized.
545
+ * @returns {string} The FNV-1a 64-bit hash as a hexadecimal string.
546
+ */
547
+ declare function hash(data: any): string;
548
+ //#endregion
549
+ export { ActiveQuery, BaseStore, Correlator, MutationOperation, Page, PagedQueryResult, PaginationInfo, QueryResult, QuerySubscription, ReactiveRemoteStore, ResourceName, StoreError, StoreErrorDetails, StoreEvent, StoreEventCorrelator, StoreRecord, StoreResult, hash };