Skip to content

Commit b40a55c

Browse files
committed
update comments, move inteceptor adapters to wf client creation
1 parent 1ac9aca commit b40a55c

File tree

4 files changed

+19
-7
lines changed

4 files changed

+19
-7
lines changed

packages/client/src/interceptor-adapters.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { WorkflowClientInterceptor, WorkflowStartInput, WorkflowStartOutput } from './interceptors';
22

3-
// Apply adapters to workflow client interceptor.
43
export function adaptWorkflowClientInterceptor(i: WorkflowClientInterceptor): WorkflowClientInterceptor {
54
return adaptLegacyStartInterceptor(i);
65
}

packages/client/src/interceptors.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,7 @@ export interface WorkflowClientInterceptor {
132132
/**
133133
* Intercept a service call to startWorkflowExecution
134134
*
135-
* Successor to {@link start}. Unlike {@link start}, this method returns
136-
* start details via {@link WorkflowStartOutput}.
135+
* This method returns start details via {@link WorkflowStartOutput}.
137136
*
138137
* If you implement this method,
139138
* {@link signalWithStart} most likely needs to be implemented too

packages/client/src/workflow-client.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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')

packages/client/src/workflow-options.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export interface WorkflowOptions extends CommonWorkflowOptions {
5656
versioningOverride?: VersioningOverride;
5757

5858
/**
59-
* Potentially reduce the latency to start this workflow by encouraging the server to
59+
* Potentially reduce the latency to start this workflow by requesting that the server
6060
* start it on a local worker running with this same client.
6161
*/
6262
requestEagerStart?: boolean;

0 commit comments

Comments
 (0)