@firebaseextensions/firestore-bigquery-change-tracker 1.1.18 → 1.1.19

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.
@@ -254,6 +254,10 @@ class FirestoreBigQueryEventHistoryTracker {
254
254
  const documentIdColExists = fields.find((column) => column.name === "document_id");
255
255
  const pathParamsColExists = fields.find((column) => column.name === "path_params");
256
256
  const oldDataColExists = fields.find((column) => column.name === "old_data");
257
+ if (!oldDataColExists) {
258
+ fields.push(schema_1.oldDataField);
259
+ logs.addNewColumn(this.rawChangeLogTableName(), schema_1.oldDataField.name);
260
+ }
257
261
  if (!documentIdColExists) {
258
262
  fields.push(schema_1.documentIdField);
259
263
  logs.addNewColumn(this.rawChangeLogTableName(), schema_1.documentIdField.name);
@@ -262,7 +266,6 @@ class FirestoreBigQueryEventHistoryTracker {
262
266
  fields.push(schema_1.documentPathParams);
263
267
  logs.addNewColumn(this.rawChangeLogTableName(), schema_1.documentPathParams.name);
264
268
  }
265
- await partitioning.addPartitioningToSchema(metadata.schema.fields);
266
269
  /** Updated table metadata if required */
267
270
  const shouldUpdate = await checkUpdates_1.tableRequiresUpdate({
268
271
  table,
@@ -272,7 +275,17 @@ class FirestoreBigQueryEventHistoryTracker {
272
275
  oldDataColExists,
273
276
  });
274
277
  if (shouldUpdate) {
278
+ /** set partitioning */
279
+ await partitioning.addPartitioningToSchema(metadata.schema.fields);
280
+ /** update table metadata with changes. */
275
281
  await table.setMetadata(metadata);
282
+ logs.updatingMetadata(this.rawChangeLogTableName(), {
283
+ table,
284
+ config: this.config,
285
+ documentIdColExists,
286
+ pathParamsColExists,
287
+ oldDataColExists,
288
+ });
276
289
  }
277
290
  }
278
291
  else {
@@ -333,8 +346,17 @@ class FirestoreBigQueryEventHistoryTracker {
333
346
  schema,
334
347
  useLegacyQuery: !this.config.useNewSnapshotQuerySyntax,
335
348
  });
336
- logs.addNewColumn(this.rawLatestView(), schema_1.documentIdField.name);
349
+ if (!documentIdColExists) {
350
+ logs.addNewColumn(this.rawLatestView(), schema_1.documentIdField.name);
351
+ }
337
352
  await view.setMetadata(metadata);
353
+ logs.updatingMetadata(this.rawLatestView(), {
354
+ metadata,
355
+ config: this.config,
356
+ documentIdColExists,
357
+ pathParamsColExists,
358
+ oldDataColExists,
359
+ });
338
360
  }
339
361
  }
340
362
  else {
@@ -15,7 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.getNewPartitionField = exports.RawChangelogSchema = exports.RawChangelogViewSchema = exports.documentPathParams = exports.documentIdField = exports.longitudeField = exports.latitudeField = exports.timestampField = exports.operationField = exports.eventIdField = exports.documentNameField = exports.dataField = void 0;
18
+ exports.getNewPartitionField = exports.RawChangelogSchema = exports.RawChangelogViewSchema = exports.oldDataField = exports.documentPathParams = exports.documentIdField = exports.longitudeField = exports.latitudeField = exports.timestampField = exports.operationField = exports.eventIdField = exports.documentNameField = exports.dataField = void 0;
19
19
  const bigQueryField = (name, type, mode, fields) => ({
20
20
  fields,
21
21
  mode: mode || "NULLABLE",
@@ -43,6 +43,12 @@ exports.documentPathParams = {
43
43
  type: "STRING",
44
44
  description: "JSON string representing wildcard params with Firestore Document ids",
45
45
  };
46
+ exports.oldDataField = {
47
+ name: "old_data",
48
+ mode: "NULLABLE",
49
+ type: "STRING",
50
+ description: "The full JSON representation of the document state before the indicated operation is applied. This field will be null for CREATE operations.",
51
+ };
46
52
  /*
47
53
  * We cannot specify a schema for view creation, and all view columns default
48
54
  * to the NULLABLE mode.
package/lib/logs.js CHANGED
@@ -15,7 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.failedToInitializeWait = exports.tableCreationError = exports.invalidClustering = exports.hourAndDatePartitioningWarning = exports.invalidTableReference = exports.invalidProjectIdWarning = exports.cannotPartitionExistingTable = exports.removedClustering = exports.updatedClustering = exports.bigQueryTableInsertErrors = exports.firestoreTimePartitioningParametersWarning = exports.firestoreTimePartitionFieldError = exports.addPartitionFieldColumn = exports.addNewColumn = exports.timestampMissingValue = exports.error = exports.dataTypeInvalid = exports.dataInserting = exports.dataInsertRetried = 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.bigQuerySchemaViewCreated = exports.bigQueryLatestSnapshotViewQueryCreated = exports.bigQueryErrorRecordingDocumentChange = exports.bigQueryDatasetExists = exports.bigQueryDatasetCreating = exports.bigQueryDatasetCreated = exports.arrayFieldInvalid = void 0;
18
+ exports.updatingMetadata = exports.failedToInitializeWait = exports.tableCreationError = exports.invalidClustering = exports.hourAndDatePartitioningWarning = exports.invalidTableReference = exports.invalidProjectIdWarning = exports.cannotPartitionExistingTable = exports.removedClustering = exports.updatedClustering = exports.bigQueryTableInsertErrors = exports.firestoreTimePartitioningParametersWarning = exports.firestoreTimePartitionFieldError = exports.addPartitionFieldColumn = exports.addNewColumn = exports.timestampMissingValue = exports.error = exports.dataTypeInvalid = exports.dataInserting = exports.dataInsertRetried = 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.bigQuerySchemaViewCreated = exports.bigQueryLatestSnapshotViewQueryCreated = exports.bigQueryErrorRecordingDocumentChange = exports.bigQueryDatasetExists = exports.bigQueryDatasetCreating = exports.bigQueryDatasetCreated = exports.arrayFieldInvalid = void 0;
19
19
  const firebase_functions_1 = require("firebase-functions");
20
20
  exports.arrayFieldInvalid = (fieldName) => {
21
21
  firebase_functions_1.logger.warn(`Array field '${fieldName}' does not contain an array, skipping`);
@@ -173,3 +173,6 @@ exports.tableCreationError = (table, message) => {
173
173
  exports.failedToInitializeWait = (message) => {
174
174
  firebase_functions_1.logger.warn(`Failed while waiting to initialize.`, message);
175
175
  };
176
+ exports.updatingMetadata = (tableName, resources) => {
177
+ firebase_functions_1.logger.info(`Updated Metadata on ${tableName}, ${JSON.stringify(resources)})`);
178
+ };
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.18",
8
+ "version": "1.1.19",
9
9
  "description": "Core change-tracker library for Cloud Firestore Collection BigQuery Exports",
10
10
  "main": "./lib/index.js",
11
11
  "scripts": {