@upstash/workflow 0.2.11 → 0.2.13

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
@@ -2,7 +2,7 @@ import {
2
2
  SDK_TELEMETRY,
3
3
  serveBase,
4
4
  serveManyBase
5
- } from "./chunk-WQAJ2RSZ.mjs";
5
+ } from "./chunk-XVNSBBDC.mjs";
6
6
 
7
7
  // platforms/hono.ts
8
8
  var telemetry = {
@@ -11,7 +11,7 @@ var telemetry = {
11
11
  };
12
12
  var serve = (routeFunction, options) => {
13
13
  const handler = async (context) => {
14
- const environment = context.env;
14
+ const environment = context.env ? context.env : typeof process === "undefined" ? {} : process.env;
15
15
  const request = context.req.raw;
16
16
  const { handler: serveHandler } = serveBase(routeFunction, telemetry, {
17
17
  // when hono is used without cf workers, it sends a DebugHTTPServer
package/index.d.mts CHANGED
@@ -1,6 +1,6 @@
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-DS9q8FyV.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-DS9q8FyV.mjs';
3
- import { HTTPMethods, State, FlowControl, 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-C1WIgVLA.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-C1WIgVLA.mjs';
3
+ import { HTTPMethods, State, FlowControl, PublishRequest, Client as Client$1, QstashError } from '@upstash/qstash';
4
4
  import 'zod';
5
5
  import 'ai';
6
6
  import '@ai-sdk/openai';
@@ -154,7 +154,11 @@ type WaitEventGroup = {
154
154
  type AsOptional<TType> = TType | {
155
155
  [P in keyof TType]?: never;
156
156
  };
157
- type StepLog = BaseStepLog & AsOptional<CallUrlGroup> & AsOptional<CallResponseStatusGroup> & AsOptional<InvokedWorkflowGroup> & AsOptional<WaitEventGroup>;
157
+ type StepLog = BaseStepLog & AsOptional<CallUrlGroup> & AsOptional<CallResponseStatusGroup> & AsOptional<InvokedWorkflowGroup> & AsOptional<{
158
+ sleepFor: number;
159
+ }> & AsOptional<{
160
+ sleepUntil: number;
161
+ }> & AsOptional<WaitEventGroup>;
158
162
  type StepLogGroup = {
159
163
  /**
160
164
  * Log which belongs to a single step
@@ -179,7 +183,7 @@ type StepLogGroup = {
179
183
  */
180
184
  steps: {
181
185
  messageId: string;
182
- state: "STEP_PROGRESS" | "STEP_RETRY" | "STEP_FAILED";
186
+ state: "STEP_PROGRESS" | "STEP_RETRY" | "STEP_FAILED" | "STEP_CANCELED";
183
187
  }[];
184
188
  /**
185
189
  * Log which belongs to the next step
@@ -419,15 +423,21 @@ declare class Client {
419
423
  * with `wfr_`.
420
424
  * @param retries retry to use in the initial request. in the rest of
421
425
  * the workflow, `retries` option of the `serve` will be used.
426
+ * @param flowControl Settings for controlling the number of active requests
427
+ * and number of requests per second with the same key.
428
+ * @param delay Delay for the workflow run. This is used to delay the
429
+ * execution of the workflow run. The delay is in seconds or can be passed
430
+ * as a string with a time unit (e.g. "1h", "30m", "15s").
422
431
  * @returns workflow run id
423
432
  */
424
- trigger({ url, body, headers, workflowRunId, retries, flowControl, }: {
433
+ trigger({ url, body, headers, workflowRunId, retries, flowControl, delay, }: {
425
434
  url: string;
426
435
  body?: unknown;
427
436
  headers?: Record<string, string>;
428
437
  workflowRunId?: string;
429
438
  retries?: number;
430
439
  flowControl?: FlowControl;
440
+ delay?: PublishRequest["delay"];
431
441
  }): Promise<{
432
442
  workflowRunId: string;
433
443
  }>;
package/index.d.ts CHANGED
@@ -1,6 +1,6 @@
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-DS9q8FyV.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-DS9q8FyV.js';
3
- import { HTTPMethods, State, FlowControl, 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-C1WIgVLA.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-C1WIgVLA.js';
3
+ import { HTTPMethods, State, FlowControl, PublishRequest, Client as Client$1, QstashError } from '@upstash/qstash';
4
4
  import 'zod';
5
5
  import 'ai';
6
6
  import '@ai-sdk/openai';
@@ -154,7 +154,11 @@ type WaitEventGroup = {
154
154
  type AsOptional<TType> = TType | {
155
155
  [P in keyof TType]?: never;
156
156
  };
157
- type StepLog = BaseStepLog & AsOptional<CallUrlGroup> & AsOptional<CallResponseStatusGroup> & AsOptional<InvokedWorkflowGroup> & AsOptional<WaitEventGroup>;
157
+ type StepLog = BaseStepLog & AsOptional<CallUrlGroup> & AsOptional<CallResponseStatusGroup> & AsOptional<InvokedWorkflowGroup> & AsOptional<{
158
+ sleepFor: number;
159
+ }> & AsOptional<{
160
+ sleepUntil: number;
161
+ }> & AsOptional<WaitEventGroup>;
158
162
  type StepLogGroup = {
159
163
  /**
160
164
  * Log which belongs to a single step
@@ -179,7 +183,7 @@ type StepLogGroup = {
179
183
  */
180
184
  steps: {
181
185
  messageId: string;
182
- state: "STEP_PROGRESS" | "STEP_RETRY" | "STEP_FAILED";
186
+ state: "STEP_PROGRESS" | "STEP_RETRY" | "STEP_FAILED" | "STEP_CANCELED";
183
187
  }[];
184
188
  /**
185
189
  * Log which belongs to the next step
@@ -419,15 +423,21 @@ declare class Client {
419
423
  * with `wfr_`.
420
424
  * @param retries retry to use in the initial request. in the rest of
421
425
  * the workflow, `retries` option of the `serve` will be used.
426
+ * @param flowControl Settings for controlling the number of active requests
427
+ * and number of requests per second with the same key.
428
+ * @param delay Delay for the workflow run. This is used to delay the
429
+ * execution of the workflow run. The delay is in seconds or can be passed
430
+ * as a string with a time unit (e.g. "1h", "30m", "15s").
422
431
  * @returns workflow run id
423
432
  */
424
- trigger({ url, body, headers, workflowRunId, retries, flowControl, }: {
433
+ trigger({ url, body, headers, workflowRunId, retries, flowControl, delay, }: {
425
434
  url: string;
426
435
  body?: unknown;
427
436
  headers?: Record<string, string>;
428
437
  workflowRunId?: string;
429
438
  retries?: number;
430
439
  flowControl?: FlowControl;
440
+ delay?: PublishRequest["delay"];
431
441
  }): Promise<{
432
442
  workflowRunId: string;
433
443
  }>;