Skip to content

Commit 7deeca8

Browse files
committed
Make HydratedSyncConfig.definitions private.
1 parent 6652686 commit 7deeca8

2 files changed

Lines changed: 14 additions & 9 deletions

File tree

packages/sync-rules/src/HydratedSyncConfig.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,13 @@ export class HydratedSyncConfig {
4848
eventDescriptors: SqlEventDescriptor[] = [];
4949
compatibility: CompatibilityContext = CompatibilityContext.FULL_BACKWARDS_COMPATIBILITY;
5050

51-
readonly definitions: SyncConfig[];
51+
/**
52+
* The source definitions.
53+
*
54+
* For most functionality, we don't use these directly, but rather use the
55+
* merged definitions such as bucketDataSources.
56+
*/
57+
private readonly sourceDefinitions: SyncConfig[];
5258

5359
/**
5460
* Bucket data sources from underlying SyncConfig definitions.
@@ -76,8 +82,8 @@ export class HydratedSyncConfig {
7682
throw new Error('HydratedSyncRules requires at least one SyncConfig definition');
7783
}
7884

79-
this.definitions = [...definitions];
80-
this.compatibility = assertSharedCompatibility(this.definitions);
85+
this.sourceDefinitions = [...definitions];
86+
this.compatibility = assertSharedCompatibility(this.sourceDefinitions);
8187

8288
this.bucketDataSources = uniqueBy(
8389
definitions.flatMap((definition) => definition.bucketDataSources),
@@ -107,22 +113,22 @@ export class HydratedSyncConfig {
107113

108114
getSourceTables() {
109115
const sourceTables = new Map<string, TablePattern>();
110-
for (const definition of this.definitions) {
116+
for (const definition of this.sourceDefinitions) {
111117
definition.writeSourceTables(sourceTables);
112118
}
113119
return [...sourceTables.values()];
114120
}
115121

116122
tableTriggersEvent(table: SourceTableRef): boolean {
117-
return this.definitions.some((definition) => definition.tableTriggersEvent(table));
123+
return this.sourceDefinitions.some((definition) => definition.tableTriggersEvent(table));
118124
}
119125

120126
tableSyncsData(table: SourceTableRef): boolean {
121-
return this.definitions.some((definition) => definition.tableSyncsData(table));
127+
return this.sourceDefinitions.some((definition) => definition.tableSyncsData(table));
122128
}
123129

124130
tableSyncsParameters(table: SourceTableRef): boolean {
125-
return this.definitions.some((definition) => definition.tableSyncsParameters(table));
131+
return this.sourceDefinitions.some((definition) => definition.tableSyncsParameters(table));
126132
}
127133

128134
getMatchingSources(source: SourceTableRef): MatchingSources {
@@ -221,7 +227,7 @@ export class HydratedSyncConfig {
221227
}
222228

223229
getBucketParameterQuerier(options: GetQuerierOptions): GetBucketParameterQuerierResult {
224-
if (this.definitions.length != 1) {
230+
if (this.sourceDefinitions.length != 1) {
225231
throw new Error('getBucketParameterQuerier() is not supported for HydratedSyncRules with multiple SyncConfigs');
226232
}
227233

packages/sync-rules/test/src/hydrated_sync_rules.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ bucket_definitions:
3333
createParams: hydrationParams
3434
});
3535

36-
expect(hydrated.definitions).toEqual([first, second]);
3736
expect(hydrated.bucketDataSources).toEqual([first.bucketDataSources[0], second.bucketDataSources[0]]);
3837
expect(hydrated.bucketParameterLookupSources).toEqual([second.bucketParameterLookupSources[0]]);
3938
expect(hydrated.bucketSourceDefinitions).toEqual([first.bucketSources[0], second.bucketSources[0]]);

0 commit comments

Comments
 (0)