@dereekb/dbx-firebase 9.2.0 → 9.3.2

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.
@@ -43,6 +43,10 @@ export declare class DbxFirebaseCollectionChangeTriggerInstance<S extends DbxFir
43
43
  /**
44
44
  * Creates a new DbxFirebaseCollectionChangeWatcher, set the modes to "auto", and creates a new DbxFirebaseCollectionChangeTriggerInstance.
45
45
  *
46
+ * If no trigger function is provided it will default to resetting the store.
47
+ *
48
+ * NOTE: Don't forget to initialize the DbxFirebaseCollectionChangeTriggerInstance and handle other lifecycle changes.
49
+ *
46
50
  * @param store
47
51
  * @param triggerFunction
48
52
  * @returns
@@ -1,11 +1,11 @@
1
- import { DocumentDataWithId, FirestoreItemPageIterationInstance, FirestoreQueryConstraint, IterationQueryDocChangeWatcher } from '@dereekb/firebase';
1
+ import { DocumentDataWithIdAndKey, FirestoreItemPageIterationInstance, FirestoreQueryConstraint, IterationQueryDocChangeWatcher } from '@dereekb/firebase';
2
2
  import { PageListLoadingState } from '@dereekb/rxjs';
3
3
  import { Maybe, ArrayOrValue } from '@dereekb/util';
4
4
  import { Observable } from 'rxjs';
5
5
  export interface DbxFirebaseCollectionLoaderAccessor<T = unknown> {
6
6
  readonly constraints$: Observable<Maybe<ArrayOrValue<FirestoreQueryConstraint>>>;
7
7
  readonly firestoreIteration$: Observable<FirestoreItemPageIterationInstance<T>>;
8
- readonly pageLoadingState$: Observable<PageListLoadingState<DocumentDataWithId<T>>>;
8
+ readonly pageLoadingState$: Observable<PageListLoadingState<DocumentDataWithIdAndKey<T>>>;
9
9
  readonly queryChangeWatcher$: Observable<IterationQueryDocChangeWatcher<T>>;
10
10
  /**
11
11
  * Restarts the loader and refreshes items from the beginning.
@@ -1,6 +1,6 @@
1
1
  import { PageListLoadingState } from '@dereekb/rxjs';
2
2
  import { BehaviorSubject, Subject, Observable } from 'rxjs';
3
- import { DocumentDataWithId, FirebaseQueryItemAccumulator, FirestoreCollectionLike, FirestoreDocument, FirestoreItemPageIterationInstance, FirestoreItemPageIteratorFilter, FirestoreQueryConstraint, IterationQueryDocChangeWatcher } from '@dereekb/firebase';
3
+ import { DocumentDataWithIdAndKey, DocumentReference, FirebaseQueryItemAccumulator, FirebaseQuerySnapshotAccumulator, FirestoreCollectionLike, FirestoreDocument, FirestoreItemPageIterationInstance, FirestoreItemPageIteratorFilter, FirestoreQueryConstraint, IterationQueryDocChangeWatcher } from '@dereekb/firebase';
4
4
  import { ArrayOrValue, Destroyable, Initialized, Maybe } from '@dereekb/util';
5
5
  import { DbxFirebaseCollectionLoader, DbxFirebaseCollectionLoaderAccessor } from './collection.loader';
6
6
  export interface DbxFirebaseCollectionLoaderInstanceInitConfig<T, D extends FirestoreDocument<T> = FirestoreDocument<T>> {
@@ -26,8 +26,16 @@ export declare class DbxFirebaseCollectionLoaderInstance<T = unknown, D extends
26
26
  readonly iteratorFilter$: Observable<FirestoreItemPageIteratorFilter>;
27
27
  readonly firestoreIteration$: Observable<FirestoreItemPageIterationInstance<T>>;
28
28
  readonly queryChangeWatcher$: Observable<IterationQueryDocChangeWatcher<T>>;
29
+ readonly snapshotAccumulator$: Observable<FirebaseQuerySnapshotAccumulator<T>>;
30
+ readonly snapshotAccumulatorDocumentRefs$: Observable<DocumentReference<T>[][]>;
31
+ readonly snapshotAccumulatorDocuments$: Observable<D[][]>;
29
32
  readonly accumulator$: Observable<FirebaseQueryItemAccumulator<T>>;
30
- readonly pageLoadingState$: Observable<PageListLoadingState<DocumentDataWithId<T>>>;
33
+ readonly accumulatorItems$: Observable<DocumentDataWithIdAndKey<T>[][]>;
34
+ readonly hasDocuments$: Observable<boolean>;
35
+ readonly allDocumentRefs$: Observable<DocumentReference<T>[]>;
36
+ readonly allDocuments$: Observable<D[]>;
37
+ readonly allDocumentData$: Observable<DocumentDataWithIdAndKey<T>[]>;
38
+ readonly pageLoadingState$: Observable<PageListLoadingState<DocumentDataWithIdAndKey<T>>>;
31
39
  constructor(_initConfig?: DbxFirebaseCollectionLoaderInstanceInitConfig<T, D> | undefined);
32
40
  init(): void;
33
41
  destroy(): void;
@@ -1,4 +1,4 @@
1
- import { DocumentDataWithId, FirestoreModelKey, DocumentReference, FirestoreDocument, FirestoreModelId, DocumentSnapshot } from '@dereekb/firebase';
1
+ import { DocumentDataWithIdAndKey, FirestoreModelKey, DocumentReference, FirestoreDocument, FirestoreModelId, DocumentSnapshot } from '@dereekb/firebase';
2
2
  import { ObservableOrValue, PageListLoadingState } from '@dereekb/rxjs';
3
3
  import { Maybe, ArrayOrValue } from '@dereekb/util';
4
4
  import { Observable } from 'rxjs';
@@ -29,7 +29,7 @@ export interface DbxLimitedFirebaseDocumentLoader<T = unknown, D extends Firesto
29
29
  /**
30
30
  * Data from the documents.
31
31
  */
32
- readonly data$: Observable<DocumentDataWithId<T>[]>;
32
+ readonly data$: Observable<DocumentDataWithIdAndKey<T>[]>;
33
33
  /**
34
34
  * Snapshot stream of the documents
35
35
  */
@@ -37,15 +37,15 @@ export interface DbxLimitedFirebaseDocumentLoader<T = unknown, D extends Firesto
37
37
  /**
38
38
  * Data stream of the documents.
39
39
  */
40
- readonly dataStream$: Observable<DocumentDataWithId<T>[]>;
40
+ readonly dataStream$: Observable<DocumentDataWithIdAndKey<T>[]>;
41
41
  /**
42
42
  * Loading state for the document data.
43
43
  */
44
- readonly pageLoadingState$: Observable<PageListLoadingState<DocumentDataWithId<T>>>;
44
+ readonly pageLoadingState$: Observable<PageListLoadingState<DocumentDataWithIdAndKey<T>>>;
45
45
  /**
46
46
  * Loading state for the streamed document data.
47
47
  */
48
- readonly pageLoadingStateStream$: Observable<PageListLoadingState<DocumentDataWithId<T>>>;
48
+ readonly pageLoadingStateStream$: Observable<PageListLoadingState<DocumentDataWithIdAndKey<T>>>;
49
49
  /**
50
50
  * Sets the keys of the models to load.
51
51
  *
@@ -1,6 +1,6 @@
1
1
  import { ObservableOrValue, PageListLoadingState, SubscriptionObject } from '@dereekb/rxjs';
2
2
  import { BehaviorSubject, Subject, Observable } from 'rxjs';
3
- import { DocumentDataWithId, DocumentReference, DocumentSnapshot, FirestoreDocument, FirestoreDocumentAccessor, FirestoreModelKey, LimitedFirestoreDocumentAccessor } from '@dereekb/firebase';
3
+ import { DocumentDataWithIdAndKey, DocumentReference, DocumentSnapshot, FirestoreDocument, FirestoreDocumentAccessor, FirestoreModelKey, LimitedFirestoreDocumentAccessor } from '@dereekb/firebase';
4
4
  import { ArrayOrValue, Destroyable, Maybe } from '@dereekb/util';
5
5
  import { DbxFirebaseDocumentLoader, DbxLimitedFirebaseDocumentLoader } from './document.loader';
6
6
  export interface DbxFirebaseDocumentLoaderInstanceInitConfig<T, D extends FirestoreDocument<T> = FirestoreDocument<T>, A extends LimitedFirestoreDocumentAccessor<T, D> = LimitedFirestoreDocumentAccessor<T, D>> {
@@ -20,7 +20,7 @@ export declare class DbxLimitedFirebaseDocumentLoaderInstance<T = unknown, D ext
20
20
  readonly ids$: Observable<string[]>;
21
21
  readonly refs$: Observable<DocumentReference<unknown>[]>;
22
22
  readonly snapshots$: Observable<DocumentSnapshot<T>[]>;
23
- readonly data$: Observable<DocumentDataWithId<T>[]>;
23
+ readonly data$: Observable<DocumentDataWithIdAndKey<T>[]>;
24
24
  /**
25
25
  * Snapshot stream of the documents
26
26
  */
@@ -28,9 +28,9 @@ export declare class DbxLimitedFirebaseDocumentLoaderInstance<T = unknown, D ext
28
28
  /**
29
29
  * Data streamd of the documents.
30
30
  */
31
- readonly dataStream$: Observable<DocumentDataWithId<T>[]>;
32
- readonly pageLoadingState$: Observable<PageListLoadingState<DocumentDataWithId<T>>>;
33
- readonly pageLoadingStateStream$: Observable<PageListLoadingState<DocumentDataWithId<T>>>;
31
+ readonly dataStream$: Observable<DocumentDataWithIdAndKey<T>[]>;
32
+ readonly pageLoadingState$: Observable<PageListLoadingState<DocumentDataWithIdAndKey<T>>>;
33
+ readonly pageLoadingStateStream$: Observable<PageListLoadingState<DocumentDataWithIdAndKey<T>>>;
34
34
  constructor(_initConfig: DbxFirebaseDocumentLoaderInstanceInitConfig<T, D, A>);
35
35
  destroy(): void;
36
36
  restart(): void;
@@ -1,5 +1,5 @@
1
1
  import { Observable, Subscription } from 'rxjs';
2
- import { FirebaseQueryItemAccumulator, FirestoreCollectionLike, FirestoreDocument, FirestoreItemPageIterationInstance, FirestoreQueryConstraint, IterationQueryDocChangeWatcher, DocumentDataWithId } from '@dereekb/firebase';
2
+ import { FirebaseQueryItemAccumulator, FirestoreCollectionLike, FirestoreDocument, FirestoreItemPageIterationInstance, FirestoreQueryConstraint, IterationQueryDocChangeWatcher, DocumentDataWithIdAndKey, DocumentReference } from '@dereekb/firebase';
3
3
  import { ObservableOrValue, PageListLoadingState } from '@dereekb/rxjs';
4
4
  import { ArrayOrValue, Maybe } from '@dereekb/util';
5
5
  import { LockSetComponentStore } from '@dereekb/dbx-core';
@@ -12,7 +12,11 @@ export interface DbxFirebaseCollectionStore<T, D extends FirestoreDocument<T> =
12
12
  readonly firestoreIteration$: Observable<FirestoreItemPageIterationInstance<T>>;
13
13
  readonly queryChangeWatcher$: Observable<IterationQueryDocChangeWatcher<T>>;
14
14
  readonly accumulator$: Observable<FirebaseQueryItemAccumulator<T>>;
15
- readonly pageLoadingState$: Observable<PageListLoadingState<DocumentDataWithId<T>>>;
15
+ readonly pageLoadingState$: Observable<PageListLoadingState<DocumentDataWithIdAndKey<T>>>;
16
+ readonly hasDocuments$: Observable<boolean>;
17
+ readonly allDocumentRefs$: Observable<DocumentReference<T>[]>;
18
+ readonly allDocuments$: Observable<D[]>;
19
+ readonly allDocumentData$: Observable<DocumentDataWithIdAndKey<T>[]>;
16
20
  setMaxPages(observableOrValue: ObservableOrValue<Maybe<number>>): Subscription;
17
21
  setItemsPerPage(observableOrValue: ObservableOrValue<Maybe<number>>): Subscription;
18
22
  setConstraints(observableOrValue: ObservableOrValue<Maybe<ArrayOrValue<FirestoreQueryConstraint>>>): Subscription;
@@ -42,7 +46,11 @@ export declare class AbstractDbxFirebaseCollectionStore<T, D extends FirestoreDo
42
46
  readonly firestoreIteration$: Observable<FirestoreItemPageIterationInstance<T>>;
43
47
  readonly queryChangeWatcher$: Observable<IterationQueryDocChangeWatcher<T>>;
44
48
  readonly accumulator$: Observable<FirebaseQueryItemAccumulator<T>>;
45
- readonly pageLoadingState$: Observable<PageListLoadingState<DocumentDataWithId<T>>>;
49
+ readonly pageLoadingState$: Observable<PageListLoadingState<DocumentDataWithIdAndKey<T>>>;
50
+ readonly hasDocuments$: Observable<boolean>;
51
+ readonly allDocumentRefs$: Observable<DocumentReference<T>[]>;
52
+ readonly allDocuments$: Observable<D[]>;
53
+ readonly allDocumentData$: Observable<DocumentDataWithIdAndKey<T>[]>;
46
54
  readonly setFirestoreCollection: (() => void) | ((observableOrValue: FirestoreCollectionLike<T, D, import("@dereekb/firebase").LimitedFirestoreDocumentAccessor<T, D>> | Observable<FirestoreCollectionLike<T, D, import("@dereekb/firebase").LimitedFirestoreDocumentAccessor<T, D>> | null | undefined> | null | undefined) => Subscription);
47
55
  static ɵfac: i0.ɵɵFactoryDeclaration<AbstractDbxFirebaseCollectionStore<any, any, any>, never>;
48
56
  static ɵprov: i0.ɵɵInjectableDeclaration<AbstractDbxFirebaseCollectionStore<any, any, any>>;
@@ -9,7 +9,7 @@ import * as i0 from "@angular/core";
9
9
  export declare abstract class DbxFirebaseCollectionStoreDirective<T = unknown, D extends FirestoreDocument<T> = FirestoreDocument<T>, S extends DbxFirebaseCollectionStore<T, D> = DbxFirebaseCollectionStore<T, D>> {
10
10
  readonly store: S;
11
11
  constructor(store: S);
12
- readonly pageLoadingState$: import("rxjs").Observable<import("../../../../../../dist/packages/rxjs/src").PageListLoadingState<import("@dereekb/firebase").DocumentDataWithId<T>>>;
12
+ readonly pageLoadingState$: import("rxjs").Observable<import("../../../../../../dist/packages/rxjs/src").PageListLoadingState<import("@dereekb/firebase").DocumentDataWithIdAndKey<T>>>;
13
13
  set maxPages(maxPages: Maybe<number>);
14
14
  set itemsPerPage(itemsPerPage: Maybe<number>);
15
15
  set constraints(constraints: Maybe<ArrayOrValue<FirestoreQueryConstraint>>);
@@ -1,5 +1,5 @@
1
1
  import { Observable, Subscription } from 'rxjs';
2
- import { DocumentSnapshot, DocumentReference, FirestoreCollection, FirestoreDocument, DocumentDataWithId, FirestoreModelId, FirestoreModelKey, FirestoreCollectionLike, FirestoreModelIdentity, FirestoreModelCollectionAndIdPair, FirestoreModelCollectionAndIdPairObject } from '@dereekb/firebase';
2
+ import { DocumentSnapshot, DocumentReference, FirestoreCollection, FirestoreDocument, DocumentDataWithIdAndKey, FirestoreModelId, FirestoreModelKey, FirestoreCollectionLike, FirestoreModelIdentity, FirestoreModelCollectionAndIdPair, FirestoreModelCollectionAndIdPairObject } from '@dereekb/firebase';
3
3
  import { LoadingState, ObservableOrValue } from '@dereekb/rxjs';
4
4
  import { Maybe } from '@dereekb/util';
5
5
  import { LockSetComponent, LockSetComponentStore } from '@dereekb/dbx-core';
@@ -18,15 +18,17 @@ export interface DbxFirebaseDocumentStore<T, D extends FirestoreDocument<T> = Fi
18
18
  readonly id$: Observable<FirestoreModelId>;
19
19
  readonly key$: Observable<FirestoreModelKey>;
20
20
  readonly ref$: Observable<DocumentReference<T>>;
21
+ readonly hasRef$: Observable<boolean>;
21
22
  readonly keyModelIds$: Observable<FirestoreModelId[]>;
22
23
  readonly keyPairs$: Observable<FirestoreModelCollectionAndIdPair[]>;
23
24
  readonly keyPairObject$: Observable<FirestoreModelCollectionAndIdPairObject>;
24
25
  readonly documentLoadingState$: Observable<LoadingState<D>>;
25
26
  readonly snapshot$: Observable<DocumentSnapshot<T>>;
26
27
  readonly snapshotLoadingState$: Observable<LoadingState<DocumentSnapshot<T>>>;
27
- readonly currentData$: Observable<Maybe<DocumentDataWithId<T>>>;
28
- readonly data$: Observable<DocumentDataWithId<T>>;
29
- readonly dataLoadingState$: Observable<LoadingState<DocumentDataWithId<T>>>;
28
+ readonly currentData$: Observable<Maybe<DocumentDataWithIdAndKey<T>>>;
29
+ readonly data$: Observable<DocumentDataWithIdAndKey<T>>;
30
+ readonly dataLoadingState$: Observable<LoadingState<DocumentDataWithIdAndKey<T>>>;
31
+ readonly currentExists$: Observable<boolean>;
30
32
  readonly exists$: Observable<boolean>;
31
33
  readonly modelIdentity$: Observable<FirestoreModelIdentity>;
32
34
  setId: (observableOrValue: ObservableOrValue<Maybe<FirestoreModelId>>) => Subscription;
@@ -67,6 +69,10 @@ export declare class AbstractDbxFirebaseDocumentStore<T, D extends FirestoreDocu
67
69
  readonly currentInputRef$: Observable<Maybe<DocumentReference<T>>>;
68
70
  readonly inputRef$: Observable<DocumentReference<T>>;
69
71
  readonly currentDocument$: Observable<Maybe<D>>;
72
+ /**
73
+ * Whether or not an id/ref/key has been input and currentDocument is not null.
74
+ */
75
+ readonly hasRef$: Observable<boolean>;
70
76
  readonly document$: Observable<D>;
71
77
  readonly documentLoadingState$: Observable<LoadingState<D>>;
72
78
  readonly id$: Observable<FirestoreModelId>;
@@ -77,9 +83,13 @@ export declare class AbstractDbxFirebaseDocumentStore<T, D extends FirestoreDocu
77
83
  readonly ref$: Observable<DocumentReference<T>>;
78
84
  readonly snapshot$: Observable<DocumentSnapshot<T>>;
79
85
  readonly snapshotLoadingState$: Observable<LoadingState<DocumentSnapshot<T>>>;
80
- readonly currentData$: Observable<Maybe<DocumentDataWithId<T>>>;
81
- readonly data$: Observable<DocumentDataWithId<T>>;
82
- readonly dataLoadingState$: Observable<LoadingState<DocumentDataWithId<T>>>;
86
+ readonly currentData$: Observable<Maybe<DocumentDataWithIdAndKey<T>>>;
87
+ readonly data$: Observable<DocumentDataWithIdAndKey<T>>;
88
+ readonly dataLoadingState$: Observable<LoadingState<DocumentDataWithIdAndKey<T>>>;
89
+ /**
90
+ * Returns false while hasRef$ is false, and then returns exists$.
91
+ */
92
+ readonly currentExists$: Observable<boolean>;
83
93
  readonly exists$: Observable<boolean>;
84
94
  readonly doesNotExist$: Observable<boolean>;
85
95
  readonly modelIdentity$: Observable<FirestoreModelIdentity>;
@@ -16,8 +16,8 @@ export declare abstract class DbxFirebaseDocumentStoreDirective<T = unknown, D e
16
16
  readonly ref$: import("rxjs").Observable<DocumentReference<T>>;
17
17
  readonly snapshot$: import("rxjs").Observable<import("@dereekb/firebase").DocumentSnapshot<T>>;
18
18
  readonly snapshotLoadingState$: import("rxjs").Observable<import("../../../../../../dist/packages/rxjs/src").LoadingState<import("@dereekb/firebase").DocumentSnapshot<T>>>;
19
- readonly data$: import("rxjs").Observable<import("@dereekb/firebase").DocumentDataWithId<T>>;
20
- readonly loadingState$: import("rxjs").Observable<import("../../../../../../dist/packages/rxjs/src").LoadingState<import("@dereekb/firebase").DocumentDataWithId<T>>>;
19
+ readonly data$: import("rxjs").Observable<import("@dereekb/firebase").DocumentDataWithIdAndKey<T>>;
20
+ readonly loadingState$: import("rxjs").Observable<import("../../../../../../dist/packages/rxjs/src").LoadingState<import("@dereekb/firebase").DocumentDataWithIdAndKey<T>>>;
21
21
  set id(id: ModelKey);
22
22
  set ref(ref: DocumentReference<T>);
23
23
  static ɵfac: i0.ɵɵFactoryDeclaration<DbxFirebaseDocumentStoreDirective<any, any, any>, never>;
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "@dereekb/dbx-firebase",
3
- "version": "9.2.0",
3
+ "version": "9.3.2",
4
4
  "peerDependencies": {
5
5
  "@angular/common": "^14.0.0",
6
6
  "@angular/core": "^14.0.0",
7
- "@dereekb/util": "9.2.0",
7
+ "@dereekb/util": "9.3.2",
8
8
  "firebase": "^9.9.2",
9
9
  "rxjs": "^7.5.0",
10
10
  "@angular/fire": "^7.4.1",
11
- "@dereekb/firebase": "9.2.0",
12
- "@dereekb/dbx-core": "9.2.0",
11
+ "@dereekb/firebase": "9.3.2",
12
+ "@dereekb/dbx-core": "9.3.2",
13
13
  "@angular/material": "^14.0.0",
14
- "@dereekb/dbx-web": "9.2.0",
15
- "@dereekb/dbx-form": "9.2.0"
14
+ "@dereekb/dbx-web": "9.3.2",
15
+ "@dereekb/dbx-form": "9.3.2"
16
16
  },
17
17
  "dependencies": {
18
18
  "tslib": "^2.3.0"