@@ -25,19 +25,8 @@ import { HistoryEvent } from "../orchestration/history-event";
2525import { convertProtoHistoryEvent } from "../utils/history-event-converter" ;
2626import { Logger , ConsoleLogger } from "../types/logger.type" ;
2727
28- /**
29- * Options for scheduling a new orchestration instance.
30- */
31- export interface StartOrchestrationOptions {
32- /** The input to pass to the orchestration. */
33- input ?: TInput ;
34- /** The unique ID for the orchestration instance. If not specified, a new GUID is generated. */
35- instanceId ?: string ;
36- /** The time when the orchestration should start executing. If not specified, starts immediately. */
37- startAt ?: Date ;
38- /** Tags to associate with the orchestration instance. */
39- tags ?: Record < string , string > ;
40- }
28+ // Re-export MetadataGenerator for backward compatibility
29+ export { MetadataGenerator } from "../utils/grpc-helper.util" ;
4130
4231/**
4332 * Options for creating a TaskHubGrpcClient.
@@ -139,36 +128,14 @@ export class TaskHubGrpcClient {
139128 * Schedules a new orchestrator using the DurableTask client.
140129 *
141130 * @param {TOrchestrator | string } orchestrator - The orchestrator or the name of the orchestrator to be scheduled.
142- * @param {TInput | StartOrchestrationOptions } inputOrOptions - The input to pass to the orchestrator, or an options object.
143- * @param {string } instanceId - (Deprecated) Use options object instead. The unique ID for the orchestration instance.
144- * @param {Date } startAt - (Deprecated) Use options object instead. The time when the orchestration should start.
145131 * @return {Promise<string> } A Promise resolving to the unique ID of the scheduled orchestrator instance.
146132 */
147133 async scheduleNewOrchestration (
148134 orchestrator : TOrchestrator | string ,
149- inputOrOptions ?: TInput | StartOrchestrationOptions ,
135+ input ?: TInput ,
150136 instanceId ?: string ,
151137 startAt ?: Date ,
152138 ) : Promise < string > {
153- // Determine if inputOrOptions is an options object or raw input
154- let input : TInput | undefined ;
155- let resolvedInstanceId : string | undefined = instanceId ;
156- let resolvedStartAt : Date | undefined = startAt ;
157- let tags : Record < string , string > | undefined ;
158-
159- if ( inputOrOptions !== null && typeof inputOrOptions === 'object' && ! Array . isArray ( inputOrOptions ) &&
160- ( 'input' in inputOrOptions || 'instanceId' in inputOrOptions || 'startAt' in inputOrOptions || 'tags' in inputOrOptions ) ) {
161- // It's an options object
162- const options = inputOrOptions as StartOrchestrationOptions ;
163- input = options . input ;
164- resolvedInstanceId = options . instanceId ?? instanceId ;
165- resolvedStartAt = options . startAt ?? startAt ;
166- tags = options . tags ;
167- } else {
168- // It's raw input (backward compatible)
169- input = inputOrOptions as TInput ;
170- }
171-
172139 let name ;
173140 if ( typeof orchestrator === "string" ) {
174141 name = orchestrator ;
@@ -177,25 +144,17 @@ export class TaskHubGrpcClient {
177144 }
178145 const req = new pb . CreateInstanceRequest ( ) ;
179146 req . setName ( name ) ;
180- req . setInstanceid ( resolvedInstanceId ?? randomUUID ( ) ) ;
147+ req . setInstanceid ( instanceId ?? randomUUID ( ) ) ;
181148
182149 const i = new StringValue ( ) ;
183150 i . setValue ( JSON . stringify ( input ) ) ;
184151
185152 const ts = new Timestamp ( ) ;
186- ts . fromDate ( new Date ( resolvedStartAt ?. getTime ( ) ?? 0 ) ) ;
153+ ts . fromDate ( new Date ( startAt ?. getTime ( ) ?? 0 ) ) ;
187154
188155 req . setInput ( i ) ;
189156 req . setScheduledstarttimestamp ( ts ) ;
190157
191- // Set tags if provided
192- if ( tags ) {
193- const tagsMap = req . getTagsMap ( ) ;
194- for ( const [ key , value ] of Object . entries ( tags ) ) {
195- tagsMap . set ( key , value ) ;
196- }
197- }
198-
199158 this . _logger . info ( `Starting new ${ name } instance with ID = ${ req . getInstanceid ( ) } ` ) ;
200159
201160 const res = await callWithMetadata < pb . CreateInstanceRequest , pb . CreateInstanceResponse > (
0 commit comments