Skip to content

Commit

Permalink
Merge pull request #300 from firebase/next
Browse files Browse the repository at this point in the history
May 7, 2020 Release
  • Loading branch information
Ashley Gau authored May 7, 2020
2 parents 7c69e04 + e17e61a commit f71d621
Show file tree
Hide file tree
Showing 30 changed files with 167 additions and 120 deletions.
28 changes: 18 additions & 10 deletions .github/workflows/scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ create_github_release(){

created=$(echo "$response" | python -c "import sys, json; data = json.load(sys.stdin); print(data.get('id', sys.stdin))")
if [ "$created" != "$response" ]; then
echo "release created successfully"
printf "release created successfully!\n"
else
echo "release failed to create; "
printf "release failed to create; "
printf "\n%s\n" "$body"
printf "\n%s\n" "$response"
exit 1;
Expand Down Expand Up @@ -87,9 +87,9 @@ update_github_release(){

updated=$(echo "$response" | python -c "import sys, json; data = json.load(sys.stdin); print(data.get('id', sys.stdin))")
if [ "$updated" != "$response" ]; then
echo "release updated successfully"
printf "release updated successfully!\n"
else
echo "release failed to update; "
printf "release failed to update; "
printf "\n%s\n" "$body"
printf "\n%s\n" "$response"
exit 1;
Expand Down Expand Up @@ -119,16 +119,24 @@ create_or_update_github_release() {

release_id=$(echo "$response" | python -c "import sys, json; data = json.load(sys.stdin); print(data.get('id', 'Not Found'))")
if [ "$release_id" != "Not Found" ]; then
echo "Existing release (${release_id}) found for $release_tag - updating it ... "
update_github_release "$release_name" "$release_body" "$release_tag" "$release_id"
existing_release_body=$(echo "$response" | python -c "import sys, json; data = json.load(sys.stdin); print(data.get('body', ''))")
existing_release_body=$(json_escape "$existing_release_body")
# Only update it if the release body is different (this can happen if a change log is manually updated)
printf "Existing release (%s) found for %s - " "$release_id" "$release_tag"
if [ "$existing_release_body" != "$release_body" ]; then
printf "updating it with updated release body ... "
update_github_release "$release_name" "$release_body" "$release_tag" "$release_id"
else
printf "skipping it as release body is already up to date.\n"
fi
else
response_message=$(echo "$response" | python -c "import sys, json; data = json.load(sys.stdin); print(data.get('message', 'OK'))")
if [ "$response_message" != "OK" ]; then
echo "Failed to create/update release '$release_name' -> GitHub API request failed with response: $response_message"
response_message=$(echo "$response" | python -c "import sys, json; data = json.load(sys.stdin); print(data.get('message'))")
if [ "$response_message" != "Not Found" ]; then
echo "Failed to query release '$release_name' -> GitHub API request failed with response: $response_message"
echo "$response"
exit 1;
else
echo "Creating new release '$release_tag' ... "
printf "Creating new release '%s' ... " "$release_tag"
create_github_release "$release_name" "$release_body" "$release_tag"
fi
fi
Expand Down
5 changes: 0 additions & 5 deletions .huskyrc

This file was deleted.

10 changes: 6 additions & 4 deletions auth-mailchimp-sync/extension.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ resources:

params:
- param: LOCATION
type: select
label: Cloud Functions location
description: >-
Where do you want to deploy the functions created for this extension?
type: select
options:
- label: Iowa (us-central1)
value: us-central1
Expand All @@ -84,6 +84,8 @@ params:
value: europe-west1
- label: London (europe-west2)
value: europe-west2
- label: Frankfurt (europe-west3)
value: europe-west3
- label: Hong Kong (asia-east2)
value: asia-east2
- label: Tokyo (asia-northeast1)
Expand All @@ -93,33 +95,33 @@ params:
immutable: true

- param: MAILCHIMP_API_KEY
type: string
label: Mailchimp API key
description: >-
What is your Mailchimp API key? To obtain a Mailchimp API key, go to your
[Mailchimp account](https://admin.mailchimp.com/account/api/).
type: string
example: a1b2c3d4e5f6g7
required: true

- param: MAILCHIMP_AUDIENCE_ID
type: string
label: Audience ID
description: >-
What is the Mailchimp Audience ID to which you want to subscribe new
users? To find your Audience ID: visit https://admin.mailchimp.com/lists,
click on the desired audience or create a new audience, then select
**Settings**. Look for **Audience ID** (for example, `27735fc60a`).
type: string
example: 1ab2345c67
required: true

- param: MAILCHIMP_CONTACT_STATUS
type: select
label: Contact status
description: >-
When the extension adds a new user to the Mailchimp audience, what is
their initial status? This value can be `subscribed` or `pending`.
`subscribed` means the user can receive campaigns; `pending` means the
user still needs to opt-in to receive campaigns.
type: select
options:
- label: Subscribed
value: subscribed
Expand Down
7 changes: 4 additions & 3 deletions auth-mailchimp-sync/functions/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
* limitations under the License.
*/
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Expand All @@ -37,7 +38,7 @@ try {
catch (err) {
logs.initError(err);
}
exports.addUserToList = functions.handler.auth.user.onCreate((user) => __awaiter(this, void 0, void 0, function* () {
exports.addUserToList = functions.handler.auth.user.onCreate((user) => __awaiter(void 0, void 0, void 0, function* () {
logs.start();
if (!mailchimp) {
logs.mailchimpNotInitialized();
Expand All @@ -61,7 +62,7 @@ exports.addUserToList = functions.handler.auth.user.onCreate((user) => __awaiter
logs.errorAddUser(err);
}
}));
exports.removeUserFromList = functions.handler.auth.user.onDelete((user) => __awaiter(this, void 0, void 0, function* () {
exports.removeUserFromList = functions.handler.auth.user.onDelete((user) => __awaiter(void 0, void 0, void 0, function* () {
logs.start();
if (!mailchimp) {
logs.mailchimpNotInitialized();
Expand Down
2 changes: 1 addition & 1 deletion auth-mailchimp-sync/functions/lib/logs.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
Object.defineProperty(exports, "__esModule", { value: true });
const config_1 = require("./config");
exports.obfuscatedConfig = Object.assign({}, config_1.default, { mailchimpApiKey: "<omitted>" });
exports.obfuscatedConfig = Object.assign(Object.assign({}, config_1.default), { mailchimpApiKey: "<omitted>" });
exports.complete = () => {
console.log("Completed execution of extension");
};
Expand Down
24 changes: 13 additions & 11 deletions delete-user-data/extension.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ resources:

params:
- param: LOCATION
type: select
label: Cloud Functions location
description: >-
Where do you want to deploy the functions created for this extension?
You usually want a location close to your database or Storage bucket.
For help selecting a location, refer to the [location selection
guide](https://firebase.google.com/docs/functions/locations).
type: select
options:
- label: Iowa (us-central1)
value: us-central1
Expand All @@ -85,6 +85,8 @@ params:
value: europe-west1
- label: London (europe-west2)
value: europe-west2
- label: Frankfurt (europe-west3)
value: europe-west3
- label: Hong Kong (asia-east2)
value: asia-east2
- label: Tokyo (asia-northeast1)
Expand All @@ -94,10 +96,7 @@ params:
immutable: true

- param: FIRESTORE_PATHS
type: string
label: Cloud Firestore paths
example: users/{UID},admins/{UID}
required: false
description: >-
Which paths in your Cloud Firestore instance contain user data? Leave
empty if you don't use Cloud Firestore.
Expand All @@ -108,14 +107,17 @@ params:
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}`.
type: string
example: users/{UID},admins/{UID}
required: false

- param: FIRESTORE_DELETE_MODE
type: select
label: Cloud Firestore delete mode
description: >-
(Only applicable if you use the `Cloud Firestore paths` parameter.) How do
you want to delete Cloud Firestore documents? To also delete documents in
subcollections, set this parameter to `recursive`.
type: select
options:
- label: Recursive
value: recursive
Expand All @@ -125,10 +127,7 @@ params:
required: true

- param: RTDB_PATHS
type: string
label: Realtime Database paths
example: users/{UID},admins/{UID}
required: false
description: >-
Which paths in your Realtime Database instance contain user data? Leave
empty if you don't use Realtime Database.
Expand All @@ -137,12 +136,12 @@ params:
of the deleted user with `{UID}`.
For example: `users/{UID},admins/{UID}`.
type: string
example: users/{UID},admins/{UID}
required: false

- param: STORAGE_PATHS
type: string
label: Cloud Storage paths
example: "{DEFAULT}/{UID}-pic.png,my-awesome-app-logs/{UID}-logs.txt"
required: false
description: >-
Where in Google Cloud Storage do you store user data? Leave empty if you
don't use Cloud Storage.
Expand All @@ -158,3 +157,6 @@ params:
`{DEFAULT}/{UID}-pic.png,my-app-logs/{UID}-logs.txt`. To *also* delete 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}`.
type: string
example: "{DEFAULT}/{UID}-pic.png,my-awesome-app-logs/{UID}-logs.txt"
required: false
5 changes: 5 additions & 0 deletions firestore-bigquery-export/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## Version 0.1.5

fixed - TypeError: Cannot read property 'constructor' of null. (Issue #284)
fixed - Filtered out blob (buffer) data types from being stored as strings in BigQuery.

## Version 0.1.4

fixed - Converted circular structure to JSON error. (Issue #236)
Expand Down
18 changes: 10 additions & 8 deletions 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.4
version: 0.1.5
specVersion: v1beta

displayName: Export Collections to BigQuery
Expand Down Expand Up @@ -60,14 +60,14 @@ resources:

params:
- param: LOCATION
type: select
label: Cloud Functions location
description: >-
Where do you want to deploy the functions created for this extension? You
usually want a location close to your database. For help selecting a
location, refer to the [location selection
guide](https://firebase.google.com/docs/functions/locations). Note that
this extension locates your BigQuery dataset in `us-central1`.
type: select
options:
- label: Iowa (us-central1)
value: us-central1
Expand All @@ -79,6 +79,8 @@ params:
value: europe-west1
- label: London (europe-west2)
value: europe-west2
- label: Frankfurt (europe-west3)
value: europe-west3
- label: Hong Kong (asia-east2)
value: asia-east2
- label: Tokyo (asia-northeast1)
Expand All @@ -88,41 +90,41 @@ params:
immutable: true

- param: COLLECTION_PATH
type: string
label: Collection path
description: >-
What is the path of the collection that you would like to export? You may
use `{wildcard}` notation to match a subcollection of all documents in a
collection (for example: `chatrooms/{chatid}/posts`).
default: posts
type: string
example: posts
default: posts
required: true

- param: DATASET_ID
type: string
label: Dataset ID
description: >-
What ID would you like to use for your BigQuery dataset? This extension
will create the dataset, if it doesn't already exist.
type: string
example: firestore_export
validationRegex: "^[a-zA-Z0-9_]+$"
validationErrorMessage: >
BigQuery dataset IDs must be alphanumeric (plus underscores) and must be
no more than 1024 characters.
default: firestore_export
example: firestore_export
required: true

- param: TABLE_ID
type: string
label: Table ID
description: >-
What identifying prefix would you like to use for your table and view
inside your BigQuery dataset? This extension will create the table and
view, if they don't already exist.
type: string
example: posts
validationRegex: "^[a-zA-Z0-9_]+$"
validationErrorMessage: >
BigQuery table IDs must be alphanumeric (plus underscores) and must be no
more than 1024 characters.
default: posts
example: posts
required: true
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"url": "github.com/firebase/extensions.git",
"directory": "firestore-bigquery-export/firestore-bigquery-change-tracker"
},
"version": "1.1.5",
"version": "1.1.7",
"description": "Core change-tracker library for Cloud Firestore Collection BigQuery Exports",
"main": "./lib/index.js",
"scripts": {
Expand All @@ -23,6 +23,7 @@
"license": "Apache-2.0",
"dependencies": {
"@google-cloud/bigquery": "^4.7.0",
"@types/traverse": "^0.6.32",
"firebase-admin": "^7.1.1",
"firebase-functions": "^2.2.1",
"generate-schema": "^2.6.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,22 @@ export class FirestoreBigQueryEventHistoryTracker
if (typeof eventData === "undefined") {
return undefined;
}
const data = traverse(eventData).map((property) => {
if (
property.constructor &&
property.constructor.name === firebase.firestore.DocumentReference.name
) {
return property.path;
}

return property;
const data = traverse<traverse.Traverse<any>>(eventData).map(function(
property
) {
if (property && property.constructor) {
if (property.constructor.name === "Buffer") {
this.remove();
}

if (
property.constructor.name ===
firebase.firestore.DocumentReference.name
) {
this.update(property.path);
}
}
});

return data;
Expand Down
2 changes: 1 addition & 1 deletion firestore-bigquery-export/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"author": "Jan Wyszynski <[email protected]>",
"license": "Apache-2.0",
"dependencies": {
"@firebaseextensions/firestore-bigquery-change-tracker": "^1.1.5",
"@firebaseextensions/firestore-bigquery-change-tracker": "^1.1.6",
"@google-cloud/bigquery": "^2.1.0",
"@types/chai": "^4.1.6",
"chai": "^4.2.0",
Expand Down
Loading

0 comments on commit f71d621

Please sign in to comment.