entropic-bond 1.53.5 → 1.53.6
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/lib/entropic-bond.js +78 -56
- package/lib/entropic-bond.js.map +1 -1
- package/lib/entropic-bond.umd.cjs +2 -2
- package/lib/entropic-bond.umd.cjs.map +1 -1
- package/lib/store/data-source.d.ts +12 -7
- package/lib/store/json-data-source.d.ts +7 -2
- package/lib/store/model.d.ts +5 -1
- package/package.json +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Persistent, PersistentObject, Collections, PersistentProperty } from '../persistent/persistent';
|
|
2
2
|
import { ClassPropNames } from '../types/utility-types';
|
|
3
|
+
import { Unsubscriber } from '../observable/observable';
|
|
3
4
|
export type DocumentObject = PersistentObject<Persistent>;
|
|
4
5
|
/**
|
|
5
6
|
* The query operators
|
|
@@ -53,14 +54,16 @@ export type QueryObject<T> = {
|
|
|
53
54
|
};
|
|
54
55
|
};
|
|
55
56
|
export type DocumentListenerUninstaller = () => void;
|
|
56
|
-
export
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
export type DocumentChangeType = 'create' | 'update' | 'delete';
|
|
58
|
+
export interface DocumentChange<T extends Persistent> {
|
|
59
|
+
before: T | undefined;
|
|
60
|
+
after: T;
|
|
59
61
|
params: {
|
|
60
62
|
[key: string]: any;
|
|
61
63
|
};
|
|
64
|
+
type: DocumentChangeType;
|
|
62
65
|
}
|
|
63
|
-
export type DocumentChangeListerner = (change: DocumentChange) => void;
|
|
66
|
+
export type DocumentChangeListerner<T extends Persistent> = (change: DocumentChange<T>) => void;
|
|
64
67
|
export interface DocumentChangeListernerHandler {
|
|
65
68
|
uninstall: DocumentListenerUninstaller;
|
|
66
69
|
nativeHandler: unknown;
|
|
@@ -70,7 +73,7 @@ type CachedPropsUpdateCallback = (doc: Persistent, prop: PersistentProperty) =>
|
|
|
70
73
|
export interface CachedPropsUpdaterConfig {
|
|
71
74
|
onUpdate?: CachedPropsUpdateCallback;
|
|
72
75
|
noThrowOnNonImplementedListener?: boolean;
|
|
73
|
-
documentChangeListerner?: (prop: PersistentProperty, listener: DocumentChangeListerner) => DocumentChangeListernerHandler | undefined;
|
|
76
|
+
documentChangeListerner?: (prop: PersistentProperty, listener: DocumentChangeListerner<Persistent>) => DocumentChangeListernerHandler | undefined;
|
|
74
77
|
}
|
|
75
78
|
interface PropWithOwner {
|
|
76
79
|
prop: PersistentProperty;
|
|
@@ -95,7 +98,7 @@ export declare abstract class DataSource {
|
|
|
95
98
|
* @returns a function that uninstalls the listener. If the returned value is undefined
|
|
96
99
|
* the method documentChangeListerner has not been implemented in the concrete data source
|
|
97
100
|
*/
|
|
98
|
-
protected subscribeToDocumentChangeListerner(collectionPathToListen: string, listener: DocumentChangeListerner): DocumentChangeListernerHandler | undefined;
|
|
101
|
+
protected subscribeToDocumentChangeListerner(collectionPathToListen: string, listener: DocumentChangeListerner<Persistent>): DocumentChangeListernerHandler | undefined;
|
|
99
102
|
/**
|
|
100
103
|
* Retrieves a document by id
|
|
101
104
|
* Implement the required logic to retrieve a document by id from your concrete
|
|
@@ -155,6 +158,8 @@ export declare abstract class DataSource {
|
|
|
155
158
|
* @see QueryObject
|
|
156
159
|
*/
|
|
157
160
|
abstract count(queryObject: QueryObject<DocumentObject>, collectionName: string): Promise<number>;
|
|
161
|
+
abstract onCollectionChange<T extends Persistent>(query: QueryObject<T>, collectionName: string, listener: DocumentChangeListerner<T>): Unsubscriber;
|
|
162
|
+
abstract onDocumentChange<T extends Persistent>(documentPath: string, documentId: string, listener: DocumentChangeListerner<T>): Unsubscriber;
|
|
158
163
|
/**
|
|
159
164
|
* Utility method to convert a query object to a property path query object
|
|
160
165
|
*
|
|
@@ -170,7 +175,7 @@ export declare abstract class DataSource {
|
|
|
170
175
|
static toPropertyPathOperations<T extends Persistent>(operations: QueryOperation<T>[]): QueryOperation<T>[];
|
|
171
176
|
static isArrayOperator(operator: QueryOperator): boolean;
|
|
172
177
|
private static toPropertyPathValue;
|
|
173
|
-
static onDocumentChange(event: DocumentChange
|
|
178
|
+
static onDocumentChange(event: DocumentChange<Persistent>, propsToUpdate: PropWithOwner[]): Promise<Promise<[Promise<void>[]]>[] | undefined>;
|
|
174
179
|
private static onUpdate;
|
|
175
180
|
}
|
|
176
181
|
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Unsubscriber } from '../observable/observable';
|
|
1
2
|
import { Collections, Persistent, PersistentObject } from '../persistent/persistent';
|
|
2
3
|
import { DataSource, DocumentChangeListerner, DocumentChangeListernerHandler, DocumentObject, QueryObject } from './data-source';
|
|
3
4
|
export interface JsonRawData {
|
|
@@ -40,6 +41,8 @@ export declare class JsonDataSource extends DataSource {
|
|
|
40
41
|
delete(id: string, collectionName: string): Promise<void>;
|
|
41
42
|
next(limit?: number): Promise<DocumentObject[]>;
|
|
42
43
|
count(queryObject: QueryObject<DocumentObject>, collectionName: string): Promise<number>;
|
|
44
|
+
onCollectionChange<T extends Persistent>(query: QueryObject<T>, collectionName: string, listener: DocumentChangeListerner<T>): Unsubscriber;
|
|
45
|
+
onDocumentChange<T extends Persistent>(collectionName: string, documentId: string, listener: DocumentChangeListerner<T>): Unsubscriber;
|
|
43
46
|
/**
|
|
44
47
|
* @returns the raw data store data as a JSON object
|
|
45
48
|
*/
|
|
@@ -51,7 +54,7 @@ export declare class JsonDataSource extends DataSource {
|
|
|
51
54
|
wait(): Promise<any[]>;
|
|
52
55
|
private incCursor;
|
|
53
56
|
simulateError(error: string | ErrorOnOperation | undefined): this;
|
|
54
|
-
protected subscribeToDocumentChangeListerner(collectionNameToListen: string, listener: DocumentChangeListerner): DocumentChangeListernerHandler | undefined;
|
|
57
|
+
protected subscribeToDocumentChangeListerner(collectionNameToListen: string, listener: DocumentChangeListerner<Persistent>): DocumentChangeListernerHandler | undefined;
|
|
55
58
|
private notifyChange;
|
|
56
59
|
private decCursor;
|
|
57
60
|
private queryProcessor;
|
|
@@ -67,5 +70,7 @@ export declare class JsonDataSource extends DataSource {
|
|
|
67
70
|
private _simulateDelay;
|
|
68
71
|
private _pendingPromises;
|
|
69
72
|
private _simulateError;
|
|
70
|
-
private
|
|
73
|
+
private _documentListeners;
|
|
74
|
+
private _collectionListeners;
|
|
75
|
+
private _serverCollectionListeners;
|
|
71
76
|
}
|
package/lib/store/model.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { Unsubscriber } from '../observable/observable';
|
|
1
2
|
import { Persistent } from '../persistent/persistent';
|
|
2
3
|
import { ClassPropNames, PropPath, PropPathType } from '../types/utility-types';
|
|
3
|
-
import { DataSource, QueryOperator, QueryObject, QueryOrder } from './data-source';
|
|
4
|
+
import { DataSource, QueryOperator, QueryObject, QueryOrder, DocumentChangeListerner } from './data-source';
|
|
4
5
|
/**
|
|
5
6
|
* Provides abstraction to the database access. You should gain access to a Model
|
|
6
7
|
* object through the Store.getModel method instead of its constructor.
|
|
@@ -60,6 +61,8 @@ export declare class Model<T extends Persistent> {
|
|
|
60
61
|
* @returns a promise resolving to a collection of matched documents
|
|
61
62
|
*/
|
|
62
63
|
next<U extends T>(limit?: number): Promise<U[]>;
|
|
64
|
+
onDocumentChange(collectionPathToListen: string, documentId: string, listener: DocumentChangeListerner<T>): Unsubscriber;
|
|
65
|
+
onCollectionChange(query: Query<T>, listener: DocumentChangeListerner<T>): Unsubscriber;
|
|
63
66
|
private mapToInstance;
|
|
64
67
|
/**
|
|
65
68
|
* Normalizes the query object to match the data source requirements.
|
|
@@ -233,6 +236,7 @@ export declare class Query<T extends Persistent> {
|
|
|
233
236
|
* const count = await query.where( 'name', '==', 'John' ).count()
|
|
234
237
|
*/
|
|
235
238
|
count(): Promise<number>;
|
|
239
|
+
getQueryObject(): QueryObject<T>;
|
|
236
240
|
private queryObject;
|
|
237
241
|
private model;
|
|
238
242
|
}
|