@dereekb/dbx-firebase 9.1.2 → 9.3.1

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.
@@ -31,7 +31,7 @@ import { provideFunctions, getFunctions, connectFunctionsEmulator, Functions } f
31
31
  import * as i1$3 from '@angular/fire/firestore';
32
32
  import { provideFirestore, getFirestore, connectFirestoreEmulator, enableIndexedDbPersistence, Firestore } from '@angular/fire/firestore';
33
33
  import { HTTP_INTERCEPTORS } from '@angular/common/http';
34
- import { clientFirebaseFirestoreContextFactory, iterationQueryDocChangeWatcher, firebaseQueryItemAccumulator, firestoreModelKeysFromDocuments, firestoreModelIdsFromDocuments, documentReferencesFromDocuments, getDocumentSnapshots, getDataFromDocumentSnapshots, streamDocumentSnapshots, dataFromDocumentSnapshots, loadDocumentsForKeys, loadDocumentsForDocumentReferences, loadDocumentsForIds, firestoreModelIdsFromKey, firestoreModelKeyPartPairs, firestoreModelKeyPairObject, documentDataWithId, clientFirebaseStorageContextFactory } from '@dereekb/firebase';
34
+ import { clientFirebaseFirestoreContextFactory, iterationQueryDocChangeWatcher, firebaseQuerySnapshotAccumulator, firebaseQueryItemAccumulator, firestoreModelKeysFromDocuments, firestoreModelIdsFromDocuments, documentReferencesFromDocuments, getDocumentSnapshots, getDataFromDocumentSnapshots, streamDocumentSnapshots, dataFromDocumentSnapshots, loadDocumentsForKeys, loadDocumentsForDocumentReferences, loadDocumentsForIds, firestoreModelIdsFromKey, firestoreModelKeyPartPairs, firestoreModelKeyPairObject, documentDataWithIdAndKey, clientFirebaseStorageContextFactory } from '@dereekb/firebase';
35
35
 
36
36
  /**
37
37
  * Enables debug token generation for AppCheck by setting FIREBASE_APPCHECK_DEBUG_TOKEN in the browser's self/window.
@@ -2011,7 +2011,17 @@ class DbxFirebaseCollectionLoaderInstance {
2011
2011
  }), cleanupDestroyable(), // cleanup the iteration
2012
2012
  shareReplay(1));
2013
2013
  this.queryChangeWatcher$ = this.firestoreIteration$.pipe(map((instance) => iterationQueryDocChangeWatcher({ instance })), shareReplay(1));
2014
+ this.snapshotAccumulator$ = this.firestoreIteration$.pipe(map((x) => firebaseQuerySnapshotAccumulator(x)), cleanupDestroyable(), shareReplay(1));
2015
+ this.snapshotAccumulatorDocumentRefs$ = this.snapshotAccumulator$.pipe(switchMap((x) => x.allItems$.pipe(map((y) => y.map((z) => z.map((zz) => zz.ref))))), shareReplay(1));
2016
+ this.snapshotAccumulatorDocuments$ = combineLatest([this.collection$.pipe(filterMaybe()), this.snapshotAccumulatorDocumentRefs$]).pipe(map(([collection, documentRefs]) => {
2017
+ const accessor = collection.documentAccessor();
2018
+ return documentRefs.map((y) => y.map((z) => accessor.loadDocument(z)));
2019
+ }), shareReplay(1));
2014
2020
  this.accumulator$ = this.firestoreIteration$.pipe(map((x) => firebaseQueryItemAccumulator(x)), cleanupDestroyable(), shareReplay(1));
2021
+ this.accumulatorItems$ = this.accumulator$.pipe(switchMap((x) => x.allItems$), shareReplay(1));
2022
+ this.allDocumentRefs$ = this.snapshotAccumulatorDocumentRefs$.pipe(map((x) => x.flat()), shareReplay(1));
2023
+ this.allDocuments$ = this.snapshotAccumulatorDocuments$.pipe(map((x) => x.flat()), shareReplay(1));
2024
+ this.allDocumentData$ = this.accumulatorItems$.pipe(map((x) => x.flat()), shareReplay(1));
2015
2025
  this.pageLoadingState$ = this.accumulator$.pipe(switchMap((x) => accumulatorFlattenPageListLoadingState(x)), shareReplay(1));
2016
2026
  }
2017
2027
  init() {
@@ -2555,6 +2565,9 @@ class AbstractDbxFirebaseCollectionStore extends LockSetComponentStore {
2555
2565
  this.queryChangeWatcher$ = this.loader$.pipe(switchMap((x) => x.queryChangeWatcher$));
2556
2566
  this.accumulator$ = this.loader$.pipe(switchMap((x) => x.accumulator$));
2557
2567
  this.pageLoadingState$ = this.loader$.pipe(switchMap((x) => x.pageLoadingState$));
2568
+ this.allDocumentRefs$ = this.loader$.pipe(switchMap((x) => x.allDocumentRefs$));
2569
+ this.allDocuments$ = this.loader$.pipe(switchMap((x) => x.allDocuments$));
2570
+ this.allDocumentData$ = this.loader$.pipe(switchMap((x) => x.allDocumentData$));
2558
2571
  this.setFirestoreCollection = this.updater((state, firestoreCollection) => ({ ...state, firestoreCollection }));
2559
2572
  }
2560
2573
  }
@@ -2613,12 +2626,12 @@ class AbstractDbxFirebaseDocumentStore extends LockSetComponentStore {
2613
2626
  this.ref$ = this.document$.pipe(map((x) => x.documentRef), shareReplay(1));
2614
2627
  this.snapshot$ = this.document$.pipe(switchMap((x) => x.accessor.stream()), shareReplay(1));
2615
2628
  this.snapshotLoadingState$ = this.currentDocument$.pipe(switchMap(() => loadingStateFromObs(this.snapshot$)), shareReplay(1));
2616
- this.currentData$ = this.document$.pipe(switchMap((x) => x.accessor.stream().pipe(map((y) => documentDataWithId(y)))), shareReplay(1));
2629
+ this.currentData$ = this.document$.pipe(switchMap((x) => x.accessor.stream().pipe(map((y) => documentDataWithIdAndKey(y)))), shareReplay(1));
2617
2630
  this.data$ = this.currentDocument$.pipe(switchMap(() => this.currentData$.pipe(filterMaybe())), shareReplay(1));
2618
2631
  this.dataLoadingState$ = this.snapshotLoadingState$.pipe(map((x) => {
2619
2632
  let result;
2620
2633
  if (x.value) {
2621
- const data = documentDataWithId(x.value);
2634
+ const data = documentDataWithIdAndKey(x.value);
2622
2635
  if (data) {
2623
2636
  result = successResult(data);
2624
2637
  }