From 670413bcd6e4d08f327b8292132ef6d41427001c Mon Sep 17 00:00:00 2001 From: Cole Rogers Date: Thu, 25 Jan 2024 14:33:24 -0800 Subject: [PATCH 1/2] add IteratedDataSnapshot interface to match with firebase admin v12 --- src/common/providers/database.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/common/providers/database.ts b/src/common/providers/database.ts index 33250f4c0..880604f2f 100644 --- a/src/common/providers/database.ts +++ b/src/common/providers/database.ts @@ -25,6 +25,14 @@ import * as database from "firebase-admin/database"; import { firebaseConfig } from "../../common/config"; import { joinPath, pathParts } from "../../common/utilities/path"; +/** + * Pulled from @firebase/database-types + * Represents a child snapshot of a `Reference` that is being iterated over. The key will never be undefined. + */ +interface IteratedDataSnapshot extends DataSnapshot { + key: string; // key of the location of this snapshot. +} + /** * Interface representing a Firebase Realtime database data snapshot. */ @@ -204,7 +212,7 @@ export class DataSnapshot implements database.DataSnapshot { * @return `true` if enumeration was canceled due to your callback * returning `true`. */ - forEach(action: (a: DataSnapshot) => boolean | void): boolean { + forEach(action: (a: IteratedDataSnapshot) => boolean | void): boolean { const val = this.val() || {}; if (typeof val === "object") { return Object.keys(val).some((key) => action(this.child(key)) === true); From 08c214b483298e084d15c05c3e61b3156fc5ed2b Mon Sep 17 00:00:00 2001 From: Cole Rogers Date: Thu, 1 Feb 2024 16:37:03 -0500 Subject: [PATCH 2/2] rebase upstream --- CHANGELOG.md | 1 + src/common/providers/database.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e97214632..0f5f3d22f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1 +1,2 @@ - Fixes access on deeply nested, nonexistent property. (#1432) +- Add IteratedDataSnapshot interface to match with firebase admin v12 (#1517). diff --git a/src/common/providers/database.ts b/src/common/providers/database.ts index 317e75dd0..d73bb5503 100644 --- a/src/common/providers/database.ts +++ b/src/common/providers/database.ts @@ -26,7 +26,7 @@ import { firebaseConfig } from "../../common/config"; import { joinPath, pathParts } from "../../common/utilities/path"; /** - * Pulled from @firebase/database-types + * Pulled from @firebase/database-types, make sure the interface is updated on dependencies upgrades. * Represents a child snapshot of a `Reference` that is being iterated over. The key will never be undefined. */ interface IteratedDataSnapshot extends DataSnapshot {