@@ -120,17 +120,18 @@ describe('OAuth2Schema', () => {
120120 expect ( parsed . refreshToken ) . toBe ( 'refresh-token-xyz' ) ;
121121 } ) ;
122122
123- it ( 'should use default grant type ' , ( ) => {
123+ it ( 'should accept OAuth2 without optional fields ' , ( ) => {
124124 const auth = {
125- type : 'oauth2' ,
125+ type : 'oauth2' as const ,
126126 clientId : 'client-id' ,
127127 clientSecret : 'client-secret' ,
128128 authorizationUrl : 'https://auth.example.com/authorize' ,
129129 tokenUrl : 'https://auth.example.com/token' ,
130130 } ;
131131
132132 const parsed = OAuth2Schema . parse ( auth ) ;
133- expect ( parsed . grantType ) . toBe ( 'authorization_code' ) ;
133+ expect ( parsed . type ) . toBe ( 'oauth2' ) ;
134+ expect ( parsed . clientId ) . toBe ( 'client-id' ) ;
134135 } ) ;
135136} ) ;
136137
@@ -226,44 +227,33 @@ describe('AuthenticationSchema', () => {
226227describe ( 'FieldMappingSchema' , ( ) => {
227228 it ( 'should accept valid field mapping' , ( ) => {
228229 const mapping : FieldMapping = {
229- sourceField : 'firstName' ,
230- targetField : 'first_name' ,
230+ source : 'firstName' ,
231+ target : 'first_name' ,
231232 dataType : 'string' ,
232233 syncMode : 'bidirectional' ,
233234 } ;
234235
235236 expect ( ( ) => FieldMappingSchema . parse ( mapping ) ) . not . toThrow ( ) ;
236237 } ) ;
237238
238- it ( 'should validate target field snake_case format' , ( ) => {
239- expect ( ( ) => FieldMappingSchema . parse ( {
240- sourceField : 'field' ,
241- targetField : 'valid_field_name' ,
242- } ) ) . not . toThrow ( ) ;
243-
244- expect ( ( ) => FieldMappingSchema . parse ( {
245- sourceField : 'field' ,
246- targetField : 'InvalidField' ,
247- } ) ) . toThrow ( ) ;
248- } ) ;
249-
250239 it ( 'should accept field with transformation' , ( ) => {
251240 const mapping = {
252- sourceField : 'name' ,
253- targetField : 'full_name' ,
241+ source : 'name' ,
242+ target : 'full_name' ,
254243 transform : {
255- type : 'uppercase' ,
244+ type : 'javascript' as const ,
245+ expression : 'value.toUpperCase()' ,
256246 } ,
257247 } ;
258248
259249 const parsed = FieldMappingSchema . parse ( mapping ) ;
260- expect ( parsed . transform ?. type ) . toBe ( 'uppercase ' ) ;
250+ expect ( parsed . transform ?. type ) . toBe ( 'javascript ' ) ;
261251 } ) ;
262252
263253 it ( 'should use default values' , ( ) => {
264254 const mapping = {
265- sourceField : 'field1' ,
266- targetField : 'field_1' ,
255+ source : 'field1' ,
256+ target : 'field_1' ,
267257 } ;
268258
269259 const parsed = FieldMappingSchema . parse ( mapping ) ;
@@ -317,41 +307,42 @@ describe('DataSyncConfigSchema', () => {
317307describe ( 'WebhookConfigSchema' , ( ) => {
318308 it ( 'should accept valid webhook configuration' , ( ) => {
319309 const webhook : WebhookConfig = {
310+ name : 'test_webhook' ,
320311 url : 'https://api.example.com/webhooks' ,
321312 events : [ 'record.created' , 'record.updated' ] ,
322313 secret : 'webhook-secret' ,
323314 signatureAlgorithm : 'hmac_sha256' ,
324- enabled : true ,
325315 } ;
326316
327317 expect ( ( ) => WebhookConfigSchema . parse ( webhook ) ) . not . toThrow ( ) ;
328318 } ) ;
329319
330320 it ( 'should accept webhook with retry configuration' , ( ) => {
331321 const webhook = {
322+ name : 'retry_webhook' ,
332323 url : 'https://api.example.com/webhooks' ,
333324 events : [ 'sync.completed' ] ,
334- retryConfig : {
335- maxAttempts : 3 ,
336- backoffMultiplier : 2 ,
325+ retryPolicy : {
326+ maxRetries : 3 ,
327+ backoffStrategy : 'exponential' as const ,
337328 initialDelayMs : 1000 ,
338329 } ,
339330 } ;
340331
341332 const parsed = WebhookConfigSchema . parse ( webhook ) ;
342- expect ( parsed . retryConfig ?. maxAttempts ) . toBe ( 3 ) ;
333+ expect ( parsed . retryPolicy ?. maxRetries ) . toBe ( 3 ) ;
343334 } ) ;
344335
345336 it ( 'should use default values' , ( ) => {
346337 const webhook = {
338+ name : 'default_webhook' ,
347339 url : 'https://api.example.com/webhooks' ,
348340 events : [ 'record.created' ] ,
349341 } ;
350342
351343 const parsed = WebhookConfigSchema . parse ( webhook ) ;
352344 expect ( parsed . signatureAlgorithm ) . toBe ( 'hmac_sha256' ) ;
353345 expect ( parsed . timeoutMs ) . toBe ( 30000 ) ;
354- expect ( parsed . enabled ) . toBe ( true ) ;
355346 } ) ;
356347} ) ;
357348
@@ -478,12 +469,13 @@ describe('ConnectorSchema', () => {
478469 } ,
479470 fieldMappings : [
480471 {
481- sourceField : 'id' ,
482- targetField : 'external_id' ,
472+ source : 'id' ,
473+ target : 'external_id' ,
483474 } ,
484475 ] ,
485476 webhooks : [
486477 {
478+ name : 'connector_webhook' ,
487479 url : 'https://api.example.com/webhook' ,
488480 events : [ 'record.created' ] ,
489481 } ,
@@ -602,14 +594,14 @@ describe('Connector Integration', () => {
602594 } ,
603595 fieldMappings : [
604596 {
605- sourceField : 'FirstName' ,
606- targetField : 'first_name' ,
597+ source : 'FirstName' ,
598+ target : 'first_name' ,
607599 dataType : 'string' ,
608600 required : true ,
609601 } ,
610602 {
611- sourceField : 'LastName' ,
612- targetField : 'last_name' ,
603+ source : 'LastName' ,
604+ target : 'last_name' ,
613605 dataType : 'string' ,
614606 required : true ,
615607 } ,
0 commit comments