Skip to content

Commit

Permalink
Merge pull request #564 from firebase/next
Browse files Browse the repository at this point in the history
Jan 14, 2021 Release
  • Loading branch information
jhuleatt authored Jan 14, 2021
2 parents 1953a6d + 74a5992 commit 3aa9fd5
Show file tree
Hide file tree
Showing 64 changed files with 253 additions and 1,163 deletions.
4 changes: 4 additions & 0 deletions delete-user-data/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## Version 0.1.8

fixed - fixed an issue where delete-user-data didn't recognize {DEFAULT} Storage bucket (#532)

## Version 0.1.7

feature - Adds an option to select an alternative database instance (#505)
Expand Down
2 changes: 1 addition & 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.7
version: 0.1.8
specVersion: v1beta

displayName: Delete User Data
Expand Down
1 change: 1 addition & 0 deletions delete-user-data/functions/lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ exports.default = {
firestoreDeleteMode: process.env.FIRESTORE_DELETE_MODE,
rtdbPaths: process.env.RTDB_PATHS,
storagePaths: process.env.STORAGE_PATHS,
storageBucketDefault: process.env.STORAGE_BUCKET,
SELECTED_DATABASE_INSTANCE: process.env.SELECTED_DATABASE_INSTANCE,
};
2 changes: 1 addition & 1 deletion delete-user-data/functions/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const clearStorageData = async (storagePaths, uid) => {
const parts = path.split("/");
const bucketName = parts[0];
const bucket = bucketName === "{DEFAULT}"
? admin.storage().bucket()
? admin.storage().bucket(config_1.default.storageBucketDefault)
: admin.storage().bucket(bucketName);
const prefix = parts.slice(1).join("/");
try {
Expand Down
1 change: 1 addition & 0 deletions delete-user-data/functions/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ export default {
firestoreDeleteMode: process.env.FIRESTORE_DELETE_MODE,
rtdbPaths: process.env.RTDB_PATHS,
storagePaths: process.env.STORAGE_PATHS,
storageBucketDefault: process.env.STORAGE_BUCKET,
SELECTED_DATABASE_INSTANCE: process.env.SELECTED_DATABASE_INSTANCE,
};
2 changes: 1 addition & 1 deletion delete-user-data/functions/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ const clearStorageData = async (storagePaths: string, uid: string) => {
const bucketName = parts[0];
const bucket =
bucketName === "{DEFAULT}"
? admin.storage().bucket()
? admin.storage().bucket(config.storageBucketDefault)
: admin.storage().bucket(bucketName);
const prefix = parts.slice(1).join("/");
try {
Expand Down
6 changes: 6 additions & 0 deletions firestore-bigquery-export/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## Version 0.1.11

feature - Add stringified_map schema type to gen-schema-view script (#518)

fixed - Switch from `console.log` to `functions.logger.log` for cleaner log outputs.

## Version 0.1.10

feature - Added a new parameter that allows customization of the BigQuery dataset location (#462)
Expand Down
2 changes: 1 addition & 1 deletion firestore-bigquery-export/extension.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

name: firestore-bigquery-export
version: 0.1.10
version: 0.1.11
specVersion: v1beta

displayName: Export Collections to BigQuery
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
export const mockConsoleLog = jest.spyOn(console, "log").mockImplementation();
import { logger } from "firebase-functions";

export const mockConsoleLog = jest.spyOn(logger, "log").mockImplementation();

export const mockConsoleError = jest
.spyOn(console, "error")
.spyOn(logger, "error")
.mockImplementation();
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { logger } from "firebase-functions";
import * as functionsTestInit from "../node_modules/firebase-functions-test";
import mockedEnv from "../node_modules/mocked-env";

Expand All @@ -20,11 +21,11 @@ jest.mock("@firebaseextensions/firestore-bigquery-change-tracker", () => ({

jest.mock("../src/logs", () => ({
start: jest.fn(() =>
console.log("Started execution of extension with configuration", config)
logger.log("Started execution of extension with configuration", config)
),
init: jest.fn(() => {}),
error: jest.fn(() => {}),
complete: jest.fn(() => console.log("Completed execution of extension")),
complete: jest.fn(() => logger.log("Completed execution of extension")),
}));

const defaultEnvironment = {
Expand Down
69 changes: 35 additions & 34 deletions firestore-bigquery-export/functions/lib/logs.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.timestampMissingValue = exports.start = exports.init = exports.error = exports.dataTypeInvalid = exports.dataInserting = exports.dataInserted = exports.complete = exports.bigQueryViewValidating = exports.bigQueryViewValidated = exports.bigQueryViewUpToDate = exports.bigQueryViewUpdating = exports.bigQueryViewUpdated = exports.bigQueryViewAlreadyExists = exports.bigQueryViewCreating = exports.bigQueryViewCreated = exports.bigQueryUserDefinedFunctionCreated = exports.bigQueryUserDefinedFunctionCreating = exports.bigQueryTableValidating = exports.bigQueryTableValidated = exports.bigQueryTableUpToDate = exports.bigQueryTableUpdating = exports.bigQueryTableUpdated = exports.bigQueryTableCreating = exports.bigQueryTableCreated = exports.bigQueryTableAlreadyExists = exports.bigQueryLatestSnapshotViewQueryCreated = exports.bigQueryErrorRecordingDocumentChange = exports.bigQueryDatasetExists = exports.bigQueryDatasetCreating = exports.bigQueryDatasetCreated = exports.arrayFieldInvalid = void 0;
/*
* Copyright 2019 Google LLC
*
Expand All @@ -14,103 +16,102 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.timestampMissingValue = exports.start = exports.init = exports.error = exports.dataTypeInvalid = exports.dataInserting = exports.dataInserted = exports.complete = exports.bigQueryViewValidating = exports.bigQueryViewValidated = exports.bigQueryViewUpToDate = exports.bigQueryViewUpdating = exports.bigQueryViewUpdated = exports.bigQueryViewAlreadyExists = exports.bigQueryViewCreating = exports.bigQueryViewCreated = exports.bigQueryUserDefinedFunctionCreated = exports.bigQueryUserDefinedFunctionCreating = exports.bigQueryTableValidating = exports.bigQueryTableValidated = exports.bigQueryTableUpToDate = exports.bigQueryTableUpdating = exports.bigQueryTableUpdated = exports.bigQueryTableCreating = exports.bigQueryTableCreated = exports.bigQueryTableAlreadyExists = exports.bigQueryLatestSnapshotViewQueryCreated = exports.bigQueryErrorRecordingDocumentChange = exports.bigQueryDatasetExists = exports.bigQueryDatasetCreating = exports.bigQueryDatasetCreated = exports.arrayFieldInvalid = void 0;
const firebase_functions_1 = require("firebase-functions");
const config_1 = require("./config");
exports.arrayFieldInvalid = (fieldName) => {
console.warn(`Array field '${fieldName}' does not contain an array, skipping`);
firebase_functions_1.logger.warn(`Array field '${fieldName}' does not contain an array, skipping`);
};
exports.bigQueryDatasetCreated = (datasetId) => {
console.log(`Created BigQuery dataset: ${datasetId}`);
firebase_functions_1.logger.log(`Created BigQuery dataset: ${datasetId}`);
};
exports.bigQueryDatasetCreating = (datasetId) => {
console.log(`Creating BigQuery dataset: ${datasetId}`);
firebase_functions_1.logger.log(`Creating BigQuery dataset: ${datasetId}`);
};
exports.bigQueryDatasetExists = (datasetId) => {
console.log(`BigQuery dataset already exists: ${datasetId}`);
firebase_functions_1.logger.log(`BigQuery dataset already exists: ${datasetId}`);
};
exports.bigQueryErrorRecordingDocumentChange = (e) => {
console.error(`Error recording document changes.`, e);
firebase_functions_1.logger.error(`Error recording document changes.`, e);
};
exports.bigQueryLatestSnapshotViewQueryCreated = (query) => {
console.log(`BigQuery latest snapshot view query:\n${query}`);
firebase_functions_1.logger.log(`BigQuery latest snapshot view query:\n${query}`);
};
exports.bigQueryTableAlreadyExists = (tableName, datasetName) => {
console.log(`BigQuery table with name ${tableName} already ` +
firebase_functions_1.logger.log(`BigQuery table with name ${tableName} already ` +
`exists in dataset ${datasetName}!`);
};
exports.bigQueryTableCreated = (tableName) => {
console.log(`Created BigQuery table: ${tableName}`);
firebase_functions_1.logger.log(`Created BigQuery table: ${tableName}`);
};
exports.bigQueryTableCreating = (tableName) => {
console.log(`Creating BigQuery table: ${tableName}`);
firebase_functions_1.logger.log(`Creating BigQuery table: ${tableName}`);
};
exports.bigQueryTableUpdated = (tableName) => {
console.log(`Updated existing BigQuery table: ${tableName}`);
firebase_functions_1.logger.log(`Updated existing BigQuery table: ${tableName}`);
};
exports.bigQueryTableUpdating = (tableName) => {
console.log(`Updating existing BigQuery table: ${tableName}`);
firebase_functions_1.logger.log(`Updating existing BigQuery table: ${tableName}`);
};
exports.bigQueryTableUpToDate = (tableName) => {
console.log(`BigQuery table: ${tableName} is up to date`);
firebase_functions_1.logger.log(`BigQuery table: ${tableName} is up to date`);
};
exports.bigQueryTableValidated = (tableName) => {
console.log(`Validated existing BigQuery table: ${tableName}`);
firebase_functions_1.logger.log(`Validated existing BigQuery table: ${tableName}`);
};
exports.bigQueryTableValidating = (tableName) => {
console.log(`Validating existing BigQuery table: ${tableName}`);
firebase_functions_1.logger.log(`Validating existing BigQuery table: ${tableName}`);
};
exports.bigQueryUserDefinedFunctionCreating = (functionDefinition) => {
console.log(`Creating BigQuery User-defined Function:\n${functionDefinition}`);
firebase_functions_1.logger.log(`Creating BigQuery User-defined Function:\n${functionDefinition}`);
};
exports.bigQueryUserDefinedFunctionCreated = (functionDefinition) => {
console.log(`Created BigQuery User-defined Function:\n${functionDefinition}`);
firebase_functions_1.logger.log(`Created BigQuery User-defined Function:\n${functionDefinition}`);
};
exports.bigQueryViewCreated = (viewName) => {
console.log(`Created BigQuery view: ${viewName}`);
firebase_functions_1.logger.log(`Created BigQuery view: ${viewName}`);
};
exports.bigQueryViewCreating = (viewName) => {
console.log(`Creating BigQuery view: ${viewName}`);
firebase_functions_1.logger.log(`Creating BigQuery view: ${viewName}`);
};
exports.bigQueryViewAlreadyExists = (viewName, datasetName) => {
console.log(`View with id ${viewName} already exists in dataset ${datasetName}.`);
firebase_functions_1.logger.log(`View with id ${viewName} already exists in dataset ${datasetName}.`);
};
exports.bigQueryViewUpdated = (viewName) => {
console.log(`Updated existing BigQuery view: ${viewName}`);
firebase_functions_1.logger.log(`Updated existing BigQuery view: ${viewName}`);
};
exports.bigQueryViewUpdating = (viewName) => {
console.log(`Updating existing BigQuery view: ${viewName}`);
firebase_functions_1.logger.log(`Updating existing BigQuery view: ${viewName}`);
};
exports.bigQueryViewUpToDate = (viewName) => {
console.log(`BigQuery view: ${viewName} is up to date`);
firebase_functions_1.logger.log(`BigQuery view: ${viewName} is up to date`);
};
exports.bigQueryViewValidated = (viewName) => {
console.log(`Validated existing BigQuery view: ${viewName}`);
firebase_functions_1.logger.log(`Validated existing BigQuery view: ${viewName}`);
};
exports.bigQueryViewValidating = (viewName) => {
console.log(`Validating existing BigQuery view: ${viewName}`);
firebase_functions_1.logger.log(`Validating existing BigQuery view: ${viewName}`);
};
exports.complete = () => {
console.log("Completed execution of extension");
firebase_functions_1.logger.log("Completed execution of extension");
};
exports.dataInserted = (rowCount) => {
console.log(`Inserted ${rowCount} row(s) of data into BigQuery`);
firebase_functions_1.logger.log(`Inserted ${rowCount} row(s) of data into BigQuery`);
};
exports.dataInserting = (rowCount) => {
console.log(`Inserting ${rowCount} row(s) of data into BigQuery`);
firebase_functions_1.logger.log(`Inserting ${rowCount} row(s) of data into BigQuery`);
};
exports.dataTypeInvalid = (fieldName, fieldType, dataType) => {
console.warn(`Field '${fieldName}' has invalid data. Expected: ${fieldType}, received: ${dataType}`);
firebase_functions_1.logger.warn(`Field '${fieldName}' has invalid data. Expected: ${fieldType}, received: ${dataType}`);
};
exports.error = (err) => {
console.error("Error when mirroring data to BigQuery", err);
firebase_functions_1.logger.error("Error when mirroring data to BigQuery", err);
};
exports.init = () => {
console.log("Initializing extension with configuration", config_1.default);
firebase_functions_1.logger.log("Initializing extension with configuration", config_1.default);
};
exports.start = () => {
console.log("Started execution of extension with configuration", config_1.default);
firebase_functions_1.logger.log("Started execution of extension with configuration", config_1.default);
};
exports.timestampMissingValue = (fieldName) => {
console.warn(`Missing value for timestamp field: ${fieldName}, using default timestamp instead.`);
firebase_functions_1.logger.warn(`Missing value for timestamp field: ${fieldName}, using default timestamp instead.`);
};
Loading

0 comments on commit 3aa9fd5

Please sign in to comment.