Skip to content

Commit

Permalink
Merge pull request #1469 from firebase/next
Browse files Browse the repository at this point in the history
Feb-15-2023 release
  • Loading branch information
dackers86 authored Feb 15, 2023
2 parents 32d00ae + 0696bfe commit 1ec1d70
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@firebaseextensions/fs-bq-schema-views",
"version": "0.4.5",
"version": "0.4.6",
"description": "Generate strongly-typed BigQuery Views based on raw JSON",
"main": "./lib/index.js",
"repository": {
Expand Down Expand Up @@ -55,4 +55,4 @@
"ts-node": "^7.0.1",
"typescript": "^4.9.3"
}
}
}
10 changes: 6 additions & 4 deletions firestore-bigquery-export/scripts/gen-schema-view/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,12 @@ async function run(): Promise<number> {
process.env.GOOGLE_CLOUD_PROJECT = config.projectId;

// Initialize Firebase
firebase.initializeApp({
credential: firebase.credential.applicationDefault(),
databaseURL: `https://${config.projectId}.firebaseio.com`,
});
if (!firebase.apps.length) {
firebase.initializeApp({
credential: firebase.credential.applicationDefault(),
databaseURL: `https://${config.projectId}.firebaseio.com`,
});
}

// @ts-ignore string not assignable to enum
if (Object.keys(config.schemas).length === 0) {
Expand Down
4 changes: 2 additions & 2 deletions firestore-bigquery-export/scripts/import/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@firebaseextensions/fs-bq-import-collection",
"version": "0.1.16",
"version": "0.1.17",
"description": "Import a Firestore Collection into a BigQuery Changelog Table",
"main": "./lib/index.js",
"repository": {
Expand Down Expand Up @@ -48,4 +48,4 @@
"ts-node": "^10.9.1",
"typescript": "^4.2.4"
}
}
}
11 changes: 6 additions & 5 deletions firestore-bigquery-export/scripts/import/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,12 @@ const run = async (): Promise<number> => {
// Initialize Firebase
// This uses applicationDefault to authenticate
// Please see https://cloud.google.com/docs/authentication/production
firebase.initializeApp({
credential: firebase.credential.applicationDefault(),
databaseURL: `https://${projectId}.firebaseio.com`,
});

if (!firebase.apps.length) {
firebase.initializeApp({
credential: firebase.credential.applicationDefault(),
databaseURL: `https://${projectId}.firebaseio.com`,
});
}
// Set project ID, so it can be used in BigQuery initialization
process.env.PROJECT_ID = projectId;
process.env.GOOGLE_CLOUD_PROJECT = projectId;
Expand Down
4 changes: 4 additions & 0 deletions firestore-send-email/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## Version 0.1.23

fixed - added template check when no message exists

## Version 0.1.22

fixed - fix typo in extension
Expand Down
2 changes: 1 addition & 1 deletion firestore-send-email/extension.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

name: firestore-send-email
version: 0.1.22
version: 0.1.23
specVersion: v1beta

displayName: Trigger Email
Expand Down
36 changes: 36 additions & 0 deletions firestore-send-email/functions/__tests__/e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,42 @@ describe("e2e testing", () => {
});
}, 8000);

test("should successfully send an email with a basic template", async (): Promise<void> => {
/** create basic template */
const template = await templatesCollection.add({
subject: "@{{username}} is now following you!",
});

/** Add a record with the template and no message object */
const record = {
to: "[email protected]",
template: {
name: template.id,
data: {
username: "ada",
},
},
};

/** Add a new mail document */
const doc = await mailCollection.add(record);

/** Check the email response */
return new Promise((resolve, reject) => {
const unsubscribe = doc.onSnapshot((snapshot) => {
const document = snapshot.data();

if (document.delivery && document.delivery.info) {
expect(document.delivery.info.accepted[0]).toEqual(record.to);
expect(document.delivery.info.response).toContain("250 Accepted");

unsubscribe();
resolve();
}
});
});
});

afterAll(() => {
server.close();
});
Expand Down
4 changes: 2 additions & 2 deletions firestore-send-email/functions/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,8 @@ async function processWrite(
const payload = snapshot.data();

// We expect the payload to contain a message object describing the email
// to be sent. If it doesn't, we can't do anything.
if (typeof payload.message !== "object") {
// to be sent. If it doesn't and is not a template, we can't do anything.
if (typeof payload.message !== "object" && !payload.template) {
logs.invalidMessage(payload.message);
return false;
}
Expand Down

0 comments on commit 1ec1d70

Please sign in to comment.