Skip to content

Commit 1ab5423

Browse files
authored
Merge pull request #248 from firebase/next
04/07/2020 Release
2 parents c6f6b60 + d4c56a5 commit 1ab5423

File tree

42 files changed

+564
-236
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+564
-236
lines changed

auth-mailchimp-sync/POSTINSTALL.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
### See it in action
22

3-
You can test out this extension right away:
3+
You can test out this extension right away!
44

5-
1. Go to your [Authentication dashboard](https://console.firebase.google.com/project/${param:PROJECT_ID}/authentication/users).
5+
1. Go to your [Authentication dashboard](https://console.firebase.google.com/project/${param:PROJECT_ID}/authentication/users) in the Firebase console.
66

77
1. Click **Add User** to add a test user.
88

delete-user-data/POSTINSTALL.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
### See it in action
22

3-
You can test out this extension right away:
3+
You can test out this extension right away!
44

5-
1. Go to your [Authentication dashboard](https://console.firebase.google.com/project/${param:PROJECT_ID}/authentication/users).
5+
1. Go to your [Authentication dashboard](https://console.firebase.google.com/project/${param:PROJECT_ID}/authentication/users) in the Firebase console.
66

7-
1. Click **Add User** to add a test user.
8-
9-
1. Copy the test user's UID to your clipboard.
7+
1. Click **Add User** to add a test user, then copy the test user's UID to your clipboard.
108

119
1. Create a new Cloud Firestore document, a new Realtime Database entry, or upload a new file to Storage - incorporating the user's UID into the path according to the schema that you configured.
1210

firestore-bigquery-export/CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
## Version 0.1.3
2+
3+
feature - Interpret data more easily with column descriptions in the exported BigQuery data (#138).
4+
5+
- The raw changelog now includes column descriptions.
6+
- The schema-views script allows you to specify custom column descriptions.
7+
8+
fixed - Updated `@firebaseextensions/firestore-bigquery-change-tracker` dependency (fixes issues #235 and #225).
9+
110
## Version 0.1.2
211

312
fixed - Added "IF NOT EXISTS" to safely run `fs-bq-schema-views` script multiple times (PR #193).
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# Development Setup
2+
3+
The firestore-bigquery-export extension is split out into 4 node.js packages, three of
4+
which are hosted on [npm](https://www.npmjs.com/search?q=firebaseextensions).
5+
6+
**[firestore-bigquery-change-tracker](https://www.npmjs.com/package/@firebaseextensions/firestore-bigquery-change-tracker)**:
7+
Contains the core interface defintions for document changes. Also exposes an
8+
API for uploading changes to BigQuery. The business-logic associated with
9+
creating the raw changelog and the latest snapshot of live documents in the
10+
changelog also lives in this package.
11+
12+
**[fs-bq-import-collection](https://www.npmjs.com/package/@firebaseextensions/fs-bq-import-collection)**:
13+
Contains a script for resumably importing a firestore collection into BigQuery
14+
using the interface definitions in `firestore-bigquery-change-tracker`.
15+
16+
**[fs-bq-schema-views](https://www.npmjs.com/package/@firebaseextensions/fs-bq-schema-views)**:
17+
Contains a script for generating BigQuery views that provide typed-checked
18+
access to the changelog created in `firestore-bigquery-change-tracker`.
19+
20+
**firestore-bigquery-export-functions (not hosted)**: Contains the definition
21+
for a Google Cloud function that is called on each write to some collection.
22+
The function constructs the relevant change event and calls the API in
23+
`firestore-bigquery-change-tracker` to upload the change to BigQuery.
24+
25+
Here are the dependency edges:
26+
27+
1. [fs-bq-import-collection -> firestore-bigquery-change-tracker](https://github.com/firebase/extensions/blob/next/firestore-bigquery-export/scripts/import/package.json#L27)
28+
1. [firestore-bigquery-export-functions -> firestore-bigquery-change-tracker](https://github.com/firebase/extensions/blob/next/firestore-bigquery-export/package.json#L17)
29+
30+
Note that `fs-bq-schema-views` is a standalone package, and all of these
31+
packages are included at the root of this extension's folder in the firebase
32+
extensions repo.
33+
34+
## Building Locally
35+
36+
### Clean up any local changes (optional)
37+
38+
Make sure you've cleaned up and partial builds:
39+
40+
```
41+
export PKGS="firestore-bigquery-change-tracker scripts/gen-schema-view scripts/import functions ."
42+
43+
for pkg in $PKGS;
44+
do
45+
pushd . && cd $pkg && npm run clean && rm -rf node_modules
46+
popd
47+
done;
48+
```
49+
50+
### Local package.json file pointers
51+
52+
Npm supports using [local paths as
53+
dependencies](https://docs.npmjs.com/files/package.json#local-paths) in package.json.
54+
You'll need to update the following package.json files with local pointers to
55+
the firestore-bigquery-change-tracker package:
56+
57+
1. firestore-bigquery-export/package.json
58+
1. firestore-bigquery-export/scripts/import/package.json
59+
60+
This can be done with jq from the root of this extension's folder:
61+
62+
```
63+
jq '.dependencies."@firebaseextensions/firestore-bigquery-change-tracker" = "file:./firestore-bigquery-change-tracker"' package.json > package.local.json
64+
jq '.dependencies."@firebaseextensions/firestore-bigquery-change-tracker" = "file:../../firestore-bigquery-change-tracker"' scripts/import/package.json > scripts/import/package.local.json
65+
66+
mv package.json package.json.bak
67+
mv scripts/import/package.json scripts/import/package.remote.json.bak
68+
69+
mv package.local.json package.json
70+
mv scripts/import/package.local.json scripts/import/package.json
71+
```
72+
73+
Now, build the components according to the dependency order.
74+
75+
```
76+
export PKGS="firestore-bigquery-change-tracker scripts/import . scripts/gen-schema-view"
77+
78+
for pkg in $PKGS;
79+
do
80+
pushd . && cd $pkg && npm install && npm run build
81+
popd
82+
done;
83+
```
84+
85+
Finally, you can install the extension you just built onto a Firebase-enabled
86+
GCP project with:
87+
88+
```
89+
firebase ext:install ./firestore-bigquery-export --project=project-id
90+
```
91+
92+
## Publishing
93+
94+
_The following instructions are for Firebase team members only._
95+
96+
We publish 3 separate npm packages for this extension. Each follows semver, so
97+
make sure to update the version numbers and corresponding dependencies.
98+
99+
For each package, `cd` into the appropriate directory, then run:
100+
101+
```
102+
npm pack
103+
npm publish
104+
```
105+
106+
In general, you should publish `firestore-bigquery-change-tracker` first, since
107+
it doesn't depend on anything else. You should also only publish _after_ your
108+
changes have been merged into the `next` branch (and before the extension is
109+
released).

firestore-bigquery-export/POSTINSTALL.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
### See it in action
22

3-
You can test out this extension right away:
3+
You can test out this extension right away!
44

5-
1. Go to your [Cloud Firestore dashboard](https://console.firebase.google.com/project/${param:PROJECT_ID}/database/firestore/data).
5+
1. Go to your [Cloud Firestore dashboard](https://console.firebase.google.com/project/${param:PROJECT_ID}/database/firestore/data) in the Firebase console.
66

7-
1. If it doesn't already exist, create the collection you specified during installation: `${param:COLLECTION_PATH}`.
7+
1. If it doesn't already exist, create the collection you specified during installation: `${param:COLLECTION_PATH}`
88

99
1. Create a document in the collection called `bigquery-mirror-test` that contains any fields with any values that you'd like.
1010

firestore-bigquery-export/docs/images/firestore-bigquery-export-dep-diagram.svg

Lines changed: 1 addition & 0 deletions
Loading

firestore-bigquery-export/extension.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# limitations under the License.
1414

1515
name: firestore-bigquery-export
16-
version: 0.1.2
16+
version: 0.1.3
1717
specVersion: v1beta
1818

1919
displayName: Export Collections to BigQuery

firestore-bigquery-export/firestore-bigquery-change-tracker/mocha.opts

Lines changed: 0 additions & 3 deletions
This file was deleted.

firestore-bigquery-export/firestore-bigquery-change-tracker/package.json

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@
55
"url": "github.com/firebase/extensions.git",
66
"directory": "firestore-bigquery-export/firestore-bigquery-change-tracker"
77
},
8-
"version": "1.0.1",
8+
"version": "1.1.2",
99
"description": "Core change-tracker library for Cloud Firestore Collection BigQuery Exports",
1010
"main": "./lib/index.js",
1111
"scripts": {
1212
"build": "npm run clean && npm run compile",
13-
"clean": "rimraf functions/lib",
13+
"clean": "rimraf lib",
1414
"compile": "tsc",
15-
"mocha": "nyc mocha -r ts-node/register --opts mocha.opts",
16-
"test": "npm run mocha",
15+
"test": "jest",
1716
"prepare": "npm run build"
1817
},
1918
"files": [
20-
"lib"
19+
"lib/*.js",
20+
"lib/bigquery/*.js"
2121
],
2222
"author": "Jan Wyszynski <[email protected]>",
2323
"license": "Apache-2.0",
@@ -31,13 +31,14 @@
3131
"sql-formatter": "^2.3.3"
3232
},
3333
"devDependencies": {
34-
"chai": "^4.2.0",
34+
"typescript": "^3.4.5",
3535
"rimraf": "^2.6.3",
36-
"mocha": "^5.0.5",
3736
"nyc": "^14.0.0",
38-
"@types/chai": "^4.1.6",
39-
"@types/mocha": "^5.2.5",
37+
"jest": "^24.9.0",
38+
"chai": "^4.2.0",
4039
"ts-node": "^7.0.1",
41-
"typescript": "^3.4.5"
40+
"ts-jest": "^24.1.0",
41+
"@types/jest": "^24.0.18",
42+
"@types/chai": "^4.1.6"
4243
}
4344
}

firestore-bigquery-export/firestore-bigquery-change-tracker/src/bigquery/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616

1717
import * as bigquery from "@google-cloud/bigquery";
18-
import { firestoreToBQTable } from "./schema";
18+
import { RawChangelogSchema, RawChangelogViewSchema } from "./schema";
1919
import { latestConsistentSnapshotView } from "./snapshot";
2020

2121
import {
@@ -25,6 +25,8 @@ import {
2525
} from "../tracker";
2626
import * as logs from "../logs";
2727

28+
export { RawChangelogSchema, RawChangelogViewSchema } from "./schema";
29+
2830
export interface FirestoreBigQueryEventHistoryTrackerConfig {
2931
datasetId: string;
3032
tableId: string;
@@ -134,7 +136,7 @@ export class FirestoreBigQueryEventHistoryTracker
134136
const options = {
135137
// `friendlyName` needs to be here to satisfy TypeScript
136138
friendlyName: changelogName,
137-
schema: firestoreToBQTable(),
139+
schema: RawChangelogSchema,
138140
};
139141
await table.create(options);
140142
logs.bigQueryTableCreated(changelogName);
@@ -164,6 +166,7 @@ export class FirestoreBigQueryEventHistoryTracker
164166
view: latestSnapshot,
165167
};
166168
await view.create(options);
169+
await view.setMetadata({ schema: RawChangelogViewSchema });
167170
logs.bigQueryViewCreated(this.rawLatestView());
168171
}
169172
return view;

0 commit comments

Comments
 (0)