@@ -44,31 +44,9 @@ import { initializeLatestView } from "./initializeLatestView";
44
44
import { logger , LogLevel } from "../logger" ;
45
45
46
46
export { RawChangelogSchema , RawChangelogViewSchema } from "./schema" ;
47
-
48
- export interface FirestoreBigQueryEventHistoryTrackerConfig {
49
- datasetId : string ;
50
- tableId : string ;
51
- firestoreInstanceId ?: 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
- useMaterializedView ?: boolean ;
67
- useIncrementalMaterializedView ?: boolean ;
68
- maxStaleness ?: string ;
69
- refreshIntervalMinutes ?: number ;
70
- logLevel ?: LogLevel | string ;
71
- }
47
+ import type { Config } from "./types" ;
48
+ import { PartitioningConfig } from "./partitioning/config" ;
49
+ export type { Config } from "./types" ;
72
50
73
51
/**
74
52
* An FirestoreEventHistoryTracker that exports data to BigQuery.
@@ -85,12 +63,15 @@ export class FirestoreBigQueryEventHistoryTracker
85
63
{
86
64
bq : bigquery . BigQuery ;
87
65
_initialized : boolean = false ;
66
+ partitioningConfig : PartitioningConfig ;
88
67
89
- constructor ( public config : FirestoreBigQueryEventHistoryTrackerConfig ) {
68
+ constructor ( public config : Config ) {
90
69
this . bq = new bigquery . BigQuery ( ) ;
91
70
92
71
this . bq . projectId = config . bqProjectId || process . env . PROJECT_ID ;
93
72
73
+ this . partitioningConfig = new PartitioningConfig ( this . config . partitioning ) ;
74
+
94
75
if ( ! this . config . datasetLocation ) {
95
76
this . config . datasetLocation = "us" ;
96
77
}
@@ -106,7 +87,7 @@ export class FirestoreBigQueryEventHistoryTracker
106
87
await this . initialize ( ) ;
107
88
}
108
89
109
- const partitionHandler = new Partitioning ( this . config ) ;
90
+ const partitionHandler = new Partitioning ( this . partitioningConfig ) ;
110
91
111
92
const rows = events . map ( ( event ) => {
112
93
const partitionValue = partitionHandler . getPartitionValue ( event ) ;
@@ -348,7 +329,7 @@ export class FirestoreBigQueryEventHistoryTracker
348
329
const dataset = this . bigqueryDataset ( ) ;
349
330
const table = dataset . table ( changelogName ) ;
350
331
const [ tableExists ] = await table . exists ( ) ;
351
- const partitioning = new Partitioning ( this . config , table ) ;
332
+ const partitioning = new Partitioning ( this . partitioningConfig , table ) ;
352
333
const clustering = new Clustering ( this . config , table ) ;
353
334
354
335
if ( tableExists ) {
0 commit comments