Skip to content

Commit 8e5b890

Browse files
committed
update comments, move inteceptor adapters to wf client creation
1 parent 9e2bfad commit 8e5b890

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
@@ -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')

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)