@firebaseextensions/firestore-bigquery-change-tracker 1.1.40 → 1.1.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,13 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const firebase = require("firebase-admin");
3
+ const admin = require("firebase-admin");
4
+ const app_1 = require("firebase-admin/app");
4
5
  const firestore_1 = require("firebase-admin/firestore");
5
- if (!firebase.apps.length) {
6
- firebase.initializeApp();
7
- firebase.firestore().settings({ ignoreUndefinedProperties: true });
6
+ if (!admin.apps.length) {
7
+ (0, app_1.initializeApp)();
8
8
  }
9
9
  exports.default = async (rows, config, e) => {
10
- const db = (0, firestore_1.getFirestore)();
10
+ const db = (0, firestore_1.getFirestore)(config.firestoreInstanceId);
11
+ db.settings({
12
+ ignoreUndefinedProperties: true,
13
+ });
11
14
  const batchArray = [db.batch()];
12
15
  let operationCounter = 0;
13
16
  let batchIndex = 0;
@@ -5,6 +5,7 @@ export { RawChangelogSchema, RawChangelogViewSchema } from "./schema";
5
5
  export interface FirestoreBigQueryEventHistoryTrackerConfig {
6
6
  datasetId: string;
7
7
  tableId: string;
8
+ firestoreInstanceId?: string;
8
9
  datasetLocation?: string | undefined;
9
10
  transformFunction?: string | undefined;
10
11
  timePartitioning?: string | undefined;
@@ -1,6 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FirestoreBigQueryEventHistoryTracker = exports.RawChangelogViewSchema = exports.RawChangelogSchema = void 0;
4
+ /*
5
+ * Copyright 2019 Google LLC
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * https://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */
4
19
  const bigquery = require("@google-cloud/bigquery");
5
20
  const firestore_1 = require("firebase-admin/firestore");
6
21
  const traverse = require("traverse");
@@ -36,6 +51,8 @@ class FirestoreBigQueryEventHistoryTracker {
36
51
  if (!this.config.datasetLocation) {
37
52
  this.config.datasetLocation = "us";
38
53
  }
54
+ this.config.firestoreInstanceId =
55
+ this.config.firestoreInstanceId || "(default)";
39
56
  logger_1.logger.setLogLevel(this.config.logLevel || logger_1.LogLevel.INFO);
40
57
  }
41
58
  async record(events) {
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Partitioning = void 0;
4
+ const __1 = require("..");
4
5
  const firebase = require("firebase-admin");
5
6
  const logs = require("../logs");
6
7
  const functions = require("firebase-functions");
@@ -143,11 +144,15 @@ class Partitioning {
143
144
  Delete changes events have no data, return early as cannot partition on empty data.
144
145
  **/
145
146
  getPartitionValue(event) {
146
- if (!event.data)
147
+ // When old data is disabled and the operation is delete
148
+ // the data and old data will be null
149
+ if (event.data == null && event.oldData == null)
147
150
  return {};
148
151
  const firestoreFieldName = this.config.timePartitioningFirestoreField;
149
152
  const fieldName = this.config.timePartitioningField;
150
- const fieldValue = event.data[firestoreFieldName];
153
+ const fieldValue = event.operation === __1.ChangeType.DELETE
154
+ ? event.oldData[firestoreFieldName]
155
+ : event.data[firestoreFieldName];
151
156
  if (!fieldName || !fieldValue) {
152
157
  return {};
153
158
  }
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "url": "github.com/firebase/extensions.git",
6
6
  "directory": "firestore-bigquery-export/firestore-bigquery-change-tracker"
7
7
  },
8
- "version": "1.1.40",
8
+ "version": "1.1.42",
9
9
  "description": "Core change-tracker library for Cloud Firestore Collection BigQuery Exports",
10
10
  "main": "./lib/index.js",
11
11
  "scripts": {
@@ -27,8 +27,8 @@
27
27
  "dependencies": {
28
28
  "@google-cloud/bigquery": "^7.6.0",
29
29
  "@google-cloud/resource-manager": "^5.1.0",
30
- "firebase-admin": "^12.0.0",
31
- "firebase-functions": "^4.9.0",
30
+ "firebase-admin": "^13.2.0",
31
+ "firebase-functions": "^6.3.2",
32
32
  "generate-schema": "^2.6.0",
33
33
  "inquirer": "^6.4.0",
34
34
  "lodash": "^4.17.14",