@upstash/workflow 0.2.8-rc-invoke → 0.2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/hono.mjs CHANGED
@@ -1,11 +1,8 @@
1
- import {
2
- createInvokeCallback,
3
- serveManyBase
4
- } from "./chunk-LCZMBGEM.mjs";
5
1
  import {
6
2
  SDK_TELEMETRY,
7
- serveBase
8
- } from "./chunk-IWAW7GIG.mjs";
3
+ serveBase,
4
+ serveManyBase
5
+ } from "./chunk-IPXJZU3K.mjs";
9
6
 
10
7
  // platforms/hono.ts
11
8
  var telemetry = {
@@ -27,20 +24,21 @@ var serve = (routeFunction, options) => {
27
24
  return handler;
28
25
  };
29
26
  var createWorkflow = (...params) => {
30
- const handler = serve(...params);
27
+ const [routeFunction, options = {}] = params;
31
28
  return {
32
- callback: createInvokeCallback(telemetry),
33
- handler,
29
+ routeFunction,
30
+ options,
34
31
  workflowId: void 0
35
32
  };
36
33
  };
37
- var serveMany = (workflows) => {
34
+ var serveMany = (workflows, options) => {
38
35
  return serveManyBase({
39
36
  workflows,
40
- getWorkflowId(params) {
41
- const components = params.req.url.split("/");
42
- return components[components.length - 1];
43
- }
37
+ getUrl(params) {
38
+ return params.req.url;
39
+ },
40
+ serveMethod: (...params) => serve(...params),
41
+ options
44
42
  }).handler;
45
43
  };
46
44
  export {
package/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
- import { R as RouteFunction, W as WorkflowServeOptions, E as ExclusiveValidationOptions, T as Telemetry, N as NotifyResponse, a as Waiter, S as Step } from './types-C7Y7WUQd.mjs';
2
- export { A as AsyncStepFunction, C as CallResponse, q as CallSettings, D as Duration, k as FailureFunctionPayload, F as FinishCondition, H as HeaderParams, t as InvokableWorkflow, s as InvokeCallback, r as InvokeStepResponse, I as InvokeWorkflowRequest, L as LogLevel, o as NotifyStepResponse, P as ParallelCallState, j as PublicServeOptions, g as RawStep, l as RequiredExceptFields, i as StepFunction, f as StepType, e as StepTypes, h as SyncStepFunction, p as WaitEventOptions, m as WaitRequest, n as WaitStepResponse, c as WorkflowClient, b as WorkflowContext, v as WorkflowLogger, u as WorkflowLoggerOptions, d as WorkflowReceiver } from './types-C7Y7WUQd.mjs';
3
- import { Client as Client$1, QstashError } from '@upstash/qstash';
1
+ import { R as RouteFunction, W as WorkflowServeOptions, E as ExclusiveValidationOptions, T as Telemetry, S as StepType, a as RawStep, N as NotifyResponse, b as Waiter, c as Step } from './types-CYhDXnf8.mjs';
2
+ export { A as AsyncStepFunction, C as CallResponse, r as CallSettings, D as Duration, l as FailureFunctionPayload, F as FinishCondition, H as HeaderParams, t as InvokableWorkflow, s as InvokeStepResponse, I as InvokeWorkflowRequest, L as LazyInvokeStepParams, u as LogLevel, p as NotifyStepResponse, P as ParallelCallState, k as PublicServeOptions, m as RequiredExceptFields, j as StepFunction, h as StepTypes, i as SyncStepFunction, q as WaitEventOptions, n as WaitRequest, o as WaitStepResponse, f as WorkflowClient, e as WorkflowContext, w as WorkflowLogger, v as WorkflowLoggerOptions, g as WorkflowReceiver, d as WorkflowTool } from './types-CYhDXnf8.mjs';
3
+ import { HTTPMethods, State, FlowControl, Client as Client$1, QstashError } from '@upstash/qstash';
4
4
  import 'zod';
5
5
  import 'ai';
6
6
  import '@ai-sdk/openai';
@@ -30,6 +30,233 @@ declare const serveBase: <TInitialPayload = unknown, TRequest extends Request =
30
30
  */
31
31
  declare const serve: <TInitialPayload = unknown, TRequest extends Request = Request, TResponse extends Response = Response, TResult = unknown>(routeFunction: RouteFunction<TInitialPayload, TResult>, options?: Omit<WorkflowServeOptions<TResponse, TInitialPayload>, "useJSONContent" | "schema" | "initialPayloadParser"> & ExclusiveValidationOptions<TInitialPayload>) => ReturnType<typeof serveBase<TInitialPayload, TRequest, TResponse, TResult>>;
32
32
 
33
+ type BaseStepLog = {
34
+ /**
35
+ * id of the step
36
+ */
37
+ stepId?: number;
38
+ /**
39
+ * name of the step
40
+ */
41
+ stepName: string;
42
+ /**
43
+ * type of the step (example: "call", "wait", "invoke")
44
+ */
45
+ stepType: StepType;
46
+ /**
47
+ * call type of the step.
48
+ *
49
+ * in most cases it's `step`. For context.call, it will become `toCallback` and `fromCallback`
50
+ * as the step executes.
51
+ */
52
+ callType: RawStep["callType"];
53
+ /**
54
+ * message id of the step
55
+ */
56
+ messageId: string;
57
+ /**
58
+ * result of the step
59
+ *
60
+ * will be undefined for an unfinished parallel step.
61
+ */
62
+ out: unknown;
63
+ /**
64
+ * number of parallel steps
65
+ *
66
+ * if the step is sequential (non-parallel), will be 1.
67
+ */
68
+ concurrent: number;
69
+ /**
70
+ * state of the step
71
+ */
72
+ state: "STEP_PROGRESS" | "STEP_SUCCESS" | "STEP_RETRY" | "STEP_FAILED";
73
+ /**
74
+ * time when the step was created
75
+ */
76
+ createdAt: number;
77
+ /**
78
+ * headers
79
+ */
80
+ headers: Record<string, string[]>;
81
+ };
82
+ type CallUrlGroup = {
83
+ /**
84
+ * URL called in context.call
85
+ */
86
+ callUrl: string;
87
+ /**
88
+ * Method used in context.call
89
+ */
90
+ callMethod: HTTPMethods;
91
+ /**
92
+ * headers sent in context.call
93
+ */
94
+ callHeaders: Record<string, string[]>;
95
+ /**
96
+ * Body sent in context.call
97
+ */
98
+ callBody: unknown;
99
+ };
100
+ type CallResponseStatusGroup = {
101
+ /**
102
+ * Status code of the context.call response
103
+ */
104
+ callResponseStatus: number;
105
+ /**
106
+ * Response body of the context.call response
107
+ */
108
+ callResponseBody: unknown;
109
+ /**
110
+ * Headers received from the context.call response
111
+ */
112
+ callResponseHeaders: Record<string, string[]>;
113
+ } & CallUrlGroup;
114
+ type InvokedWorkflowGroup = {
115
+ /**
116
+ * id of the workflow run invoked in context.invoke
117
+ */
118
+ invokedWorkflowRunId: string;
119
+ /**
120
+ * URL of the workflow invoked in context.invoke
121
+ */
122
+ invokedWorkflowUrl: string;
123
+ /**
124
+ * Time when the workflow was invoked
125
+ */
126
+ invokedWorkflowCreatedAt: number;
127
+ /**
128
+ * Body sent in context.invoke
129
+ */
130
+ invokedWorkflowRunBody: unknown;
131
+ /**
132
+ * Headers sent in context.invoke
133
+ */
134
+ invokedWorkflowRunHeaders: Record<string, string[]>;
135
+ };
136
+ type WaitEventGroup = {
137
+ /**
138
+ * id of the event waited in context.waitForEvent
139
+ */
140
+ waitEventId: string;
141
+ /**
142
+ * Duration until the time when the event will be triggered due to timeout
143
+ */
144
+ waitTimeoutDuration: string;
145
+ /**
146
+ * Time when the event will be triggered due to timeout
147
+ */
148
+ waitTimeoutDeadline: number;
149
+ /**
150
+ * Whether the event was triggered due to timeout
151
+ */
152
+ waitTimeout: boolean;
153
+ };
154
+ type AsOptional<TType> = TType | {
155
+ [P in keyof TType]?: never;
156
+ };
157
+ type StepLog = BaseStepLog & AsOptional<CallUrlGroup> & AsOptional<CallResponseStatusGroup> & AsOptional<InvokedWorkflowGroup> & AsOptional<WaitEventGroup>;
158
+ type StepLogGroup = {
159
+ /**
160
+ * Log which belongs to a single step
161
+ */
162
+ steps: [StepLog];
163
+ /**
164
+ * Log which belongs to a single step
165
+ */
166
+ type: "sequential";
167
+ } | {
168
+ /**
169
+ * Log which belongs to parallel steps
170
+ */
171
+ steps: StepLog[];
172
+ /**
173
+ * Log which belongs to parallel steps
174
+ */
175
+ type: "parallel";
176
+ } | {
177
+ /**
178
+ * Log which belongs to the next step
179
+ */
180
+ steps: {
181
+ messageId: string;
182
+ state: "STEP_PROGRESS" | "STEP_RETRY" | "STEP_FAILED";
183
+ }[];
184
+ /**
185
+ * Log which belongs to the next step
186
+ */
187
+ type: "next";
188
+ };
189
+ type FailureFunctionLog = {
190
+ /**
191
+ * messageId of the message published for handling the failure
192
+ */
193
+ messageId: string;
194
+ /**
195
+ * URL of the function that handles the failure
196
+ */
197
+ url: string;
198
+ /**
199
+ * State of the message published for failure
200
+ */
201
+ state: State;
202
+ /**
203
+ * Headers received from the step which caused the workflow to fail
204
+ */
205
+ failHeaders: Record<string, string[]>;
206
+ /**
207
+ * Status code of the step which caused the workflow to fail
208
+ */
209
+ failStatus: number;
210
+ /**
211
+ * Response body of the step which caused the workflow to fail
212
+ */
213
+ failResponse: string;
214
+ dlqId: string;
215
+ };
216
+ type WorkflowRunLog = {
217
+ /**
218
+ * Unique identifier for the workflow run
219
+ */
220
+ workflowRunId: string;
221
+ /**
222
+ * URL of the workflow that was run
223
+ */
224
+ workflowUrl: string;
225
+ /**
226
+ * State of the workflow run
227
+ *
228
+ * - RUN_STARTED: Workflow run has started and is in progress
229
+ * - RUN_SUCCESS: Workflow run has completed successfully
230
+ * - RUN_FAILED: Workflow run has failed
231
+ */
232
+ workflowState: "RUN_STARTED" | "RUN_SUCCESS" | "RUN_FAILED" | "RUN_CANCELED";
233
+ /**
234
+ * Time when the workflow run was created
235
+ *
236
+ * in unix milliseconds format
237
+ */
238
+ workflowRunCreatedAt: number;
239
+ /**
240
+ * Time when the workflow run was completed
241
+ *
242
+ * in unix milliseconds format
243
+ */
244
+ workflowRunCompletedAt?: number;
245
+ /**
246
+ * Message published when the workflow fails if failureUrl or failureFunction
247
+ * are set.
248
+ */
249
+ failureFunction?: FailureFunctionLog;
250
+ /**
251
+ *
252
+ */
253
+ steps: StepLogGroup[];
254
+ };
255
+ type WorkflowRunLogs = {
256
+ cursor: string;
257
+ runs: WorkflowRunLog[];
258
+ };
259
+
33
260
  type ClientConfig = ConstructorParameters<typeof Client$1>[0];
34
261
  /**
35
262
  * Workflow client for canceling & notifying workflows and getting waiters of an
@@ -168,15 +395,51 @@ declare class Client {
168
395
  * the workflow, `retries` option of the `serve` will be used.
169
396
  * @returns workflow run id
170
397
  */
171
- trigger({ url, body, headers, workflowRunId, retries, }: {
398
+ trigger({ url, body, headers, workflowRunId, retries, flowControl, }: {
172
399
  url: string;
173
400
  body?: unknown;
174
401
  headers?: Record<string, string>;
175
402
  workflowRunId?: string;
176
403
  retries?: number;
404
+ flowControl?: FlowControl;
177
405
  }): Promise<{
178
406
  workflowRunId: string;
179
407
  }>;
408
+ /**
409
+ * Fetches logs for workflow runs.
410
+ *
411
+ * @param workflowRunId - The ID of the workflow run to fetch logs for.
412
+ * @param cursor - The cursor for pagination.
413
+ * @param count - Number of runs to fetch. Default value is 10.
414
+ * @param state - The state of the workflow run.
415
+ * @param workflowUrl - The URL of the workflow. Should be an exact match.
416
+ * @param workflowCreatedAt - The creation time of the workflow. If you have two workflow runs with the same URL, you can use this to filter them.
417
+ * @returns A promise that resolves to either a `WorkflowRunLog` or a `WorkflowRunResponse`.
418
+ *
419
+ * @example
420
+ * Fetch logs for a specific workflow run:
421
+ * ```typescript
422
+ * const { runs } = await client.logs({ workflowRunId: '12345' });
423
+ * const steps = runs[0].steps; // access steps
424
+ * ```
425
+ *
426
+ * @example
427
+ * Fetch logs with pagination:
428
+ * ```typescript
429
+ * const { runs, cursor } = await client.logs();
430
+ * const steps = runs[0].steps // access steps
431
+ *
432
+ * const { runs: nextRuns, cursor: nextCursor } = await client.logs({ cursor, count: 2 });
433
+ * ```
434
+ */
435
+ logs(params?: {
436
+ workflowRunId?: WorkflowRunLog["workflowRunId"];
437
+ cursor?: string;
438
+ count?: number;
439
+ state?: WorkflowRunLog["workflowState"];
440
+ workflowUrl?: WorkflowRunLog["workflowUrl"];
441
+ workflowCreatedAt?: WorkflowRunLog["workflowRunCreatedAt"];
442
+ }): Promise<WorkflowRunLogs>;
180
443
  }
181
444
 
182
445
  /**
@@ -205,4 +468,4 @@ declare class WorkflowAbort extends Error {
205
468
  constructor(stepName: string, stepInfo?: Step, cancelWorkflow?: boolean);
206
469
  }
207
470
 
208
- export { Client, ExclusiveValidationOptions, NotifyResponse, RouteFunction, Step, Telemetry, Waiter, WorkflowAbort, WorkflowError, WorkflowServeOptions, serve };
471
+ export { Client, ExclusiveValidationOptions, NotifyResponse, RawStep, RouteFunction, Step, type StepLog, StepType, Telemetry, Waiter, WorkflowAbort, WorkflowError, type WorkflowRunLog, type WorkflowRunLogs, WorkflowServeOptions, serve };
package/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { R as RouteFunction, W as WorkflowServeOptions, E as ExclusiveValidationOptions, T as Telemetry, N as NotifyResponse, a as Waiter, S as Step } from './types-C7Y7WUQd.js';
2
- export { A as AsyncStepFunction, C as CallResponse, q as CallSettings, D as Duration, k as FailureFunctionPayload, F as FinishCondition, H as HeaderParams, t as InvokableWorkflow, s as InvokeCallback, r as InvokeStepResponse, I as InvokeWorkflowRequest, L as LogLevel, o as NotifyStepResponse, P as ParallelCallState, j as PublicServeOptions, g as RawStep, l as RequiredExceptFields, i as StepFunction, f as StepType, e as StepTypes, h as SyncStepFunction, p as WaitEventOptions, m as WaitRequest, n as WaitStepResponse, c as WorkflowClient, b as WorkflowContext, v as WorkflowLogger, u as WorkflowLoggerOptions, d as WorkflowReceiver } from './types-C7Y7WUQd.js';
3
- import { Client as Client$1, QstashError } from '@upstash/qstash';
1
+ import { R as RouteFunction, W as WorkflowServeOptions, E as ExclusiveValidationOptions, T as Telemetry, S as StepType, a as RawStep, N as NotifyResponse, b as Waiter, c as Step } from './types-CYhDXnf8.js';
2
+ export { A as AsyncStepFunction, C as CallResponse, r as CallSettings, D as Duration, l as FailureFunctionPayload, F as FinishCondition, H as HeaderParams, t as InvokableWorkflow, s as InvokeStepResponse, I as InvokeWorkflowRequest, L as LazyInvokeStepParams, u as LogLevel, p as NotifyStepResponse, P as ParallelCallState, k as PublicServeOptions, m as RequiredExceptFields, j as StepFunction, h as StepTypes, i as SyncStepFunction, q as WaitEventOptions, n as WaitRequest, o as WaitStepResponse, f as WorkflowClient, e as WorkflowContext, w as WorkflowLogger, v as WorkflowLoggerOptions, g as WorkflowReceiver, d as WorkflowTool } from './types-CYhDXnf8.js';
3
+ import { HTTPMethods, State, FlowControl, Client as Client$1, QstashError } from '@upstash/qstash';
4
4
  import 'zod';
5
5
  import 'ai';
6
6
  import '@ai-sdk/openai';
@@ -30,6 +30,233 @@ declare const serveBase: <TInitialPayload = unknown, TRequest extends Request =
30
30
  */
31
31
  declare const serve: <TInitialPayload = unknown, TRequest extends Request = Request, TResponse extends Response = Response, TResult = unknown>(routeFunction: RouteFunction<TInitialPayload, TResult>, options?: Omit<WorkflowServeOptions<TResponse, TInitialPayload>, "useJSONContent" | "schema" | "initialPayloadParser"> & ExclusiveValidationOptions<TInitialPayload>) => ReturnType<typeof serveBase<TInitialPayload, TRequest, TResponse, TResult>>;
32
32
 
33
+ type BaseStepLog = {
34
+ /**
35
+ * id of the step
36
+ */
37
+ stepId?: number;
38
+ /**
39
+ * name of the step
40
+ */
41
+ stepName: string;
42
+ /**
43
+ * type of the step (example: "call", "wait", "invoke")
44
+ */
45
+ stepType: StepType;
46
+ /**
47
+ * call type of the step.
48
+ *
49
+ * in most cases it's `step`. For context.call, it will become `toCallback` and `fromCallback`
50
+ * as the step executes.
51
+ */
52
+ callType: RawStep["callType"];
53
+ /**
54
+ * message id of the step
55
+ */
56
+ messageId: string;
57
+ /**
58
+ * result of the step
59
+ *
60
+ * will be undefined for an unfinished parallel step.
61
+ */
62
+ out: unknown;
63
+ /**
64
+ * number of parallel steps
65
+ *
66
+ * if the step is sequential (non-parallel), will be 1.
67
+ */
68
+ concurrent: number;
69
+ /**
70
+ * state of the step
71
+ */
72
+ state: "STEP_PROGRESS" | "STEP_SUCCESS" | "STEP_RETRY" | "STEP_FAILED";
73
+ /**
74
+ * time when the step was created
75
+ */
76
+ createdAt: number;
77
+ /**
78
+ * headers
79
+ */
80
+ headers: Record<string, string[]>;
81
+ };
82
+ type CallUrlGroup = {
83
+ /**
84
+ * URL called in context.call
85
+ */
86
+ callUrl: string;
87
+ /**
88
+ * Method used in context.call
89
+ */
90
+ callMethod: HTTPMethods;
91
+ /**
92
+ * headers sent in context.call
93
+ */
94
+ callHeaders: Record<string, string[]>;
95
+ /**
96
+ * Body sent in context.call
97
+ */
98
+ callBody: unknown;
99
+ };
100
+ type CallResponseStatusGroup = {
101
+ /**
102
+ * Status code of the context.call response
103
+ */
104
+ callResponseStatus: number;
105
+ /**
106
+ * Response body of the context.call response
107
+ */
108
+ callResponseBody: unknown;
109
+ /**
110
+ * Headers received from the context.call response
111
+ */
112
+ callResponseHeaders: Record<string, string[]>;
113
+ } & CallUrlGroup;
114
+ type InvokedWorkflowGroup = {
115
+ /**
116
+ * id of the workflow run invoked in context.invoke
117
+ */
118
+ invokedWorkflowRunId: string;
119
+ /**
120
+ * URL of the workflow invoked in context.invoke
121
+ */
122
+ invokedWorkflowUrl: string;
123
+ /**
124
+ * Time when the workflow was invoked
125
+ */
126
+ invokedWorkflowCreatedAt: number;
127
+ /**
128
+ * Body sent in context.invoke
129
+ */
130
+ invokedWorkflowRunBody: unknown;
131
+ /**
132
+ * Headers sent in context.invoke
133
+ */
134
+ invokedWorkflowRunHeaders: Record<string, string[]>;
135
+ };
136
+ type WaitEventGroup = {
137
+ /**
138
+ * id of the event waited in context.waitForEvent
139
+ */
140
+ waitEventId: string;
141
+ /**
142
+ * Duration until the time when the event will be triggered due to timeout
143
+ */
144
+ waitTimeoutDuration: string;
145
+ /**
146
+ * Time when the event will be triggered due to timeout
147
+ */
148
+ waitTimeoutDeadline: number;
149
+ /**
150
+ * Whether the event was triggered due to timeout
151
+ */
152
+ waitTimeout: boolean;
153
+ };
154
+ type AsOptional<TType> = TType | {
155
+ [P in keyof TType]?: never;
156
+ };
157
+ type StepLog = BaseStepLog & AsOptional<CallUrlGroup> & AsOptional<CallResponseStatusGroup> & AsOptional<InvokedWorkflowGroup> & AsOptional<WaitEventGroup>;
158
+ type StepLogGroup = {
159
+ /**
160
+ * Log which belongs to a single step
161
+ */
162
+ steps: [StepLog];
163
+ /**
164
+ * Log which belongs to a single step
165
+ */
166
+ type: "sequential";
167
+ } | {
168
+ /**
169
+ * Log which belongs to parallel steps
170
+ */
171
+ steps: StepLog[];
172
+ /**
173
+ * Log which belongs to parallel steps
174
+ */
175
+ type: "parallel";
176
+ } | {
177
+ /**
178
+ * Log which belongs to the next step
179
+ */
180
+ steps: {
181
+ messageId: string;
182
+ state: "STEP_PROGRESS" | "STEP_RETRY" | "STEP_FAILED";
183
+ }[];
184
+ /**
185
+ * Log which belongs to the next step
186
+ */
187
+ type: "next";
188
+ };
189
+ type FailureFunctionLog = {
190
+ /**
191
+ * messageId of the message published for handling the failure
192
+ */
193
+ messageId: string;
194
+ /**
195
+ * URL of the function that handles the failure
196
+ */
197
+ url: string;
198
+ /**
199
+ * State of the message published for failure
200
+ */
201
+ state: State;
202
+ /**
203
+ * Headers received from the step which caused the workflow to fail
204
+ */
205
+ failHeaders: Record<string, string[]>;
206
+ /**
207
+ * Status code of the step which caused the workflow to fail
208
+ */
209
+ failStatus: number;
210
+ /**
211
+ * Response body of the step which caused the workflow to fail
212
+ */
213
+ failResponse: string;
214
+ dlqId: string;
215
+ };
216
+ type WorkflowRunLog = {
217
+ /**
218
+ * Unique identifier for the workflow run
219
+ */
220
+ workflowRunId: string;
221
+ /**
222
+ * URL of the workflow that was run
223
+ */
224
+ workflowUrl: string;
225
+ /**
226
+ * State of the workflow run
227
+ *
228
+ * - RUN_STARTED: Workflow run has started and is in progress
229
+ * - RUN_SUCCESS: Workflow run has completed successfully
230
+ * - RUN_FAILED: Workflow run has failed
231
+ */
232
+ workflowState: "RUN_STARTED" | "RUN_SUCCESS" | "RUN_FAILED" | "RUN_CANCELED";
233
+ /**
234
+ * Time when the workflow run was created
235
+ *
236
+ * in unix milliseconds format
237
+ */
238
+ workflowRunCreatedAt: number;
239
+ /**
240
+ * Time when the workflow run was completed
241
+ *
242
+ * in unix milliseconds format
243
+ */
244
+ workflowRunCompletedAt?: number;
245
+ /**
246
+ * Message published when the workflow fails if failureUrl or failureFunction
247
+ * are set.
248
+ */
249
+ failureFunction?: FailureFunctionLog;
250
+ /**
251
+ *
252
+ */
253
+ steps: StepLogGroup[];
254
+ };
255
+ type WorkflowRunLogs = {
256
+ cursor: string;
257
+ runs: WorkflowRunLog[];
258
+ };
259
+
33
260
  type ClientConfig = ConstructorParameters<typeof Client$1>[0];
34
261
  /**
35
262
  * Workflow client for canceling & notifying workflows and getting waiters of an
@@ -168,15 +395,51 @@ declare class Client {
168
395
  * the workflow, `retries` option of the `serve` will be used.
169
396
  * @returns workflow run id
170
397
  */
171
- trigger({ url, body, headers, workflowRunId, retries, }: {
398
+ trigger({ url, body, headers, workflowRunId, retries, flowControl, }: {
172
399
  url: string;
173
400
  body?: unknown;
174
401
  headers?: Record<string, string>;
175
402
  workflowRunId?: string;
176
403
  retries?: number;
404
+ flowControl?: FlowControl;
177
405
  }): Promise<{
178
406
  workflowRunId: string;
179
407
  }>;
408
+ /**
409
+ * Fetches logs for workflow runs.
410
+ *
411
+ * @param workflowRunId - The ID of the workflow run to fetch logs for.
412
+ * @param cursor - The cursor for pagination.
413
+ * @param count - Number of runs to fetch. Default value is 10.
414
+ * @param state - The state of the workflow run.
415
+ * @param workflowUrl - The URL of the workflow. Should be an exact match.
416
+ * @param workflowCreatedAt - The creation time of the workflow. If you have two workflow runs with the same URL, you can use this to filter them.
417
+ * @returns A promise that resolves to either a `WorkflowRunLog` or a `WorkflowRunResponse`.
418
+ *
419
+ * @example
420
+ * Fetch logs for a specific workflow run:
421
+ * ```typescript
422
+ * const { runs } = await client.logs({ workflowRunId: '12345' });
423
+ * const steps = runs[0].steps; // access steps
424
+ * ```
425
+ *
426
+ * @example
427
+ * Fetch logs with pagination:
428
+ * ```typescript
429
+ * const { runs, cursor } = await client.logs();
430
+ * const steps = runs[0].steps // access steps
431
+ *
432
+ * const { runs: nextRuns, cursor: nextCursor } = await client.logs({ cursor, count: 2 });
433
+ * ```
434
+ */
435
+ logs(params?: {
436
+ workflowRunId?: WorkflowRunLog["workflowRunId"];
437
+ cursor?: string;
438
+ count?: number;
439
+ state?: WorkflowRunLog["workflowState"];
440
+ workflowUrl?: WorkflowRunLog["workflowUrl"];
441
+ workflowCreatedAt?: WorkflowRunLog["workflowRunCreatedAt"];
442
+ }): Promise<WorkflowRunLogs>;
180
443
  }
181
444
 
182
445
  /**
@@ -205,4 +468,4 @@ declare class WorkflowAbort extends Error {
205
468
  constructor(stepName: string, stepInfo?: Step, cancelWorkflow?: boolean);
206
469
  }
207
470
 
208
- export { Client, ExclusiveValidationOptions, NotifyResponse, RouteFunction, Step, Telemetry, Waiter, WorkflowAbort, WorkflowError, WorkflowServeOptions, serve };
471
+ export { Client, ExclusiveValidationOptions, NotifyResponse, RawStep, RouteFunction, Step, type StepLog, StepType, Telemetry, Waiter, WorkflowAbort, WorkflowError, type WorkflowRunLog, type WorkflowRunLogs, WorkflowServeOptions, serve };