Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions delete-user-data/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## Version 0.1.25

feat - add support for multiple Firestore databases via FIRESTORE_DATABASE_ID parameter

fix - run npm audit fix

## Version 0.1.24

feat - move to Node.js 20 runtimes
Expand Down
2 changes: 2 additions & 0 deletions delete-user-data/PREINSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Depending on where you'd like to delete user data from, make sure that you've se

Also, make sure that you've set up [Firebase Authentication](https://firebase.google.com/docs/auth) to manage your users.

**Note about multiple Firestore databases:** This extension supports using non-default Firestore databases. During installation, you can specify which database to use via the `FIRESTORE_DATABASE_ID` parameter. Use "(default)" for the default database, or specify your named database ID.

#### Billing
To install an extension, your project must be on the [Blaze (pay as you go) plan](https://firebase.google.com/pricing)

Expand Down
4 changes: 4 additions & 0 deletions delete-user-data/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ Depending on where you'd like to delete user data from, make sure that you've se

Also, make sure that you've set up [Firebase Authentication](https://firebase.google.com/docs/auth) to manage your users.

**Note about multiple Firestore databases:** This extension supports using non-default Firestore databases. During installation, you can specify which database to use via the `FIRESTORE_DATABASE_ID` parameter. Use "(default)" for the default database, or specify your named database ID.

#### Billing
To install an extension, your project must be on the [Blaze (pay as you go) plan](https://firebase.google.com/pricing)

Expand All @@ -37,6 +39,8 @@ To install an extension, your project must be on the [Blaze (pay as you go) plan

**Configuration Parameters:**

* Firestore Database ID: The ID of the Firestore database to use. Use "(default)" for the default database. You can view your available Firestore databases at https://console.cloud.google.com/firestore/databases.

* Cloud Firestore paths: Which paths in your Cloud Firestore instance contain data keyed on a user ID? Leave empty if you don't use Cloud Firestore.
Enter the full paths, separated by commas. Use `{UID}` as a placeholder for the user's UID.
For example, if you have the collections `users` and `admins`, and each collection has documents with User ID as document IDs, then enter `users/{UID},admins/{UID}`.
Expand Down
12 changes: 11 additions & 1 deletion delete-user-data/extension.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

name: delete-user-data
version: 0.1.24
version: 0.1.25
specVersion: v1beta

displayName: Delete User Data
Expand Down Expand Up @@ -86,6 +86,16 @@ resources:
resource: projects/${PROJECT_ID}/topics/ext-${EXT_INSTANCE_ID}-deletion

params:
- param: FIRESTORE_DATABASE_ID
label: Firestore Database ID
description: >-
The ID of the Firestore database to use. Use "(default)" for the default
database. You can view your available Firestore databases at
https://console.cloud.google.com/firestore/databases.
type: string
default: (default)
required: true

- param: FIRESTORE_PATHS
label: Cloud Firestore paths
description: >-
Expand Down
6 changes: 3 additions & 3 deletions delete-user-data/functions/__tests__/recursiveDelete.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe("recursiveDelete", () => {
foo: "bar",
});

await recursiveDelete(ref);
await recursiveDelete(ref, db);

const doc = db.doc(ref);
await doc.get().then((doc) => {
Expand All @@ -34,7 +34,7 @@ describe("recursiveDelete", () => {
foo: "bar",
});

await recursiveDelete(ref);
await recursiveDelete(ref, db);

const collection = db.collection(ref);
await collection.get().then((collection) => {
Expand All @@ -49,7 +49,7 @@ describe("recursiveDelete", () => {
foo: "bar",
});

await recursiveDelete(parentRef);
await recursiveDelete(parentRef, db);

const collection = db.collection(ref);
await collection.get().then((collection) => {
Expand Down
18 changes: 9 additions & 9 deletions delete-user-data/functions/__tests__/search.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe("discovery", () => {

describe("searches on top level collections", () => {
test("can delete is single collection named {uid}", async () => {
await search(user.uid, 1);
await search(user.uid, 1, db);

await waitForCollectionDeletion(rootCollection, 20_000);
}, 60000);
Expand All @@ -53,7 +53,7 @@ describe("discovery", () => {
describe("searches on top level collection documents", () => {
test("can delete a document named {uid}", async () => {
const document = await db.collection(generateRandomId()).doc(user.uid);
await search(user.uid, 1);
await search(user.uid, 1, db);

await waitForDocumentDeletion(document);
}, 60000);
Expand All @@ -62,14 +62,14 @@ describe("discovery", () => {
const document = await db
.collection(generateRandomId())
.add({ field1: user.uid });
await search(user.uid, 1);
await search(user.uid, 1, db);

await waitForDocumentDeletion(document, 60000);
}, 60000);

test("can check a document without any field values", async () => {
await db.collection(generateRandomId()).add({});
await search(user.uid, 1);
await search(user.uid, 1, db);

expect(true).toBeTruthy();
}, 60000);
Expand All @@ -93,7 +93,7 @@ describe("discovery", () => {

expect(checkExists).toBe(true);

await search(user.uid, 1);
await search(user.uid, 1, db);

await waitForCollectionDeletion(subcollection);
}, 60000);
Expand All @@ -118,7 +118,7 @@ describe("discovery", () => {

expect(collectionPathCount).toBeGreaterThan(config.searchDepth);

await search(user.uid, 1);
await search(user.uid, 1, db);

// /** Wait 10 seconds for the discovery to complete */
await new Promise((resolve) => setTimeout(resolve, 20000));
Expand Down Expand Up @@ -149,7 +149,7 @@ describe("discovery", () => {

expect(collectionPathCount).toBeGreaterThan(config.searchDepth);

await search(user.uid, 1);
await search(user.uid, 1, db);

// /** Wait 10 seconds for the discovery to complete */
await new Promise((resolve) => setTimeout(resolve, 20000));
Expand All @@ -169,7 +169,7 @@ describe("discovery", () => {
const collection = await db.collection(generateRandomId());
const document = await collection.add({ testing: "should-not-delete" });

await search(collection.id, -1, document);
await search(collection.id, -1, db, document);

/** Check document still exists */
const checkExists = await document.get().then((doc) => doc.exists);
Expand All @@ -180,7 +180,7 @@ describe("discovery", () => {
const document = await db
.collection(generateRandomId())
.add({ field1: "unknown" });
await search(user.uid, 1);
await search(user.uid, 1, db);

/** Wait 10 seconds */
await new Promise((resolve) => setTimeout(resolve, 10000));
Expand Down
Loading
Loading