@@ -164,6 +164,15 @@ export interface WorkflowHandle<T extends Workflow = Workflow> extends BaseWorkf
164
164
options ?: WorkflowUpdateOptions & { args ?: Args }
165
165
) : Promise < WorkflowUpdateHandle < Ret > > ;
166
166
167
+ /**
168
+ * Get a handle to an Update.
169
+ */
170
+ getUpdateHandle < Ret > (
171
+ updateId : string ,
172
+ workflowId : string ,
173
+ options ?: GetWorkflowUpdateHandleOptions
174
+ ) : WorkflowUpdateHandle < Ret > ;
175
+
167
176
/**
168
177
* Query a running or completed Workflow.
169
178
*
@@ -296,6 +305,9 @@ export interface WorkflowResultOptions {
296
305
followRuns ?: boolean ;
297
306
}
298
307
308
+ /**
309
+ * Options for {@link WorkflowClient.getHandle}
310
+ */
299
311
export interface GetWorkflowHandleOptions extends WorkflowResultOptions {
300
312
/**
301
313
* ID of the first execution in the Workflow execution chain.
@@ -351,7 +363,7 @@ export interface WorkflowUpdateHandle<Ret> {
351
363
/**
352
364
* The ID of the Run of the Workflow being targeted by this Update request.
353
365
*/
354
- workflowRunId : string ;
366
+ workflowRunId ? : string ;
355
367
356
368
/**
357
369
* Return the result of the Update.
@@ -360,6 +372,16 @@ export interface WorkflowUpdateHandle<Ret> {
360
372
result ( ) : Promise < Ret > ;
361
373
}
362
374
375
+ /**
376
+ * Options for {@link WorkflowHandle.getUpdateHandle}
377
+ */
378
+ export interface GetWorkflowUpdateHandleOptions {
379
+ /**
380
+ * The ID of the Run of the Workflow targeted by the Update.
381
+ */
382
+ workflowRunId ?: string ;
383
+ }
384
+
363
385
/**
364
386
* Options for {@link WorkflowClient.list}
365
387
*/
@@ -775,15 +797,19 @@ export class WorkflowClient extends BaseClient {
775
797
}
776
798
777
799
protected createWorkflowUpdateHandle < Ret > (
778
- input : WorkflowStartUpdateInput ,
779
- { updateId, workflowRunId, outcome } : WorkflowStartUpdateOutput
800
+ updateId : string ,
801
+ workflowId : string ,
802
+ options ?: GetWorkflowUpdateHandleOptions ,
803
+ outcome ?: temporal . api . update . v1 . IOutcome
780
804
) : WorkflowUpdateHandle < Ret > {
805
+ const workflowRunId = options ?. workflowRunId ;
781
806
return {
782
807
updateId,
783
- workflowId : input . workflowExecution . workflowId ,
808
+ workflowId,
784
809
workflowRunId,
785
810
result : async ( ) => {
786
- const completedOutcome = outcome ?? ( await this . _pollForUpdateOutcome ( updateId , input . workflowExecution ) ) ;
811
+ const completedOutcome =
812
+ outcome ?? ( await this . _pollForUpdateOutcome ( updateId , { workflowId, runId : workflowRunId } ) ) ;
787
813
if ( completedOutcome . failure ) {
788
814
throw new WorkflowUpdateFailedError (
789
815
'Workflow Update failed' ,
@@ -1048,7 +1074,12 @@ export class WorkflowClient extends BaseClient {
1048
1074
options : opts ,
1049
1075
} ;
1050
1076
const output = await fn ( input ) ;
1051
- return this . createWorkflowUpdateHandle < Ret > ( input , output ) ;
1077
+ return this . createWorkflowUpdateHandle < Ret > (
1078
+ output . updateId ,
1079
+ input . workflowExecution . workflowId ,
1080
+ { workflowRunId : output . workflowRunId } ,
1081
+ output . outcome
1082
+ ) ;
1052
1083
} ;
1053
1084
1054
1085
return {
@@ -1113,7 +1144,6 @@ export class WorkflowClient extends BaseClient {
1113
1144
options
1114
1145
) ;
1115
1146
} ,
1116
-
1117
1147
async executeUpdate < Ret , Args extends any [ ] > (
1118
1148
def : UpdateDefinition < Ret , Args > | string ,
1119
1149
options ?: WorkflowUpdateOptions & { args ?: Args }
@@ -1126,7 +1156,13 @@ export class WorkflowClient extends BaseClient {
1126
1156
) ;
1127
1157
return await handle . result ( ) ;
1128
1158
} ,
1129
-
1159
+ getUpdateHandle < Ret > (
1160
+ updateId : string ,
1161
+ workflowId : string ,
1162
+ options ?: GetWorkflowUpdateHandleOptions
1163
+ ) : WorkflowUpdateHandle < Ret > {
1164
+ return this . client . createWorkflowUpdateHandle ( updateId , workflowId , options ) ;
1165
+ } ,
1130
1166
async signal < Args extends any [ ] > ( def : SignalDefinition < Args > | string , ...args : Args ) : Promise < void > {
1131
1167
const next = this . client . _signalWorkflowHandler . bind ( this . client ) ;
1132
1168
const fn = composeInterceptors ( interceptors , 'signal' , next ) ;
0 commit comments