UNPKG

firestore-snapshot-utils

Version:

[![github license](https://img.shields.io/github/license/ericvera/firestore-snapshot-utils.svg?style=flat-square)](https://github.com/ericvera/firestore-snapshot-utils/blob/master/LICENSE) [![npm version](https://img.shields.io/npm/v/firestore-snapshot-ut

58 lines (57 loc) 2.62 kB
import type { QueryDocumentSnapshot } from 'firebase-admin/firestore'; export interface DBSnapshotChanges { added: AddedDocumentSnapshot[]; removed: RemovedDocumentSnapshot[]; modified: ModifiedDocumentSnapshot[]; unmodified: UnmodifiedDocumentSnapshot[]; } declare abstract class BaseDocumentSnapshot { protected readonly doc: QueryDocumentSnapshot; protected readonly normalizedData?: unknown | undefined; readonly normalizedPath: string; constructor(doc: QueryDocumentSnapshot, allDocs: QueryDocumentSnapshot[], normalizedData?: unknown | undefined); abstract getDiff(): string | undefined; } export declare class AddedDocumentSnapshot extends BaseDocumentSnapshot { readonly addedDoc: QueryDocumentSnapshot; private normalizedAddedData; constructor(addedDoc: QueryDocumentSnapshot, normalizedAddedData: unknown, allDocs: QueryDocumentSnapshot[]); /** * Returns a string with the differences between two objects or undefined if * there are no differences. * Timestamps are normalized to a string representation before comparison. */ getDiff(): string | undefined; } export declare class RemovedDocumentSnapshot extends BaseDocumentSnapshot { private normalizedRemovedData; constructor(removedDoc: QueryDocumentSnapshot, normalizedRemovedData: unknown, allDocs: QueryDocumentSnapshot[]); /** * Returns a string with the differences between two objects or undefined if * there are no differences. * Timestamps are normalized to a string representation before comparison. */ getDiff(): string | undefined; } export declare class ModifiedDocumentSnapshot extends BaseDocumentSnapshot { readonly beforeDoc: QueryDocumentSnapshot; readonly afterDoc: QueryDocumentSnapshot; private normalizedBeforeData; private normalizedAfterData; constructor(beforeDoc: QueryDocumentSnapshot, afterDoc: QueryDocumentSnapshot, normalizeBeforeData: unknown, normalizeAfterData: unknown, allDocs: QueryDocumentSnapshot[]); /** * Returns a string with the differences between two objects or undefined if * there are no differences. * Timestamps are normalized to a string representation before comparison. */ getDiff(): string | undefined; } export declare class UnmodifiedDocumentSnapshot extends BaseDocumentSnapshot { /** * Returns a string with the differences between two objects or undefined if * there are no differences. * Timestamps are normalized to a string representation before comparison. */ getDiff(): string | undefined; } export {};