1 | {"version":3,"file":"angular-fire-compat-database.js","sources":["../../../src/compat/database/utils.ts","../../../src/compat/database/observable/fromRef.ts","../../../src/compat/database/list/changes.ts","../../../src/compat/database/list/utils.ts","../../../src/compat/database/list/snapshot-changes.ts","../../../src/compat/database/list/state-changes.ts","../../../src/compat/database/list/audit-trail.ts","../../../src/compat/database/list/data-operation.ts","../../../src/compat/database/list/remove.ts","../../../src/compat/database/list/create-reference.ts","../../../src/compat/database/object/snapshot-changes.ts","../../../src/compat/database/object/create-reference.ts","../../../src/compat/database/database.ts","../../../src/compat/database/database.module.ts","../../../src/compat/database/angular-fire-compat-database.ts"],"sourcesContent":["import { DatabaseReference, FirebaseOperation, FirebaseOperationCases, PathReference } from './interfaces';\nimport firebase from 'firebase/compat/app';\n\nexport function isString(value: any): boolean {\n return typeof value === 'string';\n}\n\nexport function isFirebaseDataSnapshot(value: any): boolean {\n return typeof value.exportVal === 'function';\n}\n\nexport function isNil(obj: any): boolean {\n return obj === undefined || obj === null;\n}\n\nexport function isFirebaseRef(value: any): boolean {\n return typeof value.set === 'function';\n}\n\n/**\n * Returns a database reference given a Firebase App and an\n * absolute or relative path.\n * @param database - Firebase Database\n * @param pathRef - Database path, relative or absolute\n */\nexport function getRef(database: firebase.database.Database, pathRef: PathReference): DatabaseReference {\n // if a db ref was passed in, just return it\n return isFirebaseRef(pathRef) ? pathRef as DatabaseReference\n : database.ref(pathRef as string);\n}\n\nexport function checkOperationCases(item: FirebaseOperation, cases: FirebaseOperationCases): Promise<void> {\n if (isString(item)) {\n return cases.stringCase();\n } else if (isFirebaseRef(item)) {\n return cases.firebaseCase();\n } else if (isFirebaseDataSnapshot(item)) {\n return cases.snapshotCase();\n }\n throw new Error(`Expects a string, snapshot, or reference. Got: ${typeof item}`);\n}\n","import { AngularFireAction, DatabaseQuery, DatabaseSnapshot, ListenEvent } from '../interfaces';\nimport { asyncScheduler, Observable, SchedulerLike } from 'rxjs';\nimport { map, share } from 'rxjs/operators';\n\ninterface SnapshotPrevKey<T> {\n snapshot: DatabaseSnapshot<T>;\n prevKey: string | null | undefined;\n}\n\n/**\n * Create an observable from a Database Reference or Database Query.\n * @param ref Database Reference\n * @param event Listen event type ('value', 'added', 'changed', 'removed', 'moved')\n * @param listenType 'on' or 'once'\n * @param scheduler - Rxjs scheduler\n */\nexport function fromRef<T>(ref: DatabaseQuery,\n event: ListenEvent,\n listenType = 'on',\n scheduler: SchedulerLike = asyncScheduler\n): Observable<AngularFireAction<DatabaseSnapshot<T>>> {\n return new Observable<SnapshotPrevKey<T>>(subscriber => {\n let fn: any | null = null;\n fn = ref[listenType](event, (snapshot, prevKey) => {\n scheduler.schedule(() => {\n subscriber.next({ snapshot, prevKey });\n });\n if (listenType === 'once') {\n scheduler.schedule(() => subscriber.complete());\n }\n }, err => {\n scheduler.schedule(() => subscriber.error(err));\n });\n\n if (listenType === 'on') {\n return {\n unsubscribe() {\n if (fn != null) {\n ref.off(event, fn);\n }\n }\n };\n } else {\n return {\n unsubscribe() {\n }\n };\n }\n }).pipe(\n map(payload => {\n const { snapshot, prevKey } = payload;\n let key: string | null = null;\n if (snapshot.exists()) {\n key = snapshot.key;\n }\n return { type: event, payload: snapshot, prevKey, key };\n }),\n share()\n );\n}\n","import { fromRef } from '../observable/fromRef';\nimport { merge, Observable, of, SchedulerLike } from 'rxjs';\n\nimport { ChildEvent, DatabaseQuery, SnapshotAction } from '../interfaces';\nimport { isNil } from '../utils';\n\nimport { distinctUntilChanged, scan, switchMap } from 'rxjs/operators';\n\nexport function listChanges<T = any>(ref: DatabaseQuery, events: ChildEvent[], scheduler?: SchedulerLike): Observable<SnapshotAction<T>[]> {\n return fromRef(ref, 'value', 'once', scheduler).pipe(\n switchMap(snapshotAction => {\n const childEvent$ = [of(snapshotAction)];\n events.forEach(event => childEvent$.push(fromRef(ref, event, 'on', scheduler)));\n return merge(...childEvent$).pipe(scan(buildView, []));\n }),\n distinctUntilChanged()\n );\n}\n\nfunction positionFor<T>(changes: SnapshotAction<T>[], key) {\n const len = changes.length;\n for (let i = 0; i < len; i++) {\n if (changes[i].payload.key === key) {\n return i;\n }\n }\n return -1;\n}\n\nfunction positionAfter<T>(changes: SnapshotAction<T>[], prevKey?: string) {\n if (isNil(prevKey)) {\n return 0;\n } else {\n const i = positionFor(changes, prevKey);\n if (i === -1) {\n return changes.length;\n } else {\n return i + 1;\n }\n }\n}\n\nfunction buildView(current, action) {\n const { payload, prevKey, key } = action;\n const currentKeyPosition = positionFor(current, key);\n const afterPreviousKeyPosition = positionAfter(current, prevKey);\n switch (action.type) {\n case 'value':\n if (action.payload && action.payload.exists()) {\n let prevKey = null;\n action.payload.forEach(payload => {\n const action = { payload, type: 'value', prevKey, key: payload.key };\n prevKey = payload.key;\n current = [...current, action];\n return false;\n });\n }\n return current;\n case 'child_added':\n if (currentKeyPosition > -1) {\n // check that the previouskey is what we expect, else reorder\n const previous = current[currentKeyPosition - 1];\n if ((previous && previous.key || null) !== prevKey) {\n current = current.filter(x => x.payload.key !== payload.key);\n current.splice(afterPreviousKeyPosition, 0, action);\n }\n } else if (prevKey == null) {\n return [action, ...current];\n } else {\n current = current.slice();\n current.splice(afterPreviousKeyPosition, 0, action);\n }\n return current;\n case 'child_removed':\n return current.filter(x => x.payload.key !== payload.key);\n case 'child_changed':\n return current.map(x => x.payload.key === key ? action : x);\n case 'child_moved':\n if (currentKeyPosition > -1) {\n const data = current.splice(currentKeyPosition, 1)[0];\n current = current.slice();\n current.splice(afterPreviousKeyPosition, 0, data);\n return current;\n }\n return current;\n // default will also remove null results\n default:\n return current;\n }\n}\n","import { isNil } from '../utils';\n\nexport function validateEventsArray(events?: any[]) {\n if (isNil(events) || events.length === 0) {\n events = ['child_added', 'child_removed', 'child_changed', 'child_moved'];\n }\n return events;\n}\n","import { Observable, SchedulerLike } from 'rxjs';\nimport { listChanges } from './changes';\nimport { ChildEvent, DatabaseQuery, SnapshotAction } from '../interfaces';\nimport { validateEventsArray } from './utils';\n\nexport function snapshotChanges<T>(\n query: DatabaseQuery,\n events?: ChildEvent[],\n scheduler?: SchedulerLike\n): Observable<SnapshotAction<T>[]> {\n events = validateEventsArray(events);\n return listChanges<T>(query, events, scheduler);\n}\n","import { ChildEvent, DatabaseQuery } from '../interfaces';\nimport { fromRef } from '../observable/fromRef';\nimport { validateEventsArray } from './utils';\nimport { merge, SchedulerLike } from 'rxjs';\n\nexport function stateChanges<T>(query: DatabaseQuery, events?: ChildEvent[], scheduler?: SchedulerLike) {\n events = validateEventsArray(events);\n const childEvent$ = events.map(event => fromRef<T>(query, event, 'on', scheduler));\n return merge(...childEvent$);\n}\n","import { AngularFireAction, ChildEvent, DatabaseQuery, DataSnapshot, SnapshotAction } from '../interfaces';\nimport { stateChanges } from './state-changes';\nimport { Observable, SchedulerLike } from 'rxjs';\nimport { fromRef } from '../observable/fromRef';\n\nimport { map, scan, skipWhile, withLatestFrom } from 'rxjs/operators';\n\nexport function auditTrail<T>(query: DatabaseQuery, events?: ChildEvent[], scheduler?: SchedulerLike): Observable<SnapshotAction<T>[]> {\n const auditTrail$ = stateChanges<T>(query, events)\n .pipe(\n scan((current, action) => [...current, action], [])\n );\n return waitForLoaded<T>(query, auditTrail$, scheduler);\n}\n\ninterface LoadedMetadata {\n data: AngularFireAction<DataSnapshot>;\n lastKeyToLoad: any;\n}\n\nfunction loadedData<T>(query: DatabaseQuery, scheduler?: SchedulerLike): Observable<LoadedMetadata> {\n // Create an observable of loaded values to retrieve the\n // known dataset. This will allow us to know what key to\n // emit the \"whole\" array at when listening for child events.\n return fromRef<T>(query, 'value', 'on', scheduler)\n .pipe(\n map(data => {\n // Store the last key in the data set\n let lastKeyToLoad;\n // Loop through loaded dataset to find the last key\n data.payload.forEach(child => {\n lastKeyToLoad = child.key; return false;\n });\n // return data set and the current last key loaded\n return { data, lastKeyToLoad };\n })\n );\n}\n\nfunction waitForLoaded<T>(query: DatabaseQuery, action$: Observable<SnapshotAction<T>[]>, scheduler?: SchedulerLike) {\n const loaded$ = loadedData<T>(query, scheduler);\n return loaded$\n .pipe(\n withLatestFrom(action$),\n // Get the latest values from the \"loaded\" and \"child\" datasets\n // We can use both datasets to form an array of the latest values.\n map(([loaded, actions]) => {\n // Store the last key in the data set\n const lastKeyToLoad = loaded.lastKeyToLoad;\n // Store all child keys loaded at this point\n const loadedKeys = actions.map(snap => snap.key);\n return { actions, lastKeyToLoad, loadedKeys };\n }),\n // This is the magical part, only emit when the last load key\n // in the dataset has been loaded by a child event. At this point\n // we can assume the dataset is \"whole\".\n skipWhile(meta => meta.loadedKeys.indexOf(meta.lastKeyToLoad) === -1),\n // Pluck off the meta data because the user only cares\n // to iterate through the snapshots\n map(meta => meta.actions)\n );\n}\n","import { DatabaseReference, DatabaseSnapshot, FirebaseOperation } from '../interfaces';\nimport { checkOperationCases } from '../utils';\n\nexport function createDataOperationMethod<T>(ref: DatabaseReference, operation: string) {\n return function dataOperation<T>(item: FirebaseOperation, value: T) {\n return checkOperationCases(item, {\n stringCase: () => ref.child(item as string)[operation](value),\n firebaseCase: () => (item as DatabaseReference)[operation](value),\n snapshotCase: () => (item as DatabaseSnapshot<T>).ref[operation](value)\n });\n };\n}\n","import { DatabaseReference, DatabaseSnapshot, FirebaseOperation } from '../interfaces';\nimport { checkOperationCases } from '../utils';\n\n// TODO(davideast): Find out why TS thinks this returns firebase.Primise\n// instead of Promise.\nexport function createRemoveMethod<T>(ref: DatabaseReference) {\n return function remove(item?: FirebaseOperation): any {\n if (!item) { return ref.remove(); }\n return checkOperationCases(item, {\n stringCase: () => ref.child(item as string).remove(),\n firebaseCase: () => (item as DatabaseReference).remove(),\n snapshotCase: () => (item as DatabaseSnapshot<T>).ref.remove()\n });\n };\n}\n","import { AngularFireList, ChildEvent, DatabaseQuery } from '../interfaces';\nimport { snapshotChanges } from './snapshot-changes';\nimport { stateChanges } from './state-changes';\nimport { auditTrail } from './audit-trail';\nimport { createDataOperationMethod } from './data-operation';\nimport { createRemoveMethod } from './remove';\nimport { AngularFireDatabase } from '../database';\nimport { map } from 'rxjs/operators';\nimport { keepUnstableUntilFirst } from '@angular/fire';\n\nexport function createListReference<T= any>(query: DatabaseQuery, afDatabase: AngularFireDatabase): AngularFireList<T> {\n const outsideAngularScheduler = afDatabase.schedulers.outsideAngular;\n const refInZone = afDatabase.schedulers.ngZone.run(() => query.ref);\n return {\n query,\n update: createDataOperationMethod<Partial<T>>(refInZone, 'update'),\n set: createDataOperationMethod<T>(refInZone, 'set'),\n push: (data: T) => refInZone.push(data),\n remove: createRemoveMethod(refInZone),\n snapshotChanges(events?: ChildEvent[]) {\n return snapshotChanges<T>(query, events, outsideAngularScheduler).pipe(keepUnstableUntilFirst);\n },\n stateChanges(events?: ChildEvent[]) {\n return stateChanges<T>(query, events, outsideAngularScheduler).pipe(keepUnstableUntilFirst);\n },\n auditTrail(events?: ChildEvent[]) {\n return auditTrail<T>(query, events, outsideAngularScheduler).pipe(keepUnstableUntilFirst);\n },\n valueChanges<K extends string>(events?: ChildEvent[], options?: {idField?: K}) {\n const snapshotChanges$ = snapshotChanges<T>(query, events, outsideAngularScheduler);\n return snapshotChanges$.pipe(\n map(actions => actions.map(a => {\n if (options && options.idField) {\n return {\n ...a.payload.val() as T,\n ...{\n [options.idField]: a.key\n }\n };\n } else {\n return a.payload.val() as T;\n }\n })),\n keepUnstableUntilFirst\n );\n }\n };\n}\n","import { Observable, SchedulerLike } from 'rxjs';\nimport { fromRef } from '../observable/fromRef';\nimport { DatabaseQuery, SnapshotAction } from '../interfaces';\n\nexport function createObjectSnapshotChanges<T>(query: DatabaseQuery, scheduler?: SchedulerLike) {\n return function snapshotChanges(): Observable<SnapshotAction<T>> {\n return fromRef(query, 'value', 'on', scheduler);\n };\n}\n","import { map } from 'rxjs/operators';\nimport { AngularFireObject, DatabaseQuery } from '../interfaces';\nimport { createObjectSnapshotChanges } from './snapshot-changes';\nimport { AngularFireDatabase } from '../database';\nimport { keepUnstableUntilFirst } from '@angular/fire';\n\nexport function createObjectReference<T= any>(query: DatabaseQuery, afDatabase: AngularFireDatabase): AngularFireObject<T> {\n return {\n query,\n snapshotChanges<T>() {\n return createObjectSnapshotChanges<T>(query, afDatabase.schedulers.outsideAngular)().pipe(\n keepUnstableUntilFirst\n );\n },\n update(data: Partial<T>) { return query.ref.update(data as any) as Promise<void>; },\n set(data: T) { return query.ref.set(data) as Promise<void>; },\n remove() { return query.ref.remove() as Promise<void>; },\n valueChanges<T>() {\n const snapshotChanges$ = createObjectSnapshotChanges(query, afDatabase.schedulers.outsideAngular)();\n return snapshotChanges$.pipe(\n keepUnstableUntilFirst,\n map(action => action.payload.exists() ? action.payload.val() as T : null)\n );\n },\n };\n}\n","import { Inject, Injectable, InjectionToken, NgZone, Optional, PLATFORM_ID } from '@angular/core';\nimport { AngularFireList, AngularFireObject, DatabaseQuery, PathReference, QueryFn } from './interfaces';\nimport { getRef } from './utils';\nimport { createListReference } from './list/create-reference';\nimport { createObjectReference } from './object/create-reference';\nimport { ɵAngularFireSchedulers } from '@angular/fire';\nimport { FirebaseOptions } from 'firebase/app';\nimport { ɵfirebaseAppFactory, FIREBASE_APP_NAME, FIREBASE_OPTIONS, ɵcacheInstance } from '@angular/fire/compat';\nimport 'firebase/compat/auth';\nimport 'firebase/compat/database';\nimport {\n AngularFireAuth,\n USE_EMULATOR as USE_AUTH_EMULATOR,\n SETTINGS as AUTH_SETTINGS,\n TENANT_ID,\n LANGUAGE_CODE,\n USE_DEVICE_LANGUAGE,\n PERSISTENCE,\n ɵauthFactory,\n} from '@angular/fire/compat/auth';\nimport firebase from 'firebase/compat/app';\nimport { AppCheckInstances } from '@angular/fire/app-check';\n\nexport const URL = new InjectionToken<string>('angularfire2.realtimeDatabaseURL');\n\ntype UseEmulatorArguments = Parameters<firebase.database.Database['useEmulator']>;\nexport const USE_EMULATOR = new InjectionToken<UseEmulatorArguments>('angularfire2.database.use-emulator');\n\n@Injectable({\n providedIn: 'any'\n})\nexport class AngularFireDatabase {\n public readonly database: firebase.database.Database;\n\n constructor(\n @Inject(FIREBASE_OPTIONS) options: FirebaseOptions,\n @Optional() @Inject(FIREBASE_APP_NAME) name: string | null | undefined,\n @Optional() @Inject(URL) databaseURL: string | null,\n // tslint:disable-next-line:ban-types\n @Inject(PLATFORM_ID) platformId: Object,\n zone: NgZone,\n public schedulers: ɵAngularFireSchedulers,\n @Optional() @Inject(USE_EMULATOR) _useEmulator: any, // tuple isn't working here\n @Optional() auth: AngularFireAuth,\n @Optional() @Inject(USE_AUTH_EMULATOR) useAuthEmulator: any,\n @Optional() @Inject(AUTH_SETTINGS) authSettings: any, // can't use firebase.auth.AuthSettings here\n @Optional() @Inject(TENANT_ID) tenantId: string | null,\n @Optional() @Inject(LANGUAGE_CODE) languageCode: string | null,\n @Optional() @Inject(USE_DEVICE_LANGUAGE) useDeviceLanguage: boolean | null,\n @Optional() @Inject(PERSISTENCE) persistence: string | null,\n @Optional() _appCheckInstances: AppCheckInstances,\n ) {\n\n const useEmulator: UseEmulatorArguments | null = _useEmulator;\n const app = ɵfirebaseAppFactory(options, zone, name);\n\n if (auth) {\n ɵauthFactory(app, zone, useAuthEmulator, tenantId, languageCode, useDeviceLanguage, authSettings, persistence);\n }\n\n this.database = ɵcacheInstance(`${app.name}.database.${databaseURL}`, 'AngularFireDatabase', app.name, () => {\n const database = zone.runOutsideAngular(() => app.database(databaseURL || undefined));\n if (useEmulator) {\n database.useEmulator(...useEmulator);\n }\n return database;\n }, [useEmulator]);\n }\n\n list<T>(pathOrRef: PathReference, queryFn?: QueryFn): AngularFireList<T> {\n const ref = this.schedulers.ngZone.runOutsideAngular(() => getRef(this.database, pathOrRef));\n let query: DatabaseQuery = ref;\n if (queryFn) {\n query = queryFn(ref);\n }\n return createListReference<T>(query, this);\n }\n\n object<T>(pathOrRef: PathReference): AngularFireObject<T> {\n const ref = this.schedulers.ngZone.runOutsideAngular(() => getRef(this.database, pathOrRef));\n return createObjectReference<T>(ref, this);\n }\n\n createPushId() {\n const ref = this.schedulers.ngZone.runOutsideAngular(() => this.database.ref());\n return ref.push().key;\n }\n\n}\n\nexport {\n PathReference,\n DatabaseSnapshot,\n ChildEvent,\n ListenEvent,\n QueryFn,\n AngularFireList,\n AngularFireObject,\n AngularFireAction,\n Action,\n SnapshotAction\n} from './interfaces';\n","import { NgModule } from '@angular/core';\nimport { AngularFireDatabase } from './database';\nimport firebase from 'firebase/compat/app';\nimport { VERSION } from '@angular/fire';\n\n@NgModule({\n providers: [ AngularFireDatabase ]\n})\nexport class AngularFireDatabaseModule {\n constructor() {\n firebase.registerVersion('angularfire', VERSION.full, 'rtdb-compat');\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":["USE_AUTH_EMULATOR","AUTH_SETTINGS"],"mappings":";;;;;;;;;;;;;;SAGgB,QAAQ,CAAC,KAAU;IACjC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;AACnC,CAAC;SAEe,sBAAsB,CAAC,KAAU;IAC/C,OAAO,OAAO,KAAK,CAAC,SAAS,KAAK,UAAU,CAAC;AAC/C,CAAC;SAEe,KAAK,CAAC,GAAQ;IAC5B,OAAO,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,IAAI,CAAC;AAC3C,CAAC;SAEe,aAAa,CAAC,KAAU;IACtC,OAAO,OAAO,KAAK,CAAC,GAAG,KAAK,UAAU,CAAC;AACzC,CAAC;AAED;;;;;;SAMgB,MAAM,CAAC,QAAoC,EAAE,OAAsB;;IAEjF,OAAO,aAAa,CAAC,OAAO,CAAC,GAAG,OAA4B;UACxD,QAAQ,CAAC,GAAG,CAAC,OAAiB,CAAC,CAAC;AACtC,CAAC;SAEe,mBAAmB,CAAC,IAAuB,EAAE,KAA6B;IACxF,IAAI,QAAQ,CAAC,IAAI,CAAC,EAAE;QAClB,OAAO,KAAK,CAAC,UAAU,EAAE,CAAC;KAC3B;SAAM,IAAI,aAAa,CAAC,IAAI,CAAC,EAAE;QAC9B,OAAO,KAAK,CAAC,YAAY,EAAE,CAAC;KAC7B;SAAM,IAAI,sBAAsB,CAAC,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