@@ -511,6 +511,7 @@ export class WorkflowClient extends BaseClient {
511511 ...filterNullAndUndefined ( options ?? { } ) ,
512512 loadedDataConverter : this . dataConverter ,
513513 } ;
514+ this . options . interceptors = this . adaptInterceptors ( ) ;
514515 }
515516
516517 /**
@@ -1645,18 +1646,31 @@ export class WorkflowClient extends BaseClient {
16451646 return decodeCountWorkflowExecutionsResponse ( response ) ;
16461647 }
16471648
1648- protected getOrMakeInterceptors ( workflowId : string , runId ?: string ) : WorkflowClientInterceptor [ ] {
1649+ protected adaptInterceptors ( ) : WorkflowClientInterceptors | WorkflowClientInterceptor [ ] {
16491650 if ( typeof this . options . interceptors === 'object' && 'calls' in this . options . interceptors ) {
16501651 // eslint-disable-next-line deprecation/deprecation
16511652 const factories = ( this . options . interceptors as WorkflowClientInterceptors ) . calls ?? [ ] ;
1652- return factories . map ( ( ctor ) => ctor ( { workflowId, runId } ) ) ;
1653+ // Compose factory functions with adapters.
1654+ return {
1655+ calls : factories . map ( ( ctor ) => {
1656+ return ( input ) => adaptWorkflowClientInterceptor ( ctor ( input ) ) ;
1657+ } ) ,
1658+ } ;
16531659 }
16541660 const interceptors = Array . isArray ( this . options . interceptors )
16551661 ? ( this . options . interceptors as WorkflowClientInterceptor [ ] )
16561662 : [ ] ;
1657- // Apply adapters to workflow client interceptors.
16581663 return interceptors . map ( ( i ) => adaptWorkflowClientInterceptor ( i ) ) ;
16591664 }
1665+
1666+ protected getOrMakeInterceptors ( workflowId : string , runId ?: string ) : WorkflowClientInterceptor [ ] {
1667+ if ( typeof this . options . interceptors === 'object' && 'calls' in this . options . interceptors ) {
1668+ // eslint-disable-next-line deprecation/deprecation
1669+ const factories = ( this . options . interceptors as WorkflowClientInterceptors ) . calls ?? [ ] ;
1670+ return factories . map ( ( ctor ) => ctor ( { workflowId, runId } ) ) ;
1671+ }
1672+ return Array . isArray ( this . options . interceptors ) ? ( this . options . interceptors as WorkflowClientInterceptor [ ] ) : [ ] ;
1673+ }
16601674}
16611675
16621676@SymbolBasedInstanceOfError ( 'QueryRejectedError' )
0 commit comments