@@ -510,6 +510,7 @@ export class WorkflowClient extends BaseClient {
510510 ...filterNullAndUndefined ( options ?? { } ) ,
511511 loadedDataConverter : this . dataConverter ,
512512 } ;
513+ this . options . interceptors = this . adaptInterceptors ( ) ;
513514 }
514515
515516 /**
@@ -1638,18 +1639,31 @@ export class WorkflowClient extends BaseClient {
16381639 return decodeCountWorkflowExecutionsResponse ( response ) ;
16391640 }
16401641
1641- protected getOrMakeInterceptors ( workflowId : string , runId ?: string ) : WorkflowClientInterceptor [ ] {
1642+ protected adaptInterceptors ( ) : WorkflowClientInterceptors | WorkflowClientInterceptor [ ] {
16421643 if ( typeof this . options . interceptors === 'object' && 'calls' in this . options . interceptors ) {
16431644 // eslint-disable-next-line deprecation/deprecation
16441645 const factories = ( this . options . interceptors as WorkflowClientInterceptors ) . calls ?? [ ] ;
1645- return factories . map ( ( ctor ) => ctor ( { workflowId, runId } ) ) ;
1646+ // Compose factory functions with adapters.
1647+ return {
1648+ calls : factories . map ( ( ctor ) => {
1649+ return ( input ) => adaptWorkflowClientInterceptor ( ctor ( input ) ) ;
1650+ } ) ,
1651+ } ;
16461652 }
16471653 const interceptors = Array . isArray ( this . options . interceptors )
16481654 ? ( this . options . interceptors as WorkflowClientInterceptor [ ] )
16491655 : [ ] ;
1650- // Apply adapters to workflow client interceptors.
16511656 return interceptors . map ( ( i ) => adaptWorkflowClientInterceptor ( i ) ) ;
16521657 }
1658+
1659+ protected getOrMakeInterceptors ( workflowId : string , runId ?: string ) : WorkflowClientInterceptor [ ] {
1660+ if ( typeof this . options . interceptors === 'object' && 'calls' in this . options . interceptors ) {
1661+ // eslint-disable-next-line deprecation/deprecation
1662+ const factories = ( this . options . interceptors as WorkflowClientInterceptors ) . calls ?? [ ] ;
1663+ return factories . map ( ( ctor ) => ctor ( { workflowId, runId } ) ) ;
1664+ }
1665+ return Array . isArray ( this . options . interceptors ) ? ( this . options . interceptors as WorkflowClientInterceptor [ ] ) : [ ] ;
1666+ }
16531667}
16541668
16551669@SymbolBasedInstanceOfError ( 'QueryRejectedError' )
0 commit comments