@livequery/client 2.0.20 → 2.0.23
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/build/Collection.d.ts +4 -0
- package/build/Collection.js +7 -12
- package/package.json +2 -2
package/build/Collection.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export type SmartQueryItem<T> = T & {
|
|
|
15
15
|
__adding: boolean;
|
|
16
16
|
__trigger: <R extends {}>(name: string, payload?: any, query?: any) => Promise<Response<R>>;
|
|
17
17
|
__ref: string;
|
|
18
|
+
toJson: () => T;
|
|
18
19
|
};
|
|
19
20
|
export type CollectionStream<T extends LivequeryBaseEntity = LivequeryBaseEntity> = {
|
|
20
21
|
items: SmartQueryItem<T>[];
|
|
@@ -24,6 +25,9 @@ export type CollectionStream<T extends LivequeryBaseEntity = LivequeryBaseEntity
|
|
|
24
25
|
error?: boolean;
|
|
25
26
|
code?: string;
|
|
26
27
|
message?: string;
|
|
28
|
+
summary?: {
|
|
29
|
+
[key: string]: any;
|
|
30
|
+
};
|
|
27
31
|
};
|
|
28
32
|
export declare class CollectionObservable<T extends LivequeryBaseEntity = LivequeryBaseEntity> extends BehaviorSubject<CollectionStream<T>> {
|
|
29
33
|
#private;
|
package/build/Collection.js
CHANGED
|
@@ -9,12 +9,6 @@ export class CollectionObservable extends BehaviorSubject {
|
|
|
9
9
|
#sorters = new Array;
|
|
10
10
|
#IdMap = new Map();
|
|
11
11
|
#refs = [];
|
|
12
|
-
// $: BehaviorSubject<CollectionStream<T>> = new BehaviorSubject<CollectionStream<T>>({
|
|
13
|
-
// items: [] as SmartQueryItem<T>[],
|
|
14
|
-
// loading: false,
|
|
15
|
-
// options: {},
|
|
16
|
-
// paging: {}
|
|
17
|
-
// })
|
|
18
12
|
unsubscribe() {
|
|
19
13
|
super.unsubscribe();
|
|
20
14
|
this.#queries.forEach(s => s.unsubscribe());
|
|
@@ -52,7 +46,7 @@ export class CollectionObservable extends BehaviorSubject {
|
|
|
52
46
|
const state = this.getValue();
|
|
53
47
|
const realtime = this.collection_options.realtime ?? true;
|
|
54
48
|
const actions = { update: false, reindex: false };
|
|
55
|
-
for (const { data, error, code, message } of stream) {
|
|
49
|
+
for (const { data, error, code, message, } of stream) {
|
|
56
50
|
if (!from_local) {
|
|
57
51
|
state.loading = false;
|
|
58
52
|
actions.update = true;
|
|
@@ -64,6 +58,10 @@ export class CollectionObservable extends BehaviorSubject {
|
|
|
64
58
|
state.message = message;
|
|
65
59
|
actions.update = true;
|
|
66
60
|
}
|
|
61
|
+
if (data?.summary) {
|
|
62
|
+
state.summary = data.summary;
|
|
63
|
+
actions.update = true;
|
|
64
|
+
}
|
|
67
65
|
// Sync
|
|
68
66
|
for (const change of data?.changes || []) {
|
|
69
67
|
if (!change?.data?.id)
|
|
@@ -116,7 +114,8 @@ export class CollectionObservable extends BehaviorSubject {
|
|
|
116
114
|
__remove: () => this.remove(payload?.id),
|
|
117
115
|
__trigger: (name, input = undefined, query) => this.trigger(name, input, payload?.id, query),
|
|
118
116
|
__update: (input) => this.update({ ...input, id: payload?.id }),
|
|
119
|
-
__ref: change.ref
|
|
117
|
+
__ref: change.ref,
|
|
118
|
+
toJson: () => payload
|
|
120
119
|
};
|
|
121
120
|
direction == 'forward' ? state.items.push(item) : state.items.unshift(item);
|
|
122
121
|
actions.reindex = true;
|
|
@@ -278,10 +277,6 @@ export class CollectionObservable extends BehaviorSubject {
|
|
|
278
277
|
const { options } = this.getValue();
|
|
279
278
|
this.fetch_data(options, 'backward');
|
|
280
279
|
}
|
|
281
|
-
// public fetch_around_cursor(cursor: string) {
|
|
282
|
-
// const state = this.$.getValue()
|
|
283
|
-
// this.fetch_data(state.options, 'both')
|
|
284
|
-
// }
|
|
285
280
|
filter(filters) {
|
|
286
281
|
this.fetch_data(filters, 'forward', true);
|
|
287
282
|
}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"repository": {
|
|
5
5
|
"url": "https://github.com/livequery/client"
|
|
6
6
|
},
|
|
7
|
-
"version": "2.0.
|
|
7
|
+
"version": "2.0.23",
|
|
8
8
|
"description": "",
|
|
9
9
|
"main": "build/index.js",
|
|
10
10
|
"types": "build/index.d.ts",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"typescript": "^5.6.3",
|
|
19
19
|
"rxjs": "^7.8.1",
|
|
20
|
-
"@livequery/types": "^2.0.
|
|
20
|
+
"@livequery/types": "^2.0.22"
|
|
21
21
|
},
|
|
22
22
|
"scripts": {
|
|
23
23
|
"test": "echo \"Error: no test specified\" && exit 1",
|