@@ -22,14 +22,12 @@ import {
2222 SourceSchema ,
2323 SqliteInputRow ,
2424 SqliteJsonRow ,
25- SqliteRow ,
2625 StreamParseOptions ,
2726 SyncRules
2827} from './types.js' ;
2928import { BucketSource } from './BucketSource.js' ;
30- import { SyncStream } from './streams/stream.js' ;
3129import { syncStreamFromSql } from './streams/from_sql.js' ;
32- import { CompatibilityContext , Quirk } from './quirks .js' ;
30+ import { CompatibilityContext , CompatibilityEdition , CompatibilityOption } from './compatibility .js' ;
3331
3432const ACCEPT_POTENTIALLY_DANGEROUS_QUERIES = Symbol ( 'ACCEPT_POTENTIALLY_DANGEROUS_QUERIES' ) ;
3533
@@ -140,16 +138,25 @@ export class SqlSyncRules implements SyncRules {
140138 return rules ;
141139 }
142140
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 ) ;
150156 }
151- // Note: We don't need a custom warning message for unknown names here, the schema will reject those values.
152157 }
158+
159+ compatibility = new CompatibilityContext ( edition , options ) ;
153160 }
154161
155162 // Bucket definitions using explicit parameter and data queries.
@@ -194,12 +201,13 @@ export class SqlSyncRules implements SyncRules {
194201 const queryOptions : QueryParseOptions = {
195202 ...options ,
196203 accept_potentially_dangerous_queries,
197- priority : parseOptionPriority
204+ priority : parseOptionPriority ,
205+ compatibility
198206 } ;
199207 const parameters = value . get ( 'parameters' , true ) as unknown ;
200208 const dataQueries = value . get ( 'data' , true ) as unknown ;
201209
202- const descriptor = new SqlBucketDescriptor ( key , CompatibilityContext . ofFixedQuirks ( fixedQuirks ) ) ;
210+ const descriptor = new SqlBucketDescriptor ( key , compatibility ) ;
203211
204212 if ( parameters instanceof Scalar ) {
205213 rules . withScalar ( parameters , ( q ) => {
@@ -242,7 +250,7 @@ export class SqlSyncRules implements SyncRules {
242250 accept_potentially_dangerous_queries,
243251 priority : rules . parsePriority ( value ) ,
244252 auto_subscribe : value . get ( 'auto_subscribe' , true ) ?. value == true ,
245- fixedQuirks
253+ compatibility
246254 } ;
247255
248256 const data = value . get ( 'query' , true ) as unknown ;
@@ -276,7 +284,7 @@ export class SqlSyncRules implements SyncRules {
276284 continue ;
277285 }
278286
279- const eventDescriptor = new SqlEventDescriptor ( key . toString ( ) , CompatibilityContext . ofFixedQuirks ( fixedQuirks ) ) ;
287+ const eventDescriptor = new SqlEventDescriptor ( key . toString ( ) , compatibility ) ;
280288 for ( let item of payloads . items ) {
281289 if ( ! isScalar ( item ) ) {
282290 rules . errors . push ( new YamlError ( new Error ( `Payload queries for events must be scalar.` ) ) ) ;
0 commit comments