11import { NotifyResponse , Waiter } from "../types" ;
2- import { FlowControl , Client as QStashClient } from "@upstash/qstash" ;
2+ import { FlowControl , PublishRequest , Client as QStashClient } from "@upstash/qstash" ;
33import { makeGetWaitersRequest , makeNotifyRequest } from "./utils" ;
44import { getWorkflowRunId } from "../utils" ;
55import { triggerFirstInvocation } from "../workflow-requests" ;
@@ -190,6 +190,11 @@ export class Client {
190190 * with `wfr_`.
191191 * @param retries retry to use in the initial request. in the rest of
192192 * the workflow, `retries` option of the `serve` will be used.
193+ * @param flowControl Settings for controlling the number of active requests
194+ * and number of requests per second with the same key.
195+ * @param delay Delay for the workflow run. This is used to delay the
196+ * execution of the workflow run. The delay is in seconds or can be passed
197+ * as a string with a time unit (e.g. "1h", "30m", "15s").
193198 * @returns workflow run id
194199 */
195200 public async trigger ( {
@@ -199,13 +204,15 @@ export class Client {
199204 workflowRunId,
200205 retries,
201206 flowControl,
207+ delay,
202208 } : {
203209 url : string ;
204210 body ?: unknown ;
205211 headers ?: Record < string , string > ;
206212 workflowRunId ?: string ;
207213 retries ?: number ;
208214 flowControl ?: FlowControl ;
215+ delay ?: PublishRequest [ "delay" ] ;
209216 } ) : Promise < { workflowRunId : string } > {
210217 const finalWorkflowRunId = getWorkflowRunId ( workflowRunId ) ;
211218 const context = new WorkflowContext ( {
@@ -223,6 +230,7 @@ export class Client {
223230 const result = await triggerFirstInvocation ( {
224231 workflowContext : context ,
225232 telemetry : undefined , // can't know workflow telemetry here
233+ delay,
226234 } ) ;
227235 if ( result . isOk ( ) ) {
228236 return { workflowRunId : finalWorkflowRunId } ;
0 commit comments