(options: StartWorkflowOptions)
| 113 | } |
| 114 | |
| 115 | async startWorkflow(options: StartWorkflowOptions): Promise<WorkflowStartResult> { |
| 116 | const client = await this.getClient(); |
| 117 | const workflowId = options.workflowId ?? `shipsec-workflow-${randomUUID()}`; |
| 118 | const taskQueue = options.taskQueue ?? this.defaultTaskQueue; |
| 119 | |
| 120 | const argsSummary = this.formatArgsSummary(options.args); |
| 121 | this.logger.log( |
| 122 | `Starting Temporal workflow ${options.workflowType} (workflowId=${workflowId}, taskQueue=${taskQueue}, args=${argsSummary})`, |
| 123 | ); |
| 124 | |
| 125 | // Map workflow type string to function reference |
| 126 | const workflowFn = this.getWorkflowFunction(options.workflowType); |
| 127 | |
| 128 | const handle = await client.start(workflowFn, { |
| 129 | workflowId, |
| 130 | taskQueue, |
| 131 | args: (options.args ?? []) as any, |
| 132 | memo: options.memo, |
| 133 | searchAttributes: options.searchAttributes as any, |
| 134 | }); |
| 135 | |
| 136 | this.logger.log( |
| 137 | `Started Temporal workflow ${handle.workflowId} (run ${handle.firstExecutionRunId})`, |
| 138 | ); |
| 139 | |
| 140 | return { |
| 141 | workflowId: handle.workflowId, |
| 142 | runId: handle.firstExecutionRunId, |
| 143 | taskQueue, |
| 144 | }; |
| 145 | } |
| 146 | |
| 147 | private getWorkflowFunction(workflowType: string) { |
| 148 | switch (workflowType) { |
no test coverage detected