@upstash/workflow 0.1.0

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 ADDED
@@ -0,0 +1,22 @@
1
+ import {
2
+ serve
3
+ } from "./chunk-JDMP6KKR.mjs";
4
+
5
+ // platforms/hono.ts
6
+ var serve2 = (routeFunction, options) => {
7
+ const handler = async (context) => {
8
+ const environment = context.env;
9
+ const request = context.req.raw;
10
+ const serveHandler = serve(routeFunction, {
11
+ // when hono is used without cf workers, it sends a DebugHTTPServer
12
+ // object in `context.env`. don't pass env if this is the case:
13
+ env: "QSTASH_TOKEN" in environment ? environment : void 0,
14
+ ...options
15
+ });
16
+ return await serveHandler(request);
17
+ };
18
+ return handler;
19
+ };
20
+ export {
21
+ serve2 as serve
22
+ };
package/index.d.mts ADDED
@@ -0,0 +1,57 @@
1
+ import { R as RouteFunction, W as WorkflowServeOptions, N as NotifyResponse, S as Step } from './types-CfN1Epuj.mjs';
2
+ export { A as AsyncStepFunction, i as FailureFunctionPayload, F as FinishCondition, L as LogLevel, P as ParallelCallState, f as RawStep, j as RequiredExceptFields, h as StepFunction, e as StepType, d as StepTypes, g as SyncStepFunction, m as WaitRequest, k as WaitResult, n as WaitStepResponse, l as Waiter, b as WorkflowClient, a as WorkflowContext, p as WorkflowLogger, o as WorkflowLoggerOptions, c as WorkflowReceiver } from './types-CfN1Epuj.mjs';
3
+ import { Client as Client$1, QstashError } from '@upstash/qstash';
4
+
5
+ /**
6
+ * Creates an async method that handles incoming requests and runs the provided
7
+ * route function as a workflow.
8
+ *
9
+ * @param routeFunction - A function that uses WorkflowContext as a parameter and runs a workflow.
10
+ * @param options - Options including the client, onFinish callback, and initialPayloadParser.
11
+ * @returns An async method that consumes incoming requests and runs the workflow.
12
+ */
13
+ declare const serve: <TInitialPayload = unknown, TRequest extends Request = Request, TResponse extends Response = Response>(routeFunction: RouteFunction<TInitialPayload>, options?: WorkflowServeOptions<TResponse, TInitialPayload>) => ((request: TRequest) => Promise<TResponse>);
14
+
15
+ type ClientConfig = ConstructorParameters<typeof Client$1>[0];
16
+ declare class Client {
17
+ private client;
18
+ constructor(clientConfig: ClientConfig);
19
+ /**
20
+ * Cancel an ongoing workflow
21
+ *
22
+ * @param workflowRunId run id of the workflow to delete
23
+ * @returns true if workflow is succesfully deleted. Otherwise throws QStashError
24
+ */
25
+ cancel({ workflowRunId }: {
26
+ workflowRunId: string;
27
+ }): Promise<true | {
28
+ error: string;
29
+ }>;
30
+ /**
31
+ * Notify a workflow run waiting for an event
32
+ *
33
+ * @param eventId event id to notify
34
+ * @param notifyData data to provide to the workflow
35
+ */
36
+ notify({ eventId, notifyBody, }: {
37
+ eventId: string;
38
+ notifyBody?: string;
39
+ }): Promise<NotifyResponse[]>;
40
+ }
41
+
42
+ /**
43
+ * Error raised during Workflow execution
44
+ */
45
+ declare class QStashWorkflowError extends QstashError {
46
+ constructor(message: string);
47
+ }
48
+ /**
49
+ * Raised when the workflow executes a function and aborts
50
+ */
51
+ declare class QStashWorkflowAbort extends Error {
52
+ stepInfo?: Step;
53
+ stepName: string;
54
+ constructor(stepName: string, stepInfo?: Step);
55
+ }
56
+
57
+ export { Client, NotifyResponse, QStashWorkflowAbort, QStashWorkflowError, RouteFunction, Step, WorkflowServeOptions, serve };
package/index.d.ts ADDED
@@ -0,0 +1,57 @@
1
+ import { R as RouteFunction, W as WorkflowServeOptions, N as NotifyResponse, S as Step } from './types-CfN1Epuj.js';
2
+ export { A as AsyncStepFunction, i as FailureFunctionPayload, F as FinishCondition, L as LogLevel, P as ParallelCallState, f as RawStep, j as RequiredExceptFields, h as StepFunction, e as StepType, d as StepTypes, g as SyncStepFunction, m as WaitRequest, k as WaitResult, n as WaitStepResponse, l as Waiter, b as WorkflowClient, a as WorkflowContext, p as WorkflowLogger, o as WorkflowLoggerOptions, c as WorkflowReceiver } from './types-CfN1Epuj.js';
3
+ import { Client as Client$1, QstashError } from '@upstash/qstash';
4
+
5
+ /**
6
+ * Creates an async method that handles incoming requests and runs the provided
7
+ * route function as a workflow.
8
+ *
9
+ * @param routeFunction - A function that uses WorkflowContext as a parameter and runs a workflow.
10
+ * @param options - Options including the client, onFinish callback, and initialPayloadParser.
11
+ * @returns An async method that consumes incoming requests and runs the workflow.
12
+ */
13
+ declare const serve: <TInitialPayload = unknown, TRequest extends Request = Request, TResponse extends Response = Response>(routeFunction: RouteFunction<TInitialPayload>, options?: WorkflowServeOptions<TResponse, TInitialPayload>) => ((request: TRequest) => Promise<TResponse>);
14
+
15
+ type ClientConfig = ConstructorParameters<typeof Client$1>[0];
16
+ declare class Client {
17
+ private client;
18
+ constructor(clientConfig: ClientConfig);
19
+ /**
20
+ * Cancel an ongoing workflow
21
+ *
22
+ * @param workflowRunId run id of the workflow to delete
23
+ * @returns true if workflow is succesfully deleted. Otherwise throws QStashError
24
+ */
25
+ cancel({ workflowRunId }: {
26
+ workflowRunId: string;
27
+ }): Promise<true | {
28
+ error: string;
29
+ }>;
30
+ /**
31
+ * Notify a workflow run waiting for an event
32
+ *
33
+ * @param eventId event id to notify
34
+ * @param notifyData data to provide to the workflow
35
+ */
36
+ notify({ eventId, notifyBody, }: {
37
+ eventId: string;
38
+ notifyBody?: string;
39
+ }): Promise<NotifyResponse[]>;
40
+ }
41
+
42
+ /**
43
+ * Error raised during Workflow execution
44
+ */
45
+ declare class QStashWorkflowError extends QstashError {
46
+ constructor(message: string);
47
+ }
48
+ /**
49
+ * Raised when the workflow executes a function and aborts
50
+ */
51
+ declare class QStashWorkflowAbort extends Error {
52
+ stepInfo?: Step;
53
+ stepName: string;
54
+ constructor(stepName: string, stepInfo?: Step);
55
+ }
56
+
57
+ export { Client, NotifyResponse, QStashWorkflowAbort, QStashWorkflowError, RouteFunction, Step, WorkflowServeOptions, serve };