@asaidimu/utils-remote-store 1.2.8 → 1.3.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.
- package/README.md +921 -567
- package/index.d.mts +24 -24
- package/index.d.ts +24 -24
- package/package.json +2 -2
package/index.d.mts
CHANGED
|
@@ -85,51 +85,51 @@ type CacheEventBase<Type extends string, Payload = {}> = {
|
|
|
85
85
|
key: string;
|
|
86
86
|
timestamp: number;
|
|
87
87
|
} & Payload;
|
|
88
|
-
type CacheReadHitEvent<T = any> = CacheEventBase<
|
|
88
|
+
type CacheReadHitEvent<T = any> = CacheEventBase<"cache:read:hit", {
|
|
89
89
|
data: T;
|
|
90
90
|
isStale: boolean;
|
|
91
91
|
}>;
|
|
92
|
-
type CacheReadMissEvent = CacheEventBase<
|
|
93
|
-
type CacheFetchStartEvent = CacheEventBase<
|
|
92
|
+
type CacheReadMissEvent = CacheEventBase<"cache:read:miss">;
|
|
93
|
+
type CacheFetchStartEvent = CacheEventBase<"cache:fetch:start", {
|
|
94
94
|
attempt: number;
|
|
95
95
|
}>;
|
|
96
|
-
type CacheFetchSuccessEvent<T = any> = CacheEventBase<
|
|
96
|
+
type CacheFetchSuccessEvent<T = any> = CacheEventBase<"cache:fetch:success", {
|
|
97
97
|
data: T;
|
|
98
98
|
}>;
|
|
99
|
-
type CacheFetchErrorEvent = CacheEventBase<
|
|
99
|
+
type CacheFetchErrorEvent = CacheEventBase<"cache:fetch:error", {
|
|
100
100
|
error: Error;
|
|
101
101
|
attempt: number;
|
|
102
102
|
}>;
|
|
103
|
-
type CacheDataEvictEvent = CacheEventBase<
|
|
103
|
+
type CacheDataEvictEvent = CacheEventBase<"cache:data:evict", {
|
|
104
104
|
reason?: string;
|
|
105
105
|
}>;
|
|
106
|
-
type CacheDataInvalidateEvent = CacheEventBase<
|
|
107
|
-
type CacheDataSetEvent<T = any> = CacheEventBase<
|
|
106
|
+
type CacheDataInvalidateEvent = CacheEventBase<"cache:data:invalidate">;
|
|
107
|
+
type CacheDataSetEvent<T = any> = CacheEventBase<"cache:data:set", {
|
|
108
108
|
newData: T;
|
|
109
109
|
oldData?: T;
|
|
110
110
|
}>;
|
|
111
|
-
type CachePersistenceLoadSuccessEvent = CacheEventBase<
|
|
111
|
+
type CachePersistenceLoadSuccessEvent = CacheEventBase<"cache:persistence:load:success", {
|
|
112
112
|
message?: string;
|
|
113
113
|
}>;
|
|
114
|
-
type CachePersistenceLoadErrorEvent = CacheEventBase<
|
|
114
|
+
type CachePersistenceLoadErrorEvent = CacheEventBase<"cache:persistence:load:error", {
|
|
115
115
|
message?: string;
|
|
116
116
|
error?: any;
|
|
117
117
|
}>;
|
|
118
|
-
type CachePersistenceSaveSuccessEvent = CacheEventBase<
|
|
119
|
-
type CachePersistenceSaveErrorEvent = CacheEventBase<
|
|
118
|
+
type CachePersistenceSaveSuccessEvent = CacheEventBase<"cache:persistence:save:success">;
|
|
119
|
+
type CachePersistenceSaveErrorEvent = CacheEventBase<"cache:persistence:save:error", {
|
|
120
120
|
message?: string;
|
|
121
121
|
error?: any;
|
|
122
122
|
}>;
|
|
123
|
-
type CachePersistenceClearSuccessEvent = CacheEventBase<
|
|
124
|
-
type CachePersistenceClearErrorEvent = CacheEventBase<
|
|
123
|
+
type CachePersistenceClearSuccessEvent = CacheEventBase<"cache:persistence:clear:success">;
|
|
124
|
+
type CachePersistenceClearErrorEvent = CacheEventBase<"cache:persistence:clear:error", {
|
|
125
125
|
message?: string;
|
|
126
126
|
error?: any;
|
|
127
127
|
}>;
|
|
128
|
-
type CachePersistenceSyncEvent = CacheEventBase<
|
|
128
|
+
type CachePersistenceSyncEvent = CacheEventBase<"cache:persistence:sync", {
|
|
129
129
|
message?: string;
|
|
130
130
|
}>;
|
|
131
131
|
type CacheEvent = CacheReadHitEvent | CacheReadMissEvent | CacheFetchStartEvent | CacheFetchSuccessEvent | CacheFetchErrorEvent | CacheDataEvictEvent | CacheDataInvalidateEvent | CacheDataSetEvent | CachePersistenceLoadSuccessEvent | CachePersistenceLoadErrorEvent | CachePersistenceSaveSuccessEvent | CachePersistenceSaveErrorEvent | CachePersistenceClearSuccessEvent | CachePersistenceClearErrorEvent | CachePersistenceSyncEvent;
|
|
132
|
-
type CacheEventType = CacheEvent[
|
|
132
|
+
type CacheEventType = CacheEvent["type"];
|
|
133
133
|
|
|
134
134
|
declare class QueryCache {
|
|
135
135
|
private cache;
|
|
@@ -233,7 +233,7 @@ interface StoreEvent {
|
|
|
233
233
|
/**
|
|
234
234
|
* Defines the types of mutation operations that can occur.
|
|
235
235
|
*/
|
|
236
|
-
type MutationOperation =
|
|
236
|
+
type MutationOperation = "create" | "update" | "delete" | "upload";
|
|
237
237
|
/**
|
|
238
238
|
* A correlator function that determines which active queries should be invalidated
|
|
239
239
|
* based on a mutation operation.
|
|
@@ -342,7 +342,7 @@ interface BaseStore<T extends StoreRecord, TFindOptions = Record<string, unknown
|
|
|
342
342
|
/** A function to call to cancel the ongoing stream. */
|
|
343
343
|
cancel: () => void;
|
|
344
344
|
/** A getter function that returns the current status of the stream ('active', 'cancelled', or 'completed'). */
|
|
345
|
-
status: () =>
|
|
345
|
+
status: () => "active" | "cancelled" | "completed";
|
|
346
346
|
};
|
|
347
347
|
}
|
|
348
348
|
/**
|
|
@@ -512,12 +512,12 @@ declare class ReactiveRemoteStore<T extends StoreRecord, TFindOptions = Record<s
|
|
|
512
512
|
file: File;
|
|
513
513
|
options?: TUploadOptions;
|
|
514
514
|
}): Promise<T | undefined>;
|
|
515
|
-
refresh(operation:
|
|
516
|
-
refresh(operation:
|
|
517
|
-
refresh(operation:
|
|
518
|
-
prefetch(operation:
|
|
519
|
-
prefetch(operation:
|
|
520
|
-
prefetch(operation:
|
|
515
|
+
refresh(operation: "read", params: TReadOptions): Promise<T | undefined>;
|
|
516
|
+
refresh(operation: "list", params: TListOptions): Promise<Page<T> | undefined>;
|
|
517
|
+
refresh(operation: "find", query: TFindOptions): Promise<Page<T> | undefined>;
|
|
518
|
+
prefetch(operation: "read", params: TReadOptions): void;
|
|
519
|
+
prefetch(operation: "list", params: TListOptions): void;
|
|
520
|
+
prefetch(operation: "find", params: TFindOptions): void;
|
|
521
521
|
invalidate(operation: string, params: any): Promise<void>;
|
|
522
522
|
invalidateAll(): Promise<void>;
|
|
523
523
|
getStats(): {
|
package/index.d.ts
CHANGED
|
@@ -85,51 +85,51 @@ type CacheEventBase<Type extends string, Payload = {}> = {
|
|
|
85
85
|
key: string;
|
|
86
86
|
timestamp: number;
|
|
87
87
|
} & Payload;
|
|
88
|
-
type CacheReadHitEvent<T = any> = CacheEventBase<
|
|
88
|
+
type CacheReadHitEvent<T = any> = CacheEventBase<"cache:read:hit", {
|
|
89
89
|
data: T;
|
|
90
90
|
isStale: boolean;
|
|
91
91
|
}>;
|
|
92
|
-
type CacheReadMissEvent = CacheEventBase<
|
|
93
|
-
type CacheFetchStartEvent = CacheEventBase<
|
|
92
|
+
type CacheReadMissEvent = CacheEventBase<"cache:read:miss">;
|
|
93
|
+
type CacheFetchStartEvent = CacheEventBase<"cache:fetch:start", {
|
|
94
94
|
attempt: number;
|
|
95
95
|
}>;
|
|
96
|
-
type CacheFetchSuccessEvent<T = any> = CacheEventBase<
|
|
96
|
+
type CacheFetchSuccessEvent<T = any> = CacheEventBase<"cache:fetch:success", {
|
|
97
97
|
data: T;
|
|
98
98
|
}>;
|
|
99
|
-
type CacheFetchErrorEvent = CacheEventBase<
|
|
99
|
+
type CacheFetchErrorEvent = CacheEventBase<"cache:fetch:error", {
|
|
100
100
|
error: Error;
|
|
101
101
|
attempt: number;
|
|
102
102
|
}>;
|
|
103
|
-
type CacheDataEvictEvent = CacheEventBase<
|
|
103
|
+
type CacheDataEvictEvent = CacheEventBase<"cache:data:evict", {
|
|
104
104
|
reason?: string;
|
|
105
105
|
}>;
|
|
106
|
-
type CacheDataInvalidateEvent = CacheEventBase<
|
|
107
|
-
type CacheDataSetEvent<T = any> = CacheEventBase<
|
|
106
|
+
type CacheDataInvalidateEvent = CacheEventBase<"cache:data:invalidate">;
|
|
107
|
+
type CacheDataSetEvent<T = any> = CacheEventBase<"cache:data:set", {
|
|
108
108
|
newData: T;
|
|
109
109
|
oldData?: T;
|
|
110
110
|
}>;
|
|
111
|
-
type CachePersistenceLoadSuccessEvent = CacheEventBase<
|
|
111
|
+
type CachePersistenceLoadSuccessEvent = CacheEventBase<"cache:persistence:load:success", {
|
|
112
112
|
message?: string;
|
|
113
113
|
}>;
|
|
114
|
-
type CachePersistenceLoadErrorEvent = CacheEventBase<
|
|
114
|
+
type CachePersistenceLoadErrorEvent = CacheEventBase<"cache:persistence:load:error", {
|
|
115
115
|
message?: string;
|
|
116
116
|
error?: any;
|
|
117
117
|
}>;
|
|
118
|
-
type CachePersistenceSaveSuccessEvent = CacheEventBase<
|
|
119
|
-
type CachePersistenceSaveErrorEvent = CacheEventBase<
|
|
118
|
+
type CachePersistenceSaveSuccessEvent = CacheEventBase<"cache:persistence:save:success">;
|
|
119
|
+
type CachePersistenceSaveErrorEvent = CacheEventBase<"cache:persistence:save:error", {
|
|
120
120
|
message?: string;
|
|
121
121
|
error?: any;
|
|
122
122
|
}>;
|
|
123
|
-
type CachePersistenceClearSuccessEvent = CacheEventBase<
|
|
124
|
-
type CachePersistenceClearErrorEvent = CacheEventBase<
|
|
123
|
+
type CachePersistenceClearSuccessEvent = CacheEventBase<"cache:persistence:clear:success">;
|
|
124
|
+
type CachePersistenceClearErrorEvent = CacheEventBase<"cache:persistence:clear:error", {
|
|
125
125
|
message?: string;
|
|
126
126
|
error?: any;
|
|
127
127
|
}>;
|
|
128
|
-
type CachePersistenceSyncEvent = CacheEventBase<
|
|
128
|
+
type CachePersistenceSyncEvent = CacheEventBase<"cache:persistence:sync", {
|
|
129
129
|
message?: string;
|
|
130
130
|
}>;
|
|
131
131
|
type CacheEvent = CacheReadHitEvent | CacheReadMissEvent | CacheFetchStartEvent | CacheFetchSuccessEvent | CacheFetchErrorEvent | CacheDataEvictEvent | CacheDataInvalidateEvent | CacheDataSetEvent | CachePersistenceLoadSuccessEvent | CachePersistenceLoadErrorEvent | CachePersistenceSaveSuccessEvent | CachePersistenceSaveErrorEvent | CachePersistenceClearSuccessEvent | CachePersistenceClearErrorEvent | CachePersistenceSyncEvent;
|
|
132
|
-
type CacheEventType = CacheEvent[
|
|
132
|
+
type CacheEventType = CacheEvent["type"];
|
|
133
133
|
|
|
134
134
|
declare class QueryCache {
|
|
135
135
|
private cache;
|
|
@@ -233,7 +233,7 @@ interface StoreEvent {
|
|
|
233
233
|
/**
|
|
234
234
|
* Defines the types of mutation operations that can occur.
|
|
235
235
|
*/
|
|
236
|
-
type MutationOperation =
|
|
236
|
+
type MutationOperation = "create" | "update" | "delete" | "upload";
|
|
237
237
|
/**
|
|
238
238
|
* A correlator function that determines which active queries should be invalidated
|
|
239
239
|
* based on a mutation operation.
|
|
@@ -342,7 +342,7 @@ interface BaseStore<T extends StoreRecord, TFindOptions = Record<string, unknown
|
|
|
342
342
|
/** A function to call to cancel the ongoing stream. */
|
|
343
343
|
cancel: () => void;
|
|
344
344
|
/** A getter function that returns the current status of the stream ('active', 'cancelled', or 'completed'). */
|
|
345
|
-
status: () =>
|
|
345
|
+
status: () => "active" | "cancelled" | "completed";
|
|
346
346
|
};
|
|
347
347
|
}
|
|
348
348
|
/**
|
|
@@ -512,12 +512,12 @@ declare class ReactiveRemoteStore<T extends StoreRecord, TFindOptions = Record<s
|
|
|
512
512
|
file: File;
|
|
513
513
|
options?: TUploadOptions;
|
|
514
514
|
}): Promise<T | undefined>;
|
|
515
|
-
refresh(operation:
|
|
516
|
-
refresh(operation:
|
|
517
|
-
refresh(operation:
|
|
518
|
-
prefetch(operation:
|
|
519
|
-
prefetch(operation:
|
|
520
|
-
prefetch(operation:
|
|
515
|
+
refresh(operation: "read", params: TReadOptions): Promise<T | undefined>;
|
|
516
|
+
refresh(operation: "list", params: TListOptions): Promise<Page<T> | undefined>;
|
|
517
|
+
refresh(operation: "find", query: TFindOptions): Promise<Page<T> | undefined>;
|
|
518
|
+
prefetch(operation: "read", params: TReadOptions): void;
|
|
519
|
+
prefetch(operation: "list", params: TListOptions): void;
|
|
520
|
+
prefetch(operation: "find", params: TFindOptions): void;
|
|
521
521
|
invalidate(operation: string, params: any): Promise<void>;
|
|
522
522
|
invalidateAll(): Promise<void>;
|
|
523
523
|
getStats(): {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@asaidimu/utils-remote-store",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "A reactive store for remote data, built on top of @asaidimu/utils-cache",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.mjs",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"./*"
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@asaidimu/utils-cache": "3.0.
|
|
12
|
+
"@asaidimu/utils-cache": "3.0.6",
|
|
13
13
|
"eventsource": "^4.0.0"
|
|
14
14
|
},
|
|
15
15
|
"exports": {
|