@@ -22,14 +22,12 @@ import {
22
22
SourceSchema ,
23
23
SqliteInputRow ,
24
24
SqliteJsonRow ,
25
- SqliteRow ,
26
25
StreamParseOptions ,
27
26
SyncRules
28
27
} from './types.js' ;
29
28
import { BucketSource } from './BucketSource.js' ;
30
- import { SyncStream } from './streams/stream.js' ;
31
29
import { syncStreamFromSql } from './streams/from_sql.js' ;
32
- import { CompatibilityContext , Quirk } from './quirks .js' ;
30
+ import { CompatibilityContext , CompatibilityEdition , CompatibilityOption } from './compatibility .js' ;
33
31
34
32
const ACCEPT_POTENTIALLY_DANGEROUS_QUERIES = Symbol ( 'ACCEPT_POTENTIALLY_DANGEROUS_QUERIES' ) ;
35
33
@@ -140,16 +138,25 @@ export class SqlSyncRules implements SyncRules {
140
138
return rules ;
141
139
}
142
140
143
- const rawFixedQuirks = parsed . get ( 'fixed_quirks' ) as YAMLSeq < Scalar > | null ;
144
- const fixedQuirks : Quirk [ ] = [ ] ;
145
- if ( rawFixedQuirks != null ) {
146
- for ( const entry of rawFixedQuirks . items ) {
147
- const quirk = Quirk . byName [ entry . value as string ] ;
148
- if ( quirk != null ) {
149
- fixedQuirks . push ( quirk ) ;
141
+ const declaredOptions = parsed . get ( 'config' ) as YAMLMap | null ;
142
+ let compatibility = CompatibilityContext . FULL_BACKWARDS_COMPATIBILITY ;
143
+ if ( declaredOptions != null ) {
144
+ const edition = ( declaredOptions . get ( 'edition' ) ?? CompatibilityEdition . LEGACY ) as CompatibilityEdition ;
145
+ const options = new Map < CompatibilityOption , boolean > ( ) ;
146
+
147
+ for ( const entry of declaredOptions . items ) {
148
+ const {
149
+ key : { value : key } ,
150
+ value : { value }
151
+ } = entry as { key : Scalar < string > ; value : Scalar < boolean > } ;
152
+
153
+ const option = CompatibilityOption . byName [ key ] ;
154
+ if ( option ) {
155
+ options . set ( option , value ) ;
150
156
}
151
- // Note: We don't need a custom warning message for unknown names here, the schema will reject those values.
152
157
}
158
+
159
+ compatibility = new CompatibilityContext ( edition , options ) ;
153
160
}
154
161
155
162
// Bucket definitions using explicit parameter and data queries.
@@ -194,12 +201,13 @@ export class SqlSyncRules implements SyncRules {
194
201
const queryOptions : QueryParseOptions = {
195
202
...options ,
196
203
accept_potentially_dangerous_queries,
197
- priority : parseOptionPriority
204
+ priority : parseOptionPriority ,
205
+ compatibility
198
206
} ;
199
207
const parameters = value . get ( 'parameters' , true ) as unknown ;
200
208
const dataQueries = value . get ( 'data' , true ) as unknown ;
201
209
202
- const descriptor = new SqlBucketDescriptor ( key , CompatibilityContext . ofFixedQuirks ( fixedQuirks ) ) ;
210
+ const descriptor = new SqlBucketDescriptor ( key , compatibility ) ;
203
211
204
212
if ( parameters instanceof Scalar ) {
205
213
rules . withScalar ( parameters , ( q ) => {
@@ -242,7 +250,7 @@ export class SqlSyncRules implements SyncRules {
242
250
accept_potentially_dangerous_queries,
243
251
priority : rules . parsePriority ( value ) ,
244
252
auto_subscribe : value . get ( 'auto_subscribe' , true ) ?. value == true ,
245
- fixedQuirks
253
+ compatibility
246
254
} ;
247
255
248
256
const data = value . get ( 'query' , true ) as unknown ;
@@ -276,7 +284,7 @@ export class SqlSyncRules implements SyncRules {
276
284
continue ;
277
285
}
278
286
279
- const eventDescriptor = new SqlEventDescriptor ( key . toString ( ) , CompatibilityContext . ofFixedQuirks ( fixedQuirks ) ) ;
287
+ const eventDescriptor = new SqlEventDescriptor ( key . toString ( ) , compatibility ) ;
280
288
for ( let item of payloads . items ) {
281
289
if ( ! isScalar ( item ) ) {
282
290
rules . errors . push ( new YamlError ( new Error ( `Payload queries for events must be scalar.` ) ) ) ;
0 commit comments