entropic-bond 1.53.4 → 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.
@@ -8,6 +8,5 @@ export declare class ServerAuthMock extends ServerAuthService {
8
8
  updateUser<T extends CustomCredentials>(userId: string, credentials: Partial<UserCredentials<T>>): Promise<UserCredentials<T>>;
9
9
  deleteUser(userId: string): Promise<void>;
10
10
  get userCredentials(): Collection<UserCredentials<{}>>;
11
- notifyUserChanges(): void;
12
11
  private _userCredentials;
13
12
  }
@@ -7,7 +7,6 @@ export declare abstract class ServerAuthService {
7
7
  abstract getUser<T extends CustomCredentials>(userId: string): Promise<UserCredentials<T> | undefined>;
8
8
  abstract updateUser<T extends CustomCredentials>(userId: string, credentials: Partial<UserCredentials<T>>): Promise<UserCredentials<T>>;
9
9
  abstract deleteUser(userId: string): Promise<void>;
10
- abstract notifyUserChanges(): void;
11
10
  }
12
11
  export declare class ServerAuth extends ServerAuthService {
13
12
  static error: {
@@ -20,7 +19,6 @@ export declare class ServerAuth extends ServerAuthService {
20
19
  updateUser<T extends CustomCredentials>(userId: string, credentials: Partial<UserCredentials<T>>): Promise<UserCredentials<T>>;
21
20
  setCustomCredentials<T extends CustomCredentials>(userId: string, customCredentials: T): Promise<void>;
22
21
  deleteUser(userId: string): Promise<void>;
23
- notifyUserChanges(): void;
24
22
  private static _instance;
25
23
  private static _authService;
26
24
  }
@@ -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 interface DocumentChange {
57
- before: Persistent | undefined;
58
- after: Persistent;
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, propsToUpdate: PropWithOwner[]): Promise<Promise<[Promise<void>[]]>[] | undefined>;
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 _listener;
73
+ private _documentListeners;
74
+ private _collectionListeners;
75
+ private _serverCollectionListeners;
71
76
  }
@@ -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
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "entropic-bond",
3
3
  "type": "module",
4
- "version": "1.53.4",
4
+ "version": "1.53.6",
5
5
  "description": "Tidy up your messy components",
6
6
  "main": "./lib/entropic-bond.umd.cjs",
7
7
  "module": "./lib/entropic-bond.js",