1313 * See the License for the specific language governing permissions and
1414 * limitations under the License.
1515 */
16- import * as admin from "firebase-admin" ;
1716import * as bigquery from "@google-cloud/bigquery" ;
1817import { DocumentReference } from "firebase-admin/firestore" ;
1918import * as traverse from "traverse" ;
@@ -45,25 +44,9 @@ import { tableRequiresUpdate, viewRequiresUpdate } from "./checkUpdates";
4544import { parseErrorMessage , waitForInitialization } from "./utils" ;
4645
4746export { RawChangelogSchema , RawChangelogViewSchema } from "./schema" ;
48-
49- export interface FirestoreBigQueryEventHistoryTrackerConfig {
50- datasetId : string ;
51- tableId : string ;
52- datasetLocation ?: string | undefined ;
53- transformFunction ?: string | undefined ;
54- timePartitioning ?: string | undefined ;
55- timePartitioningField ?: string | undefined ;
56- timePartitioningFieldType ?: string | undefined ;
57- timePartitioningFirestoreField ?: string | undefined ;
58- clustering : string [ ] | null ;
59- databaseId ?: string | undefined ;
60- wildcardIds ?: boolean ;
61- bqProjectId ?: string | undefined ;
62- backupTableId ?: string | undefined ;
63- useNewSnapshotQuerySyntax ?: boolean ;
64- skipInit ?: boolean ;
65- kmsKeyName ?: string | undefined ;
66- }
47+ import type { Config } from "./types" ;
48+ import { PartitioningConfig } from "./partitioning/config" ;
49+ export type { Config } from "./types" ;
6750
6851/**
6952 * An FirestoreEventHistoryTracker that exports data to BigQuery.
@@ -80,12 +63,15 @@ export class FirestoreBigQueryEventHistoryTracker
8063{
8164 bq : bigquery . BigQuery ;
8265 _initialized : boolean = false ;
66+ partitioningConfig : PartitioningConfig ;
8367
84- constructor ( public config : FirestoreBigQueryEventHistoryTrackerConfig ) {
68+ constructor ( public config : Config ) {
8569 this . bq = new bigquery . BigQuery ( ) ;
8670
8771 this . bq . projectId = config . bqProjectId || process . env . PROJECT_ID ;
8872
73+ this . partitioningConfig = new PartitioningConfig ( this . config . partitioning ) ;
74+
8975 if ( ! this . config . datasetLocation ) {
9076 this . config . datasetLocation = "us" ;
9177 }
@@ -96,7 +82,7 @@ export class FirestoreBigQueryEventHistoryTracker
9682 await this . initialize ( ) ;
9783 }
9884
99- const partitionHandler = new Partitioning ( this . config ) ;
85+ const partitionHandler = new Partitioning ( this . partitioningConfig ) ;
10086
10187 const rows = events . map ( ( event ) => {
10288 const partitionValue = partitionHandler . getPartitionValue ( event ) ;
@@ -327,7 +313,7 @@ export class FirestoreBigQueryEventHistoryTracker
327313 const dataset = this . bigqueryDataset ( ) ;
328314 const table = dataset . table ( changelogName ) ;
329315 const [ tableExists ] = await table . exists ( ) ;
330- const partitioning = new Partitioning ( this . config , table ) ;
316+ const partitioning = new Partitioning ( this . partitioningConfig , table ) ;
331317 const clustering = new Clustering ( this . config , table ) ;
332318
333319 if ( tableExists ) {
0 commit comments