Skip to content

Commit dd11f35

Browse files
committed
ran prettier fixes
1 parent c61243f commit dd11f35

32 files changed

+15457
-686
lines changed

extensions/export-user-data/README.md

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -31,45 +31,38 @@ To install an extension, your project must be on the Blaze (pay as you go) plan
3131

3232
**Configuration Parameters:**
3333

34-
* Cloud Functions location: Where do you want to deploy the functions created for this extension? For help selecting a location, refer to the [location selection guide](https://firebase.google.com/docs/functions/locations).
34+
- Cloud Functions location: Where do you want to deploy the functions created for this extension? For help selecting a location, refer to the [location selection guide](https://firebase.google.com/docs/functions/locations).
3535

36-
* Cloud Storage bucket for exports: To which Cloud Storage bucket will you export your data? It is recommended to create a separate bucket for this extension. For more information, refer to the [pre-installation guide](https://firebase.google.com/products/extensions/storage-resize-images).
36+
- Cloud Storage bucket for exports: To which Cloud Storage bucket will you export your data? It is recommended to create a separate bucket for this extension. For more information, refer to the [pre-installation guide](https://firebase.google.com/products/extensions/storage-resize-images).
3737

38+
- Folder for storing exported data: To which Cloud Storage folder will you upload exported data?
3839

39-
* Folder for storing exported data: To which Cloud Storage folder will you upload exported data?
40+
- Firestore collection to record export metadata: What is the path to the collection that will contain the export tracking documents?
4041

42+
- Cloud Firestore paths: Which paths in your Cloud Firestore instance contain data keyed by User ID? Leave empty if you don't use Cloud Firestore. Enter the full paths, separated by commas. You can represent the User ID of the user with `{UID}`. For example, if you have the collections `users` and `admins`, and each collection has documents with User ID as document IDs, then you can enter `users/{UID},admins/{UID}`.
4143

42-
* Firestore collection to record export metadata: What is the path to the collection that will contain the export tracking documents?
44+
- Realtime Database instance: From which Realtime Database instance do you want to export data keyed by User ID? If this parameter is not specified, this extension will use your default database instance.
4345

46+
- Realtime Database location: (Only applicable if you provided the `Realtime Database instance` parameter.) From which Realtime Database location do you want to export data keyed by User ID?
4447

45-
* Cloud Firestore paths: Which paths in your Cloud Firestore instance contain data keyed by User ID? Leave empty if you don't use Cloud Firestore. Enter the full paths, separated by commas. You can represent the User ID of the user with `{UID}`. For example, if you have the collections `users` and `admins`, and each collection has documents with User ID as document IDs, then you can enter `users/{UID},admins/{UID}`.
48+
- Realtime Database paths: Which paths in your Realtime Database instance contain data keyed by User ID? Leave empty if you don't use Realtime Database. Enter the full paths, separated by commas. You can represent the User ID of the exported user with `{UID}`. For example: `users/{UID},admins/{UID}`.
4649

47-
* Realtime Database instance: From which Realtime Database instance do you want to export data keyed by User ID? If this parameter is not specified, this extension will use your default database instance.
50+
- Cloud Storage paths: Where in Google Cloud Storage do you store data keyed by User ID? Leave empty if you don't use Cloud Storage. Enter the full paths to files or directories in your Storage buckets, separated by commas. Use `{UID}` to represent the User ID of the user whose data we're exporting, and use `{DEFAULT}` to represent your default Storage bucket. Here's a series of examples. To export all the files in your default bucket with the file naming scheme `{UID}-pic.png`, enter `{DEFAULT}/{UID}-pic.png`. To also export all the files in another bucket called my-app-logs with the file naming scheme `{UID}-logs.txt`, enter `{DEFAULT}/{UID}-pic.png,my-app-logs/{UID}-logs.txt`. To _also_ export a User ID-labeled directory and all its files (like `media/{UID}`), enter `{DEFAULT}/{UID}-pic.png,my-app-logs/{UID}-logs.txt,{DEFAULT}/media/{UID}`.
4851

52+
- Custom hook endpoint: Specify a function URL to call that will return an object listing paths in services to export data from. See the pre-install documentation for more details.
4953

50-
* Realtime Database location: (Only applicable if you provided the `Realtime Database instance` parameter.) From which Realtime Database location do you want to export data keyed by User ID?
51-
52-
53-
* Realtime Database paths: Which paths in your Realtime Database instance contain data keyed by User ID? Leave empty if you don't use Realtime Database. Enter the full paths, separated by commas. You can represent the User ID of the exported user with `{UID}`. For example: `users/{UID},admins/{UID}`.
54-
55-
* Cloud Storage paths: Where in Google Cloud Storage do you store data keyed by User ID? Leave empty if you don't use Cloud Storage. Enter the full paths to files or directories in your Storage buckets, separated by commas. Use `{UID}` to represent the User ID of the user whose data we're exporting, and use `{DEFAULT}` to represent your default Storage bucket. Here's a series of examples. To export all the files in your default bucket with the file naming scheme `{UID}-pic.png`, enter `{DEFAULT}/{UID}-pic.png`. To also export all the files in another bucket called my-app-logs with the file naming scheme `{UID}-logs.txt`, enter `{DEFAULT}/{UID}-pic.png,my-app-logs/{UID}-logs.txt`. To *also* export a User ID-labeled directory and all its files (like `media/{UID}`), enter `{DEFAULT}/{UID}-pic.png,my-app-logs/{UID}-logs.txt,{DEFAULT}/media/{UID}`.
56-
57-
* Custom hook endpoint: Specify a function URL to call that will return an object listing paths in services to export data from. See the pre-install documentation for more details.
58-
59-
* Enable Zipping of Exports: If enabled, will compress all exports into one zip file in storage.
60-
54+
- Enable Zipping of Exports: If enabled, will compress all exports into one zip file in storage.
6155

6256
**Cloud Functions:**
6357

64-
* **exportUserData:** Triggers an export and returns a unique export ID.
65-
58+
- **exportUserData:** Triggers an export and returns a unique export ID.
6659

6760
**Access Required**:
6861

6962
This extension will operate with the following project IAM roles:
7063

71-
* datastore.owner (Reason: Allows the extension to export (user) data from Cloud Firestore.)
64+
- datastore.owner (Reason: Allows the extension to export (user) data from Cloud Firestore.)
7265

73-
* firebasedatabase.admin (Reason: Allows the extension to export (user) data from Realtime Database.)
66+
- firebasedatabase.admin (Reason: Allows the extension to export (user) data from Realtime Database.)
7467

75-
* storage.admin (Reason: Allows the extension to export (user) data from Cloud Storage.)
68+
- storage.admin (Reason: Allows the extension to export (user) data from Cloud Storage.)

extensions/export-user-data/extension.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: export-user-data
22
displayName: Export User Data
33

44
description: >-
5-
Export certain data keyed on a user ID from Firestore, Realtime Database, or Cloud Storage to a Google Cloud Storage bucket.
5+
Export certain data keyed on a user ID from Firestore, Realtime Database, or Cloud Storage to a Google Cloud Storage bucket.
66
77
billingRequired: true
88

@@ -106,7 +106,7 @@ params:
106106
default: exports
107107
example: exports
108108
required: false
109-
validationRegex: "^[^/]+(/[^/]+/[^/]+)*$"
109+
validationRegex: '^[^/]+(/[^/]+/[^/]+)*$'
110110
validationErrorMessage: Must be a valid Cloud Firestore collection
111111

112112
- param: FIRESTORE_PATHS
@@ -177,7 +177,7 @@ params:
177177
ID-labeled directory and all its files (like `media/{UID}`), enter
178178
`{DEFAULT}/{UID}-pic.png,my-app-logs/{UID}-logs.txt,{DEFAULT}/media/{UID}`.
179179
type: string
180-
example: "{DEFAULT}/{UID}-pic.png,my-awesome-app-logs/{UID}-logs.txt"
180+
example: '{DEFAULT}/{UID}-pic.png,my-awesome-app-logs/{UID}-logs.txt'
181181
required: false
182182

183183
- param: CUSTOM_HOOK_ENDPOINT
@@ -201,7 +201,6 @@ params:
201201
value: no
202202
default: no
203203
required: false
204-
205204

206205
events:
207206
- type: firebase.extensions.export-user-data.v1.firestore

extensions/export-user-data/functions/__tests__/custom_hook/badResponse.test.ts

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,61 +14,61 @@
1414
* limitations under the License.
1515
*/
1616

17-
import * as admin from "firebase-admin";
18-
import waitForExpect from "wait-for-expect";
19-
import { UserRecord } from "firebase-functions/v1/auth";
17+
import * as admin from 'firebase-admin';
18+
import waitForExpect from 'wait-for-expect';
19+
import { UserRecord } from 'firebase-functions/v1/auth';
2020
import {
2121
createFirebaseUser,
2222
resetFirebaseData,
2323
validateCompleteRecord,
2424
validateCSVFile,
2525
validatePendingRecord,
26-
} from "../helpers";
27-
import setupEnvironment from "../helpers/setupEnvironment";
28-
import config from "../../src/config";
29-
import { fetchFromCustomHook } from "../../src/utils";
26+
} from '../helpers';
27+
import setupEnvironment from '../helpers/setupEnvironment';
28+
import config from '../../src/config';
29+
import { fetchFromCustomHook } from '../../src/utils';
3030

31-
const fft = require("firebase-functions-test")();
31+
const fft = require('firebase-functions-test')();
3232

3333
if (!admin.apps.length) {
3434
admin.initializeApp();
3535
}
3636

3737
setupEnvironment();
38-
jest.spyOn(admin, "initializeApp").mockImplementation();
38+
jest.spyOn(admin, 'initializeApp').mockImplementation();
3939

40-
import * as funcs from "../../src/index";
40+
import * as funcs from '../../src/index';
4141

4242
/** prepare extension functions */
4343

4444
// const exportUserDatafn = fft.wrap(funcs.exportUserData);
4545

46-
jest.mock("../../src/config", () => ({
46+
jest.mock('../../src/config', () => ({
4747
cloudStorageBucketDefault: process.env.STORAGE_BUCKET,
48-
cloudStorageExportDirectory: "exports",
49-
firestoreExportsCollection: "exports",
48+
cloudStorageExportDirectory: 'exports',
49+
firestoreExportsCollection: 'exports',
5050
customHookEndpoint: `http://localhost:1123`,
5151
zip: false,
5252
}));
5353

54-
jest.mock("../../src/utils", () => {
55-
const data = "asdas akksfd";
54+
jest.mock('../../src/utils', () => {
55+
const data = 'asdas akksfd';
5656

5757
const response = Promise.resolve({
5858
ok: true,
5959
status: 200,
6060
text: () => JSON.stringify(data),
6161
});
6262

63-
const original = jest.requireActual("../../src/utils"); // Step 2.
63+
const original = jest.requireActual('../../src/utils'); // Step 2.
6464
return {
6565
...original,
6666
fetchFromCustomHook: () => response,
6767
};
6868
});
6969

70-
describe("extension", () => {
71-
describe("custom hooks", () => {
70+
describe('extension', () => {
71+
describe('custom hooks', () => {
7272
let user: UserRecord;
7373
let unsubscribe;
7474

@@ -80,19 +80,19 @@ describe("extension", () => {
8080
afterEach(async () => {
8181
jest.clearAllMocks();
8282
await resetFirebaseData(user);
83-
if (unsubscribe && typeof unsubscribe === "function") {
83+
if (unsubscribe && typeof unsubscribe === 'function') {
8484
unsubscribe();
8585
}
8686
});
8787

88-
xtest("should skip on bad response from hook", async () => {
88+
xtest('should skip on bad response from hook', async () => {
8989
/** Create a top level collection with a single document */
9090
const ref = await admin
9191
.firestore()
92-
.collection("users")
92+
.collection('users')
9393
.doc(user.uid)
94-
.collection("comments")
95-
.add({ content: "hello world" });
94+
.collection('comments')
95+
.add({ content: 'hello world' });
9696

9797
/** Create a subcollection with a single document */
9898

@@ -110,12 +110,12 @@ describe("extension", () => {
110110
const { exportId } = await exportUserDatafn.call(
111111
{},
112112
{ uid: user.uid },
113-
{ auth: { uid: user.uid } }
113+
{ auth: { uid: user.uid } },
114114
);
115115

116116
// // // expect exportId to be defined and to be a string
117117
expect(exportId).toBeDefined();
118-
expect(typeof exportId).toBe("string");
118+
expect(typeof exportId).toBe('string');
119119

120120
// // // wait for the record to have been updated
121121
await waitForExpect(() => {
@@ -148,7 +148,7 @@ describe("extension", () => {
148148
const expectedFileName = `users_${user.uid}_comments.firestore.csv`;
149149
const expectedCSVData = [
150150
[
151-
"FIRESTORE",
151+
'FIRESTORE',
152152
`users/${user.uid}/comments/${commentId}`,
153153
// TODO: why so many quotation marks?
154154
'"{""content"":""hello world""}"',

extensions/export-user-data/functions/__tests__/custom_hook/databasePaths.test.ts

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,48 +14,48 @@
1414
* limitations under the License.
1515
*/
1616

17-
import * as admin from "firebase-admin";
18-
import waitForExpect from "wait-for-expect";
19-
import { UserRecord } from "firebase-functions/v1/auth";
17+
import * as admin from 'firebase-admin';
18+
import waitForExpect from 'wait-for-expect';
19+
import { UserRecord } from 'firebase-functions/v1/auth';
2020
import {
2121
createFirebaseUser,
2222
generateDatabaseNode,
2323
resetFirebaseData,
2424
validateCompleteRecord,
2525
validateCSVFile,
2626
validatePendingRecord,
27-
} from "../helpers";
28-
import setupEnvironment from "../helpers/setupEnvironment";
29-
import config from "../../src/config";
30-
import fetch from "node-fetch";
31-
import { fetchFromCustomHook } from "../../src/utils";
32-
import { Response, Headers } from "node-fetch";
27+
} from '../helpers';
28+
import setupEnvironment from '../helpers/setupEnvironment';
29+
import config from '../../src/config';
30+
import fetch from 'node-fetch';
31+
import { fetchFromCustomHook } from '../../src/utils';
32+
import { Response, Headers } from 'node-fetch';
3333

34-
const fft = require("firebase-functions-test")();
34+
const fft = require('firebase-functions-test')();
3535

3636
if (!admin.apps.length) {
3737
admin.initializeApp();
3838
}
3939

4040
setupEnvironment();
41-
jest.spyOn(admin, "initializeApp").mockImplementation();
41+
jest.spyOn(admin, 'initializeApp').mockImplementation();
4242

43-
import * as funcs from "../../src/index";
43+
import * as funcs from '../../src/index';
4444

4545
/** prepare extension functions */
4646

4747
// const exportUserDatafn = fft.wrap(funcs.exportUserData);
4848

49-
jest.mock("../../src/config", () => ({
49+
jest.mock('../../src/config', () => ({
5050
cloudStorageBucketDefault: process.env.STORAGE_BUCKET,
51-
cloudStorageExportDirectory: "exports",
52-
firestoreExportsCollection: "exports",
51+
cloudStorageExportDirectory: 'exports',
52+
firestoreExportsCollection: 'exports',
5353
customHookEndpoint: `http://localhost:1123`,
5454
zip: false,
5555
}));
5656

57-
jest.mock("../../src/utils", () => {
58-
const data = { databasePaths: ["{UID}"] };
57+
jest.mock('../../src/utils', () => {
58+
const data = { databasePaths: ['{UID}'] };
5959

6060
const response = Promise.resolve({
6161
ok: true,
@@ -64,15 +64,15 @@ jest.mock("../../src/utils", () => {
6464
text: () => JSON.stringify(data),
6565
});
6666

67-
const original = jest.requireActual("../../src/utils"); // Step 2.
67+
const original = jest.requireActual('../../src/utils'); // Step 2.
6868
return {
6969
...original,
7070
fetchFromCustomHook: () => response,
7171
};
7272
});
7373

74-
describe("extension", () => {
75-
describe("custom hooks", () => {
74+
describe('extension', () => {
75+
describe('custom hooks', () => {
7676
let user: UserRecord;
7777
let unsubscribe;
7878

@@ -84,13 +84,13 @@ describe("extension", () => {
8484
afterEach(async () => {
8585
jest.clearAllMocks();
8686
await resetFirebaseData();
87-
if (unsubscribe && typeof unsubscribe === "function") {
87+
if (unsubscribe && typeof unsubscribe === 'function') {
8888
unsubscribe();
8989
}
9090
});
9191

92-
test("can subcollection a top level collection with an id of {userId} to a csv", async () => {
93-
const ref = await generateDatabaseNode({ foo: "bar" }, user.uid);
92+
test('can subcollection a top level collection with an id of {userId} to a csv', async () => {
93+
const ref = await generateDatabaseNode({ foo: 'bar' }, user.uid);
9494
const exportUserDatafn = fft.wrap(funcs.exportUserData);
9595

9696
// watch the exports collection for changes
@@ -104,11 +104,11 @@ describe("extension", () => {
104104
const { exportId } = await exportUserDatafn.call(
105105
{},
106106
{ uid: user.uid },
107-
{ auth: { uid: user.uid } }
107+
{ auth: { uid: user.uid } },
108108
);
109109
// // expect exportId to be defined and to be a string
110110
expect(exportId).toBeDefined();
111-
expect(typeof exportId).toBe("string");
111+
expect(typeof exportId).toBe('string');
112112

113113
// wait for the record to have been updated
114114
await waitForExpect(() => {
@@ -140,7 +140,7 @@ describe("extension", () => {
140140
const expectedFileName = `${user.uid}.database.csv`;
141141
const expectedCSVData = [
142142
[
143-
"DATABASE",
143+
'DATABASE',
144144
`${user.uid}/${ref.key}`,
145145
// TODO: why so many quotation marks?
146146
'"{""foo"":""bar""}"',

0 commit comments

Comments
 (0)